KiCad PCB EDA Suite
SYMBOL_LIB_TABLE_ROW Class Reference

Hold a record identifying a symbol library accessed by the appropriate symbol library SCH_PLUGIN object in the SYMBOL_LIB_TABLE. More...

#include <symbol_lib_table.h>

Inheritance diagram for SYMBOL_LIB_TABLE_ROW:
LIB_TABLE_ROW

Public Types

typedef SCH_IO_MGR::SCH_FILE_T LIB_T
 

Public Member Functions

 SYMBOL_LIB_TABLE_ROW (const wxString &aNick, const wxString &aURI, const wxString &aType, const wxString &aOptions=wxEmptyString, const wxString &aDescr=wxEmptyString)
 
 SYMBOL_LIB_TABLE_ROW ()
 
bool operator== (const SYMBOL_LIB_TABLE_ROW &aRow) const
 
bool operator!= (const SYMBOL_LIB_TABLE_ROW &aRow) const
 
const wxString GetType () const override
 Return the type of symbol library table represented by this row. More...
 
void SetType (const wxString &aType) override
 Change the schematic plugin type represented by this row. More...
 
bool operator== (const LIB_TABLE_ROW &r) const
 
bool operator!= (const LIB_TABLE_ROW &r) const
 
const wxString & GetNickName () const
 
void SetNickName (const wxString &aNickName)
 Change the logical name of this library, useful for an editor. More...
 
bool GetIsEnabled () const
 
void SetEnabled (bool aEnabled=true)
 Change the enabled status of this library. More...
 
const wxString GetFullURI (bool aSubstituted=false) const
 Return the full location specifying URI for the LIB, either in original UI form or in environment variable expanded form. More...
 
void SetFullURI (const wxString &aFullURI)
 Change the full URI for the library. More...
 
const wxString & GetOptions () const
 Return the options string, which may hold a password or anything else needed to instantiate the underlying library plugin. More...
 
void SetOptions (const wxString &aOptions)
 Change the library options strings. More...
 
const wxString & GetDescr () const
 Return the description of the library referenced by this row. More...
 
void SetDescr (const wxString &aDescr)
 Change the description of the library referenced by this row. More...
 
const PROPERTIESGetProperties () const
 Return the constant PROPERTIES for this library (LIB_TABLE_ROW). More...
 
void Format (OUTPUTFORMATTER *out, int nestLevel) const
 Serialize this object as utf8 text to an OUTPUTFORMATTER, and tries to make it look good using multiple lines and indentation. More...
 
LIB_TABLE_ROWclone () const
 

Static Public Member Functions

static void Parse (std::unique_ptr< LIB_TABLE_ROW > &aRow, LIB_TABLE_LEXER *in)
 

Protected Member Functions

 SYMBOL_LIB_TABLE_ROW (const SYMBOL_LIB_TABLE_ROW &aRow)
 

Private Member Functions

virtual LIB_TABLE_ROWdo_clone () const override
 
void setPlugin (SCH_PLUGIN *aPlugin)
 

Private Attributes

SCH_PLUGIN::SCH_PLUGIN_RELEASER plugin
 
LIB_T type
 

Friends

class SYMBOL_LIB_TABLE
 

Detailed Description

Hold a record identifying a symbol library accessed by the appropriate symbol library SCH_PLUGIN object in the SYMBOL_LIB_TABLE.

Definition at line 41 of file symbol_lib_table.h.

Member Typedef Documentation

typedef SCH_IO_MGR::SCH_FILE_T SYMBOL_LIB_TABLE_ROW::LIB_T

Definition at line 46 of file symbol_lib_table.h.

Constructor & Destructor Documentation

SYMBOL_LIB_TABLE_ROW::SYMBOL_LIB_TABLE_ROW ( const wxString &  aNick,
const wxString &  aURI,
const wxString &  aType,
const wxString &  aOptions = wxEmptyString,
const wxString &  aDescr = wxEmptyString 
)
inline

Definition at line 48 of file symbol_lib_table.h.

References LIB_TABLE_ROW::SetEnabled(), and SetType().

