12#ifndef ZYPP_BASE_STRMATCHER_H
13#define ZYPP_BASE_STRMATCHER_H
18#include <zypp/base/PtrTypes.h>
19#include <zypp/base/Exception.h>
96 explicit operator bool()
const
123 _val &= ~rhs.flagval();
128 { onoff ?
set( rhs ) :
unset( rhs ); }
132 {
set( rhs );
return *
this; }
136 {
unset( rhs );
return *
this; }
218 {
return lhs.
get() == rhs.
get(); }
221 {
return lhs.
get() != rhs.
get(); }
225 {
return Match(lhs) |= rhs; }
228 {
return Match(lhs) |= rhs; }
232 {
return Match(lhs) -= rhs; }
235 {
return Match(lhs) -= rhs; }
241 std::ostream &
operator<<( std::ostream &
str,
const Match & obj );
331 StrMatcher(
const std::string & search_r,
int flags_r );
333 StrMatcher( std::string && search_r,
int flags_r );
347 {
return doMatch( string_r.c_str() ); }
350 {
return doMatch( string_r ); }
388 bool doMatch(
const char * string_r )
const;
403 {
return !( lhs == rhs ); }
Base class for Exception.
String matching option flags as used e.g.
static const Match DISABLED_REPOS
LookupAttr: internal.
int flagval() const
Return the flags integer representation.
void setModeGlob()
Set the mode GLOB.
Match()
Default ctor 0 or NOTHING.
int get() const
Return the integer representation.
std::string asString() const
String representation.
void setModeStringend()
Set the mode STRINGEND.
void setModeStringstart()
Set the mode STRINGSTART.
static const Match ARRAYSENTINEL
LookupAttr: internal.
bool isModeSubstring() const
Whether this has mode SUBSTRING.
Match operator-(const Match &lhs, const Match &rhs)
bool isModeStringstart() const
Whether this has mode STRINGSTART.
void setMode(Mode rhs)
Set the mode part to rhs .
static const Match SUB
LookupAttr: internal.
Mode
Mode flags (mutual exclusive).
@ STRINGEND
Match at string end.
@ REGEX
Regular Expression.
@ STRINGSTART
Match at string start.
@ SUBSTRING
Match substring.
static const Match COMPLETE_FILELIST
LookupAttr: internal.
static const Match CHECKSUMS
LookupAttr: also look for matches in checksums.
Match operator|(const Match &lhs, const Match &rhs)
bool isModeString() const
Whether this has mode STRING.
static const int _flagmask
Match(Mode val_r)
Ctor from Mode value.
static const Match NO_STORAGE_SOLVABLE
LookupAttr: internal.
void unset(const Match &rhs)
Unset all of the rhs bits (unsets mode if the same as rhs).
static const Match FILES
LookupAttr: match full path when matching in filelists, otherwise just the basenames.
void setModeRegex()
Set the mode REGEX.
static const Match SKIP_KIND
LookupAttr: skip any kind: prefix when looking at a Solvable name.
static const Match NOCASE
If set, match case insensitive.
bool isModeGlob() const
Whether this has mode GLOB.
Match(int val_r)
Just in case one needs it.
bool isModeStringend() const
Whether this has mode STRINGEND.
void setModeString()
Set the mode STRING.
void turn(const Match &rhs, bool onoff)
Depending on the value of onoff, set or unset flags.
Match flags() const
Return the flags part.
int modeval() const
Return the modes integer representation.
bool isModeRegex() const
Whether this has mode REGEX.
static const int _modemask
Mode mode() const
Return the mode part.
bool operator!=(const Match &lhs, const Match &rhs)
void set(const Match &rhs)
Set all of the rhs bits (setting a new mode if rhs has one).
Match & operator|=(const Match &rhs)
Add flags.
Match & operator-=(const Match &rhs)
Remove flags.
bool isMode(Mode rhs) const
Whether this has mode rhs.
bool testAnyOf(const Match &rhs) const
Whether at least one of the rhs bits is set (or the same mode).
bool test(const Match &rhs) const
Test whether all of the rhs bits are set (same mode if rhs has one).
bool operator==(const Match &lhs, const Match &rhs)
void setModeSubstring()
Set the mode SUBSTRING.
String matching (STRING|SUBSTRING|GLOB|REGEX).
bool doMatch(const char *string_r) const
Return whether string matches.
friend std::ostream & operator<<(std::ostream &str, const StrMatcher &obj)
const std::string & searchstring() const
The current searchstring.
const Match & flags() const
The current search flags.
RWCOW_pointer< Impl > _pimpl
Pointer to implementation.
bool operator!=(const StrMatcher &lhs, const StrMatcher &rhs)
StrMatcher()
Default ctor matches nothing.
void setSearchstring(const std::string &string_r)
Set a new searchstring.
void setFlags(const Match &flags_r)
Set new search flags.
bool isCompiled() const
Whether the StrMatcher is already compiled.
bool operator()(const Tp &string_r) const
Return whether string matches.
bool operator()(const char *string_r) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
void compile() const
Compile the pattern e.g.
String related utilities and Regular expression matching.
Easy-to use interface to the ZYPP dependency resolver.
bool operator<(const StrMatcher &lhs, const StrMatcher &rhs)
bool operator==(const SetRelation::Enum &lhs, const SetCompare &rhs)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Match operator|(Match::Mode lhs, Match::Mode rhs)
std::ostream & operator<<(std::ostream &str, const SerialNumber &obj)
Match operator-(Match::Mode lhs, Match::Mode rhs)
Exceptions thrown from attribute matching.
MatchException(const std::string &msg_r)
Supplied message.
Invalid regular expression (failed ::regcomp).
MatchInvalidRegexException(const std::string &msg_r)
Supplied message.
MatchUnknownModeException(const std::string &msg_r)
Supplied message.
RW_pointer supporting 'copy on write' functionality.
StrMatcher implementation.