|
|
|
@ -2,7 +2,7 @@ |
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application. |
|
|
|
* |
|
|
|
* Copyright (C) 2015-2017 Chris Pavlina <pavlina.chris@gmail.com> |
|
|
|
* Copyright (C) 2015-2019 KiCad Developers, see AUTHORS.txt for contributors. |
|
|
|
* Copyright (C) 2015-2022 KiCad Developers, see AUTHORS.txt for contributors. |
|
|
|
* |
|
|
|
* This program is free software; you can redistribute it and/or |
|
|
|
* modify it under the terms of the GNU General Public License |
|
|
|
@ -85,6 +85,20 @@ bool EDA_PATTERN_MATCH_REGEX::SetPattern( const wxString& aPattern ) |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
bool EDA_PATTERN_MATCH_REGEX_EXPLICIT::SetPattern( const wxString& aPattern ) |
|
|
|
{ |
|
|
|
wxString pattern( aPattern ); |
|
|
|
|
|
|
|
if( !pattern.StartsWith( wxT( "^" ) ) ) |
|
|
|
pattern = wxT( "^" ) + pattern; |
|
|
|
|
|
|
|
if( !pattern.EndsWith( wxT( "$" ) ) ) |
|
|
|
pattern += wxT( "$" ); |
|
|
|
|
|
|
|
return EDA_PATTERN_MATCH_REGEX::SetPattern( pattern ); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
wxString const& EDA_PATTERN_MATCH_REGEX::GetPattern() const |
|
|
|
{ |
|
|
|
return m_pattern; |
|
|
|
@ -349,16 +363,27 @@ const std::map<wxString, double> EDA_PATTERN_MATCH_RELATIONAL::m_units = { |
|
|
|
{ "ti", 1099511627776. } }; |
|
|
|
|
|
|
|
|
|
|
|
EDA_COMBINED_MATCHER::EDA_COMBINED_MATCHER( const wxString& aPattern ) |
|
|
|
EDA_COMBINED_MATCHER::EDA_COMBINED_MATCHER( const wxString& aPattern, |
|
|
|
COMBINED_MATCHER_CONTEXT aContext ) |
|
|
|
: m_pattern( aPattern ) |
|
|
|
{ |
|
|
|
// Whatever syntax users prefer, it shall be matched.
|
|
|
|
AddMatcher( aPattern, std::make_unique<EDA_PATTERN_MATCH_REGEX>() ); |
|
|
|
AddMatcher( aPattern, std::make_unique<EDA_PATTERN_MATCH_WILDCARD>() ); |
|
|
|
AddMatcher( aPattern, std::make_unique<EDA_PATTERN_MATCH_RELATIONAL>() ); |
|
|
|
// If any of the above matchers couldn't be created because the pattern
|
|
|
|
// syntax does not match, the substring will try its best.
|
|
|
|
AddMatcher( aPattern, std::make_unique<EDA_PATTERN_MATCH_SUBSTR>() ); |
|
|
|
switch( aContext ) |
|
|
|
{ |
|
|
|
case CTX_LIBITEM: |
|
|
|
// Whatever syntax users prefer, it shall be matched.
|
|
|
|
AddMatcher( aPattern, std::make_unique<EDA_PATTERN_MATCH_REGEX>() ); |
|
|
|
AddMatcher( aPattern, std::make_unique<EDA_PATTERN_MATCH_WILDCARD>() ); |
|
|
|
AddMatcher( aPattern, std::make_unique<EDA_PATTERN_MATCH_RELATIONAL>() ); |
|
|
|
// If any of the above matchers couldn't be created because the pattern
|
|
|
|
// syntax does not match, the substring will try its best.
|
|
|
|
AddMatcher( aPattern, std::make_unique<EDA_PATTERN_MATCH_SUBSTR>() ); |
|
|
|
break; |
|
|
|
|
|
|
|
case CTX_NETCLASS: |
|
|
|
AddMatcher( aPattern, std::make_unique<EDA_PATTERN_MATCH_REGEX_EXPLICIT>() ); |
|
|
|
AddMatcher( aPattern, std::make_unique<EDA_PATTERN_MATCH_WILDCARD_EXPLICIT>() ); |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|