50  :
51  LIB_TABLE_ROW( aNick, aURI, aOptions, aDescr )
52  {
53  SetType( aType );
54  SetEnabled( true );
55  }
void SetType(const wxString &aType) override
Change the schematic plugin type represented by this row.
void SetEnabled(bool aEnabled=true)
Change the enabled status of this library.
SYMBOL_LIB_TABLE_ROW::SYMBOL_LIB_TABLE_ROW ( )
inline

Definition at line 57 of file symbol_lib_table.h.

References LIB_TABLE_ROW::SetEnabled().

Referenced by do_clone().

57  :
58  type( SCH_IO_MGR::SCH_LEGACY )
59  {
60  SetEnabled( true );
61  }
void SetEnabled(bool aEnabled=true)
Change the enabled status of this library.
SYMBOL_LIB_TABLE_ROW::SYMBOL_LIB_TABLE_ROW ( const SYMBOL_LIB_TABLE_ROW aRow)
inlineprotected

Definition at line 78 of file symbol_lib_table.h.

References LIB_TABLE_ROW::GetIsEnabled(), and LIB_TABLE_ROW::SetEnabled().

78  :
79  LIB_TABLE_ROW( aRow ),
80  type( aRow.type )
81  {
82  SetEnabled( aRow.GetIsEnabled() );
83  }
void SetEnabled(bool aEnabled=true)
Change the enabled status of this library.
bool GetIsEnabled() const

Member Function Documentation

LIB_TABLE_ROW* LIB_TABLE_ROW::clone ( ) const
inlineinherited

Definition at line 176 of file lib_table_base.h.

References LIB_TABLE_ROW::do_clone().

Referenced by new_clone().

177  {
178  return do_clone();
179  }
virtual LIB_TABLE_ROW * do_clone() const =0
virtual LIB_TABLE_ROW* SYMBOL_LIB_TABLE_ROW::do_clone ( ) const
inlineoverrideprivatevirtual

Implements LIB_TABLE_ROW.

Definition at line 87 of file symbol_lib_table.h.

References SYMBOL_LIB_TABLE_ROW().

88  {
89  return new SYMBOL_LIB_TABLE_ROW( *this );
90  }
void LIB_TABLE_ROW::Format ( OUTPUTFORMATTER out,
int  nestLevel 
) const
inherited

Serialize this object as utf8 text to an OUTPUTFORMATTER, and tries to make it look good using multiple lines and indentation.

Parameters
outis an OUTPUTFORMATTER
nestLevelis the indentation level to base all lines of the output. Actual indentation will be 2 spaces for each nestLevel.

Definition at line 83 of file lib_table_base.cpp.

References OUTPUTFORMATTER::Print(), and OUTPUTFORMATTER::Quotew().

84 {
85  // In Kicad, we save path and file names using the Unix notation (separator = '/')
86  // So ensure separator is always '/' is saved URI string
87  wxString uri = GetFullURI();
88  uri.Replace( '\\', '/' );
89 
90  wxString extraOptions;
91 
92  if( !GetIsEnabled() )
93  {
94  extraOptions += "(disabled)";
95  }
96 
97  out->Print( nestLevel, "(lib (name %s)(type %s)(uri %s)(options %s)(descr %s)%s)\n",
98  out->Quotew( GetNickName() ).c_str(),
99  out->Quotew( GetType() ).c_str(),
100  out->Quotew( uri ).c_str(),
101  out->Quotew( GetOptions() ).c_str(),
102  out->Quotew( GetDescr() ).c_str(),
103  extraOptions.ToStdString().c_str()
104  );
105 }
const wxString & GetOptions() const
Return the options string, which may hold a password or anything else needed to instantiate the under...
virtual const wxString GetType() const =0
Return the type of library represented by this row.
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...
std::string Quotew(const wxString &aWrapee)
Definition: richio.cpp:482
const wxString & GetDescr() const
Return the description of the library referenced by this row.
const wxString & GetNickName() const
bool GetIsEnabled() const
int PRINTF_FUNC Print(int nestLevel, const char *fmt,...)
Function Print formats and writes text to the output stream.
Definition: richio.cpp:404
const wxString& LIB_TABLE_ROW::GetDescr ( ) const
inlineinherited

