KiCad PCB EDA Suite
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.

Typedefs

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

Functions

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

Typedef Documentation

typedef const PTREE CPTREE

Definition at line 55 of file ptree.h.

typedef boost::property_tree::ptree PTREE

Definition at line 54 of file ptree.h.

typedef boost::property_tree::ptree_error PTREE_ERROR

Definition at line 56 of file ptree.h.

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(), CMP_TREE_MODEL_ADAPTER::AddAliasList(), AddGerberX2Header(), CMP_TREE_MODEL_ADAPTER_BASE::AddLibrariesWithProgress(), CMP_TREE_MODEL_ADAPTER::AddLibrary(), LIB_EDIT_FRAME::addLibraryFile(), PCBNEW_CONTROL::AppendBoard(), SCH_EDIT_FRAME::AppendSchematic(), 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(), DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copyOptionsToPanel(), CONTEXT_MENU::create(), create_backup_file(), CINFO3D_VISU::createLayers(), PCB_BASE_EDIT_FRAME::CreateNewLibrary(), CreateShapesSection(), 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_FP_PLUGIN_OPTIONS::DIALOG_FP_PLUGIN_OPTIONS(), DIALOG_PNS_LENGTH_TUNING_SETTINGS::DIALOG_PNS_LENGTH_TUNING_SETTINGS(), SELECTION_TOOL::disambiguationMenu(), LIB_VIEW_FRAME::DisplayLibInfos(), SCH_BASE_FRAME::DisplayListComponentsInLib(), DIALOG_PAD_PROPERTIES::displayPrimitivesList(), PCB_EDIT_FRAME::DoGenFootprintsPositionFile(), WIZARD_3DSHAPE_LIBS_DOWNLOADER::downloadGithubLibsFromList(), EDIT_TOOL::Duplicate(), DSNLEXER::Duplicate(), SCH_EDIT_FRAME::EditComponentFieldText(), DIALOG_ENV_VAR_CONFIG::EditSelectedEntry(), SCH_EDIT_FRAME::EditSheet(), MODULE_EDITOR_TOOLS::EnumeratePads(), KICAD_MANAGER_FRAME::Execute(), DSNLEXER::Expecting(), FOOTPRINT_EDIT_FRAME::Export_Module(), DIALOG_SVG_PRINT::ExportSVGFile(), PCB_EDIT_FRAME::ExportToGenCAD(), FILE_LINE_READER::FILE_LINE_READER(), FILE_OUTPUTFORMATTER::FILE_OUTPUTFORMATTER(), FP_LIB_TABLE::FindRow(), SYMBOL_LIB_TABLE::FindRow(), LIB_EDIT_FRAME::fixDuplicateAliases(), 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(), FormatWildcardExt(), DSN::SPECCTRA_DB::FromBOARD(), DSN::SPECCTRA_DB::FromSESSION(), ALIAS_INFO_GENERATOR::GenerateHtml(), 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(), LIB_MANAGER::GetUniqueComponentName(), LIB_MANAGER::GetUniqueLibraryName(), DRAWSEGMENT::HitTest(), FOOTPRINT_EDIT_FRAME::Import_Module(), SCH_EDIT_FRAME::ImportFile(), incrementTextCtrl(), DIALOG_EXCHANGE_MODULE::init(), DIALOG_EDIT_COMPONENT_IN_LIBRARY::InitBasicPanel(), DIALOG_FOOTPRINT_WIZARD_LIST::initLists(), PANEL_PREV_3D::initPanel(), PGM_BASE::InitPgm(), TOOL_MANAGER::InitTools(), EAGLE_PLUGIN::kicad_layer(), kiCadComponentRotation(), KIWAY::KiFACE(), PART_LIBS::LibNamesAndPaths(), EAGLE_PLUGIN::Load(), SCH_EAGLE_PLUGIN::Load(), SCH_IO_MGR::Load(), FP_CACHE::Load(), IO_MGR::Load(), GPCB_FPL_CACHE::Load(), SCH_LEGACY_PLUGIN_CACHE::Load(), PART_LIBS::LoadAllLibraries(), SCH_EDIT_FRAME::LoadCmpToFootprintLinkFile(), SCH_LEGACY_PLUGIN_CACHE::loadDocs(), EAGLE_PLUGIN::loadElements(), FP_LIB_TABLE::LoadGlobalTable(), SYMBOL_LIB_TABLE::LoadGlobalTable(), EAGLE_PLUGIN::loadLibrary(), LEGACY_PLUGIN::loadMODULE(), PCB_BASE_FRAME::LoadModuleFromLibrary(), LIB_EDIT_FRAME::loadPart(), SCH_EAGLE_PLUGIN::loadPin(), SCH_EAGLE_PLUGIN::loadSymbol(), 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(), NormalizePath(), not_implemented(), KICAD_MANAGER_FRAME::OnArchiveFiles(), LIB_EDIT_FRAME::OnCheckComponent(), DIALOG_EDIT_COMPONENTS_LIBID::onClickOrphansButton(), SCH_EDIT_FRAME::OnCloseWindow(), PCB_EDIT_FRAME::OnCloseWindow(), SCH_EDIT_FRAME::OnConvertTextType(), TREE_PROJECT_FRAME::OnCreateNewDirectory(), LIB_EDIT_FRAME::OnCreateNewPart(), SCH_EDIT_FRAME::OnDragItem(), CVPCB_MAINFRAME::OnEditFootprintLibraryTable(), SCH_EDIT_FRAME::OnEditItem(), PCB_EDIT_FRAME::OnExportSTEP(), 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(), LIB_EDIT_FRAME::OnRemovePart(), 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(), DIALOG_CHOOSE_COMPONENT::OnSchViewPaint(), SCH_EDIT_FRAME::OnSelectUnit(), SIM_PLOT_FRAME::onSimFinished(), DIALOG_DRC_CONTROL::OnStartdrcClick(), KICAD_MANAGER_FRAME::TERMINATE_HANDLER::OnTerminate(), KICAD_MANAGER_FRAME::OnUnarchiveFiles(), LIB_EDIT_FRAME::OnUpdateViewDoc(), DIALOG_PAGES_SETTINGS::OnWksFileSelection(), PL_EDITOR_FRAME::OpenProjectFiles(), SCH_EDIT_FRAME::OpenProjectFiles(), PCB_EDIT_FRAME::OpenProjectFiles(), EDA_ITEM::operator<(), EAGLE_PLUGIN::packageCircle(), EAGLE_PLUGIN::packagePolygon(), EAGLE_PLUGIN::packageRectangle(), EAGLE_PLUGIN::packageText(), EAGLE_PLUGIN::packageWire(), PCAD2KICAD::PCB_VIA::Parse(), PCAD2KICAD::PCB_PAD::Parse(), FP_LIB_TABLE::Parse(), SYMBOL_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_CHOOSE_COMPONENT::PopulateFootprintSelector(), 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(), SCH_EDIT_FRAME::SaveCopyInUndoList(), BITMAP_BASE::SaveData(), FOOTPRINT_EDIT_FRAME::SaveFootprintInLibrary(), LIB_EDIT_FRAME::saveLibrary(), DIALOG_PAGES_SETTINGS::SavePageSettings(), PCB_EDIT_FRAME::SavePcbCopy(), PCB_EDIT_FRAME::SavePcbFile(), SCH_BASE_FRAME::saveSymbolLibTables(), 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(), DIALOG_CHOOSE_COMPONENT::ShowFootprintFor(), DIALOG_DXF_IMPORT::showPCBdefaultLineWidth(), DIALOG_DXF_IMPORT::showPcbImportOffsets(), SCH_IO_MGR::ShowType(), IO_MGR::ShowType(), StringFromValue(), SCH_BITMAP::SwapData(), SCH_SHEET_PIN::SwapData(), SCH_SHEET::SwapData(), LIB_EDIT_FRAME::SyncLibraries(), FOOTPRINT_EDIT_FRAME::ToolOnRightClick(), SPICE_VALUE::ToString(), TRACE_DESC::TRACE_DESC(), BOARD::TracksInNetBetweenPoints(), DIALOG_GLOBAL_SYM_LIB_TABLE_CONFIG::TransferDataFromWindow(), DIALOG_GENCAD_EXPORT_OPTIONS::TransferDataFromWindow(), DIALOG_SET_GRID::TransferDataFromWindow(), DIALOG_SIM_SETTINGS::TransferDataFromWindow(), DIALOG_SIGNAL_LIST::TransferDataToWindow(), DIALOG_PAD_PRIMITIVES_PROPERTIES::TransferDataToWindow(), DSNLEXER::Unexpected(), HIGHLIGHT_MENU::update(), 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
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