KiCad PCB EDA Suite
EDA_PATTERN_MATCH_REGEX_EXPLICIT Class Reference

#include <eda_pattern_match.h>

Inheritance diagram for EDA_PATTERN_MATCH_REGEX_EXPLICIT:
EDA_PATTERN_MATCH_REGEX EDA_PATTERN_MATCH

Public Member Functions

virtual bool SetPattern (const wxString &aPattern) override
 Set the pattern against which candidates will be matched. More...
 
virtual wxString const & GetPattern () const override
 Return the pattern passed to SetPattern(). More...
 
virtual FIND_RESULT Find (const wxString &aCandidate) const override
 Return the location and possibly length of a match iff a given candidate string matches the set pattern. More...
 

Protected Attributes

wxString m_pattern
 
wxRegEx m_regex
 

Detailed Description

Definition at line 115 of file eda_pattern_match.h.

Member Function Documentation

◆ Find()

EDA_PATTERN_MATCH::FIND_RESULT EDA_PATTERN_MATCH_REGEX::Find ( const wxString &  aCandidate) const
overridevirtualinherited

Return the location and possibly length of a match iff a given candidate string matches the set pattern.

Otherwise, return an invalid FIND_RESULT.

Implements EDA_PATTERN_MATCH.

Reimplemented in EDA_PATTERN_MATCH_WILDCARD.

Definition at line 108 of file eda_pattern_match.cpp.

109{
110 if( m_regex.IsValid() )
111 {
112 if( m_regex.Matches( aCandidate ) )
113 {
114 size_t start, len;
115 m_regex.GetMatch( &start, &len, 0 );
116
117 return { static_cast<int>( std::min( start, static_cast<size_t>( INT_MAX ) ) ),
118 static_cast<int>( std::min( len, static_cast<size_t>( INT_MAX ) ) ) };
119 }
120 else
121 {
122 return {};
123 }
124 }
125 else
126 {
127 int loc = aCandidate.Find( m_pattern );
128
129 if( loc == wxNOT_FOUND )
130 return {};
131 else
132 return { loc, static_cast<int>( m_pattern.size() ) };
133 }
134}

References EDA_PATTERN_MATCH_REGEX::m_pattern, and EDA_PATTERN_MATCH_REGEX::m_regex.

Referenced by EDA_PATTERN_MATCH_WILDCARD::Find().

◆ GetPattern()

wxString const & EDA_PATTERN_MATCH_REGEX::GetPattern ( ) const
overridevirtualinherited

Return the pattern passed to SetPattern().

Implements EDA_PATTERN_MATCH.

Reimplemented in EDA_PATTERN_MATCH_WILDCARD.

Definition at line 102 of file eda_pattern_match.cpp.

103{
104 return m_pattern;
105}

References EDA_PATTERN_MATCH_REGEX::m_pattern.

◆ SetPattern()

bool EDA_PATTERN_MATCH_REGEX_EXPLICIT::SetPattern ( const wxString &  aPattern)
overridevirtual

Set the pattern against which candidates will be matched.

If the pattern can not be processed, returns false.

Reimplemented from EDA_PATTERN_MATCH_REGEX.

Definition at line 88 of file eda_pattern_match.cpp.

89{
90 wxString pattern( aPattern );
91
92 if( !pattern.StartsWith( wxT( "^" ) ) )
93 pattern = wxT( "^" ) + pattern;
94
95 if( !pattern.EndsWith( wxT( "$" ) ) )
96 pattern += wxT( "$" );
97
99}
virtual bool SetPattern(const wxString &aPattern) override
Set the pattern against which candidates will be matched.

References EDA_PATTERN_MATCH_REGEX::SetPattern().

Member Data Documentation

◆ m_pattern

wxString EDA_PATTERN_MATCH_REGEX::m_pattern
protectedinherited

◆ m_regex

wxRegEx EDA_PATTERN_MATCH_REGEX::m_regex
protectedinherited

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