Return the description of the library referenced by this row.

Definition at line 151 of file lib_table_base.h.

References LIB_TABLE_ROW::description.

Referenced by SCH_EDIT_FRAME::AppendSchematic(), LIB_TABLE::GetDescription(), and LIB_TABLE_GRID::GetValue().

151 { return description; }
wxString description
const wxString LIB_TABLE_ROW::GetFullURI ( bool  aSubstituted = false) const
inherited

Return the full location specifying URI for the LIB, either in original UI form or in environment variable expanded form.

Parameters
aSubstitutedTells if caller wanted the substituted form, else not.

Definition at line 67 of file lib_table_base.cpp.

References LIB_TABLE::ExpandSubstitutions().

Referenced by SYMBOL_LIB_TABLE::CreateSymbolLib(), SYMBOL_LIB_TABLE::DeleteAlias(), FOOTPRINT_EDIT_FRAME::DeleteModuleFromCurrentLibrary(), SYMBOL_LIB_TABLE::DeleteSymbol(), SYMBOL_LIB_TABLE::DeleteSymbolLib(), LIB_VIEW_FRAME::DisplayLibInfos(), SYMBOL_LIB_TABLE::EnumerateSymbolLib(), FP_LIB_TABLE::FootprintDelete(), FP_LIB_TABLE::FootprintEnumerate(), FP_LIB_TABLE::FootprintLibCreate(), FP_LIB_TABLE::FootprintLibDelete(), FP_LIB_TABLE::FootprintLoad(), FP_LIB_TABLE::FootprintSave(), LIB_TABLE::GetFullURI(), FOOTPRINT_EDIT_FRAME::getLibPath(), SYMBOL_LIB_TABLE::GetSymbolCount(), LIB_TABLE_GRID::GetValue(), FP_LIB_TABLE::IsFootprintLibWritable(), SYMBOL_LIB_TABLE::IsSymbolLibWritable(), SYMBOL_LIB_TABLE::LoadSymbol(), FP_LIB_TABLE::PrefetchLib(), FOOTPRINT_EDIT_FRAME::SaveFootprintInLibrary(), SYMBOL_LIB_TABLE::SaveSymbol(), FOOTPRINT_VIEWER_FRAME::UpdateTitle(), and FOOTPRINT_EDIT_FRAME::updateTitle().

68 {
69  if( aSubstituted )
70  {
71 #if !FP_LATE_ENVVAR // early expansion
72  return uri_expanded;
73 
74 #else // late expansion
76 #endif
77  }
78 
79  return uri_user;
80 }
static const wxString ExpandSubstitutions(const wxString &aString)
Replaces any environment variable references with their values and is here to fully embellish the TAB...
wxString uri_user
what user entered from UI or loaded from disk
bool LIB_TABLE_ROW::GetIsEnabled ( ) const
inlineinherited
Returns
the enabled status of this library row

Definition at line 106 of file lib_table_base.h.

References LIB_TABLE_ROW::enabled.

Referenced by LIB_TABLE_GRID::GetAttr(), LIB_TABLE_GRID::GetValue(), and SYMBOL_LIB_TABLE_ROW().

106 { return enabled; }
bool enabled
Whether the LIB_TABLE_ROW is enabled.
const wxString& LIB_TABLE_ROW::GetNickName ( ) const
inlineinherited
const wxString& LIB_TABLE_ROW::GetOptions ( ) const
inlineinherited

Return the options string, which may hold a password or anything else needed to instantiate the underlying library plugin.

Definition at line 141 of file lib_table_base.h.

References LIB_TABLE_ROW::options.

Referenced by SCH_EDIT_FRAME::AppendSchematic(), SYMBOL_LIB_TABLE::EnumerateSymbolLib(), LIB_TABLE_GRID::GetValue(), and DIALOG_FP_LIB_TABLE::optionsEditor().

