KiCad PCB EDA Suite
ptree.cpp File Reference
#include <macros.h>
#include <boost/property_tree/ptree.hpp>
#include <assert.h>
#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)
 Function scanList reads a sexpr list from the input stream into a new node with key aLexer->CurText(). More...
 
void scanAtom (PTREE *aTree, DSNLEXER *aLexer)
 
void Scan (PTREE *aTree, DSNLEXER *aLexer)
 Function Scan fills an empty PTREE with information from a KiCad s-expresion stream. More...
 
bool isAtom (CPTREE &aTree)
 
bool isLast (CPTREE &aTree, CITER it)
 
CITER next (CITER it)
 
static void formatNode (OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const std::string &aKey, CPTREE &aTree)
 
static void formatList (OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
 
void Format (OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
 Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative. More...
 

Macro Definition Documentation

#define CTL_IN_ATTRS   (1<<1)

Definition at line 45 of file ptree.cpp.

Referenced by formatList().

#define CTL_OMIT_NL   (1<<0)

Definition at line 44 of file ptree.cpp.

Referenced by formatList(), and formatNode().

Typedef Documentation

typedef PTREE::const_iterator CITER

Definition at line 35 of file ptree.cpp.

typedef PTREE::iterator ITER

Definition at line 36 of file ptree.cpp.

Function Documentation

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

Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.

Definition at line 205 of file ptree.cpp.

References formatNode().

Referenced by add_search_paths(), AddGerberX2Header(), PCBNEW_CONTROL::AppendBoard(), SCH_EDIT_FRAME::AppendOneEEProject(), SCH_EDIT_FRAME::backAnnotateFootprints(), DIALOG_MODULE_MODULE_EDITOR::BrowseAndAdd3DShapeFile(), DIALOG_MODULE_BOARD_EDITOR::BrowseAndAdd3DShapeFile(), BuildGerberX2Header(), SCH_EDIT_FRAME::BuildNetListBase(), EAGLE_PLUGIN::cacheLib(), GITHUB_PLUGIN::cacheLib(), EDA_BASE_FRAME::CheckForAutoSaveFile(), checkGlError(), PICKED_ITEMS_LIST::ClearListAndDeleteItems(), FOOTPRINT_VIEWER_FRAME::ClickOnFootprintList(), ConfigBaseWriteDouble(), copy_pro_file_template(), MODULE_EDITOR_TOOLS::CopyItems(), DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copyOptionsToPanel(), DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copyPanelToOptions(), CONTEXT_MENU::create(), create_backup_file(), CINFO3D_VISU::createLayers(), PCB_BASE_EDIT_FRAME::CreateNewLibrary(), LIB_EDIT_FRAME::CreateNewLibraryPart(), SCH_LEGACY_PLUGIN::CreateSymbolLib(), TREEPROJECT_ITEM::Delete(), SCH_LEGACY_PLUGIN_CACHE::DeleteAlias(), FOOTPRINT_EDIT_FRAME::DeleteModuleFromCurrentLibrary(), SCH_LEGACY_PLUGIN_CACHE::DeleteSymbol(), SCH_LEGACY_PLUGIN::DeleteSymbolLib(), DIALOG_CONFIG_EQUFILES::DIALOG_CONFIG_EQUFILES(), DIALOG_EESCHEMA_CONFIG::DIALOG_EESCHEMA_CONFIG(), DIALOG_FP_PLUGIN_OPTIONS::DIALOG_FP_PLUGIN_OPTIONS(), DIALOG_PNS_LENGTH_TUNING_SETTINGS::DIALOG_PNS_LENGTH_TUNING_SETTINGS(), SELECTION_TOOL::disambiguationMenu(), LIB_VIEW_FRAME::DisplayLibInfos(), LIB_EDIT_FRAME::DisplayLibInfos(), DIALOG_PAD_PROPERTIES::displayPrimitivesList(), PCB_EDIT_FRAME::DoGenFootprintsPositionFile(), WIZARD_3DSHAPE_LIBS_DOWNLOADER::downloadGithubLibsFromList(), EDIT_TOOL::Duplicate(), DSNLEXER::Duplicate(), SCH_EDIT_FRAME::EditSheet(), MODULE_EDITOR_TOOLS::EnumeratePads(), KICAD_MANAGER_FRAME::Execute(), DSNLEXER::Expecting(), FOOTPRINT_EDIT_FRAME::Export_Module(), DIALOG_SVG_PRINT::ExportSVGFile(), FILE_LINE_READER::FILE_LINE_READER(), FILE_OUTPUTFORMATTER::FILE_OUTPUTFORMATTER(), SYMBOL_LIB_TABLE::FindRow(), FP_LIB_TABLE::FindRow(), GPCB_PLUGIN::FootprintDelete(), PCB_IO::FootprintDelete(), GITHUB_PLUGIN::FootprintDelete(), GPCB_PLUGIN::FootprintEnumerate(), PCB_IO::FootprintEnumerate(), PCB_IO::FootprintLibCreate(), GPCB_PLUGIN::FootprintLibDelete(), LEGACY_PLUGIN::FootprintLibDelete(), PCB_IO::FootprintLibDelete(), PCB_IO::FootprintSave(), FootprintWriteShape(), WORKSHEET_LAYOUT_IO::Format(), NETLIST_EXPORTER_PSPICE::Format(), TEMPLATES::Format(), PCB_IO::format(), formatCoord(), formatPreviewDimension(), DSN::SPECCTRA_DB::FromBOARD(), DSN::SPECCTRA_DB::FromSESSION(), DIALOG_SPICE_MODEL::generatePowerSource(), DISPLAY_FOOTPRINTS_FRAME::Get_Module(), GetBuildVersion(), DRC_ITEM::GetErrorText(), BOM_TABLE_GROUP::GetFieldValue(), EDA_BASE_FRAME::GetFileFromHistory(), GITHUB_GETLIBLIST::GetFootprintLibraryList(), GetGerberProtelExtension(), EDA_BASE_FRAME::GetKicadHelp(), EAGLE_PLUGIN::getModificationTime(), FOOTPRINT_LIST::GetModuleInfo(), MODULE::GetNextPadName(), LIB_CIRCLE::GetSelectMenuText(), LIB_RECTANGLE::GetSelectMenuText(), LIB_POLYLINE::GetSelectMenuText(), LIB_ARC::GetSelectMenuText(), LIB_FIELD::GetSelectMenuText(), ZONE_CONTAINER::GetSelectMenuText(), NETLIST_EXPORTER_PSPICE_SIM::GetSheetSimCommand(), NETLIST_EXPORTER_PSPICE_SIM::GetSpiceVector(), DRAWSEGMENT::HitTest(), FOOTPRINT_EDIT_FRAME::Import_Module(), incrementTextCtrl(), DIALOG_EXCHANGE_MODULE::init(), DIALOG_EDIT_COMPONENT_IN_LIBRARY::InitBasicPanel(), DIALOG_FOOTPRINT_WIZARD_LIST::initLists(), PGM_BASE::InitPgm(), TOOL_MANAGER::InitTools(), EAGLE_PLUGIN::kicad_layer(), KIWAY::KiFACE(), PART_LIBS::LibNamesAndPaths(), EAGLE_PLUGIN::Load(), SCH_IO_MGR::Load(), IO_MGR::Load(), FP_CACHE::Load(), GPCB_FPL_CACHE::Load(), SCH_LEGACY_PLUGIN_CACHE::Load(), SCH_EDIT_FRAME::Load_Component(), PART_LIBS::LoadAllLibraries(), SCH_EDIT_FRAME::LoadCmpToFootprintLinkFile(), SCH_LEGACY_PLUGIN_CACHE::loadDocs(), EAGLE_PLUGIN::loadElements(), SYMBOL_LIB_TABLE::LoadGlobalTable(), FP_LIB_TABLE::LoadGlobalTable(), EAGLE_PLUGIN::loadLibrary(), LEGACY_PLUGIN::loadMODULE(), PCB_BASE_FRAME::LoadModuleFromLibrary(), LIB_EDIT_FRAME::LoadOneLibraryPart(), PCB_PARSER::lookUpLayer(), DSN::SPECCTRA_DB::makeTRACK(), DSN::SPECCTRA_DB::makeVIA(), PCAD2KICAD::PCB::MapLayer(), SIM_PLOT_FRAME::menuSaveCsv(), HTML_MESSAGE_BOX::MessageSet(), DSNLEXER::NeedNUMBER(), SIM_PLOT_FRAME::NewPlotPanel(), not_implemented(), DIALOG_EESCHEMA_CONFIG::OnAddOrInsertLibClick(), KICAD_MANAGER_FRAME::OnArchiveFiles(), LIB_EDIT_FRAME::OnCheckComponent(), SCH_EDIT_FRAME::OnCloseWindow(), LIB_EDIT_FRAME::OnCloseWindow(), PCB_EDIT_FRAME::OnCloseWindow(), SCH_EDIT_FRAME::OnConvertTextType(), TREE_PROJECT_FRAME::OnCreateNewDirectory(), SCH_EDIT_FRAME::OnDragItem(), CVPCB_MAINFRAME::OnEditFootprintLibraryTable(), SCH_EDIT_FRAME::OnEditItem(), SCH_BASE_FRAME::OnEditSymbolLibTable(), PCB_EDIT_FRAME::OnExportSTEP(), LIB_EDIT_FRAME::OnImportPart(), FOOTPRINT_VIEWER_FRAME::OnIterateFootprintList(), LIB_EDIT_FRAME::OnLeftClick(), SCH_EDIT_FRAME::OnLeftClick(), PCB_EDIT_FRAME::OnLeftClick(), PCB_EDIT_FRAME::OnLeftDClick(), DIALOG_DRC_CONTROL::OnListUnconnectedClick(), SCH_EDIT_FRAME::OnMoveItem(), SCH_EDIT_FRAME::OnNewProject(), DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::OnOKButtonClick(), DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnOKButtonClick(), DIALOG_PAD_PROPERTIES::OnPadShapeSelection(), EDA_3D_CANVAS::OnPaint(), TREE_PROJECT_FRAME::OnRenameFile(), GERBVIEW_FRAME::OnRightClick(), LIB_EDIT_FRAME::OnRightClick(), SCH_EDIT_FRAME::OnRightClick(), SCH_EDIT_FRAME::OnRotate(), FOOTPRINT_EDIT_FRAME::OnSaveLibraryAs(), SCH_EDIT_FRAME::OnSaveProject(), SCH_EDIT_FRAME::OnSelectUnit(), SIM_PLOT_FRAME::onSimFinished(), DIALOG_DRC_CONTROL::OnStartdrcClick(), KICAD_MANAGER_FRAME::TERMINATE_HANDLER::OnTerminate(), DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnTestChipName(), KICAD_MANAGER_FRAME::OnUnarchiveFiles(), DIALOG_PAGES_SETTINGS::OnWksFileSelection(), PL_EDITOR_FRAME::OpenProjectFiles(), SCH_EDIT_FRAME::OpenProjectFiles(), PCB_EDIT_FRAME::OpenProjectFiles(), EDA_ITEM::operator<(), PCAD2KICAD::PCB_VIA::Parse(), PCAD2KICAD::PCB_PAD::Parse(), SYMBOL_LIB_TABLE::Parse(), FP_LIB_TABLE::Parse(), PCB_PARSER::parseD_PAD(), parseInt(), PCB_PARSER::parseLayers(), PCB_PARSER::parseTEXTE_MODULE(), PCB_PARSER::parseTRACK(), PCB_PARSER::parseVIA(), PCB_PARSER::parseZONE_CONTAINER(), SCH_EDIT_FRAME::PasteListOfItems(), DIALOG_RESCUE_EACH::PopulateInstanceList(), KICAD_MANAGER_FRAME::PrintPrjInfo(), PCB_EDIT_FRAME::Process_Config(), SCH_EDIT_FRAME::Process_Special_Functions(), PCB_EDIT_FRAME::Process_Special_Functions(), FOOTPRINT_EDIT_FRAME::ProcessPreferences(), SCH_EDIT_FRAME::PutDataInPreviousState(), LP_CACHE::ReadAndVerifyHeader(), CVPCB_MAINFRAME::ReadNetListAndFpFiles(), CVPCB_MAINFRAME::ReadSchematicNetlist(), EXCELLON_IMAGE::readToolInformation(), PL_EDITOR_FRAME::RebuildDesignTree(), C3D_RENDER_OGL_LEGACY::reload(), C3D_RENDER_RAYTRACING::reload(), GITHUB_PLUGIN::remoteGetZip(), FP_CACHE::Remove(), GPCB_FPL_CACHE::Remove(), PCB_EDIT_FRAME::RemoveStruct(), C3D_RENDER_RAYTRACING::render(), GITHUB_GETLIBLIST::repoURL2listURL(), SCH_EDIT_FRAME::ReSizeSheet(), WIDGET_HOTKEY_LIST::ResolveKeyConflicts(), C3D_RENDER_RAYTRACING::rt_render_tracing(), TOOL_MANAGER::RunAction(), CONTEXT_MENU::runOnSubmenus(), SCH_IO_MGR::Save(), FP_CACHE::Save(), IO_MGR::Save(), PART_LIB::Save(), save_library(), SCH_EDIT_FRAME::SaveCopyInUndoList(), BITMAP_BASE::SaveData(), FOOTPRINT_EDIT_FRAME::SaveFootprintInLibrary(), DIALOG_PAGES_SETTINGS::SavePageSettings(), PCB_EDIT_FRAME::SavePcbCopy(), PCB_EDIT_FRAME::SavePcbFile(), SIM_PLOT_FRAME::saveWorkbook(), ALIAS_INFO_GENERATOR::SetHtmlAliasOf(), ALIAS_INFO_GENERATOR::SetHtmlDesc(), ALIAS_INFO_GENERATOR::SetHtmlKeywords(), PANEL_PREV_3D::SetModelDataIdx(), CVPCB_MAINFRAME::SetNewPkg(), EDA_DRAW_FRAME::SetToolID(), COLORS_DESIGN_SETTINGS::setupConfigParams(), WIZARD_FPLIB_TABLE::setupReview(), SCH_IO_MGR::ShowType(), IO_MGR::ShowType(), StringFromValue(), SCH_BITMAP::SwapData(), SCH_SHEET_PIN::SwapData(), SCH_SHEET::SwapData(), FOOTPRINT_EDIT_FRAME::ToolOnRightClick(), SPICE_VALUE::ToString(), TRACE_DESC::TRACE_DESC(), BOARD::TracksInNetBetweenPoints(), DIALOG_GLOBAL_SYM_LIB_TABLE_CONFIG::TransferDataFromWindow(), DIALOG_SET_GRID::TransferDataFromWindow(), DIALOG_SIM_SETTINGS::TransferDataFromWindow(), DIALOG_SIGNAL_LIST::TransferDataToWindow(), DIALOG_PAD_PRIMITIVES_PROPERTIES::TransferDataToWindow(), DSNLEXER::Unexpected(), FOOTPRINT_VIEWER_FRAME::Update3D_Frame(), CONTEXT_MENU::UpdateAll(), DIALOG_DRC_CONTROL::UpdateDisplayedCounts(), LIB_EDIT_FRAME::UpdatePartSelectList(), SIM_PLOT_FRAME::updatePlot(), DIALOG_PAD_PROPERTIES::updateRoundRectCornerValues(), INCREMENTAL_TEXT_CTRL::updateTextValue(), DIALOG_BOM_EDITOR::UpdateTitle(), PCB_BASE_FRAME::updateZoomSelectBox(), SPICE_VALIDATOR::Validate(), PANEL_PREV_3D::ValidateWithMessage(), DIALOG_SYMBOL_LIB_TABLE::verifyTables(), DIALOG_FP_LIB_TABLE::verifyTables(), FILE_OUTPUTFORMATTER::write(), WriteDiagnosticERC(), SCH_EDIT_FRAME::WriteNetListFile(), and ZOOM_MENU::ZOOM_MENU().

206 {
207  if( aTree.size() == 1 && !aTree.data().size() )
208  {
209  // The topmost node is basically only a container for the document root.
210  // It anchors the paths which traverse the tree deeper.
211  CITER it = aTree.begin();
212  formatNode( out, aNestLevel, aCtl, it->first, it->second );
213  }
214  else
215  {
216  // This is not expected, neither for sexpr nor xml.
217  formatNode( out, aNestLevel, aCtl, "", aTree );
218  }
219 }
PTREE::const_iterator CITER
Definition: ptree.cpp:35
static void formatNode(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const std::string &aKey, CPTREE &aTree)
Definition: ptree.cpp:171
static void formatList ( OUTPUTFORMATTER out,
int  aNestLevel,
int  aCtl,
CPTREE aTree 
)
static

Definition at line 141 of file ptree.cpp.

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

Referenced by formatNode().

143 {
144  for( CITER it = aTree.begin(); it != aTree.end(); ++it )
145  {
146  // Processing a tree which was read in with xml_parser?
147  if( it->first == "<xmlattr>" )
148  {
149  formatList( out, aNestLevel, aCtl | CTL_IN_ATTRS, it->second );
150  continue;
151  }
152 
153  int ctl = 0;
154 
155  if( isLast( aTree, it ) ) // is "it" the last one?
156  {
157  //if( !( aCtl & CTL_IN_ATTRS ) )
158  ctl = CTL_OMIT_NL;
159  }
160  else if( isAtom( next( it )->second ) )
161  {
162  /* if( !( aCtl & CTL_IN_ATTRS ) ) */
163  ctl = CTL_OMIT_NL;
164  }
165 
166  formatNode( out, aNestLevel+1, ctl, it->first, it->second );
167  }
168 }
CITER next(CITER it)
Definition: ptree.cpp:130
bool isLast(CPTREE &aTree, CITER it)
Definition: ptree.cpp:122
PTREE::const_iterator CITER
Definition: ptree.cpp:35
static void formatList(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Definition: ptree.cpp:141
bool isAtom(CPTREE &aTree)
Definition: ptree.cpp:116
#define CTL_IN_ATTRS
Definition: ptree.cpp:45
static void formatNode(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const std::string &aKey, CPTREE &aTree)
Definition: ptree.cpp:171
#define CTL_OMIT_NL
Definition: ptree.cpp:44
static void formatNode ( OUTPUTFORMATTER out,
int  aNestLevel,
int  aCtl,
const std::string &  aKey,
CPTREE aTree 
)
static

Definition at line 171 of file ptree.cpp.

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

Referenced by Format(), and formatList().

174 {
175  if( !isAtom( aTree ) ) // is a list, not an atom
176  {
177  int ctl = CTL_OMIT_NL;
178 
179  // aTree is list and its first child is a list
180  if( aTree.size() && !isAtom( aTree.begin()->second ) && !aTree.data().size() )
181  ctl = 0;
182 
183  out->Print( aNestLevel, "(%s%s", out->Quotes( aKey ).c_str(), ctl & CTL_OMIT_NL ? "" : "\n" );
184 
185  if( aTree.data().size() ) // sexpr format does not use data()
186  {
187  out->Print( 0, " %s%s",
188  out->Quotes( aTree.data() ).c_str(),
189  aTree.size() ? "\n" : ""
190  );
191  }
192 
193  formatList( out, aNestLevel, aCtl, aTree );
194 
195  out->Print( 0, ")%s", aCtl & CTL_OMIT_NL ? "" : "\n" );
196  }
197 
198  else // is an atom, not a list
199  {
200  out->Print( 0, " %s", out->Quotes( aKey ).c_str() );
201  }
202 }
static void formatList(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Definition: ptree.cpp:141
bool isAtom(CPTREE &aTree)
Definition: ptree.cpp:116
virtual std::string Quotes(const std::string &aWrapee)
Function Quotes checks aWrapee input string for a need to be quoted (e.g.
Definition: richio.cpp:437
#define CTL_OMIT_NL
Definition: ptree.cpp:44
int PRINTF_FUNC Print(int nestLevel, const char *fmt,...)
Function Print formats and writes text to the output stream.
Definition: richio.cpp:408
bool isAtom ( CPTREE aTree)
inline

Definition at line 116 of file ptree.cpp.

Referenced by formatList(), and formatNode().

117 {
118  return aTree.size()==0 && aTree.data().size()==0;
119 }
bool isLast ( CPTREE aTree,
CITER  it 
)
inline

Definition at line 122 of file ptree.cpp.

References next().

Referenced by formatList(), and PCB_LAYER_WIDGET::onPopupSelection().

123 {
124  CITER next = it;
125  ++next;
126  return next == aTree.end();
127 }
CITER next(CITER it)
Definition: ptree.cpp:130
PTREE::const_iterator CITER
Definition: ptree.cpp:35
void Scan ( PTREE aTree,
DSNLEXER aLexer 
)

Function Scan fills an empty PTREE with information from a KiCad s-expresion 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 90 of file ptree.cpp.

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

Referenced by SCH_EDIT_FRAME::backAnnotateFootprints(), and scanList().

91 {
92  int tok = aLexer->CurTok();
93 
94  // conditionally read first token.
95  if( tok == DSN_NONE )
96  tok = aLexer->NextTok();
97 
98  if( tok == DSN_EOF )
99  {
100  aLexer->Unexpected( DSN_EOF );
101  }
102 
103  if( tok == DSN_LEFT )
104  {
105  scanList( aTree, aLexer );
106  }
107  else
108  {
109  scanAtom( aTree, aLexer );
110  }
111 }
void Unexpected(int aTok)
Function Unexpected throws an IO_ERROR exception with an input file specific error message...
Definition: dsnlexer.cpp:369
void scanList(PTREE *aTree, DSNLEXER *aLexer)
Function scanList reads a sexpr list from the input stream into a new node with key aLexer->CurText()...
Definition: ptree.cpp:55
int CurTok()
Function CurTok returns whatever NextTok() returned the last time it was called.
Definition: dsnlexer.h:320
void scanAtom(PTREE *aTree, DSNLEXER *aLexer)
Definition: ptree.cpp:80
int NextTok()
Function NextTok returns the next token found in the input file or DSN_EOF when reaching the end of f...
Definition: dsnlexer.cpp:540
void scanAtom ( PTREE aTree,
DSNLEXER aLexer 
)
inline

Definition at line 80 of file ptree.cpp.

References DSNLEXER::CurText().

Referenced by Scan().

81 {
82  const char* key = aLexer->CurText();
83 
84  //D(printf( "%s: '%s'\n", __func__, key );)
85 
86  aTree->push_back( PTREE::value_type( key, PTREE() ) );
87 }
boost::property_tree::ptree PTREE
Definition: ptree.h:54
const char * CurText()
Function CurText returns a pointer to the current token's text.
Definition: dsnlexer.h:479
void scanList ( PTREE aTree,
DSNLEXER aLexer 
)
inline

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

Definition at line 55 of file ptree.cpp.

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

Referenced by FOOTPRINT_EDIT_FRAME::ModeditLocateAndDisplay(), PCB_BASE_FRAME::PcbGeneralLocateAndDisplay(), and Scan().

56 {
57  assert( aLexer->CurTok() == DSN_LEFT );
58 
59  int tok = aLexer->NextTok();
60 
61  const char* key = aLexer->CurText();
62 
63  //D(printf( "%s: '%s'\n", __func__, key );)
64 
65  PTREE* list = &aTree->push_back( PTREE::value_type( key, PTREE() ) )->second;
66 
67  if( tok != DSN_RIGHT )
68  {
69  while( ( tok = aLexer->NextTok() ) != DSN_RIGHT )
70  {
71  if( tok == DSN_EOF )
72  aLexer->Unexpected( DSN_EOF );
73 
74  Scan( list, aLexer );
75  }
76  }
77 }
void Scan(PTREE *aTree, DSNLEXER *aLexer)
Function Scan fills an empty PTREE with information from a KiCad s-expresion stream.
Definition: ptree.cpp:90
void Unexpected(int aTok)
Function Unexpected throws an IO_ERROR exception with an input file specific error message...
Definition: dsnlexer.cpp:369
boost::property_tree::ptree PTREE
Definition: ptree.h:54
int CurTok()
Function CurTok returns whatever NextTok() returned the last time it was called.
Definition: dsnlexer.h:320
int NextTok()
Function NextTok returns the next token found in the input file or DSN_EOF when reaching the end of f...
Definition: dsnlexer.cpp:540
const char * CurText()
Function CurText returns a pointer to the current token's text.
Definition: dsnlexer.h:479