26 #ifndef _LIB_TABLE_BASE_H_ 27 #define _LIB_TABLE_BASE_H_ 30 #include <boost/noncopyable.hpp> 31 #include <boost/ptr_container/ptr_vector.hpp> 39 #define FP_LATE_ENVVAR 1 42 class LIB_TABLE_LEXER;
79 LIB_TABLE_ROW(
const wxString& aNick,
const wxString& aURI,
const wxString& aOptions,
80 const wxString& aDescr = wxEmptyString ) :
128 virtual const wxString
GetType()
const = 0;
134 virtual void SetType(
const wxString& aType ) = 0;
142 const wxString
GetFullURI(
bool aSubstituted =
false )
const;
196 uri_expanded( aRow.uri_expanded ),
220 wxString uri_expanded;
293 virtual void Parse( LIB_TABLE_LEXER* aLexer ) = 0;
336 if(
rows.size() ==
r.rows.size() )
340 for( i = 0; i <
rows.size() &&
rows[i] ==
r.rows[i]; ++i )
343 if( i ==
rows.size() )
386 bool IsEmpty(
bool aIncludeFallback =
true );
400 bool HasLibrary(
const wxString& aNickname,
bool aCheckEnabled =
false )
const;
411 wxString
GetFullURI(
const wxString& aLibNickname,
bool aExpandEnvVars =
true )
const;
434 for(
auto iter =
rows.begin(); iter !=
rows.end(); ++iter )
438 rows.erase( iter, iter + 1 );
459 void Load(
const wxString& aFileName );
466 void Save(
const wxString& aFileName )
const;
534 typedef std::map<wxString,int>
INDEX;
548 #endif // _LIB_TABLE_BASE_H_ An 8 bit string that is assuredly encoded in UTF8, and supplies special conversion support to and fro...
const wxString & GetOptions() const
Return the options string, which may hold a password or anything else needed to instantiate the under...
LIB_TABLE_ROW(const LIB_TABLE_ROW &aRow)
bool HasLibrary(const wxString &aNickname, bool aCheckEnabled=false) const
Test for the existence of aNickname in the library table.
Hold a record identifying a library accessed by the appropriate plug in object in the LIB_TABLE.
void Clear()
Delete all rows.
bool InsertRow(LIB_TABLE_ROW *aRow, bool doReplace=false)
Adds aRow if it does not already exist or if doReplace is true.
unsigned GetCount() const
Get the number of rows contained in the table.
std::map< wxString, int > INDEX
this is a non-owning index into the LIB_TABLE_ROWS table
bool enabled
Whether the LIB_TABLE_ROW is enabled.
INDEX::const_iterator INDEX_CITER
void setProperties(PROPERTIES *aProperties)
LIB_TABLE(LIB_TABLE *aFallBackTable=nullptr)
Build a library table by pre-pending this table fragment in front of aFallBackTable.
virtual void SetType(const wxString &aType)=0
Change the type of library represented by this row that must be implemented in the derived object to ...
bool operator==(const LIB_TABLE &r) const
Compares this table against another.
A logical library item identifier and consists of various portions much like a URI.
virtual const wxString GetType() const =0
Return the type of library represented by this row.
A name/value tuple with unique names and optional values.
std::unique_ptr< PROPERTIES > properties
bool operator==(const LIB_TABLE_ROW &r) const
static UTF8 FormatOptions(const PROPERTIES *aProperties)
Returns a list of options from the aProperties parameter.
INDEX::value_type INDEX_VALUE
const wxString & GetDescr() const
Return the description of the library referenced by this row.
This abstract base class mixes any object derived from LIB_TABLE into wxGridTableBase so the result c...
const wxString GetFullURI(bool aSubstituted=false) const
Return the full location specifying URI for the LIB, either in original UI form or in environment var...
void SetLoaded(bool aLoaded)
Mark the row as being a loaded library.
void SetEnabled(bool aEnabled=true)
Change the enabled status of this library.
const wxString & GetNickName() const
static PROPERTIES * ParseOptions(const std::string &aOptionsList)
Parses aOptionsList and places the result into a PROPERTIES object which is returned.
LIB_TABLE_ROW * clone() const
bool GetIsEnabled() const
virtual void Parse(LIB_TABLE_LEXER *aLexer)=0
Parse the #LIB_TABLE_LEXER s-expression library table format into the appropriate LIB_TABLE_ROW objec...
const wxString GetDescription(const wxString &aNickname)
wxString GetFullURI(const wxString &aLibNickname, bool aExpandEnvVars=true) const
Return the full URI of the library mapped to aLibNickname.
const LIB_TABLE_ROW * FindRowByURI(const wxString &aURI)
const LIB_TABLE_ROW & At(unsigned aIndex) const
Get the 'n'th LIB_TABLE_ROW object.
virtual void Format(OUTPUTFORMATTER *aOutput, int aIndentLevel) const =0
Generate the table in s-expression format to aOutput with an indentation level of aIndentLevel.
void operator=(const LIB_TABLE_ROW &aRow)
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,...
void Load(const wxString &aFileName)
Load the library table using the path defined by aFileName aFallBackTable.
#define FP_LATE_ENVVAR
late=1/early=0 environment variable expansion
bool RemoveRow(LIB_TABLE_ROW *aRow)
Removes a row from the table.
bool operator!=(const LIB_TABLE &r) const
void Format(OUTPUTFORMATTER *out, int nestLevel) const
Serialize this object as utf8 text to an OUTPUTFORMATTER, and tries to make it look good using multip...
bool operator!=(const LIB_TABLE_ROW &r) const
LIB_TABLE_ROW * new_clone(const LIB_TABLE_ROW &aRow)
Allows boost pointer containers to make clones of the data stored in them.
void SetFullURI(const wxString &aFullURI)
Change the full URI for the library.
LIB_TABLE_ROWS::const_iterator LIB_TABLE_ROWS_CITER
LIB_TABLE_ROW & At(unsigned aIndex)
Get the 'n'th LIB_TABLE_ROW object.
INDEX::iterator INDEX_ITER
virtual LIB_TABLE_ROW * do_clone() const =0
void SetNickName(const wxString &aNickName)
Change the logical name of this library, useful for an editor.
LIB_TABLE_ROWS::iterator LIB_TABLE_ROWS_ITER
void Save(const wxString &aFileName) const
Write this library table to aFileName in s-expression form.
A PROJECT can hold stuff it knows nothing about, in the form of _ELEM derivatives.
void SetOptions(const wxString &aOptions)
Change the library options strings.
const PROPERTIES * GetProperties() const
Return the constant PROPERTIES for this library (LIB_TABLE_ROW).
boost::ptr_vector< LIB_TABLE_ROW > LIB_TABLE_ROWS
Dialog to show and edit symbol library tables.
LIB_TABLE_ROW(const wxString &aNick, const wxString &aURI, const wxString &aOptions, const wxString &aDescr=wxEmptyString)
std::recursive_mutex m_nickIndexMutex
Mutex to protect access to the nickIndex variable.
wxString uri_user
what user entered from UI or loaded from disk
void SetDescr(const wxString &aDescr)
Change the description of the library referenced by this row.
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
INDEX nickIndex
this particular key is the nickName within each row.
bool m_loaded
Whether the LIB_TABLE_ROW is loaded.
bool IsEmpty(bool aIncludeFallback=true)
Return true if the table is empty.
std::vector< wxString > GetLogicalLibs()
Return the logical library names, all of them that are pertinent to a look up done on this LIB_TABLE.
Manage LIB_TABLE_ROW records (rows), and can be searched based on library nickname.