141 { return options; }
wxString options
const wxString SYMBOL_LIB_TABLE_ROW::GetType ( ) const
inlineoverridevirtual

Return the type of symbol library table represented by this row.

Implements LIB_TABLE_ROW.

Definition at line 70 of file symbol_lib_table.h.

References SCH_IO_MGR::ShowType(), and type.

Referenced by SCH_EDIT_FRAME::AppendSchematic().

70 { return SCH_IO_MGR::ShowType( type ); }
static const wxString ShowType(SCH_FILE_T aFileType)
Return a brief name for a plugin, given aFileType enum.
Definition: sch_io_mgr.cpp:76
bool SYMBOL_LIB_TABLE_ROW::operator!= ( const SYMBOL_LIB_TABLE_ROW aRow) const
inline

Definition at line 65 of file symbol_lib_table.h.

65 { return !( *this == aRow ); }
bool LIB_TABLE_ROW::operator!= ( const LIB_TABLE_ROW r) const
inlineinherited

Definition at line 91 of file lib_table_base.h.

91 { return !( *this == r ); }
bool SYMBOL_LIB_TABLE_ROW::operator== ( const SYMBOL_LIB_TABLE_ROW aRow) const

Definition at line 54 of file symbol_lib_table.cpp.

References LIB_TABLE_ROW::operator==(), and type.

55 {
56  return LIB_TABLE_ROW::operator == ( aRow ) && type == aRow.type;
57 }
bool operator==(const LIB_TABLE_ROW &r) const
bool LIB_TABLE_ROW::operator== ( const LIB_TABLE_ROW r) const
inherited

Definition at line 209 of file lib_table_base.cpp.

References LIB_TABLE_ROW::description, LIB_TABLE_ROW::enabled, LIB_TABLE_ROW::nickName, LIB_TABLE_ROW::options, and LIB_TABLE_ROW::uri_user.

Referenced by FP_LIB_TABLE_ROW::operator==(), and operator==().

210 {
211  return nickName == r.nickName
212  && uri_user == r.uri_user
213  && options == r.options
214  && description == r.description
215  && enabled == r.enabled;
216 }
bool enabled
Whether the LIB_TABLE_ROW is enabled.
wxString description
wxString options
wxString nickName
wxString uri_user
what user entered from UI or loaded from disk
void LIB_TABLE_ROW::Parse ( std::unique_ptr< LIB_TABLE_ROW > &  aRow,
LIB_TABLE_LEXER in 
)
staticinherited

Definition at line 108 of file lib_table_base.cpp.

References DSNLEXER::Duplicate(), DSNLEXER::Expecting(), DSNLEXER::FromUTF8(), DSNLEXER::NeedLEFT(), DSNLEXER::NeedRIGHT(), LIB_TABLE_LEXER::NeedSYMBOLorNUMBER(), LIB_TABLE_LEXER::NextTok(), LIB_TABLE_T::T_descr, LIB_TABLE_T::T_EOF, LIB_TABLE_T::T_LEFT, LIB_TABLE_T::T_lib, LIB_TABLE_T::T_name, LIB_TABLE_T::T_options, LIB_TABLE_T::T_RIGHT, LIB_TABLE_T::T_type, LIB_TABLE_T::T_uri, and DSNLEXER::Unexpected().

