KiCad PCB EDA Suite
FP_LIB_TABLE_ROW Class Reference

Class FP_LIB_TABLE_ROW. More...

#include <fp_lib_table.h>

Inheritance diagram for FP_LIB_TABLE_ROW:
LIB_TABLE_ROW

Public Types

typedef IO_MGR::PCB_FILE_T LIB_T
 

Public Member Functions

 FP_LIB_TABLE_ROW (const wxString &aNick, const wxString &aURI, const wxString &aType, const wxString &aOptions, const wxString &aDescr=wxEmptyString)
 
 FP_LIB_TABLE_ROW ()
 
bool operator== (const FP_LIB_TABLE_ROW &aRow) const
 
bool operator!= (const FP_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
 
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

 FP_LIB_TABLE_ROW (const FP_LIB_TABLE_ROW &aRow)
 

Private Member Functions

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

Private Attributes

PLUGIN::RELEASER plugin
 
LIB_T type
 

Friends

class FP_LIB_TABLE
 

Detailed Description

Class FP_LIB_TABLE_ROW.

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

Definition at line 42 of file fp_lib_table.h.

Member Typedef Documentation

Definition at line 47 of file fp_lib_table.h.

Constructor & Destructor Documentation

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

Definition at line 49 of file fp_lib_table.h.

References SetType().

50  :
51  LIB_TABLE_ROW( aNick, aURI, aOptions, aDescr )
52  {
53  SetType( aType );
54  }
void SetType(const wxString &aType) override
Function SetType.
FP_LIB_TABLE_ROW::FP_LIB_TABLE_ROW ( )
inline

Definition at line 56 of file fp_lib_table.h.

References operator==().

Referenced by do_clone().

56  :
58  {
59  }
S-expression Pcbnew file format.
Definition: io_mgr.h:55
FP_LIB_TABLE_ROW::FP_LIB_TABLE_ROW ( const FP_LIB_TABLE_ROW aRow)
inlineprotected

Definition at line 80 of file fp_lib_table.h.

80  :
81  LIB_TABLE_ROW( aRow ),
82  type( aRow.type )
83  {
84  }

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* FP_LIB_TABLE_ROW::do_clone ( ) const
inlineoverrideprivatevirtual

Implements LIB_TABLE_ROW.

Definition at line 88 of file fp_lib_table.h.

References FP_LIB_TABLE_ROW().

89  {
90  return new FP_LIB_TABLE_ROW( *this );
91  }
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 84 of file lib_table_base.cpp.

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

Referenced by LIB_TABLE_ROW::GetProperties().

85 {
86  // In Kicad, we save path and file names using the Unix notation (separator = '/')
87  // So ensure separator is always '/' is saved URI string
88  wxString uri = GetFullURI();
89  uri.Replace( '\\', '/' );
90 
91  wxString extraOptions;
92 
93  if( !GetIsEnabled() )
94  {
95  extraOptions += "(disabled)";
96  }
97 
98  out->Print( nestLevel, "(lib (name %s)(type %s)(uri %s)(options %s)(descr %s)%s)\n",
99  out->Quotew( GetNickName() ).c_str(),
100  out->Quotew( GetType() ).c_str(),
101  out->Quotew( uri ).c_str(),
102  out->Quotew( GetOptions() ).c_str(),
103  out->Quotew( GetDescr() ).c_str(),
104  extraOptions.ToStdString().c_str()
105  );
106 }
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(), LIB_TABLE_GRID::GetValue(), and LIB_MANAGER_ADAPTER::Sync().

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 68 of file lib_table_base.cpp.

References LIB_TABLE::ExpandSubstitutions().

Referenced by LIB_TABLE::At(), 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(), FP_LIB_TABLE::GenerateTimestamp(), LIB_TABLE::GetFullURI(), FOOTPRINT_EDIT_FRAME::getLibPath(), SYMBOL_LIB_TABLE::GetSymbolCount(), LIB_TABLE_GRID::GetValue(), FP_LIB_TABLE::IsFootprintLibWritable(), SYMBOL_LIB_TABLE::IsSymbolLibWritable(), FP_LIB_TABLE::LoadEnumeratedFootprint(), SYMBOL_LIB_TABLE::LoadSymbol(), SYMBOL_LIB_TABLE::LoadSymbolLib(), FP_LIB_TABLE::PrefetchLib(), FOOTPRINT_EDIT_FRAME::SaveFootprintInLibrary(), SYMBOL_LIB_TABLE::SaveSymbol(), LIB_TABLE_ROW::SetEnabled(), FOOTPRINT_VIEWER_FRAME::UpdateTitle(), and FOOTPRINT_EDIT_FRAME::updateTitle().

69 {
70  if( aSubstituted )
71  {
72 #if !FP_LATE_ENVVAR // early expansion
73  return uri_expanded;
74 
75 #else // late expansion
77 #endif
78  }
79 
80  return uri_user;
81 }
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::GetValue(), LIB_TABLE_GRID::GetValueAsBool(), and SYMBOL_LIB_TABLE_ROW::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, and LIB_TABLE_ROW::SetOptions().

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

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

Function GetType.

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

Implements LIB_TABLE_ROW.

Definition at line 70 of file fp_lib_table.h.

References SetType(), IO_MGR::ShowType(), and type.

70 { return IO_MGR::ShowType( type ); }
static const wxString ShowType(PCB_FILE_T aFileType)
Function ShowType returns a brief name for a plugin, given aFileType enum.
Definition: io_mgr.cpp:77
bool FP_LIB_TABLE_ROW::operator!= ( const FP_LIB_TABLE_ROW aRow) const
inline

Definition at line 63 of file fp_lib_table.h.

63 { 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 FP_LIB_TABLE_ROW::operator== ( const FP_LIB_TABLE_ROW aRow) const

Definition at line 44 of file fp_lib_table.cpp.

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

Referenced by FP_LIB_TABLE_ROW().

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

Definition at line 210 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 LIB_TABLE_ROW::LIB_TABLE_ROW(), operator==(), and SYMBOL_LIB_TABLE_ROW::operator==().

211 {
212  return nickName == r.nickName
213  && uri_user == r.uri_user
214  && options == r.options
215  && description == r.description
216  && enabled == r.enabled;
217 }
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 109 of file lib_table_base.cpp.

Referenced by LIB_TABLE_ROW::GetProperties().

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

Referenced by LIB_TABLE_GRID::SetValue(), LIB_TABLE_GRID::SetValueAsBool(), and SYMBOL_LIB_TABLE_ROW::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 58 of file lib_table_base.cpp.

References LIB_TABLE::ExpandSubstitutions().

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

59 {
60  uri_user = aFullURI;
61 
62 #if !FP_LATE_ENVVAR
63  uri_expanded = FP_LIB_TABLE::ExpandSubstitutions( aFullURI );
64 #endif
65 }
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 220 of file lib_table_base.cpp.

References LIB_TABLE::ParseOptions(), and TO_UTF8.

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

221 {
222  options = aOptions;
223 
224  // set PROPERTIES* from options
226 }
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 FP_LIB_TABLE_ROW::setPlugin ( PLUGIN aPlugin)
inlineprivate

Definition at line 93 of file fp_lib_table.h.

References plugin, and PLUGIN::RELEASER::set().

Referenced by FP_LIB_TABLE::FindRow().

94  {
95  plugin.set( aPlugin );
96  }
PLUGIN::RELEASER plugin
Definition: fp_lib_table.h:98
void set(PLUGIN *aPlugin)
Definition: io_mgr.h:591
void FP_LIB_TABLE_ROW::SetType ( const wxString &  aType)
overridevirtual

Function SetType.

changes the type represented by this row.

Implements LIB_TABLE_ROW.

Definition at line 50 of file fp_lib_table.cpp.

References IO_MGR::EnumFromStr(), and IO_MGR::KICAD_SEXP.

Referenced by FP_LIB_TABLE_ROW(), and GetType().

51 {
52  type = IO_MGR::EnumFromStr( aType );
53 
54  if( IO_MGR::PCB_FILE_T( -1 ) == type )
56 }
static PCB_FILE_T EnumFromStr(const wxString &aFileType)
Function EnumFromStr returns the PCB_FILE_T from the corresponding plugin type name: "kicad"...
Definition: io_mgr.cpp:93
PCB_FILE_T
Enum PCB_FILE_T is a set of file types that the IO_MGR knows about, and for which there has been a pl...
Definition: io_mgr.h:52
S-expression Pcbnew file format.
Definition: io_mgr.h:55

Friends And Related Function Documentation

friend class FP_LIB_TABLE
friend

Definition at line 44 of file fp_lib_table.h.

Member Data Documentation

LIB_T FP_LIB_TABLE_ROW::type
private

Definition at line 99 of file fp_lib_table.h.

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


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