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

Constructor & Destructor Documentation

EDA_COMBINED_MATCHER::EDA_COMBINED_MATCHER ( const wxString &  aPattern)

Definition at line 303 of file eda_pattern_match.cpp.

References AddMatcher().

304  : m_pattern( aPattern )
305 {
306  // Whatever syntax users prefer, it shall be matched.
307  AddMatcher( aPattern, std::make_unique<EDA_PATTERN_MATCH_REGEX>() );
308  AddMatcher( aPattern, std::make_unique<EDA_PATTERN_MATCH_WILDCARD>() );
309  AddMatcher( aPattern, std::make_unique<EDA_PATTERN_MATCH_RELATIONAL>() );
310  // If any of the above matchers couldn't be created because the pattern
311  // syntax does not match, the substring will try its best.
312  AddMatcher( aPattern, std::make_unique<EDA_PATTERN_MATCH_SUBSTR>() );
313 }
void AddMatcher(const wxString &aPattern, std::unique_ptr< EDA_PATTERN_MATCH > aMatcher)

Member Function Documentation

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

Definition at line 346 of file eda_pattern_match.cpp.

References m_matchers.

Referenced by EDA_COMBINED_MATCHER().

349 {
350  if ( aMatcher->SetPattern( aPattern ) )
351  {
352  m_matchers.push_back( std::move( aMatcher ) );
353  }
354 }
std::vector< std::unique_ptr< EDA_PATTERN_MATCH > > m_matchers
bool EDA_COMBINED_MATCHER::Find ( const wxString &  aTerm,
int &  aMatchersTriggered,
int &  aPosition 
)

Definition at line 316 of file eda_pattern_match.cpp.

References EDA_PATTERN_NOT_FOUND, and m_matchers.

Referenced by CMP_TREE_NODE_ALIAS::UpdateScore().

317 {
318  aPosition = EDA_PATTERN_NOT_FOUND;
319  aMatchersTriggered = 0;
320 
321  for( auto const& matcher : m_matchers )
322  {
323  int local_find = matcher->Find( aTerm );
324 
325  if ( local_find != EDA_PATTERN_NOT_FOUND )
326  {
327  aMatchersTriggered += 1;
328 
329  if ( local_find < aPosition || aPosition == EDA_PATTERN_NOT_FOUND )
330  {
331  aPosition = local_find;
332  }
333  }
334  }
335 
336  return aPosition != EDA_PATTERN_NOT_FOUND;
337 }
std::vector< std::unique_ptr< EDA_PATTERN_MATCH > > m_matchers
static const int EDA_PATTERN_NOT_FOUND
wxString const & EDA_COMBINED_MATCHER::GetPattern ( ) const

Definition at line 340 of file eda_pattern_match.cpp.

References m_pattern.

Referenced by CMP_TREE_NODE_ALIAS::UpdateScore().

341 {
342  return m_pattern;
343 }

Member Data Documentation

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

Definition at line 170 of file eda_pattern_match.h.

Referenced by AddMatcher(), and Find().

wxString EDA_COMBINED_MATCHER::m_pattern
private

Definition at line 171 of file eda_pattern_match.h.

Referenced by GetPattern().


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