109 {
110  /*
111  * (lib (name NICKNAME)(descr DESCRIPTION)(type TYPE)(full_uri FULL_URI)(options OPTIONS))
112  *
113  * Elements after (name) are order independent.
114  */
115 
116  T tok = in->NextTok();
117 
118  if( tok != T_lib )
119  in->Expecting( T_lib );
120 
121  // (name NICKNAME)
122  in->NeedLEFT();
123 
124  if( ( tok = in->NextTok() ) != T_name )
125  in->Expecting( T_name );
126 
127  in->NeedSYMBOLorNUMBER();
128 
129  aRow->SetNickName( in->FromUTF8() );
130 
131  in->NeedRIGHT();
132 
133  // After (name), remaining (lib) elements are order independent, and in
134  // some cases optional.
135  bool sawType = false;
136  bool sawOpts = false;
137  bool sawDesc = false;
138  bool sawUri = false;
139 
140  while( ( tok = in->NextTok() ) != T_RIGHT )
141  {
142  if( tok == T_EOF )
143  in->Unexpected( T_EOF );
144 
145  if( tok != T_LEFT )
146  in->Expecting( T_LEFT );
147 
148  tok = in->NeedSYMBOLorNUMBER();
149 
150  switch( tok )
151  {
152  case T_uri:
153  if( sawUri )
154  in->Duplicate( tok );
155  sawUri = true;
156  in->NeedSYMBOLorNUMBER();
157  // Saved path and file names use the Unix notation (separator = '/')
158  // However old files, and files edited by hands can use the woindows
159  // separator. Force the unix notation
160  // (It works on windows, and moreover, wxFileName and wxDir takes care to that
161  // on windows)
162  // moreover, URLs use the '/' as separator
163  {
164  wxString uri = in->FromUTF8();
165  uri.Replace( '\\', '/' );
166  aRow->SetFullURI( uri );
167  }
168  break;
169 
170  case T_type:
171  if( sawType )
172  in->Duplicate( tok );
173  sawType = true;
174  in->NeedSYMBOLorNUMBER();
175  aRow->SetType( in->FromUTF8() );
176  break;
177 
178  case T_options:
179  if( sawOpts )
180  in->Duplicate( tok );
181  sawOpts = true;
182  in->NeedSYMBOLorNUMBER();
183  aRow->SetOptions( in->FromUTF8() );
184  break;
185 
186  case T_descr:
187  if( sawDesc )
188  in->Duplicate( tok );
189  sawDesc = true;
190  in->NeedSYMBOLorNUMBER();
191  aRow->SetDescr( in->FromUTF8() );
192  break;
193 
194  default:
195  in->Unexpected( tok );
196  }
197 
198  in->NeedRIGHT();
199  }
200 
201  if( !sawType )
202  in->Expecting( T_type );
203 
204  if( !sawUri )
205  in->Expecting( T_uri );
206 }
T
enum T contains all this lexer's tokens.
void Unexpected(int aTok)
Function Unexpected throws an IO_ERROR exception with an input file specific error message...
Definition: dsnlexer.cpp:369
wxString FromUTF8()
Function FromUTF8 returns the current token text as a wxString, assuming that the input byte stream i...
Definition: dsnlexer.h:498
void NeedLEFT()
Function NeedLEFT calls NextTok() and then verifies that the token read in is a DSN_LEFT.
Definition: dsnlexer.cpp:393
LIB_TABLE_T::T NeedSYMBOLorNUMBER()
Function NeedSYMBOLorNUMBER calls NextTok() and then verifies that the token read in satisfies bool I...
void Expecting(int aTok)
Function Expecting throws an IO_ERROR exception with an input file specific error message...
Definition: dsnlexer.cpp:353
LIB_TABLE_T::T NextTok()
Function NextTok returns the next token found in the input file or T_EOF when reaching the end of fil...
void Duplicate(int aTok)
Function Duplicate throws an IO_ERROR exception with a message saying specifically that aTok is a dup...
Definition: dsnlexer.cpp:377
void NeedRIGHT()
Function NeedRIGHT calls NextTok() and then verifies that the token read in is a DSN_RIGHT.
Definition: dsnlexer.cpp:401
void LIB_TABLE_ROW::SetDescr ( const wxString &  aDescr)
inlineinherited

Change the description of the library referenced by this row.

Definition at line 156 of file lib_table_base.h.

References LIB_TABLE_ROW::description.

Referenced by LIB_TABLE_GRID::SetValue().

156 { description = aDescr; }
wxString description
void LIB_TABLE_ROW::SetEnabled ( bool  aEnabled = true)
inlineinherited

Change the enabled status of this library.

Definition at line 111 of file lib_table_base.h.

References LIB_TABLE_ROW::enabled.

Referenced by LIB_TABLE_GRID::SetValue(), and SYMBOL_LIB_TABLE_ROW().

111 { enabled = aEnabled; }
bool enabled
Whether the LIB_TABLE_ROW is enabled.
void LIB_TABLE_ROW::SetFullURI ( const wxString &  aFullURI)
inherited

Change the full URI for the library.

Definition at line 57 of file lib_table_base.cpp.

References LIB_TABLE::ExpandSubstitutions().

Referenced by LIB_TABLE_ROW::LIB_TABLE_ROW(), and LIB_TABLE_GRID::SetValue().

58 {
59  uri_user = aFullURI;
60 
61 #if !FP_LATE_ENVVAR
62  uri_expanded = FP_LIB_TABLE::ExpandSubstitutions( aFullURI );
63 #endif
64 }
static const wxString ExpandSubstitutions(const wxString &aString)
Replaces any environment variable references with their values and is here to fully embellish the TAB...
wxString uri_user
what user entered from UI or loaded from disk
void LIB_TABLE_ROW::SetNickName ( const wxString &  aNickName)
inlineinherited

Change the logical name of this library, useful for an editor.

Definition at line 101 of file lib_table_base.h.

References LIB_TABLE_ROW::nickName.

Referenced by LIB_TABLE_GRID::SetValue().

101 { nickName = aNickName; }
wxString nickName
void LIB_TABLE_ROW::SetOptions ( const wxString &  aOptions)
inherited

Change the library options strings.

Definition at line 219 of file lib_table_base.cpp.

References LIB_TABLE::ParseOptions(), and TO_UTF8.

Referenced by SYMBOL_LIB_TABLE::EnumerateSymbolLib(), LIB_TABLE_ROW::LIB_TABLE_ROW(), DIALOG_FP_LIB_TABLE::optionsEditor(), and LIB_TABLE_GRID::SetValue().

220 {
221  options = aOptions;
222 
223  // set PROPERTIES* from options
225 }
void setProperties(PROPERTIES *aProperties)
#define TO_UTF8(wxstring)
Macro TO_UTF8 converts a wxString to a UTF8 encoded C string for all wxWidgets build modes...
Definition: macros.h:47
static PROPERTIES * ParseOptions(const std::string &aOptionsList)
Parses aOptionsList and places the result into a PROPERTIES object which is returned.
wxString options
void SYMBOL_LIB_TABLE_ROW::setPlugin ( SCH_PLUGIN aPlugin)
inlineprivate

Definition at line 92 of file symbol_lib_table.h.

References plugin, and SCH_PLUGIN::SCH_PLUGIN_RELEASER::set().

Referenced by SYMBOL_LIB_TABLE::FindRow().

93  {
94  plugin.set( aPlugin );
95  }
SCH_PLUGIN::SCH_PLUGIN_RELEASER plugin
void set(SCH_PLUGIN *aPlugin)
Definition: sch_io_mgr.h:551
void SYMBOL_LIB_TABLE_ROW::SetType ( const wxString &  aType)
overridevirtual

Change the schematic plugin type represented by this row.

Implements LIB_TABLE_ROW.

Definition at line 60 of file symbol_lib_table.cpp.

References SCH_IO_MGR::EnumFromStr().

Referenced by SYMBOL_LIB_TABLE_ROW().

61 {
62  type = SCH_IO_MGR::EnumFromStr( aType );
63 
64  if( SCH_IO_MGR::SCH_FILE_T( -1 ) == type )
65  type = SCH_IO_MGR::SCH_LEGACY;
66 }
static SCH_FILE_T EnumFromStr(const wxString &aFileType)
Return the #SCH_FILE_T from the corresponding plugin type name: "kicad", "legacy", etc.
Definition: sch_io_mgr.cpp:96

Friends And Related Function Documentation

friend class SYMBOL_LIB_TABLE
friend

Definition at line 43 of file symbol_lib_table.h.

Member Data Documentation

LIB_T SYMBOL_LIB_TABLE_ROW::type
private

Definition at line 98 of file symbol_lib_table.h.

Referenced by SYMBOL_LIB_TABLE::FindRow(), GetType(), and operator==().


The documentation for this class was generated from the following files: