14 #include <solv/repo.h>
56 case SEARCH_STRING:
return STRING;
break;
58 case SEARCH_STRINGEND:
return STRINGEND;
break;
59 case SEARCH_SUBSTRING:
return SUBSTRING;
break;
60 case SEARCH_GLOB:
return GLOB;
break;
61 case SEARCH_REGEX:
return REGEX;
break;
71 case STRING:
return SEARCH_STRING;
break;
73 case STRINGEND:
return SEARCH_STRINGEND;
break;
74 case SUBSTRING:
return SEARCH_SUBSTRING;
break;
75 case GLOB:
return SEARCH_GLOB;
break;
76 case REGEX:
return SEARCH_REGEX;
break;
77 case OTHER:
return SEARCH_STRINGMASK;
break;
79 return SEARCH_STRINGMASK;
83 { std::ostringstream str; str << *
this;
return str.str(); }
89 #define OUTS(V) case Match::V: return str << #V; break
100 return str <<
"Match::Mode::UNKNOWN";
106 return str <<
"NOTHING";
108 const char * sep =
"|";
116 str << mode<<
"("<<obj.
modeval()<<
")";
126 #define OUTS(V) if ( val & Match::V.get() ) { val &= ~Match::V.get(); if ( sep ) str << sep; else sep = "|"; str << #V; }
128 OUTS( NO_STORAGE_SOLVABLE );
130 OUTS( ARRAYSENTINEL );
131 OUTS( DISABLED_REPOS );
132 OUTS( COMPLETE_FILELIST );
139 if ( sep ) str << sep;
152 : str::
form(
_(
"Unknown match mode '%s' for pattern '%s'"), mode_r.
asString().c_str(), msg_r.c_str() ) )
156 :
MatchException( regcomp_r ? str::
form(
_(
"Invalid regular expression '%s': regcomp returned %d"), regex_r.c_str(), regcomp_r )
157 : str::
form(
_(
"Invalid regular expression '%s'"), regex_r.c_str() ) )
172 Impl(
const std::string & search_r,
const Match & flags_r )
188 _matcher.reset( new ::_Datamatcher );
209 return ::datamatcher_match(
_matcher.get(), string_r );
233 ::datamatcher_free(
_matcher.get() );
243 friend Impl * rwcowClone<Impl>(
const Impl * rhs );
264 : _pimpl( new
Impl( search_r,
Match::STRING ) )
268 : _pimpl( new
Impl( search_r, flags_r ) )
272 : _pimpl( new
Impl( search_r, flags_r ) )
276 : _pimpl( new
Impl( search_r,
Match(flags_r) ) )
280 {
return _pimpl->compile(); }
283 {
return _pimpl->isCompiled(); }
286 {
return _pimpl->doMatch( string_r ); }
289 {
return _pimpl->searchstring(); }
292 {
_pimpl->setSearchstring( string_r ); }
296 _pimpl->setSearchstring( string_r );
297 _pimpl->setFlags( flags_r );
301 {
return _pimpl->flags(); }
304 {
_pimpl->setFlags( flags_r ); }
307 {
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.
Impl(const std::string &search_r, const Match &flags_r)
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.
scoped_ptr< ::_Datamatcher > _matcher
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.
Impl * clone() const
clone for RWCOW_pointer
void setSearchstring(const std::string &string_r)
Set a new searchstring.
std::ostream & operator<<(std::ostream &str, const Exception &obj)
static const Match NO_STORAGE_SOLVABLE
LookupAttr: internal.
StrMatcher implementation.
bool doMatch(const char *string_r) const
Return whether string matches.
std::string asString() const
String representation.
#define _(MSG)
Return translated text.
Mode
Mode flags (mutual exclusive).
void setSearchstring(const std::string &string_r)
Set a new searchstring.
Invalid regular expression (failed ::regcomp).
const Match & flags() const
The current search flags.
bool isCompiled() const
Whether the StrMatcher is already compiled.
std::string asString(const Patch::SeverityFlag &obj)
bool operator==(const StrMatcher &lhs, const StrMatcher &rhs)
const std::string & searchstring() const
The current searchstring.
int flagval() const
Return the flags integer representation.
std::string form(const char *format,...)
Printf style construction of std::string.
MatchUnknownModeException(const std::string &msg_r)
Supplied message.
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.
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.
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