14 #include <solv/repo.h> 57 case SEARCH_STRING:
return STRING;
break;
59 case SEARCH_STRINGEND:
return STRINGEND;
break;
60 case SEARCH_SUBSTRING:
return SUBSTRING;
break;
61 case SEARCH_GLOB:
return GLOB;
break;
62 case SEARCH_REGEX:
return REGEX;
break;
72 case STRING:
return SEARCH_STRING;
break;
74 case STRINGEND:
return SEARCH_STRINGEND;
break;
75 case SUBSTRING:
return SEARCH_SUBSTRING;
break;
76 case GLOB:
return SEARCH_GLOB;
break;
77 case REGEX:
return SEARCH_REGEX;
break;
78 case OTHER:
return SEARCH_STRINGMASK;
break;
80 return SEARCH_STRINGMASK;
84 { std::ostringstream
str; str << *
this;
return str.str(); }
90 #define OUTS(V) case Match::V: return str << #V; break 101 return str <<
"Match::Mode::UNKNOWN";
107 return str <<
"NOTHING";
109 const char * sep =
"|";
127 #define OUTS(V) if ( val & Match::V.get() ) { val &= ~Match::V.get(); if ( sep ) str << sep; else sep = "|"; str << #V; } 140 if ( sep ) str << sep;
153 :
str::
form(
_(
"Unknown match mode '%s' for pattern '%s'"), mode_r.
asString().c_str(), msg_r.c_str() ) )
157 :
MatchException( regcomp_r ?
str::
form(
_(
"Invalid regular expression '%s': regcomp returned %d"), regex_r.c_str(), regcomp_r )
158 :
str::
form(
_(
"Invalid regular expression '%s'"), regex_r.c_str() ) )
174 : _search(
std::move(search_r) )
190 int res = ::datamatcher_init( _matcher.get(), _search.c_str(), _flags.get() );
201 {
return _matcher !=
nullptr; }
210 return ::datamatcher_match( _matcher.get(), string_r );
219 { invalidate(); _search = std::move(string_r); }
227 { invalidate(); _flags = flags_r; }
234 ::datamatcher_free( _matcher.get() );
241 mutable scoped_ptr< sat::detail::CDatamatcher>
_matcher;
244 friend Impl * rwcowClone<Impl>(
const Impl * rhs );
247 {
return new Impl( _search, _flags ); }
327 {
return str << *obj.
_pimpl; }
void setFlags(const Match &flags_r)
Set new search flags.
void compile() const
Compile the pattern.
const Match & flags() const
The current search flags.
#define ZYPP_THROW(EXCPT)
Drops a logline and throws the Exception.
String matching option flags as used e.g.
void invalidate()
Has to be called if _search or _flags change.
StrMatcher()
Default ctor matches nothing.
static const Match SKIP_KIND
LookupAttr: skip any kind: prefix when looking at a Solvable name.
String matching (STRING|SUBSTRING|GLOB|REGEX).
static const Match CHECKSUMS
LookupAttr: also look for matches in checksums.
std::ostream & operator<<(std::ostream &str, const Match &obj)
String related utilities and Regular expression matching.
Impl(std::string search_r, const Match &flags_r)
int modeval() const
Return the modes integer representation.
Exceptions thrown from attribute matching.
void setFlags(const Match &flags_r)
Set new search flags.
RWCOW_pointer< Impl > _pimpl
Pointer to implementation.
std::string form(const char *format,...) __attribute__((format(printf
Printf style construction of std::string.
Impl * clone() const
clone for RWCOW_pointer
void setSearchstring(const std::string &string_r)
Set a new searchstring.
static const Match NO_STORAGE_SOLVABLE
LookupAttr: internal.
scoped_ptr< sat::detail::CDatamatcher > _matcher
StrMatcher implementation.
friend std::ostream & operator<<(std::ostream &str, const StrMatcher &obj)
bool doMatch(const char *string_r) const
Return whether string matches.
std::string asString() const
String representation.
Mode
Mode flags (mutual exclusive).
const Match & flags() const
The current search flags.
bool isCompiled() const
Whether the StrMatcher is already compiled.
const std::string & searchstring() const
The current searchstring.
int flagval() const
Return the flags integer representation.
MatchUnknownModeException(const std::string &msg_r)
Supplied message.
void setSearchstring(std::string string_r)
Set a new searchstring.
bool doMatch(const char *string_r) const
Return whether string matches.
static const Match DISABLED_REPOS
LookupAttr: internal.
static const Match NOCASE
If set, match case insensitive.
const std::string & searchstring() const
The current searchstring.
bool isCompiled() const
Whether the pattern is already compiled.
int get() const
Return the integer representation.
bool operator==(const StrMatcher &lhs, const StrMatcher &rhs)
static const Match ARRAYSENTINEL
LookupAttr: internal.
Mode mode() const
Return the mode part.
static const int _flagmask
static const Match COMPLETE_FILELIST
LookupAttr: internal.
static const Match SUB
LookupAttr: internal.
MatchInvalidRegexException(const std::string &msg_r)
Supplied message.
::_Datamatcher CDatamatcher
Wrapped libsolv C data type exposed as backdoor.
Easy-to use interface to the ZYPP dependency resolver.
bool operator<(const StrMatcher &lhs, const StrMatcher &rhs)
std::ostream & operator<<(std::ostream &str, const StrMatcher::Impl &obj)
static const Match FILES
LookupAttr: match full path when matching in filelists, otherwise just the basenames.
std::string hexstring(char n, int w=4)
void compile() const
Compile the pattern e.g.
static const int _modemask