30#include <boost/property_tree/ptree.hpp>
35typedef PTREE::const_iterator
CITER;
36typedef PTREE::iterator
ITER;
44#define CTL_OMIT_NL (1<<0)
45#define CTL_IN_ATTRS (1<<1)
61 const char* key = aLexer->
CurText();
63 PTREE* list = &aTree->push_back( PTREE::value_type( key,
PTREE() ) )->second;
80 const char* key = aLexer->
CurText();
82 aTree->push_back( PTREE::value_type( key,
PTREE() ) );
88 int tok = aLexer->
CurTok();
114 return aTree.size() == 0 && aTree.data().size() == 0;
122 return next == aTree.end();
134 const std::string& aKey,
const CPTREE& aTree );
139 for(
CITER it = aTree.begin(); it != aTree.end(); ++it )
142 if( it->first ==
"<xmlattr>" )
161 formatNode( out, aNestLevel+1, ctl, it->first, it->second );
167 const std::string& aKey,
const CPTREE& aTree )
175 if( aTree.size() && !
isAtom( aTree.begin()->second ) && !aTree.data().size() )
180 if( aTree.data().size() )
182 out->
Print( 0,
" %s%s",
183 out->
Quotes( aTree.data() ).c_str(),
184 aTree.size() ?
"\n" :
""
195 out->
Print( 0,
" %s", out->
Quotes( aKey ).c_str() );
202 if( aTree.size() == 1 && !aTree.data().size() )
206 CITER it = aTree.begin();
207 formatNode( out, aNestLevel, aCtl, it->first, it->second );
212 formatNode( out, aNestLevel, aCtl,
"", aTree );
Implement a lexical analyzer for the SPECCTRA DSN file format.
const char * CurText() const
Return a pointer to the current token's text.
int NextTok()
Return the next token found in the input file or DSN_EOF when reaching the end of file.
int CurTok() const
Return whatever NextTok() returned the last time it was called.
void Unexpected(int aTok) const
Throw an IO_ERROR exception with an input file specific error message.
This file contains miscellaneous commonly used macros and functions.
void scanList(PTREE *aTree, DSNLEXER *aLexer)
Function scanList reads a sexpr list from the input stream into a new node with key aLexer->CurText()...
bool isLast(const CPTREE &aTree, CITER it)
void scanAtom(PTREE *aTree, const DSNLEXER *aLexer)
static void formatList(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
bool isAtom(const CPTREE &aTree)
PTREE::const_iterator CITER
static void formatNode(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const std::string &aKey, const CPTREE &aTree)
void Scan(PTREE *aTree, DSNLEXER *aLexer)
Fill an empty PTREE with information from a KiCad s-expression stream.
boost::property_tree::ptree PTREE