KiCad PCB EDA Suite
Loading...
Searching...
No Matches
lib_id.h
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2010-2012 SoftPLC Corporation, Dick Hollenbeck <[email protected]>
5 * Copyright (C) 2012 Wayne Stambaugh <[email protected]>
6 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <https://www.gnu.org/licenses/>.
20 */
21
22#ifndef _LIB_ID_H_
23#define _LIB_ID_H_
24
25#include <kicommon.h>
26#include <core/utf8.h>
27
45{
46public:
47 LIB_ID() {}
48
49 // NOTE: don't define any constructors which call Parse() on their arguments. We want it
50 // to be obvious to callers that parsing is involved (and that valid IDs are guaranteed in
51 // the presence of disallowed characters, malformed ids, etc.).
52
62 LIB_ID( const wxString& aLibraryName, const wxString& aItemName );
63
78 int Parse( const UTF8& aId, bool aFix = false );
79
83 const UTF8& GetLibNickname() const { return m_libraryName; }
84 const wxString GetUniStringLibNickname() const { return m_libraryName.wx_str(); }
85
93 int SetLibNickname( const UTF8& aLibNickname );
94
98 const UTF8& GetLibItemName() const { return m_itemName; }
99
108 const wxString GetUniStringLibItemName() const { return m_itemName.wx_str(); }
109
117 int SetLibItemName( const UTF8& aLibItemName );
118
127 void SetSubLibraryName( const UTF8& aName ) { m_subLibraryName = aName; }
128 const wxString GetUniStringSubLibraryName() const { return m_subLibraryName.wx_str(); }
129
133 const wxString GetFullLibraryName() const;
134
138 UTF8 Format() const;
139
144 wxString GetUniStringLibId() const
145 {
146 return Format().wx_str();
147 }
148
155 static UTF8 Format( const UTF8& aLibraryName, const UTF8& aLibItemName );
156
168 bool IsValid() const
169 {
170 return !m_libraryName.empty() && !m_itemName.empty();
171 }
172
176 bool IsLegacy() const
177 {
178 return m_libraryName.empty() && !m_itemName.empty();
179 }
180
184 void clear();
185
189 bool empty() const
190 {
191 return m_libraryName.empty() && m_itemName.empty();
192 }
193
201 int compare( const LIB_ID& aLibId ) const;
202
203 bool operator < ( const LIB_ID& aLibId ) const { return this->compare( aLibId ) < 0; }
204 bool operator > ( const LIB_ID& aLibId ) const { return this->compare( aLibId ) > 0; }
205 bool operator ==( const LIB_ID& aLibId ) const { return this->compare( aLibId ) == 0; }
206 bool operator !=( const LIB_ID& aLibId ) const { return !(*this == aLibId); }
207
214 static int HasIllegalChars( const UTF8& aLibItemName );
215
223 static UTF8 FixIllegalChars( const UTF8& aLibItemName, bool aLib );
224
231 static unsigned FindIllegalLibraryNameChar( const UTF8& aLibraryName );
232
233protected:
257 static bool isLegalChar( unsigned aUniChar );
258
265 static bool isLegalLibraryNameChar( unsigned aUniChar );
266
270};
271
272
273#endif // _LIB_ID_H_
bool operator==(const wxAuiPaneInfo &aLhs, const wxAuiPaneInfo &aRhs)
bool operator!=(const BOM_FIELD &lhs, const BOM_FIELD &rhs)
A logical library item identifier and consists of various portions much like a URI.
Definition lib_id.h:45
LIB_ID()
Definition lib_id.h:47
bool IsValid() const
Check if this LID_ID is valid.
Definition lib_id.h:168
int compare(const LIB_ID &aLibId) const
Compare the contents of LIB_ID objects by performing a std::string comparison of the library nickname...
Definition lib_id.cpp:157
bool empty() const
Definition lib_id.h:189
wxString GetUniStringLibId() const
Definition lib_id.h:144
const wxString GetUniStringSubLibraryName() const
Definition lib_id.h:128
UTF8 m_libraryName
The nickname of the library or empty.
Definition lib_id.h:267
void SetSubLibraryName(const UTF8 &aName)
Definition lib_id.h:127
const wxString GetUniStringLibItemName() const
Get strings for display messages in dialogs.
Definition lib_id.h:108
const wxString GetUniStringLibNickname() const
Definition lib_id.h:84
const UTF8 & GetLibItemName() const
Definition lib_id.h:98
bool IsLegacy() const
Definition lib_id.h:176
UTF8 GetSubLibraryName() const
Some LIB_IDs can have a sub-library identifier in addition to a library nickname.
Definition lib_id.h:126
const UTF8 & GetLibNickname() const
Return the logical library name portion of a LIB_ID.
Definition lib_id.h:83
UTF8 m_itemName
The name of the entry in the logical library.
Definition lib_id.h:268
UTF8 m_subLibraryName
Optional sub-library name used for grouping within a library.
Definition lib_id.h:269
An 8 bit string that is assuredly encoded in UTF8, and supplies special conversion support to and fro...
Definition utf8.h:67
bool operator<(const DESIGN_BLOCK_INFO &lhs, const DESIGN_BLOCK_INFO &rhs)
bool operator>(const EDA_ANGLE &aAngleA, const EDA_ANGLE &aAngleB)
Definition eda_angle.h:368
#define KICOMMON_API
Definition kicommon.h:27
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition ptree.cpp:194
netlist clear()