![]() |
KiCad PCB EDA Suite
|
Manage LIB_TABLE_ROW records (rows), and can be searched based on library nickname. More...
#include <lib_table_base.h>
Public Member Functions | |
virtual void | Parse (LIB_TABLE_LEXER *aLexer)=0 |
Parse the #LIB_TABLE_LEXER s-expression library table format into the appropriate LIB_TABLE_ROW objects. More... | |
virtual void | Format (OUTPUTFORMATTER *aOutput, int aIndentLevel) const =0 |
Generate the table in s-expression format to aOutput with an indention level of aIndentLevel. More... | |
LIB_TABLE (LIB_TABLE *aFallBackTable=nullptr) | |
Build a library table by pre-pending this table fragment in front of aFallBackTable. More... | |
virtual | ~LIB_TABLE () |
void | Clear () |
Delete all rows. More... | |
bool | operator== (const LIB_TABLE &r) const |
Compares this table against another. More... | |
bool | operator!= (const LIB_TABLE &r) const |
unsigned | GetCount () const |
Get the number of rows contained in the table. More... | |
LIB_TABLE_ROW & | At (unsigned aIndex) |
Get the 'n'th LIB_TABLE_ROW object. More... | |
const LIB_TABLE_ROW & | At (unsigned aIndex) const |
Get the 'n'th LIB_TABLE_ROW object. More... | |
bool | IsEmpty (bool aIncludeFallback=true) |
Return true if the table is empty. More... | |
const wxString | GetDescription (const wxString &aNickname) |
bool | HasLibrary (const wxString &aNickname, bool aCheckEnabled=false) const |
Test for the existence of aNickname in the library table. More... | |
std::vector< wxString > | GetLogicalLibs () |
Return the logical library names, all of them that are pertinent to a look up done on this LIB_TABLE. More... | |
wxString | GetFullURI (const wxString &aLibNickname, bool aExpandEnvVars=true) const |
Return the full URI of the library mapped to aLibNickname. More... | |
bool | InsertRow (LIB_TABLE_ROW *aRow, bool doReplace=false) |
Adds aRow if it does not already exist or if doReplace is true. More... | |
bool | RemoveRow (LIB_TABLE_ROW *aRow) |
Removes a row from the table. More... | |
const LIB_TABLE_ROW * | FindRowByURI (const wxString &aURI) |
void | Load (const wxString &aFileName) |
Load the library table using the path defined by aFileName aFallBackTable. More... | |
void | Save (const wxString &aFileName) const |
Write this library table to aFileName in s-expression form. More... | |
virtual KICAD_T | Type ()=0 |
Static Public Member Functions | |
static PROPERTIES * | ParseOptions (const std::string &aOptionsList) |
Parses aOptionsList and places the result into a PROPERTIES object which is returned. More... | |
static UTF8 | FormatOptions (const PROPERTIES *aProperties) |
Returns a list of options from the aProperties parameter. More... | |
Protected Types | |
typedef std::map< wxString, int > | INDEX |
this is a non-owning index into the LIB_TABLE_ROWS table More... | |
typedef INDEX::iterator | INDEX_ITER |
typedef INDEX::const_iterator | INDEX_CITER |
typedef INDEX::value_type | INDEX_VALUE |
Protected Member Functions | |
LIB_TABLE_ROW * | findRow (const wxString &aNickname, bool aCheckIfEnabled=false) const |
Return a LIB_TABLE_ROW if aNickname is found in this table or in any chained fallBack table fragment, else NULL. More... | |
void | reindex () |
void | ensureIndex () |
Protected Attributes | |
LIB_TABLE_ROWS | rows |
INDEX | nickIndex |
this particular key is the nickName within each row. More... | |
LIB_TABLE * | fallBack |
Friends | |
class | PANEL_FP_LIB_TABLE |
class | LIB_TABLE_GRID |
Manage LIB_TABLE_ROW records (rows), and can be searched based on library nickname.
This class owns the library table, which is like fstab in concept and maps logical library name to the library URI, type, and options. It is heavily based on the SWEET parser work done by Dick Hollenbeck and can be seen in new/sch_lib_table.h. A library table has the following columns:
The Library Type can be one of:
For now, the Library URI types needed to support the various types can be one of those shown below, which are typical of each type:
The library table is built up from several additive entries (table fragments), and the final table is a (conceptual) merging of the table fragments. Two anticipated sources of the entries are a personal table saved in the KiCad configuration and a project resident table that resides in project file. The project footprint table entries are considered a higher priority in the final dynamically assembled library table. An row in the project file contribution to the library table takes precedence over the personal table if there is a collision of logical library names. Otherwise, the entries simply combine without issue to make up the applicable library table.
Definition at line 277 of file lib_table_base.h.
|
protected |
this is a non-owning index into the LIB_TABLE_ROWS table
Definition at line 527 of file lib_table_base.h.
|
protected |
Definition at line 529 of file lib_table_base.h.
|
protected |
Definition at line 528 of file lib_table_base.h.
|
protected |
Definition at line 530 of file lib_table_base.h.
LIB_TABLE::LIB_TABLE | ( | LIB_TABLE * | aFallBackTable = nullptr | ) |
Build a library table by pre-pending this table fragment in front of aFallBackTable.
Loading of this table fragment is done by using Parse().
aFallBackTable | is another LIB_TABLE which is searched only when a row is not found in this table. No ownership is taken of aFallBackTable. |
Definition at line 124 of file lib_table_base.cpp.
|
virtual |
Definition at line 132 of file lib_table_base.cpp.
|
inline |
Get the 'n'th LIB_TABLE_ROW object.
aIndex | index of row (must exist: from 0 to GetCount() - 1) |
Definition at line 362 of file lib_table_base.h.
References rows.
Referenced by SYMBOL_GRID_TRICKS::paste_text(), FP_GRID_TRICKS::paste_text(), and SCH::IFACE::SaveFileAs().
|
inline |
Get the 'n'th LIB_TABLE_ROW object.
aIndex | index of row (must exist: from 0 to GetCount() - 1) |
Definition at line 370 of file lib_table_base.h.
References rows.
|
inline |
Delete all rows.
Definition at line 319 of file lib_table_base.h.
References nickIndex, and rows.
Referenced by PANEL_FP_LIB_TABLE::TransferDataFromWindow(), and PANEL_SYM_LIB_TABLE::TransferDataFromWindow().
|
inlineprotected |
Definition at line 510 of file lib_table_base.h.
References nickIndex, and reindex().
Referenced by findRow(), FindRowByURI(), and InsertRow().
|
protected |
Return a LIB_TABLE_ROW if aNickname is found in this table or in any chained fallBack table fragment, else NULL.
aNickname | is the name of the library table entry to find. |
aCheckIfEnabled | is a flag to check if the library table entry is enabled. |
Definition at line 183 of file lib_table_base.cpp.
References ensureIndex(), fallBack, LIB_TABLE_ROW::GetIsEnabled(), nickIndex, and rows.
Referenced by FP_LIB_TABLE::FindRow(), SYMBOL_LIB_TABLE::FindRow(), GetDescription(), GetFullURI(), and HasLibrary().
const LIB_TABLE_ROW * LIB_TABLE::FindRowByURI | ( | const wxString & | aURI | ) |
Definition at line 226 of file lib_table_base.cpp.
References ensureIndex(), fallBack, and rows.
Referenced by FOOTPRINT_EDIT_FRAME::KiwayMailIn(), and SYMBOL_EDIT_FRAME::KiwayMailIn().
|
pure virtual |
Generate the table in s-expression format to aOutput with an indention level of aIndentLevel.
aOutput | is the OUTPUTFORMATTER to format the table into. |
aIndentLevel | is the indentation level (2 spaces) to indent. |
IO_ERROR | if an I/O error occurs during output. |
boost::interprocess::lock_except | if separate process attempt to access the table. |
Implemented in SYMBOL_LIB_TABLE, FP_LIB_TABLE, and TEST_LIB_TABLE.
Referenced by Save().
|
static |
Returns a list of options from the aProperties parameter.
The name=value pairs will be separated with the '|' character. The =value portion may not be present. You might expect something like "name1=value1|name2=value2|flag_me". Notice that flag_me does not have a value. This is ok.
aProperties | is the PROPERTIES to format or NULL. If NULL the returned string will be empty. |
Definition at line 407 of file lib_table_base.cpp.
References UTF8::begin(), UTF8::end(), name, OPT_SEP, and UTF8::size().
Referenced by DIALOG_FP_PLUGIN_OPTIONS::TransferDataFromWindow().
|
inline |
Get the number of rows contained in the table.
Definition at line 352 of file lib_table_base.h.
References rows.
Referenced by BOOST_AUTO_TEST_CASE(), FP_TREE_SYNCHRONIZING_ADAPTER::GetLibrariesCount(), SYMBOL_GRID_TRICKS::paste_text(), FP_GRID_TRICKS::paste_text(), and SCH::IFACE::SaveFileAs().
const wxString LIB_TABLE::GetDescription | ( | const wxString & | aNickname | ) |
Definition at line 147 of file lib_table_base.cpp.
References findRow(), and LIB_TABLE_ROW::GetDescr().
Referenced by SYMBOL_TREE_MODEL_ADAPTER::AddLibrary(), FOOTPRINT_EDIT_FRAME::SaveFootprintAs(), SYMBOL_EDIT_FRAME::savePartAs(), and PCB_BASE_FRAME::SelectLibrary().
wxString LIB_TABLE::GetFullURI | ( | const wxString & | aLibNickname, |
bool | aExpandEnvVars = true |
||
) | const |
Return the full URI of the library mapped to aLibNickname.
Definition at line 170 of file lib_table_base.cpp.
References findRow(), and LIB_TABLE_ROW::GetFullURI().
Referenced by CVPCB_MAINFRAME::DisplayStatus(), SCH_EDIT_FRAME::LoadSheetFromFile(), NETLIST_EXPORTER_XML::makeLibraries(), and FOOTPRINT_EDITOR_CONTROL::SaveAs().
std::vector< wxString > LIB_TABLE::GetLogicalLibs | ( | ) |
Return the logical library names, all of them that are pertinent to a look up done on this LIB_TABLE.
Definition at line 262 of file lib_table_base.cpp.
References fallBack, and rows.
Referenced by FP_TREE_MODEL_ADAPTER::AddLibraries(), CVPCB_MAINFRAME::BuildLIBRARY_LISTBOX(), DIALOG_SYMBOL_REMAP::createProjectSymbolLibTable(), FP_LIB_TABLE::FootprintLoadWithOptionalNickname(), FP_LIB_TABLE::GenerateTimestamp(), GetFootprintLibraries(), SYMBOL_LIB_TABLE::GetModifyHash(), guessNickname(), CVPCB_MAINFRAME::LoadFootprintFiles(), SYMBOL_LIB_TABLE::LoadSymbolWithOptionalNickname(), FOOTPRINT_VIEWER_FRAME::OnActivate(), SYMBOL_VIEWER_FRAME::OnSelectSymbol(), SCH_BASE_FRAME::PickSymbolFromLibTree(), FOOTPRINT_VIEWER_FRAME::ReCreateLibraryList(), FOOTPRINT_EDIT_FRAME::SaveFootprintAs(), SYMBOL_EDIT_FRAME::savePartAs(), PCB_BASE_FRAME::SelectLibrary(), FOOTPRINT_LIST_IMPL::startWorkers(), and FP_TREE_SYNCHRONIZING_ADAPTER::Sync().
bool LIB_TABLE::HasLibrary | ( | const wxString & | aNickname, |
bool | aCheckEnabled = false |
||
) | const |
Test for the existence of aNickname in the library table.
aCheckEnabled | if true will only return true for enabled libraries |
Definition at line 159 of file lib_table_base.cpp.
References findRow().
Referenced by SYMBOL_EDIT_FRAME::addLibTableEntry(), CVPCB_MAINFRAME::DisplayStatus(), FOOTPRINT_EDIT_FRAME::KiwayMailIn(), SYMBOL_EDIT_FRAME::KiwayMailIn(), SYMBOL_LIBRARY_MANAGER::LibraryExists(), CADSTAR_SCH_ARCHIVE_PLUGIN::Load(), SCH_ALTIUM_PLUGIN::Load(), SCH_EAGLE_PLUGIN::Load(), SCH_EDIT_FRAME::LoadSheetFromFile(), NETLIST_EXPORTER_XML::makeLibraries(), SCH_BASE_FRAME::PickSymbolFromLibTree(), SYMBOL_VIEWER_FRAME::ShowModal(), FOOTPRINT_VIEWER_FRAME::ShowModal(), FP_TREE_SYNCHRONIZING_ADAPTER::Sync(), ERC_TESTER::TestLibSymbolIssues(), and SCH_SCREEN::UpdateSymbolLinks().
bool LIB_TABLE::InsertRow | ( | LIB_TABLE_ROW * | aRow, |
bool | doReplace = false |
||
) |
Adds aRow if it does not already exist or if doReplace is true.
If doReplace is not true and the key for aRow already exists, the function fails and returns false.
The key for the table is the nickName, and all in this table must be unique.
aRow | is the new row to insert, or to forcibly add if doReplace is true. |
doReplace | if true, means insert regardless of whether aRow's key already exists. If false, then fail if the key already exists. |
Definition at line 302 of file lib_table_base.cpp.
References ensureIndex(), LIB_TABLE_ROW::GetNickName(), nickIndex, and rows.
Referenced by PCB_BASE_EDIT_FRAME::AddLibrary(), SYMBOL_LIBRARY_MANAGER::addLibrary(), SYMBOL_EDIT_FRAME::addLibTableEntry(), DIALOG_SYMBOL_REMAP::createProjectSymbolLibTable(), LIB_TABLE_TEST_FIXTURE::LIB_TABLE_TEST_FIXTURE(), CADSTAR_SCH_ARCHIVE_PLUGIN::Load(), SCH_ALTIUM_PLUGIN::Load(), SCH_EAGLE_PLUGIN::Load(), PCB_EDIT_FRAME::OpenProjectFiles(), FP_LIB_TABLE::Parse(), and SYMBOL_LIB_TABLE::Parse().
bool LIB_TABLE::IsEmpty | ( | bool | aIncludeFallback = true | ) |
Return true if the table is empty.
aIncludeFallback | is used to determine if the fallback table should be included in the test. |
Definition at line 138 of file lib_table_base.cpp.
References fallBack, IsEmpty(), and rows.
Referenced by BOOST_AUTO_TEST_CASE(), DIALOG_SYMBOL_REMAP::createProjectSymbolLibTable(), IsEmpty(), PCB_EDIT_FRAME::LoadFootprints(), and SCH_EDIT_FRAME::LoadSheetFromFile().
void LIB_TABLE::Load | ( | const wxString & | aFileName | ) |
Load the library table using the path defined by aFileName aFallBackTable.
aFileName | contains the full path to the s-expression file. |
IO_ERROR | if an error occurs attempting to load the footprint library table. |
Definition at line 325 of file lib_table_base.cpp.
References Parse().
Referenced by FP_LIB_TABLE::LoadGlobalTable(), SYMBOL_LIB_TABLE::LoadGlobalTable(), SCH_EDIT_FRAME::LoadSheetFromFile(), PROJECT::PcbFootprintLibs(), SCH::IFACE::SaveFileAs(), DIALOG_GLOBAL_FP_LIB_TABLE_CONFIG::TransferDataFromWindow(), and DIALOG_GLOBAL_SYM_LIB_TABLE_CONFIG::TransferDataFromWindow().
|
inline |
Definition at line 347 of file lib_table_base.h.
|
inline |
Compares this table against another.
This compares the row contents against each other. Any fallback tables are not checked.
Definition at line 331 of file lib_table_base.h.
References rows.
|
pure virtual |
Parse the #LIB_TABLE_LEXER s-expression library table format into the appropriate LIB_TABLE_ROW objects.
aLexer | is the lexer to parse. |
IO_ERROR | if an I/O error occurs during parsing. |
PARSER_ERROR | if the lexer format to parse is invalid. |
boost::bad_pointer | if an any attempt to add an invalid pointer to the boost::ptr_vector. |
boost::bad_index | if an index outside the row table bounds is accessed. |
Implemented in SYMBOL_LIB_TABLE, FP_LIB_TABLE, and TEST_LIB_TABLE.
Referenced by Load().
|
static |
Parses aOptionsList and places the result into a PROPERTIES object which is returned.
If the options field is empty, then the returned PROPERTIES will be a NULL pointer.
Typically aOptionsList comes from the "options" field within a LIB_TABLE_ROW and the format is simply a comma separated list of name value pairs. e.g.: [name1[=value1][|name2[=value2]]] etc. When using the UI to create or edit a library table, this formatting is handled for you.
Definition at line 346 of file lib_table_base.cpp.
Referenced by LIB_TABLE_ROW::SetOptions(), and DIALOG_FP_PLUGIN_OPTIONS::TransferDataToWindow().
|
inlineprotected |
Definition at line 502 of file lib_table_base.h.
References nickIndex, and rows.
Referenced by ensureIndex(), PANEL_FP_LIB_TABLE::TransferDataFromWindow(), and PANEL_SYM_LIB_TABLE::TransferDataFromWindow().
|
inline |
Removes a row from the table.
aRow | is the row to remove |
Definition at line 429 of file lib_table_base.h.
References rows.
Referenced by SYMBOL_LIBRARY_MANAGER::addLibrary().
void LIB_TABLE::Save | ( | const wxString & | aFileName | ) | const |
Write this library table to aFileName in s-expression form.
aFileName | is the name of the file to write to. |
Definition at line 339 of file lib_table_base.cpp.
References Format().
Referenced by PCB_BASE_EDIT_FRAME::AddLibrary(), SYMBOL_EDIT_FRAME::addLibTableEntry(), InvokePcbLibTableEditor(), InvokeSchEditSymbolLibTable(), FP_LIB_TABLE::LoadGlobalTable(), SYMBOL_LIB_TABLE::LoadGlobalTable(), PCB_EDIT_FRAME::OpenProjectFiles(), SYMBOL_EDIT_FRAME::replaceLibTableEntry(), SCH::IFACE::SaveFileAs(), SCH_BASE_FRAME::saveSymbolLibTables(), DIALOG_GLOBAL_SYM_LIB_TABLE_CONFIG::TransferDataFromWindow(), and DIALOG_GLOBAL_FP_LIB_TABLE_CONFIG::TransferDataFromWindow().
|
pure virtualinherited |
Implemented in PART_LIBS, SYMBOL_LIB_TABLE, FP_LIB_TABLE, TEST_LIB_TABLE, S3D_CACHE, and SEARCH_STACK.
|
friend |
Definition at line 521 of file lib_table_base.h.
|
friend |
Definition at line 520 of file lib_table_base.h.
|
protected |
Definition at line 535 of file lib_table_base.h.
Referenced by findRow(), FindRowByURI(), GetLogicalLibs(), and IsEmpty().
|
protected |
this particular key is the nickName within each row.
Definition at line 533 of file lib_table_base.h.
Referenced by Clear(), ensureIndex(), findRow(), InsertRow(), and reindex().
|
protected |
Definition at line 524 of file lib_table_base.h.
Referenced by SYMBOL_LIB_TABLE_GRID::at(), FP_LIB_TABLE_GRID::at(), At(), SYMBOL_LIB_TABLE_GRID::begin(), FP_LIB_TABLE_GRID::begin(), Clear(), SYMBOL_LIB_TABLE_GRID::erase(), FP_LIB_TABLE_GRID::erase(), findRow(), FindRowByURI(), FP_LIB_TABLE::Format(), SYMBOL_LIB_TABLE::Format(), FP_LIB_TABLE_GRID::FP_LIB_TABLE_GRID(), GetCount(), GetLogicalLibs(), SYMBOL_LIB_TABLE_GRID::insert(), FP_LIB_TABLE_GRID::insert(), InsertRow(), IsEmpty(), PANEL_SYM_LIB_TABLE::moveDownHandler(), PANEL_FP_LIB_TABLE::moveDownHandler(), PANEL_SYM_LIB_TABLE::moveUpHandler(), PANEL_FP_LIB_TABLE::moveUpHandler(), FP_LIB_TABLE::operator==(), operator==(), SYMBOL_GRID_TRICKS::paste_text(), FP_GRID_TRICKS::paste_text(), SYMBOL_LIB_TABLE_GRID::push_back(), FP_LIB_TABLE_GRID::push_back(), reindex(), RemoveRow(), SYMBOL_LIB_TABLE_GRID::size(), FP_LIB_TABLE_GRID::size(), SYMBOL_LIB_TABLE_GRID::SYMBOL_LIB_TABLE_GRID(), PANEL_FP_LIB_TABLE::TransferDataFromWindow(), and PANEL_SYM_LIB_TABLE::TransferDataFromWindow().