KiCad PCB EDA Suite
SYMBOL_LIB_TABLE_ROW Class Reference

Class SYMBOL_LIB_TABLE_ROW. 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, 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
 Function GetType. More...
 
void SetType (const wxString &aType) override
 Function SetType. More...
 
bool operator== (const LIB_TABLE_ROW &r) const
 
bool operator!= (const LIB_TABLE_ROW &r) const
 
const wxString & GetNickName () const
 Function GetNickName. More...
 
void SetNickName (const wxString &aNickName)
 Function SetNickName. More...
 
const wxString GetFullURI (bool aSubstituted=false) const
 Function GetFullURI. More...
 
void SetFullURI (const wxString &aFullURI)
 Function SetFullURI. More...
 
const wxString & GetOptions () const
 Function GetOptions. More...
 
void SetOptions (const wxString &aOptions)
 Function SetOptions. More...
 
const wxString & GetDescr () const
 Function GetDescr. More...
 
void SetDescr (const wxString &aDescr)
 Function SetDescr. More...
 
const PROPERTIESGetProperties () const
 Function GetProperties. More...
 
void Format (OUTPUTFORMATTER *out, int nestLevel) const
 Function Format. 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

Class SYMBOL_LIB_TABLE_ROW.

holds a record identifying a library accessed by the appropriate footprint library PLUGIN object in the SYMBOL_LIB_TABLE.

Definition at line 39 of file symbol_lib_table.h.

Member Typedef Documentation

Constructor & Destructor Documentation

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

Definition at line 46 of file symbol_lib_table.h.

References SetType().

47  :
48  LIB_TABLE_ROW( aNick, aURI, aOptions, aDescr )
49  {
50  SetType( aType );
51  }
void SetType(const wxString &aType) override
Function SetType.
SYMBOL_LIB_TABLE_ROW::SYMBOL_LIB_TABLE_ROW ( )
inline

Definition at line 53 of file symbol_lib_table.h.

Referenced by do_clone().

53  :
55  {
56  }
The s-expression version of the schematic file formats.
Definition: sch_io_mgr.h:56
SYMBOL_LIB_TABLE_ROW::SYMBOL_LIB_TABLE_ROW ( const SYMBOL_LIB_TABLE_ROW aRow)
inlineprotected

Definition at line 77 of file symbol_lib_table.h.

77  :
78  LIB_TABLE_ROW( aRow ),
79  type( aRow.type )
80  {
81  }

Member Function Documentation

LIB_TABLE_ROW* LIB_TABLE_ROW::clone ( ) const
inlineinherited

Definition at line 185 of file lib_table_base.h.

References LIB_TABLE_ROW::do_clone().

Referenced by new_clone().

186  {
187  return do_clone();
188  }
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 85 of file symbol_lib_table.h.

References SYMBOL_LIB_TABLE_ROW().

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

Function Format.

serializes 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  out->Print( nestLevel, "(lib (name %s)(type %s)(uri %s)(options %s)(descr %s))\n",
91  out->Quotew( GetNickName() ).c_str(),
92  out->Quotew( GetType() ).c_str(),
93  out->Quotew( uri ).c_str(),
94  out->Quotew( GetOptions() ).c_str(),
95  out->Quotew( GetDescr() ).c_str()
96  );
97 }
const wxString & GetOptions() const
Function GetOptions.
virtual const wxString GetType() const =0
Function GetType.
const wxString GetFullURI(bool aSubstituted=false) const
Function GetFullURI.
std::string Quotew(const wxString &aWrapee)
Definition: richio.cpp:486
const wxString & GetDescr() const
Function GetDescr.
const wxString & GetNickName() const
Function GetNickName.
int PRINTF_FUNC Print(int nestLevel, const char *fmt,...)
Function Print formats and writes text to the output stream.
Definition: richio.cpp:408
const wxString& LIB_TABLE_ROW::GetDescr ( ) const
inlineinherited

Function GetDescr.

returns the description of the library referenced by this row.

Definition at line 154 of file lib_table_base.h.

References LIB_TABLE_ROW::description.

Referenced by LIB_TABLE::GetDescription(), and FP_TBL_MODEL::GetValue().

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

Function GetFullURI.

