21#include <boost/lexical_cast.hpp>
60 wxFileName file( aPath );
62 m_path = file.GetAbsolutePath();
64 if( !file.FileExists() )
72 tl::expected<LIBRARY_TABLE_IR, LIBRARY_PARSE_ERROR> ir = parser.
Parse(
m_path.ToStdString() );
92 tl::expected<LIBRARY_TABLE_IR, LIBRARY_PARSE_ERROR> ir =
97 m_ok = initFromIR( *ir );
102 m_errorDescription = ir.error().description;
125 catch(
const boost::bad_lexical_cast & )
142 row.
m_uri = wxString::FromUTF8( aIR.
uri );
151 m_rows.emplace_back( row );
158 static const std::map<LIBRARY_TABLE_TYPE, wxString> types = {
164 wxCHECK( types.contains(
Type() ), );
166 XNODE self( wxXML_ELEMENT_NODE, types.at(
Type() ) );
173 wxString uri = row.URI();
174 uri.Replace(
'\\',
'/' );
176 XNODE* rowNode =
new XNODE( wxXML_ELEMENT_NODE,
"lib" );
184 rowNode->AddChild(
new XNODE( wxXML_ELEMENT_NODE,
"disabled" ) );
187 rowNode->AddChild(
new XNODE( wxXML_ELEMENT_NODE,
"hidden" ) );
189 self.AddChild( rowNode );
217 if( row.Nickname() == aNickname )
226 bool aSubstituted )
const
230 if( !aSubstituted && row.URI() == aUri )
245 if( row.Nickname() == aNickname )
257 if( row.Nickname() == aNickname )
static wxString ExpandURI(const wxString &aShortURI, const PROJECT &aProject)
tl::expected< LIBRARY_TABLE_IR, LIBRARY_PARSE_ERROR > ParseBuffer(const std::string &aBuffer)
tl::expected< LIBRARY_TABLE_IR, LIBRARY_PARSE_ERROR > Parse(const std::filesystem::path &aPath)
LIBRARY_TABLE_ROW()=default
void SetOk(bool aOk=true)
bool operator==(const LIBRARY_TABLE_ROW &aOther) const
std::map< std::string, UTF8 > GetOptionsMap() const
static const wxString TABLE_TYPE_NAME
void SetScope(LIBRARY_TABLE_SCOPE aScope)
LIBRARY_TABLE_SCOPE m_scope
bool operator==(const LIBRARY_TABLE &aOther) const
void Format(OUTPUTFORMATTER *aOutput) const
LIBRARY_TABLE_TYPE Type() const
LIBRARY_TABLE_TYPE m_type
What type of content this table contains (footprint, symbol, design block, etc)
std::optional< LIBRARY_TABLE_ROW * > Row(const wxString &aNickname)
std::vector< LIBRARY_TABLE_ROW > m_rows
LIBRARY_TABLE_ROW & InsertRow()
Builds a new row and inserts it at the end of the table; returning a reference to the row.
wxString m_path
The full path to the file this table was parsed from, if any.
wxString m_errorDescription
LIBRARY_TABLE_ROW MakeRow() const
Builds a new row that is suitable for this table (does not insert it)
bool HasRow(const wxString &aNickname) const
LIBRARY_TABLE(const wxFileName &aPath, LIBRARY_TABLE_SCOPE aScope)
Creates a library table from a file on disk.
bool HasRowWithURI(const wxString &aUri, const PROJECT &aProject, bool aSubstituted=false) const
Returns true if the given (fully-expanded) URI exists as a library in this table.
std::optional< int > m_version
The format version, if present in the parsed file.
const std::vector< LIBRARY_TABLE_ROW > & Rows() const
bool addRowFromIR(const LIBRARY_TABLE_ROW_IR &aIR)
LIBRARY_TABLE_SCOPE m_scope
bool initFromIR(const LIBRARY_TABLE_IR &aIR)
static std::map< std::string, UTF8 > ParseOptions(const std::string &aOptionsList)
Parses aOptionsList and places the result into a #PROPERTIES object which is returned.
static void ResolvePossibleSymlinks(wxFileName &aFilename)
An extension of wxXmlNode that can format its contents as KiCad-style s-expressions.
void Format(OUTPUTFORMATTER *out) const
Write this object as UTF8 out to an OUTPUTFORMATTER as an S-expression.
void AddAttribute(const wxString &aName, const wxString &aValue) override
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
The intermediate representation that a library table is parsed into.
std::vector< LIBRARY_TABLE_ROW_IR > rows
wxLogTrace helper definitions.