KiCad PCB EDA Suite
Loading...
Searching...
No Matches
ptree.cpp File Reference
#include <macros.h>
#include <boost/property_tree/ptree.hpp>
#include <cassert>
#include <ptree.h>

Go to the source code of this file.

Macros

#define D(x)
 
#define CTL_OMIT_NL   ( 1 << 0 )
 
#define CTL_IN_ATTRS   ( 1 << 1 )
 

Typedefs

typedef PTREE::const_iterator CITER
 
typedef PTREE::iterator ITER
 

Functions

void scanList (PTREE *aTree, DSNLEXER *aLexer)
 Read a sexpr list from the input stream into a new node with key aLexer->CurText().
 
void scanAtom (PTREE *aTree, const DSNLEXER *aLexer)
 
void Scan (PTREE *aTree, DSNLEXER *aLexer)
 Fill an empty PTREE with information from a KiCad s-expression stream.
 
bool isAtom (const CPTREE &aTree)
 
bool isLast (const CPTREE &aTree, CITER it)
 
CITER next (CITER it)
 
static void formatNode (OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const std::string &aKey, const CPTREE &aTree)
 
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.
 

Macro Definition Documentation

◆ CTL_IN_ATTRS

#define CTL_IN_ATTRS   ( 1 << 1 )

Definition at line 45 of file ptree.cpp.

Referenced by formatList().

◆ CTL_OMIT_NL

#define CTL_OMIT_NL   ( 1 << 0 )

Definition at line 44 of file ptree.cpp.

Referenced by formatList(), and formatNode().

◆ D

Typedef Documentation

◆ CITER

typedef PTREE::const_iterator CITER

Definition at line 35 of file ptree.cpp.

◆ ITER

typedef PTREE::iterator ITER

Definition at line 36 of file ptree.cpp.

Function Documentation

◆ Format()

◆ formatList()

static void formatList ( OUTPUTFORMATTER * out,
int aNestLevel,
int aCtl,
const CPTREE & aTree )
static

Definition at line 135 of file ptree.cpp.

References CTL_IN_ATTRS, CTL_OMIT_NL, formatList(), formatNode(), isAtom(), isLast(), and next().

Referenced by formatList(), and formatNode().

◆ formatNode()

static void formatNode ( OUTPUTFORMATTER * out,
int aNestLevel,
int aCtl,
const std::string & aKey,
const CPTREE & aTree )
static

Definition at line 164 of file ptree.cpp.

References CTL_OMIT_NL, formatList(), isAtom(), OUTPUTFORMATTER::Print(), and OUTPUTFORMATTER::Quotes().

Referenced by Format(), and formatList().

◆ isAtom()

bool isAtom ( const CPTREE & aTree)
inline

Definition at line 110 of file ptree.cpp.

Referenced by formatList(), and formatNode().

◆ isLast()

bool isLast ( const CPTREE & aTree,
CITER it )
inline

Definition at line 116 of file ptree.cpp.

References next().

Referenced by formatList().

◆ next()

CITER next ( CITER it)
inline

Definition at line 124 of file ptree.cpp.

Referenced by CVPCB_MAINFRAME::AutomaticFootprintMatching(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), CheckDuplicatePins(), TEARDROP_MANAGER::computeAnchorPoints(), PNS::TOPOLOGY::ConnectedJoints(), CornerListToPolygon(), GENCAD_EXPORTER::createPadsShapesSection(), doConvertOutlineToPolygon(), KIGFX::PREVIEW::ANGLE_ITEM::drawPreviewShape(), POLYGON_TRIANGULATION::earcutList(), TMATCH::CONNECTION_GRAPH::FindIsomorphism(), PNS::TOPOLOGY::followBranch(), formatList(), FractureEdge::FractureEdge(), KIEVAL_TEXT_TOKENIZER::get_next_token(), SHAPE_POLY_SET::GetNeighbourIndexes(), hexParse(), intParse(), isLast(), IsUTF8(), EDA_ITEM::Matches(), SEARCH_PANE_LISTVIEW::OnChar(), SYMBOL_VIEWER_FRAME::OnCharHook(), DIALOG_DIELECTRIC_MATERIAL::onListKeyDown(), PCB_POINT_EDITOR::OnSelectionChange(), KIEVAL_TEXT_TOKENIZER::parse_text_content(), parseChar(), parseDouble(), parseHex(), parseInt(), parseQuotedString(), parseUnquotedString(), KICAD_FORMAT::Prettify(), BOARD::recalcOpposites(), ALTIUM_PCB::remapUnsureLayers(), EDA_ITEM::Replace(), DRC_TEST_PROVIDER_SLIVER_CHECKER::Run(), FOOTPRINT_VIEWER_FRAME::selectNext(), POLYGON_TRIANGULATION::simplifyList(), snapCorner(), POLYGON_TRIANGULATION::splitPolygon(), STROKE_PARAMS::Stroke(), unfracture(), SHAPE_POLY_SET::unfractureSingle(), wordbreakMarkup(), PCB_SELECTION_TOOL::ZoomFitCrossProbeBBox(), and SCH_SELECTION_TOOL::ZoomFitCrossProbeBBox().

◆ Scan()

void Scan ( PTREE * aTree,
DSNLEXER * aLexer )

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 84 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().

◆ scanAtom()

void scanAtom ( PTREE * aTree,
const DSNLEXER * aLexer )
inline

Definition at line 76 of file ptree.cpp.

References DSNLEXER::CurText().

Referenced by Scan().

◆ scanList()

void scanList ( PTREE * aTree,
DSNLEXER * aLexer )
inline

Read a sexpr list from the input stream into a new node with key aLexer->CurText().

Definition at line 53 of file ptree.cpp.

References DSNLEXER::CurText(), DSNLEXER::CurTok(), DSN_EOF, DSN_LEFT, DSN_RIGHT, DSNLEXER::NextTok(), Scan(), and DSNLEXER::Unexpected().

Referenced by Scan().