KiCad PCB EDA Suite
EDA_COMBINED_MATCHER Class Reference

#include <eda_pattern_match.h>

Public Member Functions

 EDA_COMBINED_MATCHER (const wxString &aPattern, COMBINED_MATCHER_CONTEXT aContext)
 
bool Find (const wxString &aTerm, int &aMatchersTriggered, int &aPosition)
 
const wxString & GetPattern () const
 

Private Member Functions

void AddMatcher (const wxString &aPattern, std::unique_ptr< EDA_PATTERN_MATCH > aMatcher)
 

Private Attributes

std::vector< std::unique_ptr< EDA_PATTERN_MATCH > > m_matchers
 
wxString m_pattern
 

Detailed Description

Definition at line 184 of file eda_pattern_match.h.

Constructor & Destructor Documentation

◆ EDA_COMBINED_MATCHER()

EDA_COMBINED_MATCHER::EDA_COMBINED_MATCHER ( const wxString &  aPattern,
COMBINED_MATCHER_CONTEXT  aContext 
)

Definition at line 369 of file eda_pattern_match.cpp.

370 :
371 m_pattern( aPattern )
372{
373 switch( aContext )
374 {
375 case CTX_LIBITEM:
376 // Whatever syntax users prefer, it shall be matched.
377 AddMatcher( aPattern, std::make_unique<EDA_PATTERN_MATCH_REGEX>() );
378 AddMatcher( aPattern, std::make_unique<EDA_PATTERN_MATCH_WILDCARD>() );
379 AddMatcher( aPattern, std::make_unique<EDA_PATTERN_MATCH_RELATIONAL>() );
380 // If any of the above matchers couldn't be created because the pattern
381 // syntax does not match, the substring will try its best.
382 AddMatcher( aPattern, std::make_unique<EDA_PATTERN_MATCH_SUBSTR>() );
383 break;
384
385 case CTX_NETCLASS:
386 AddMatcher( aPattern, std::make_unique<EDA_PATTERN_MATCH_REGEX_EXPLICIT>() );
387 AddMatcher( aPattern, std::make_unique<EDA_PATTERN_MATCH_WILDCARD_EXPLICIT>() );
388 break;
389 }
390}
void AddMatcher(const wxString &aPattern, std::unique_ptr< EDA_PATTERN_MATCH > aMatcher)
@ CTX_NETCLASS
@ CTX_LIBITEM

References AddMatcher(), CTX_LIBITEM, and CTX_NETCLASS.

Member Function Documentation

◆ AddMatcher()

void EDA_COMBINED_MATCHER::AddMatcher ( const wxString &  aPattern,
std::unique_ptr< EDA_PATTERN_MATCH aMatcher 
)
private

Definition at line 421 of file eda_pattern_match.cpp.

423{
424 if ( aMatcher->SetPattern( aPattern ) )
425 m_matchers.push_back( std::move( aMatcher ) );
426}
std::vector< std::unique_ptr< EDA_PATTERN_MATCH > > m_matchers

References m_matchers.

Referenced by EDA_COMBINED_MATCHER().

◆ Find()

bool EDA_COMBINED_MATCHER::Find ( const wxString &  aTerm,
int &  aMatchersTriggered,
int &  aPosition 
)

Definition at line 393 of file eda_pattern_match.cpp.

394{
395 aPosition = EDA_PATTERN_NOT_FOUND;
396 aMatchersTriggered = 0;
397
398 for( const std::unique_ptr<EDA_PATTERN_MATCH>& matcher : m_matchers )
399 {
400 EDA_PATTERN_MATCH::FIND_RESULT local_find = matcher->Find( aTerm );
401
402 if( local_find )
403 {
404 aMatchersTriggered += 1;
405
406 if( local_find.start < aPosition || aPosition == EDA_PATTERN_NOT_FOUND )
407 aPosition = local_find.start;
408 }
409 }
410
411 return aPosition != EDA_PATTERN_NOT_FOUND;
412}
static const int EDA_PATTERN_NOT_FOUND

References EDA_PATTERN_NOT_FOUND, m_matchers, and EDA_PATTERN_MATCH::FIND_RESULT::start.

Referenced by DIALOG_ASSIGN_NETCLASS::onPatternText(), PANEL_SETUP_NETCLASSES::OnUpdateUI(), FOOTPRINT_VIEWER_FRAME::ReCreateFootprintList(), SYMBOL_VIEWER_FRAME::ReCreateLibList(), FOOTPRINT_VIEWER_FRAME::ReCreateLibraryList(), SYMBOL_VIEWER_FRAME::ReCreateSymbolList(), LIB_TREE_NODE_LIB_ID::UpdateScore(), and LIB_TREE_NODE_LIB::UpdateScore().

◆ GetPattern()

wxString const & EDA_COMBINED_MATCHER::GetPattern ( ) const

Definition at line 415 of file eda_pattern_match.cpp.

416{
417 return m_pattern;
418}

References m_pattern.

Referenced by LIB_TREE_NODE_LIB_ID::UpdateScore(), and LIB_TREE_NODE_LIB::UpdateScore().

Member Data Documentation

◆ m_matchers

std::vector<std::unique_ptr<EDA_PATTERN_MATCH> > EDA_COMBINED_MATCHER::m_matchers
private

Definition at line 207 of file eda_pattern_match.h.

Referenced by AddMatcher(), and Find().

◆ m_pattern

wxString EDA_COMBINED_MATCHER::m_pattern
private

Definition at line 208 of file eda_pattern_match.h.

Referenced by GetPattern().


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