29#include <design_block_info.h>
30#include <fp_lib_table.h>
38#include <wx/tokenzr.h>
41DESIGN_BLOCK_INFO* DESIGN_BLOCK_LIST::GetDesignBlockInfo(
const wxString& aLibNickname,
42 const wxString& aDesignBlockName )
44 if( aDesignBlockName.IsEmpty() )
47 for( std::unique_ptr<DESIGN_BLOCK_INFO>& db : m_list )
49 if( aLibNickname == db->GetLibNickname() && aDesignBlockName == db->GetDesignBlockName() )
57DESIGN_BLOCK_INFO* DESIGN_BLOCK_LIST::GetDesignBlockInfo(
const wxString& aDesignBlockName )
59 if( aDesignBlockName.IsEmpty() )
64 wxCHECK_MSG( dbid.
Parse( aDesignBlockName ) < 0,
nullptr,
65 wxString::Format( wxT(
"'%s' is not a valid LIB_ID." ), aDesignBlockName ) );
71std::vector<SEARCH_TERM> DESIGN_BLOCK_INFO::GetSearchTerms()
73 std::vector<SEARCH_TERM> terms;
75 terms.emplace_back(
SEARCH_TERM( GetLibNickname(), 4 ) );
79 wxStringTokenizer keywordTokenizer( GetKeywords(),
" \t\r\n", wxTOKEN_STRTOK );
81 while( keywordTokenizer.HasMoreTokens() )
82 terms.emplace_back(
SEARCH_TERM( keywordTokenizer.GetNextToken(), 4 ) );
85 terms.emplace_back(
SEARCH_TERM( GetKeywords(), 1 ) );
92bool DESIGN_BLOCK_INFO::InLibrary(
const wxString& aLibrary )
const
94 return aLibrary == m_nickname;
98bool operator<(
const DESIGN_BLOCK_INFO& lhs,
const DESIGN_BLOCK_INFO& rhs )
100 int retv =
StrNumCmp( lhs.m_nickname, rhs.m_nickname,
false );
109 return StrNumCmp( lhs.m_dbname, rhs.m_dbname,
false ) < 0;
A logical library item identifier and consists of various portions much like a URI.
int Parse(const UTF8 &aId, bool aFix=false)
Parse LIB_ID with the information from aId.
const UTF8 & GetLibItemName() const
const UTF8 & GetLibNickname() const
Return the logical library name portion of a LIB_ID.
bool operator<(const DESIGN_BLOCK_INFO &lhs, const DESIGN_BLOCK_INFO &rhs)
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
int StrNumCmp(const wxString &aString1, const wxString &aString2, bool aIgnoreCase)
Compare two strings with alphanumerical content.
A structure for storing weighted search terms.