KiCad PCB EDA Suite
EDA_COMBINED_MATCHER Class Reference

#include <eda_pattern_match.h>

Public Member Functions

 EDA_COMBINED_MATCHER (const wxString &aPattern)
 
bool Find (const wxString &aTerm, int &aMatchersTriggered, int &aPosition)
 
wxString const & 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 154 of file eda_pattern_match.h.

Constructor & Destructor Documentation

◆ EDA_COMBINED_MATCHER()

EDA_COMBINED_MATCHER::EDA_COMBINED_MATCHER ( const wxString &  aPattern)

Definition at line 340 of file eda_pattern_match.cpp.

341  : m_pattern( aPattern )
342 {
343  // Whatever syntax users prefer, it shall be matched.
344  AddMatcher( aPattern, std::make_unique<EDA_PATTERN_MATCH_REGEX>() );
345  AddMatcher( aPattern, std::make_unique<EDA_PATTERN_MATCH_WILDCARD>() );
346  AddMatcher( aPattern, std::make_unique<EDA_PATTERN_MATCH_RELATIONAL>() );
347  // If any of the above matchers couldn't be created because the pattern
348  // syntax does not match, the substring will try its best.
349  AddMatcher( aPattern, std::make_unique<EDA_PATTERN_MATCH_SUBSTR>() );
350 }
void AddMatcher(const wxString &aPattern, std::unique_ptr< EDA_PATTERN_MATCH > aMatcher)

References AddMatcher().

Member Function Documentation

◆ AddMatcher()

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

Definition at line 383 of file eda_pattern_match.cpp.

386 {
387  if ( aMatcher->SetPattern( aPattern ) )
388  {
389  m_matchers.push_back( std::move( aMatcher ) );
390  }
391 }
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 353 of file eda_pattern_match.cpp.

354 {
355  aPosition = EDA_PATTERN_NOT_FOUND;
356  aMatchersTriggered = 0;
357 
358  for( auto const& matcher : m_matchers )
359  {
360  int local_find = matcher->Find( aTerm );
361 
362  if ( local_find != EDA_PATTERN_NOT_FOUND )
363  {
364  aMatchersTriggered += 1;
365 
366  if ( local_find < aPosition || aPosition == EDA_PATTERN_NOT_FOUND )
367  {
368  aPosition = local_find;
369  }
370  }
371  }
372 
373  return aPosition != EDA_PATTERN_NOT_FOUND;
374 }
std::vector< std::unique_ptr< EDA_PATTERN_MATCH > > m_matchers
static const int EDA_PATTERN_NOT_FOUND

References EDA_PATTERN_NOT_FOUND, and m_matchers.

Referenced by FOOTPRINT_VIEWER_FRAME::ReCreateFootprintList(), FOOTPRINT_VIEWER_FRAME::ReCreateLibraryList(), LIB_TREE_NODE_LIB_ID::UpdateScore(), and LIB_TREE_NODE_LIB::UpdateScore().

◆ GetPattern()

wxString const & EDA_COMBINED_MATCHER::GetPattern ( ) const

Definition at line 377 of file eda_pattern_match.cpp.

378 {
379  return m_pattern;
380 }

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 177 of file eda_pattern_match.h.

Referenced by AddMatcher(), and Find().

◆ m_pattern

wxString EDA_COMBINED_MATCHER::m_pattern
private

Definition at line 178 of file eda_pattern_match.h.

Referenced by GetPattern().


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