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) throw ( IO_ERROR )
 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) throw ( IO_ERROR )
 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 
)
throw (IO_ERROR
)

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(), AddGerberX2Attribute(), PCBNEW_CONTROL::AppendBoard(), PCB_EDIT_FRAME::AppendBoardFile(), SCH_EDIT_FRAME::AppendOneEEProject(), SCH_EDIT_FRAME::backAnnotateFootprints(), DIALOG_MODULE_MODULE_EDITOR::BrowseAndAdd3DShapeFile(), DIALOG_MODULE_BOARD_EDITOR::BrowseAndAdd3DShapeFile(), SCH_EDIT_FRAME::BuildNetListBase(), 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(), LIB_VIEW_FRAME::DisplayLibInfos(), LIB_EDIT_FRAME::DisplayLibInfos(), 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(), formatPreviewDimension(), DSN::SPECCTRA_DB::FromBOARD(), DSN::SPECCTRA_DB::FromSESSION(), DIALOG_SPICE_MODEL::generatePowerSource(), DISPLAY_FOOTPRINTS_FRAME::Get_Module(), GetBuildVersion(), PCB_EDIT_FRAME::GetConfigurationSettings(), DRC_ITEM::GetErrorText(), 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(), KIWAY::KiFACE(), PART_LIBS::LibNamesAndPaths(), 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(), FP_LIB_TABLE::LoadGlobalTable(), SYMBOL_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(), 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(), PCB_EDIT_FRAME::OnExportSTEP(), LIB_EDIT_FRAME::OnImportPart(), FOOTPRINT_VIEWER_FRAME::OnIterateFootprintList(), CV::IFACE::OnKifaceStart(), SCH::IFACE::OnKifaceStart(), PCB::IFACE::OnKifaceStart(), LIB_EDIT_FRAME::OnLeftClick(), SCH_EDIT_FRAME::OnLeftClick(), PCB_EDIT_FRAME::OnLeftClick(), DIALOG_DRC_CONTROL::OnListUnconnectedClick(), KICAD_MANAGER_FRAME::OnLoadProject(), 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::ReadNetListAndLinkFiles(), 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(), FP_CACHE::Save(), SCH_IO_MGR::Save(), IO_MGR::Save(), PART_LIB::Save(), LIB_TABLE::Save(), save_library(), SaveBoard(), 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(), WIZARD_FPLIB_TABLE::setupReview(), SCH_IO_MGR::ShowType(), IO_MGR::ShowType(), StringFromValue(), SCH_BITMAP::SwapData(), SCH_SHEET_PIN::SwapData(), SCH_SHEET::SwapData(), PCB_BASE_FRAME::TestForActiveLinksInRatsnest(), SPICE_VALUE::ToString(), TRACE_DESC::TRACE_DESC(), BOARD::TracksInNetBetweenPoints(), DIALOG_SET_GRID::TransferDataFromWindow(), DIALOG_SIM_SETTINGS::TransferDataFromWindow(), DIALOG_SIGNAL_LIST::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(), PCB_BASE_FRAME::updateZoomSelectBox(), SPICE_VALIDATOR::Validate(), PANEL_PREV_3D::ValidateWithMessage(), 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 }
static void formatNode(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const std::string &aKey, CPTREE &aTree)
Definition: ptree.cpp:171
PTREE::const_iterator CITER
void Scan ( PTREE aTree,
DSNLEXER aLexer 
)
throw (IO_ERROR
)

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 DSN_EOF, DSN_LEFT, DSN_NONE, scanAtom(), and scanList().

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:370
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:541