KiCad PCB EDA Suite
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)
 Function scanList reads a sexpr list from the input stream into a new node with key aLexer->CurText(). More...
 
void scanAtom (PTREE *aTree, const 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 (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)
 Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative. More...
 

Macro Definition Documentation

◆ CTL_IN_ATTRS

#define CTL_IN_ATTRS   (1<<1)

Definition at line 45 of file ptree.cpp.

◆ CTL_OMIT_NL

#define CTL_OMIT_NL   (1<<0)

Definition at line 44 of file ptree.cpp.

◆ D

#define D (   x)

Definition at line 41 of file ptree.cpp.

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

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

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

Definition at line 200 of file ptree.cpp.

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

References formatNode().

Referenced by ACTION_MENU::AddClose(), WX_HTML_REPORT_BOX::addHeader(), WX_HTML_REPORT_PANEL::addHeader(), TREE_PROJECT_FRAME::AddItemToTreeProject(), GERBER_JOBFILE_WRITER::addJSONMaterialStackup(), SYMBOL_TREE_MODEL_ADAPTER::AddLibraries(), SYMBOL_TREE_MODEL_ADAPTER::AddLibrary(), SYMBOL_EDIT_FRAME::AddLibraryFile(), ACTION_MENU::AddQuitOrClose(), altium_layer_from_name(), APAD6::APAD6(), PCBNEW_CONTROL::AppendBoard(), PROJECT_ARCHIVER::Archive(), KIID::AsLegacyTimestampString(), CVPCB_ASSOCIATION_TOOL::Associate(), CVPCB_MAINFRAME::AssociateFootprint(), AUTOPLACE_TOOL::autoplace(), AR_AUTOPLACER::AutoplaceFootprints(), SYMBOL_EDIT_FRAME::backupFile(), SETTINGS_MANAGER::BackupProject(), BOM_GENERATOR_HANDLER::BOM_GENERATOR_HANDLER(), FIELDS_GRID_TABLE< SCH_FIELD >::BoolFromString(), PANEL_SYM_LIB_TABLE::browseLibrariesHandler(), PANEL_FP_LIB_TABLE::browseLibrariesHandler(), CONNECTION_GRAPH::buildConnectionGraph(), WS_DRAW_ITEM_LIST::BuildFullText(), EAGLE_PLUGIN::cacheLib(), PYTHON_ACTION_PLUGIN::CallMethod(), PYTHON_FOOTPRINT_WIZARD::CallMethod(), FOOTPRINT_EDIT_FRAME::canCloseWindow(), PL_EDITOR_FRAME::canCloseWindow(), PCB_EDIT_FRAME::canCloseWindow(), SCH_EDIT_FRAME::canCloseWindow(), SCH_EDIT_TOOL::ChangeTextType(), CADSTAR_PCB_ARCHIVE_LOADER::checkAndLogHatchCode(), PANEL_SETUP_LAYERS::CheckCopperLayerCount(), EDA_BASE_FRAME::CheckForAutoSaveFile(), BACK_ANNOTATE::checkForUnusedSymbols(), checkGlError(), EE_INSPECTION_TOOL::CheckSymbol(), DIALOG_IMAGE_EDITOR::CheckValues(), FOOTPRINT_VIEWER_FRAME::ClickOnFootprintList(), DRC_RULE_CONDITION::Compile(), DRC_ENGINE::compileRules(), NETLIST_EXPORTER_PSPICE_SIM::ComponentToVector(), NUMBER_BADGE::computeSize(), ConfigBaseWriteDouble(), ConvertArcCenter(), DIALOG_BOARD_REANNOTATE::CoordTowxString(), ACTION_MENU::create(), createBoard(), PCB_BASE_EDIT_FRAME::CreateNewLibrary(), SYMBOL_EDIT_FRAME::CreateNewPart(), DIALOG_ABOUT::createNotebookHtmlPage(), DIALOG_PLOT_SCHEMATIC::createPlotFileName(), CreateShapesSection(), SCH_SEXPR_PLUGIN::CreateSymbolLib(), SCH_LEGACY_PLUGIN::CreateSymbolLib(), CADSTAR_PCB_ARCHIVE_LOADER::createUniqueGroupID(), TREEPROJECT_ITEM::Delete(), FOOTPRINT_EDIT_FRAME::DeleteFootprintFromLibrary(), SYMBOL_EDIT_FRAME::DeletePartFromLibrary(), SCH_SEXPR_PLUGIN_CACHE::DeleteSymbol(), SCH_LEGACY_PLUGIN_CACHE::DeleteSymbol(), SCH_SEXPR_PLUGIN::DeleteSymbolLib(), SCH_LEGACY_PLUGIN::DeleteSymbolLib(), DIALOG_ABOUT::DIALOG_ABOUT(), DIALOG_CONFIG_EQUFILES::DIALOG_CONFIG_EQUFILES(), DIALOG_FP_PLUGIN_OPTIONS::DIALOG_FP_PLUGIN_OPTIONS(), DIALOG_IMPORT_GFX::DIALOG_IMPORT_GFX(), KIGFX::PREVIEW::DimensionLabel(), LIB_VIEW_FRAME::DisplayLibInfos(), DIALOG_PAD_PROPERTIES::displayPrimitivesList(), CVPCB_MAINFRAME::DisplayStatus(), SYMBOL_PREVIEW_WIDGET::DisplaySymbol(), PCB_EDIT_FRAME::doCloseWindow(), SCH_FIELD::DoHypertextMenu(), doPrintFile(), EDA_3D_CANVAS::DoRePaint(), ACTION_TOOLBAR::doSelectAction(), PL_SELECTION_TOOL::doSelectionMenu(), EE_SELECTION_TOOL::doSelectionMenu(), SELECTION_TOOL::doSelectionMenu(), CADSTAR_PCB_ARCHIVE_LOADER::drawCadstarShape(), SCH_EDIT_TOOL::Duplicate(), EDIT_TOOL::Duplicate(), DSNLEXER::Duplicate(), PCB_EDIT_FRAME::Edit_Zone_Params(), SCH_EDIT_TOOL::editFieldText(), PAD_TOOL::EnumeratePads(), CONNECTION_GRAPH::ercCheckBusToBusEntryConflicts(), CONNECTION_GRAPH::ercCheckHierSheets(), DRC_ENGINE::EvalRulesForItems(), KICAD_MANAGER_CONTROL::Execute(), EXCELLON_IMAGE::Execute_EXCELLON_G_Command(), existsOnLayer(), DSNLEXER::Expecting(), FOOTPRINT_EDIT_FRAME::ExportFootprint(), DIALOG_EXPORT_SVG::ExportSVGFile(), PCB_EDIT_FRAME::ExportToGenCAD(), LIB_CONTROL::ExportView(), FILE_LINE_READER::FILE_LINE_READER(), PCB_EDIT_FRAME::Files_io_from_id(), PNS::DIFF_PAIR_PLACER::findDpPrimitivePair(), FP_LIB_TABLE::FindRow(), EXCELLON_IMAGE::FinishRouteCommand(), LIB_PART::Flatten(), GPCB_PLUGIN::FootprintDelete(), PCB_IO::FootprintDelete(), GPCB_PLUGIN::FootprintEnumerate(), PCB_IO::FootprintLibCreate(), GPCB_PLUGIN::FootprintLibDelete(), LEGACY_PLUGIN::FootprintLibDelete(), PCB_IO::FootprintLibDelete(), PCB_IO::FootprintSave(), FootprintWriteShape(), WS_DATA_MODEL_IO::Format(), NETLIST_EXPORTER_PSPICE::Format(), PCB_IO::format(), LIBEVAL::UOP::Format(), formatConstraint(), formatCoord(), DIALOG_NET_INSPECTOR::formatCount(), DIALOG_NET_INSPECTOR::formatNetCode(), PANEL_PREV_3D::formatOffsetValue(), PANEL_PREV_3D::formatRotationValue(), PANEL_PREV_3D::formatScaleValue(), formatWildcardExt(), DSN::SPECCTRA_DB::FromBOARD(), DSN::SPECCTRA_DB::FromSESSION(), GbrMakeProjectGUIDfromString(), FOOTPRINT_INFO_GENERATOR::GenerateHtml(), DIALOG_SPICE_MODEL::generatePowerSource(), PLACE_FILE_EXPORTER::GenPositionData(), CURSOR_STORE::Get(), SYMBOL_LIBRARY_MANAGER::GetBufferedPart(), GetBuildDate(), GetBuildVersion(), BACK_ANNOTATE::getChangeList(), TEMPLATE_FIELDNAME::GetDefaultFieldName(), SCH_SHEET::GetDefaultFieldName(), TOOL_ACTION::GetDescription(), EDA_BASE_FRAME::GetFileFromHistory(), DISPLAY_FOOTPRINTS_FRAME::GetFootprint(), FOOTPRINT_LIST::GetFootprintInfo(), GetGerberProtelExtension(), GetKeyName(), PCAD2KICAD::PCB::GetKiCadLayer(), GetKicadLockFilePath(), CADSTAR_PCB_ARCHIVE_LOADER::getKiCadNet(), CADSTAR_PCB_ARCHIVE_LOADER::getKiCadPad(), PCAD2KICAD::PCB::GetLayerNetNameRef(), PCAD2KICAD::PCB::GetLayerType(), SYMBOL_LIBRARY_MANAGER::getLibraryBuffer(), FOOTPRINT::GetLocalClearance(), PAD::GetLocalClearance(), CADSTAR_SCH_ARCHIVE_LOADER::getLocationOfNetElement(), GetMajorMinorVersion(), PCB_GROUP::GetMsgPanelInfo(), DIMENSION_BASE::GetMsgPanelInfo(), SCH_COMPONENT::GetMsgPanelInfo(), LEADER::GetMsgPanelInfo(), DRC_CONSTRAINT::GetName(), ALTIUM_PCB::GetNetCode(), CADSTAR_SCH_ARCHIVE_LOADER::getNetName(), FOOTPRINT::GetNextPadName(), KIGFX::ACCELERATING_ZOOM_CONTROLLER::GetScaleForRotation(), KIGFX::CONSTANT_ZOOM_CONTROLLER::GetScaleForRotation(), DIALOG_PRINT_GENERIC::getScaleValue(), SCH_PIN::GetSelectMenuText(), LIB_RECTANGLE::GetSelectMenuText(), LIB_CIRCLE::GetSelectMenuText(), PCB_MARKER::GetSelectMenuText(), LIB_TEXT::GetSelectMenuText(), LIB_POLYLINE::GetSelectMenuText(), PCB_TEXT::GetSelectMenuText(), LIB_ARC::GetSelectMenuText(), FP_SHAPE::GetSelectMenuText(), WS_DRAW_ITEM_LINE::GetSelectMenuText(), PCB_GROUP::GetSelectMenuText(), SCH_FIELD::GetSelectMenuText(), WS_DRAW_ITEM_POLYPOLYGONS::GetSelectMenuText(), LIB_FIELD::GetSelectMenuText(), SCH_SHEET_PIN::GetSelectMenuText(), FP_TEXT::GetSelectMenuText(), TRACK::GetSelectMenuText(), SCH_LINE::GetSelectMenuText(), WS_DRAW_ITEM_RECT::GetSelectMenuText(), DIMENSION_BASE::GetSelectMenuText(), LIB_PIN::GetSelectMenuText(), GERBER_DRAW_ITEM::GetSelectMenuText(), SCH_TEXT::GetSelectMenuText(), WS_DRAW_ITEM_TEXT::GetSelectMenuText(), PCB_SHAPE::GetSelectMenuText(), SCH_LABEL::GetSelectMenuText(), SCH_GLOBALLABEL::GetSelectMenuText(), VIA::GetSelectMenuText(), SCH_HIERLABEL::GetSelectMenuText(), SCH_SHEET::GetSelectMenuText(), BOARD::GetSelectMenuText(), FOOTPRINT::GetSelectMenuText(), PAD::GetSelectMenuText(), SCH_COMPONENT::GetSelectMenuText(), ZONE::GetSelectMenuText(), GetSemanticVersion(), NETLIST_EXPORTER_PSPICE_SIM::GetSheetSimCommand(), SYMBOL_LIBRARY_MANAGER::GetUniqueLibraryName(), FIELDS_EDITOR_GRID_DATA_MODEL::GetValue(), AM_PARAM::GetValue(), TEXT_MOD_GRID_TABLE::GetValueAsBool(), FIELDS_GRID_TABLE< SCH_FIELD >::GetValueAsBool(), TEXT_MOD_GRID_TABLE::GetValueAsLong(), DIMENSION_BASE::GetValueText(), GERBVIEW_FRAME::GetVisibleElementColor(), EDA_DRAW_FRAME::GetZoomLevelIndicator(), ALTIUM_PCB::HelperCreateAndAddDrawsegment(), ALTIUM_PCB::HelperParseDimensions6Center(), ALTIUM_PCB::HelperParseDimensions6Datum(), ALTIUM_PCB::HelperParseDimensions6Leader(), ALTIUM_PCB::HelperParseDimensions6Linear(), ALTIUM_PCB::HelperParsePad6NonCopper(), IFSTREAM_LINE_READER::IFSTREAM_LINE_READER(), PCB_EDIT_FRAME::importFile(), SCH_EDIT_FRAME::importFile(), FOOTPRINT_EDIT_FRAME::ImportFootprint(), SCH_EDITOR_CONTROL::ImportFPAssignments(), PANEL_SETUP_FORMATTING::ImportSettingsFrom(), FOOTPRINT_FILTER::ITERATOR::increment(), FOOTPRINT::IncrementReference(), LAYERS_MAP_DIALOG::initDialog(), DISPLAY_FOOTPRINTS_FRAME::InitDisplay(), DRC_ENGINE::InitEngine(), DIALOG_FOOTPRINT_WIZARD_LIST::initLists(), PGM_BASE::InitPgm(), TOOL_MANAGER::InitTools(), CADSTAR_ARCHIVE_PARSER::InsertAttributeAtEnd(), insideArea(), insideCourtyard(), PCB_INSPECTION_TOOL::InspectClearance(), PCB_INSPECTION_TOOL::InspectConstraints(), DIALOG_BOM::installGeneratorsList(), io_benchmark_func(), GERBVIEW_FRAME::IsElementVisible(), kiCadComponentRotation(), KIWAY::KiFACE(), LayerName(), LIBEVAL::COMPILER::lexDefault(), CADSTAR_PCB_ARCHIVE_LOADER::Load(), CADSTAR_SCH_ARCHIVE_LOADER::Load(), SCH_EAGLE_PLUGIN::Load(), FP_CACHE::Load(), EAGLE_PLUGIN::Load(), GPCB_FPL_CACHE::Load(), IO_MGR::Load(), SCH_SEXPR_PLUGIN_CACHE::Load(), SCH_LEGACY_PLUGIN_CACHE::Load(), PART_LIBS::LoadAllLibraries(), PCB_TEST_FRAME_BASE::LoadAndDisplayBoard(), CADSTAR_ARCHIVE_PARSER::LoadArchiveFile(), CADSTAR_PCB_ARCHIVE_LOADER::loadAreas(), CADSTAR_PCB_ARCHIVE_LOADER::loadBoards(), CADSTAR_PCB_ARCHIVE_LOADER::loadBoardStackup(), CADSTAR_SCH_ARCHIVE_LOADER::loadChildSheets(), CADSTAR_PCB_ARCHIVE_LOADER::loadComponents(), CADSTAR_PCB_ARCHIVE_LOADER::loadDimensions(), SCH_LEGACY_PLUGIN_CACHE::loadDocs(), CADSTAR_SCH_ARCHIVE_LOADER::loadDocumentationSymbols(), CADSTAR_PCB_ARCHIVE_LOADER::loadDocumentationSymbols(), EAGLE_PLUGIN::loadElements(), GERBVIEW_FRAME::LoadExcellonFiles(), CADSTAR_PCB_ARCHIVE_LOADER::loadFigures(), LEGACY_PLUGIN::loadFOOTPRINT(), SYMBOL_LIB_TABLE::LoadGlobalTable(), FP_LIB_TABLE::LoadGlobalTable(), CADSTAR_PCB_ARCHIVE_LOADER::loadGroups(), DRC_ENGINE::loadImplicitRules(), SCH_EAGLE_PLUGIN::loadInstance(), EAGLE_PLUGIN::loadLibrary(), CADSTAR_PCB_ARCHIVE_LOADER::loadLibraryAreas(), CADSTAR_PCB_ARCHIVE_LOADER::loadLibraryCoppers(), CADSTAR_PCB_ARCHIVE_LOADER::loadLibraryFigures(), GERBVIEW_FRAME::LoadListOfGerberAndDrillFiles(), CADSTAR_SCH_ARCHIVE_LOADER::loadNets(), CADSTAR_PCB_ARCHIVE_LOADER::loadNets(), CADSTAR_PCB_ARCHIVE_LOADER::loadNetVia(), CADSTAR_SCH_ARCHIVE_LOADER::loadPartsLibrary(), SCH_EAGLE_PLUGIN::loadPin(), EAGLE_PLUGIN::loadPlain(), EAGLE_PLUGIN::loadPolygon(), CADSTAR_SCH_ARCHIVE_LOADER::loadSchematicSymbol(), CADSTAR_SCH_ARCHIVE_LOADER::loadSchematicSymbolInstances(), SCH_EAGLE_PLUGIN::loadSheet(), CADSTAR_SCH_ARCHIVE_LOADER::loadSheetAndChildSheets(), SCH_EDIT_FRAME::LoadSheetFromFile(), CADSTAR_SCH_ARCHIVE_LOADER::loadSheets(), SCH_EAGLE_PLUGIN::loadSymbol(), CADSTAR_SCH_ARCHIVE_LOADER::loadSymDefIntoLibrary(), CADSTAR_PCB_ARCHIVE_LOADER::loadTemplates(), CADSTAR_PCB_ARCHIVE_LOADER::logBoardStackupMessage(), CADSTAR_PCB_ARCHIVE_LOADER::logBoardStackupWarning(), DIALOG_BOARD_REANNOTATE::LogChangePlan(), DIALOG_BOARD_REANNOTATE::LogFootprints(), DIALOG_BOARD_REANNOTATE::MakeSampleText(), DSN::SPECCTRA_DB::makeTRACK(), DSN::SPECCTRA_DB::makeVIA(), PCAD2KICAD::PCB::MapLayer(), memberOf(), SIM_PLOT_FRAME::menuSaveCsv(), HTML_MESSAGE_BOX::MessageSet(), PROJECT_FILE::MigrateFromLegacy(), BOARD_ITEM::Move(), DSNLEXER::NeedNUMBER(), SIM_PLOT_FRAME::NewPlotPanel(), NormalizePath(), not_implemented(), DIALOG_FOOTPRINT_FP_EDITOR::On3DModelCellChanged(), DIALOG_FOOTPRINT_PROPERTIES::On3DModelCellChanged(), DIALOG_FOOTPRINT_FP_EDITOR::OnAdd3DModel(), DIALOG_FOOTPRINT_PROPERTIES::OnAdd3DModel(), PANEL_SETUP_BOARD_STACKUP::onAddDielectricLayer(), DIALOG_FIELDS_EDITOR_GLOBAL::OnAddField(), DIALOG_BOM::OnAddGenerator(), DIALOG_NET_INSPECTOR::onAddNet(), DIALOG_SCHEMATIC_SETUP::OnAuxiliaryAction(), DIALOG_BOARD_SETUP::OnAuxiliaryAction(), DIALOG_EDIT_COMPONENTS_LIBID::onClickOrphansButton(), PANEL_SETUP_RULES::OnCompile(), DIALOG_PAD_PROPERTIES::onCornerRadiusChange(), TREE_PROJECT_FRAME::OnCreateNewDirectory(), DIALOG_SHEET_PROPERTIES::OnDeleteField(), DIALOG_SYMBOL_PROPERTIES::OnDeleteField(), DIALOG_LIB_SYMBOL_PROPERTIES::OnDeleteField(), TREE_PROJECT_FRAME::OnDeleteFile(), DIALOG_NET_INSPECTOR::onDeleteNet(), DIALOG_DRC::OnDRCItemRClick(), DIALOG_ERC::OnERCItemRClick(), DIALOG_EXPORT_STEP::onExportButton(), PCB_EDIT_FRAME::OnExportIDF3(), PCB_EDIT_FRAME::OnExportVRML(), DIALOG_CONFIGURE_PATHS::OnGridCellChanging(), DIALOG_SYMBOL_PROPERTIES::OnGridCellChanging(), DIALOG_LIB_SYMBOL_PROPERTIES::OnGridCellChanging(), KICAD_MANAGER_FRAME::OnIdle(), SCH_EDIT_FRAME::OnImportProject(), FOOTPRINT_VIEWER_FRAME::OnIterateFootprintList(), KIGFX::WX_VIEW_CONTROLS::onMotion(), EDA_3D_CANVAS::OnMouseMove(), APPEARANCE_CONTROLS::OnNetGridRightClick(), DIALOG_PAD_PROPERTIES::OnPadShapeSelection(), NUMBER_BADGE::onPaint(), LIB_TREE::onPreselect(), PANEL_SETUP_BOARD_STACKUP::onRemoveDielectricLayer(), TREE_PROJECT_FRAME::OnRenameFile(), DIALOG_NET_INSPECTOR::onRenameNet(), DIALOG_ERC::OnSaveReport(), DIALOG_DRC::OnSaveReport(), TERMINATE_HANDLER::OnTerminate(), KICAD_MANAGER_FRAME::OnUnarchiveFiles(), LIB_VIEW_FRAME::onUpdateUnitChoice(), DIALOG_PAGES_SETTINGS::OnWksFileSelection(), PL_EDITOR_FRAME::OpenProjectFiles(), BM2CMP_FRAME::OpenProjectFiles(), PCB_EDIT_FRAME::OpenProjectFiles(), EDA_ITEM::operator<(), EAGLE_PLUGIN::packageCircle(), EAGLE_PLUGIN::packagePolygon(), EAGLE_PLUGIN::packageRectangle(), EAGLE_PLUGIN::packageText(), EAGLE_PLUGIN::packageWire(), DIALOG_PAD_PROPERTIES::padValuesOK(), PANEL_SETUP_BOARD_STACKUP::PANEL_SETUP_BOARD_STACKUP(), PCAD2KICAD::PCB_VIA::Parse(), PCAD2KICAD::PCB_PAD::Parse(), CADSTAR_PCB_ARCHIVE_PARSER::MATERIAL::Parse(), CADSTAR_SCH_ARCHIVE_PARSER::TERMINALCODE::Parse(), SCH_ALTIUM_PLUGIN::Parse(), FP_LIB_TABLE::Parse(), ALTIUM_PCB::Parse(), SYMBOL_LIB_TABLE::Parse(), CADSTAR_SCH_ARCHIVE_PARSER::TERMINAL::Parse(), CADSTAR_ARCHIVE_PARSER::TIMESTAMP::Parse(), CADSTAR_ARCHIVE_PARSER::HEADER::Parse(), CADSTAR_PCB_ARCHIVE_PARSER::LAYER::Parse(), CADSTAR_ARCHIVE_PARSER::LINECODE::Parse(), CADSTAR_ARCHIVE_PARSER::HATCHCODE::Parse(), CADSTAR_SCH_ARCHIVE_PARSER::SYMBOL::Parse(), CADSTAR_ARCHIVE_PARSER::EVALUE::Parse(), CADSTAR_PCB_ARCHIVE_PARSER::PADCODE::Parse(), CADSTAR_PCB_ARCHIVE_PARSER::VIACODE::Parse(), CADSTAR_PCB_ARCHIVE_PARSER::LAYERPAIR::Parse(), KICAD_NETLIST_PARSER::Parse(), CADSTAR_PCB_ARCHIVE_PARSER::COMPONENT_AREA::Parse(), CADSTAR_PCB_ARCHIVE_PARSER::COMPONENT_PAD::Parse(), CADSTAR_ARCHIVE_PARSER::ATTRNAME::Parse(), CADSTAR_ARCHIVE_PARSER::NETCLASS::Parse(), CADSTAR_ARCHIVE_PARSER::FIGURE::Parse(), CADSTAR_PCB_ARCHIVE_PARSER::BOARD::Parse(), CADSTAR_PCB_ARCHIVE_PARSER::AREA::Parse(), CADSTAR_ARCHIVE_PARSER::ParseAllChildPoints(), ParseAltiumPcb(), SCH_ALTIUM_PLUGIN::ParseAltiumSch(), SCH_ALTIUM_PLUGIN::ParseArc(), PCB_PARSER::parseARC(), ALTIUM_PCB::ParseArcs6Data(), SCH_ALTIUM_PLUGIN::ParseBezier(), PCB_PARSER::parseBOARD_unchecked(), ALTIUM_PCB::ParseClasses6Data(), SCH_ALTIUM_PLUGIN::ParseComponent(), ALTIUM_PCB::ParseComponentsBodies6Data(), DRC_RULES_PARSER::parseConstraint(), SCH_ALTIUM_PLUGIN::ParseDesignator(), ALTIUM_PCB::ParseDimensions6Data(), DRC_RULES_PARSER::parseDRC_RULE(), SCH_ALTIUM_PLUGIN::ParseFileName(), ALTIUM_PCB::ParseFills6Data(), PCB_PARSER::parseFP_TEXT(), parseInt(), SCH_ALTIUM_PLUGIN::ParseLabel(), DRC_RULES_PARSER::parseLayer(), PCB_PARSER::parseLayers(), SCH_ALTIUM_PLUGIN::ParseLine(), ALTIUM_PCB::ParseModelsData(), PCB_PARSER::parsePAD(), ALTIUM_PCB::ParsePads6Data(), SCH_ALTIUM_PLUGIN::ParsePin(), SCH_ALTIUM_PLUGIN::ParsePolygon(), ALTIUM_PCB::ParsePolygons6Data(), SCH_ALTIUM_PLUGIN::ParsePolyline(), SCH_ALTIUM_PLUGIN::ParsePort(), SCH_ALTIUM_PLUGIN::ParsePowerPort(), SCH_ALTIUM_PLUGIN::ParseRectangle(), ALTIUM_PCB::ParseRegions6Data(), SCH_ALTIUM_PLUGIN::ParseRoundRectangle(), ALTIUM_PCB::ParseShapeBasedRegions6Data(), SCH_ALTIUM_PLUGIN::ParseSheetEntry(), SCH_ALTIUM_PLUGIN::ParseSheetName(), ALTIUM_PCB::ParseTexts6Data(), PCB_PARSER::parseTRACK(), ALTIUM_PCB::ParseTracks6Data(), DRC_RULES_PARSER::parseValueWithUnits(), PCB_PARSER::parseVIA(), ALTIUM_PCB::ParseVias6Data(), PCB_PARSER::parseZONE(), SCH_EDITOR_CONTROL::Paste(), DIALOG_CHOOSE_COMPONENT::PopulateFootprintSelector(), DIALOG_RESCUE_EACH::PopulateInstanceList(), KICAD_MANAGER_FRAME::PrintPrjInfo(), FOOTPRINT_WIZARD_FRAME::Process_Special_Functions(), PNS::SHOVE::ProcessSingleLine(), ALTIUM_PARSER::PropertiesReadKicadUnit(), PCB_BASE_EDIT_FRAME::PutDataInPreviousState(), SCH_EDIT_FRAME::PutDataInPreviousState(), LP_CACHE::ReadAndVerifyHeader(), CVPCB_MAINFRAME::ReadNetListAndFpFiles(), CVPCB_MAINFRAME::ReadSchematicNetlist(), EXCELLON_IMAGE::readToolInformation(), DIALOG_BOARD_REANNOTATE::ReannotateBoard(), NET_SELECTOR_COMBOPOPUP::rebuildList(), APPEARANCE_CONTROLS::rebuildNets(), SYMBOL_EDIT_FRAME::RebuildSymbolUnitsList(), PCB_EDIT_FRAME::RecreateCmpFileFromBoard(), DIALOG_INSPECTOR::ReCreateDesignList(), DIALOG_PLOT::reInitDialog(), C3D_RENDER_RAYTRACING::Reload(), C3D_RENDER_OGL_LEGACY::reload(), FP_CACHE::Remove(), GPCB_FPL_CACHE::Remove(), C3D_RENDER_RAYTRACING::render(), PCB_EDITOR_CONTROL::RepairBoard(), ReplaceIllegalFileNameChars(), PCB_INSPECTION_TOOL::reportClearance(), DRC_RULES_PARSER::reportError(), DRC_TEST_PROVIDER::reportRuleStatistics(), DRC_ENGINE::ReportViolation(), PCB_INSPECTION_TOOL::reportZoneConnection(), CONNECTION_SUBGRAPH::ResolveDrivers(), WIDGET_HOTKEY_LIST::ResolveKeyConflicts(), SCH_SHEET::ResolveTextVar(), SCH_GLOBALLABEL::ResolveTextVar(), WIDGET_SAVE_RESTORE::RestoreConfigToControls(), SYMBOL_EDIT_FRAME::Revert(), FOOTPRINT_EDIT_FRAME::RevertFootprint(), C3D_RENDER_RAYTRACING::rt_render_tracing(), test::DRC_TEST_PROVIDER_DIFF_PAIR_COUPLING::Run(), TOOL_MANAGER::RunAction(), DRC_TEST_PROVIDER_MATCHED_LENGTH::runInternal(), DRC_ENGINE::RunTests(), SCH_SEXPR_PLUGIN::Save(), FP_CACHE::Save(), PCB_IO::Save(), IO_MGR::Save(), PART_LIB::Save(), PCB_BASE_EDIT_FRAME::SaveCopyInUndoList(), SCH_EDIT_FRAME::SaveCopyInUndoList(), BITMAP_BASE::SaveData(), FOOTPRINT_EDIT_FRAME::SaveFootprintAs(), SYMBOL_LIBRARY_MANAGER::SaveLibrary(), SYMBOL_EDIT_FRAME::saveLibrary(), FOOTPRINT_EDIT_FRAME::SaveLibraryAs(), SYMBOL_EDIT_FRAME::SaveOneSymbol(), SYMBOL_EDIT_FRAME::savePartAs(), PCB_EDIT_FRAME::SavePcbCopy(), PCB_EDIT_FRAME::SavePcbFile(), SCH_EDIT_FRAME::SaveProject(), SIM_PLOT_FRAME::saveWorkbook(), SchGetLibPart(), PCB_MARKER::Serialize(), SCH_MARKER::Serialize(), GERBVIEW_FRAME::SetElementVisibility(), FOOTPRINT_INFO_GENERATOR::SetHtmlAliasOf(), FOOTPRINT_INFO_GENERATOR::SetHtmlDesc(), FOOTPRINT_INFO_GENERATOR::SetHtmlKeywords(), KIWAY::SetLanguage(), DIALOG_PRINT_GENERIC::setScaleValue(), ZONE_SETTINGS::SetupLayersList(), TEXT_MOD_GRID_TABLE::SetValue(), FIELDS_GRID_TABLE< SCH_FIELD >::SetValue(), TEXT_MOD_GRID_TABLE::SetValueAsBool(), FIELDS_GRID_TABLE< SCH_FIELD >::SetValueAsBool(), TEXT_MOD_GRID_TABLE::SetValueAsLong(), GERBVIEW_FRAME::SetVisibleElementColor(), RC_ITEM::ShowCoord(), DIALOG_CHOOSE_COMPONENT::ShowFootprintFor(), COMMON_CONTROL::ShowHelp(), DIALOG_IMPORT_GFX::showPCBdefaultLineWidth(), DIALOG_IMPORT_GFX::showPcbImportOffsets(), RC_ITEM::ShowReport(), SCH_IO_MGR::ShowType(), IO_MGR::ShowType(), StringFromValue(), SCH_BITMAP::SwapData(), SCH_SHEET_PIN::SwapData(), SCH_SHEET::SwapData(), SYMBOL_EDIT_FRAME::SyncLibraries(), PNS_KICAD_IFACE_BASE::syncZone(), PANEL_SETUP_LAYERS::testLayerNames(), ERC_TESTER::TestMultUnitPinConflicts(), ERC_TESTER::TestPinToPin(), SPICE_VALUE::ToString(), TRACE_DESC::TRACE_DESC(), DIALOG_GLOBAL_FP_LIB_TABLE_CONFIG::TransferDataFromWindow(), DIALOG_GLOBAL_SYM_LIB_TABLE_CONFIG::TransferDataFromWindow(), DIALOG_SCH_IMPORT_SETTINGS::TransferDataFromWindow(), DIALOG_IMPORT_SETTINGS::TransferDataFromWindow(), DIALOG_GENCAD_EXPORT_OPTIONS::TransferDataFromWindow(), DIALOG_SHEET_PROPERTIES::TransferDataFromWindow(), DIALOG_SIM_SETTINGS::TransferDataFromWindow(), DIALOG_PIN_PROPERTIES::TransferDataFromWindow(), PANEL_SETUP_LAYERS::TransferDataFromWindow(), DIALOG_EXPORT_IDF3::TransferDataFromWindow(), DIALOG_SIGNAL_LIST::TransferDataToWindow(), DIALOG_GRID_SETTINGS::TransferDataToWindow(), PANEL_SETUP_FORMATTING::TransferDataToWindow(), DIALOG_PNS_LENGTH_TUNING_SETTINGS::TransferDataToWindow(), PANEL_SETUP_FEATURE_CONSTRAINTS::TransferDataToWindow(), DSNLEXER::Unexpected(), GL_CONTEXT_MANAGER::UnlockCtx(), HIGHLIGHT_MENU::update(), FOOTPRINT_VIEWER_FRAME::Update3DView(), DIALOG_POSITION_RELATIVE::UpdateAnchor(), DIALOG_BOARD_STATISTICS::updateDrillGrid(), BM2CMP_FRAME::updateImageInfo(), DIALOG_PAD_PROPERTIES::UpdateLayersDropdown(), PCBNEW_CONTROL::UpdateMessagePanel(), SCH_EDIT_FRAME::UpdateNetHighlightStatus(), SIM_PLOT_FRAME::updatePlot(), DIALOG_PAD_PROPERTIES::updateRoundRectCornerValues(), SYMBOL_EDIT_FRAME::updateTitle(), FOOTPRINT_EDIT_FRAME::updateTitle(), PCB_EDIT_FRAME::UpdateTitle(), CONSOLE_PROGRESS_REPORTER::updateUI(), DIALOG_BOARD_STATISTICS::updateWidets(), EDA_DRAW_FRAME::UpdateZoomSelectBox(), UNIT_BINDER::Validate(), REGEX_VALIDATOR::Validate(), SPICE_VALIDATOR::Validate(), validateAxisOptions(), PANEL_SYM_LIB_TABLE::verifyTables(), PANEL_FP_LIB_TABLE::verifyTables(), FOOTPRINT_LIST_IMPL::WriteCacheToFile(), WriteHotKeyConfig(), SCH_EDIT_FRAME::WriteNetListFile(), DIALOG_ERC::writeReport(), ZOOM_MENU::ZOOM_MENU(), and DIALOG_BOM::~DIALOG_BOM().

◆ formatList()

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

Definition at line 137 of file ptree.cpp.

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

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

Referenced by formatNode().

◆ formatNode()

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

Definition at line 166 of file ptree.cpp.

169 {
170  if( !isAtom( aTree ) ) // is a list, not an atom
171  {
172  int ctl = CTL_OMIT_NL;
173 
174  // aTree is list and its first child is a list
175  if( aTree.size() && !isAtom( aTree.begin()->second ) && !aTree.data().size() )
176  ctl = 0;
177 
178  out->Print( aNestLevel, "(%s%s", out->Quotes( aKey ).c_str(), ctl & CTL_OMIT_NL ? "" : "\n" );
179 
180  if( aTree.data().size() ) // sexpr format does not use data()
181  {
182  out->Print( 0, " %s%s",
183  out->Quotes( aTree.data() ).c_str(),
184  aTree.size() ? "\n" : ""
185  );
186  }
187 
188  formatList( out, aNestLevel, aCtl, aTree );
189 
190  out->Print( 0, ")%s", aCtl & CTL_OMIT_NL ? "" : "\n" );
191  }
192 
193  else // is an atom, not a list
194  {
195  out->Print( 0, " %s", out->Quotes( aKey ).c_str() );
196  }
197 }
static void formatList(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Definition: ptree.cpp:137
bool isAtom(const CPTREE &aTree)
Definition: ptree.cpp:112
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

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 112 of file ptree.cpp.

113 {
114  return aTree.size() == 0 && aTree.data().size() == 0;
115 }

Referenced by formatList(), and formatNode().

◆ isLast()

bool isLast ( const CPTREE aTree,
CITER  it 
)
inline

Definition at line 118 of file ptree.cpp.

119 {
120  CITER next = it;
121  ++next;
122  return next == aTree.end();
123 }
CITER next(CITER it)
Definition: ptree.cpp:126
PTREE::const_iterator CITER
Definition: ptree.cpp:35

References next().

Referenced by formatList().

◆ next()

◆ Scan()

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 86 of file ptree.cpp.

87 {
88  int tok = aLexer->CurTok();
89 
90  // conditionally read first token.
91  if( tok == DSN_NONE )
92  tok = aLexer->NextTok();
93 
94  if( tok == DSN_EOF )
95  {
96  aLexer->Unexpected( DSN_EOF );
97  }
98 
99  if( tok == DSN_LEFT )
100  {
101  scanList( aTree, aLexer );
102  }
103  else
104  {
105  scanAtom( aTree, aLexer );
106  }
107 }
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
void scanAtom(PTREE *aTree, const DSNLEXER *aLexer)
Definition: ptree.cpp:78
int CurTok() const
Function CurTok returns whatever NextTok() returned the last time it was called.
Definition: dsnlexer.h:321
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:508
void Unexpected(int aTok) const
Function Unexpected throws an IO_ERROR exception with an input file specific error message.
Definition: dsnlexer.cpp:337

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 78 of file ptree.cpp.

79 {
80  const char* key = aLexer->CurText();
81 
82  aTree->push_back( PTREE::value_type( key, PTREE() ) );
83 }
const char * CurText() const
Function CurText returns a pointer to the current token's text.
Definition: dsnlexer.h:489
boost::property_tree::ptree PTREE
Definition: ptree.h:54

References DSNLEXER::CurText().

Referenced by Scan().

◆ scanList()

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.

56 {
57  assert( aLexer->CurTok() == DSN_LEFT );
58 
59  int tok = aLexer->NextTok();
60 
61  const char* key = aLexer->CurText();
62 
63  PTREE* list = &aTree->push_back( PTREE::value_type( key, PTREE() ) )->second;
64 
65  if( tok != DSN_RIGHT )
66  {
67  while( ( tok = aLexer->NextTok() ) != DSN_RIGHT )
68  {
69  if( tok == DSN_EOF )
70  aLexer->Unexpected( DSN_EOF );
71 
72  Scan( list, aLexer );
73  }
74  }
75 }
void Scan(PTREE *aTree, DSNLEXER *aLexer)
Function Scan fills an empty PTREE with information from a KiCad s-expresion stream.
Definition: ptree.cpp:86
const char * CurText() const
Function CurText returns a pointer to the current token's text.
Definition: dsnlexer.h:489
boost::property_tree::ptree PTREE
Definition: ptree.h:54
int CurTok() const
Function CurTok returns whatever NextTok() returned the last time it was called.
Definition: dsnlexer.h:321
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:508
void Unexpected(int aTok) const
Function Unexpected throws an IO_ERROR exception with an input file specific error message.
Definition: dsnlexer.cpp:337

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

Referenced by Scan().