returns 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(), SYMBOL_LIB_TABLE::DeleteSymbol(), SYMBOL_LIB_TABLE::DeleteSymbolLib(), 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(), FOOTPRINT_EDIT_FRAME::getLibPath(), FP_TBL_MODEL::GetValue(), FP_LIB_TABLE::IsFootprintLibWritable(), SYMBOL_LIB_TABLE::IsSymbolLibWritable(), SYMBOL_LIB_TABLE::LoadSymbol(), 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)
Function ExpandSubstitutions.
wxString uri_user
what user entered from UI or loaded from disk
const wxString& LIB_TABLE_ROW::GetNickName ( ) const
inlineinherited

Function GetNickName.

Returns
the logical name of this library table row.

Definition at line 95 of file lib_table_base.h.

References LIB_TABLE_ROW::nickName.

Referenced by FP_LIB_TABLE::FootprintLoad(), FP_TBL_MODEL::GetValue(), LIB_TABLE::InsertRow(), SYMBOL_LIB_TABLE::LoadSymbol(), and DIALOG_FP_LIB_TABLE::optionsEditor().

95 { return nickName; }
wxString nickName
const wxString& LIB_TABLE_ROW::GetOptions ( ) const
inlineinherited

Function GetOptions.

returns the options string, which may hold a password or anything else needed to instantiate the underlying LIB_SOURCE.

Definition at line 142 of file lib_table_base.h.

References LIB_TABLE_ROW::options.

Referenced by FP_TBL_MODEL::GetValue(), and DIALOG_FP_LIB_TABLE::optionsEditor().

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

Function GetType.

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

Implements LIB_TABLE_ROW.

Definition at line 67 of file symbol_lib_table.h.

References SCH_IO_MGR::ShowType(), and type.

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

Definition at line 60 of file symbol_lib_table.h.

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

Definition at line 88 of file lib_table_base.h.

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

Definition at line 46 of file symbol_lib_table.cpp.

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

47 {
48  return LIB_TABLE_ROW::operator == ( aRow ) && type == aRow.type;
49 }
bool operator==(const LIB_TABLE_ROW &r) const
bool LIB_TABLE_ROW::operator== ( const LIB_TABLE_ROW r) const
inherited

Definition at line 201 of file lib_table_base.cpp.

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

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

202 {
203  return nickName == r.nickName
204  && uri_user == r.uri_user
205  && options == r.options
206  && description == r.description;
207 }
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 100 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().

101 {
102  /*
103  * (lib (name NICKNAME)(descr DESCRIPTION)(type TYPE)(full_uri FULL_URI)(options OPTIONS))
104  *
105  * Elements after (name) are order independent.
106  */
107 
108  T tok = in->NextTok();
109 
110  if( tok != T_lib )
111  in->Expecting( T_lib );
112 
113  // (name NICKNAME)
114  in->NeedLEFT();
115 
116  if( ( tok = in->NextTok() ) != T_name )
117  in->Expecting( T_name );
118 
119  in->NeedSYMBOLorNUMBER();
120 
121  aRow->SetNickName( in->FromUTF8() );
122 
123  in->NeedRIGHT();
124 
125  // After (name), remaining (lib) elements are order independent, and in
126  // some cases optional.
127  bool sawType = false;
128  bool sawOpts = false;
129  bool sawDesc = false;
130  bool sawUri = false;
131 
132  while( ( tok = in->NextTok() ) != T_RIGHT )
133  {
134  if( tok == T_EOF )
135  in->Unexpected( T_EOF );
136 
137  if( tok != T_LEFT )
138  in->Expecting( T_LEFT );
139 
140  tok = in->NeedSYMBOLorNUMBER();
141 
142  switch( tok )
143  {
144  case T_uri:
145  if( sawUri )
146  in->Duplicate( tok );
147  sawUri = true;
148  in->NeedSYMBOLorNUMBER();
149  // Saved path and file names use the Unix notation (separator = '/')
150  // However old files, and files edited by hands can use the woindows
151  // separator. Force the unix notation
152  // (It works on windows, and moreover, wxFileName and wxDir takes care to that
153  // on windows)
154  // moreover, URLs use the '/' as separator
155  {
156  wxString uri = in->FromUTF8();
157  uri.Replace( '\\', '/' );
158  aRow->SetFullURI( uri );
159  }
160  break;
161 
162  case T_type:
163  if( sawType )
164  in->Duplicate( tok );
165  sawType = true;
166  in->NeedSYMBOLorNUMBER();
167  aRow->SetType( in->FromUTF8() );
168  break;
169 
170  case T_options:
171  if( sawOpts )
172  in->Duplicate( tok );
173  sawOpts = true;
174  in->NeedSYMBOLorNUMBER();
175  aRow->SetOptions( in->FromUTF8() );
176  break;
177 
178  case T_descr:
179  if( sawDesc )
180  in->Duplicate( tok );
181  sawDesc = true;
182  in->NeedSYMBOLorNUMBER();
183  aRow->SetDescr( in->FromUTF8() );
184  break;
185 
186  default:
187  in->Unexpected( tok );
188  }
189 
190  in->NeedRIGHT();
191  }
192 
193  if( !sawType )
194  in->Expecting( T_type );
195 
196  if( !sawUri )
197  in->Expecting( T_uri );
198 }
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:370
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:394
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:354
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:378
void NeedRIGHT()
Function NeedRIGHT calls NextTok() and then verifies that the token read in is a DSN_RIGHT.
Definition: dsnlexer.cpp:402
void LIB_TABLE_ROW::SetDescr ( const wxString &  aDescr)
inlineinherited

