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 )
59 const char* key = aLexer->
CurText();
61 PTREE* list = &aTree->push_back( PTREE::value_type( key,
PTREE() ) )->second;
78 const char* key = aLexer->
CurText();
80 aTree->push_back( PTREE::value_type( key,
PTREE() ) );
86 int tok = aLexer->
CurTok();
112 return aTree.size() == 0 && aTree.data().size() == 0;
120 return next == aTree.end();
132 const std::string& aKey,
const CPTREE& aTree );
137 for(
CITER it = aTree.begin(); it != aTree.end(); ++it )
140 if( it->first ==
"<xmlattr>" )
159 formatNode( out, aNestLevel+1, ctl, it->first, it->second );
165 const std::string& aKey,
const CPTREE& aTree )
173 if( aTree.size() && !
isAtom( aTree.begin()->second ) && !aTree.data().size() )
176 out->
Print( aNestLevel,
"(%s%s", out->
Quotes( aKey ).c_str(),
179 if( aTree.data().size() )
181 out->
Print( 0,
" %s%s",
182 out->
Quotes( aTree.data() ).c_str(),
183 aTree.size() ?
"\n" :
"" );
193 out->
Print( 0,
" %s", out->
Quotes( aKey ).c_str() );
200 if( aTree.size() == 1 && !aTree.data().size() )
204 CITER it = aTree.begin();
205 formatNode( out, aNestLevel, aCtl, it->first, it->second );
210 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)
Read 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