KiCad PCB EDA Suite
No Matches
ptree.h File Reference
#include <boost/property_tree/ptree_fwd.hpp>
#include <richio.h>
#include <dsnlexer.h>

Go to the source code of this file.


typedef boost::property_tree::ptree PTREE
typedef const PTREE CPTREE
typedef boost::property_tree::ptree_error PTREE_ERROR


void Scan (PTREE *aTree, DSNLEXER *aLexer)
 Fill an empty PTREE with information from a KiCad s-expression stream.
void Format (OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
 Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.

Typedef Documentation


typedef const PTREE CPTREE

Definition at line 53 of file ptree.h.


typedef boost::property_tree::ptree PTREE

Definition at line 52 of file ptree.h.


typedef boost::property_tree::ptree_error PTREE_ERROR

Definition at line 54 of file ptree.h.

Function Documentation

◆ Format()

void Format ( OUTPUTFORMATTER out,
int  aNestLevel,
int  aCtl,
const CPTREE aTree 

◆ Scan()

void Scan ( PTREE aTree,

Fill an empty PTREE with information from a KiCad s-expression stream.

Use a DSNLEXER with an empty keyword table as aLexer. Useful for parsing s-expression files or strings of arbitrary grammars, say from a file or clipboard. The s-expression must be "KiCad compatible". See Documentation/s-expressions.txt for this KiCad compatible definition (it is the non-specctra mode). And also see in tools/property_tree.cpp for example usage.

FILE* fp = fopen( argv[1], "r" );

static const KEYWORD empty_keywords[1] = {};

DSNLEXER lexer( empty_keywords, 0, fp, wxString( From_UTF8( argv[1] ) ) );

try { PTREE doc; Scan( &doc, &lexer ); } catch( const IO_ERROR& ioe ) { fprintf( stderr, "%s\n", TO_UTF8( ioe.errorText ) ); }

Definition at line 86 of file ptree.cpp.

References DSNLEXER::CurTok(), DSN_EOF, DSN_LEFT, DSN_NONE, DSNLEXER::NextTok(), scanAtom(), scanList(), and DSNLEXER::Unexpected().

Referenced by SCH_EDITOR_CONTROL::AssignFootprints(), BACK_ANNOTATE::getPcbModulesFromString(), and scanList().