Function SetDescr.

changes the description of the library referenced by this row.

Definition at line 161 of file lib_table_base.h.

References LIB_TABLE_ROW::description.

Referenced by FP_TBL_MODEL::SetValue().

161 { description = aDescr; }
wxString description
void LIB_TABLE_ROW::SetFullURI ( const wxString &  aFullURI)
inherited

Function SetFullURI.

changes 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 FP_TBL_MODEL::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)
Function ExpandSubstitutions.
wxString uri_user
what user entered from UI or loaded from disk
void LIB_TABLE_ROW::SetNickName ( const wxString &  aNickName)
inlineinherited

Function SetNickName.

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

Definition at line 102 of file lib_table_base.h.

References LIB_TABLE_ROW::nickName.

Referenced by FP_TBL_MODEL::SetValue().

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

Function SetOptions.

Definition at line 210 of file lib_table_base.cpp.

References LIB_TABLE::ParseOptions(), and TO_UTF8.

Referenced by LIB_TABLE_ROW::LIB_TABLE_ROW(), DIALOG_FP_LIB_TABLE::optionsEditor(), and FP_TBL_MODEL::SetValue().

211 {
212  options = aOptions;
213 
214  // set PROPERTIES* from options
216 }
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)
Function ParseOptions.
wxString options
void SYMBOL_LIB_TABLE_ROW::setPlugin ( SCH_PLUGIN aPlugin)
inlineprivate

Definition at line 90 of file symbol_lib_table.h.

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

Referenced by SYMBOL_LIB_TABLE::FindRow().

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

Function SetType.

changes the type represented by this row.

Implements LIB_TABLE_ROW.

Definition at line 52 of file symbol_lib_table.cpp.

References SCH_IO_MGR::EnumFromStr(), and SCH_IO_MGR::SCH_KICAD.

Referenced by SYMBOL_LIB_TABLE_ROW().

53 {
54  type = SCH_IO_MGR::EnumFromStr( aType );
55 
56  if( SCH_IO_MGR::SCH_FILE_T( -1 ) == type )
58 }
The s-expression version of the schematic file formats.
Definition: sch_io_mgr.h:56
static SCH_FILE_T EnumFromStr(const wxString &aFileType)
Function EnumFromStr returns the SCH_FILE_T from the corresponding plugin type name: "kicad"...
Definition: sch_io_mgr.cpp:92
SCH_FILE_T
Enum SCH_FILE_T is a set of file types that the SCH_IO_MGR knows about, and for which there has been ...
Definition: sch_io_mgr.h:53

Friends And Related Function Documentation

friend class SYMBOL_LIB_TABLE
friend

Definition at line 41 of file symbol_lib_table.h.

Member Data Documentation

LIB_T SYMBOL_LIB_TABLE_ROW::type
private

Definition at line 96 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: