KiCad PCB EDA Suite
Loading...
Searching...
No Matches
design_block.cpp
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 The KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software: you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation, either version 3 of the License, or (at your
9 * option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#include <design_block.h>
21
22#include <wx/tokenzr.h>
23
24
25std::vector<SEARCH_TERM>& DESIGN_BLOCK::GetSearchTerms()
26{
27 m_searchTerms.clear();
28 m_searchTerms.reserve( 6 );
29
30 m_searchTerms.emplace_back( SEARCH_TERM( GetLibNickname(), 4 ) );
31 m_searchTerms.emplace_back( SEARCH_TERM( GetName(), 8 ) );
32 m_searchTerms.emplace_back( SEARCH_TERM( GetLIB_ID().Format(), 16 ) );
33
34 wxStringTokenizer keywordTokenizer( GetKeywords(), wxS( " " ), wxTOKEN_STRTOK );
35
36 while( keywordTokenizer.HasMoreTokens() )
37 m_searchTerms.emplace_back( SEARCH_TERM( keywordTokenizer.GetNextToken(), 4 ) );
38
39 // Also include keywords as one long string, just in case
40 m_searchTerms.emplace_back( SEARCH_TERM( GetKeywords(), 1 ) );
41 m_searchTerms.emplace_back( SEARCH_TERM( GetDesc(), 1 ) );
42
43 return m_searchTerms;
44}
wxString GetLibNickname() const override
std::vector< SEARCH_TERM > & GetSearchTerms() override
wxString GetDesc() override
LIB_ID GetLIB_ID() const override
const wxString & GetKeywords() const
std::vector< SEARCH_TERM > m_searchTerms
wxString GetName() const override
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:198
A structure for storing weighted search terms.