libzypp 17.37.17
|
String matching (STRING|SUBSTRING|GLOB|REGEX). More...
#include <zypp/base/StrMatcher.h>
Classes | |
class | Impl |
StrMatcher implementation. More... |
Public Types | |
using | Exception = MatchException |
Public Member Functions | |
StrMatcher () | |
Default ctor matches nothing. | |
StrMatcher (const std::string &search_r) | |
Ctor from string matches in Match::STRING mode per default. | |
StrMatcher (std::string &&search_r) | |
StrMatcher (const std::string &search_r, const Match &flags_r) | |
Ctor taking string and Match flags. | |
StrMatcher (std::string &&search_r, const Match &flags_r) | |
StrMatcher (const std::string &search_r, const Match::Mode &flags_r) | |
Ctor taking string and Match::Mode. | |
StrMatcher (std::string &&search_r, const Match::Mode &flags_r) | |
StrMatcher (const std::string &search_r, int flags_r) | |
Low level interface wraps flags into Match. | |
StrMatcher (std::string &&search_r, int flags_r) | |
operator bool () const | |
Evaluate in a boolean context ( !
| |
template<class Tp> | |
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 only in what argument(s) it accepts. | |
const std::string & | searchstring () const |
The current searchstring. | |
void | setSearchstring (const std::string &string_r) |
Set a new searchstring. | |
void | setSearchstring (std::string &&string_r) |
void | setSearchstring (const std::string &string_r, const Match &flags_r) |
Set a new searchstring and flags. | |
void | setSearchstring (std::string &&string_r, const Match &flags_r) |
const Match & | flags () const |
The current search flags. | |
void | setFlags (const Match &flags_r) |
Set new search flags. | |
void | compile () const |
Compile the pattern e.g. | |
bool | isCompiled () const |
Whether the StrMatcher is already compiled. | |
bool | doMatch (const char *string_r) const |
Return whether string matches. |
Private Attributes | |
RWCOW_pointer< Impl > | _pimpl |
Pointer to implementation. |
Friends | |
std::ostream & | operator<< (std::ostream &str, const StrMatcher &obj) |
Related Symbols | |
(Note that these are not member symbols.) | |
std::ostream & | operator<< (std::ostream &str, const StrMatcher::Impl &obj) |
Stream output. | |
std::ostream & | operator<< (std::ostream &str, const StrMatcher &obj) |
Stream output. | |
bool | operator== (const StrMatcher &lhs, const StrMatcher &rhs) |
bool | operator!= (const StrMatcher &lhs, const StrMatcher &rhs) |
bool | operator< (const StrMatcher &lhs, const StrMatcher &rhs) |
Arbitrary order for std::container. |
String matching (STRING|SUBSTRING|GLOB|REGEX).
Used by e.g. PoolQuery and LookupAttr for queries, but it can also be used for matching arbitrary strings.
\Note Those flags are always set: REG_EXTENDED | REG_NOSUB | REG_NEWLINE
Definition at line 297 of file StrMatcher.h.
Definition at line 302 of file StrMatcher.h.
zypp::StrMatcher::StrMatcher | ( | ) |
Default ctor matches nothing.
Definition at line 265 of file StrMatcher.cc.
zypp::StrMatcher::StrMatcher | ( | const std::string & | search_r | ) |
Ctor from string matches in Match::STRING mode per default.
Definition at line 269 of file StrMatcher.cc.
zypp::StrMatcher::StrMatcher | ( | std::string && | search_r | ) |
Definition at line 272 of file StrMatcher.cc.
zypp::StrMatcher::StrMatcher | ( | const std::string & | search_r, |
const Match & | flags_r ) |
Ctor taking string and Match flags.
Definition at line 276 of file StrMatcher.cc.
zypp::StrMatcher::StrMatcher | ( | std::string && | search_r, |
const Match & | flags_r ) |
Definition at line 279 of file StrMatcher.cc.
zypp::StrMatcher::StrMatcher | ( | const std::string & | search_r, |
const Match::Mode & | flags_r ) |
Ctor taking string and Match::Mode.
Needed because we want them to be treated as Match, and not as int as the compiler woud do.
Definition at line 283 of file StrMatcher.cc.
zypp::StrMatcher::StrMatcher | ( | std::string && | search_r, |
const Match::Mode & | flags_r ) |
Definition at line 286 of file StrMatcher.cc.
zypp::StrMatcher::StrMatcher | ( | const std::string & | search_r, |
int | flags_r ) |
Low level interface wraps flags into Match.
Definition at line 290 of file StrMatcher.cc.
zypp::StrMatcher::StrMatcher | ( | std::string && | search_r, |
int | flags_r ) |
Definition at line 293 of file StrMatcher.cc.
|
inlineexplicit |
Evaluate in a boolean context ( !
searchstring().empty() ).
Definition at line 336 of file StrMatcher.h.
|
inline |
Return whether string matches.
You can use it with any class that impements c_str
. (std::string
, Pathname, IdString, ...). \Note NULL
never matches.
Definition at line 346 of file StrMatcher.h.
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 349 of file StrMatcher.h.
const std::string & zypp::StrMatcher::searchstring | ( | ) | const |
The current searchstring.
Definition at line 306 of file StrMatcher.cc.
void zypp::StrMatcher::setSearchstring | ( | const std::string & | string_r | ) |
Set a new searchstring.
Definition at line 309 of file StrMatcher.cc.
void zypp::StrMatcher::setSearchstring | ( | std::string && | string_r | ) |
Definition at line 311 of file StrMatcher.cc.
void zypp::StrMatcher::setSearchstring | ( | const std::string & | string_r, |
const Match & | flags_r ) |
Set a new searchstring and flags.
Definition at line 314 of file StrMatcher.cc.
void zypp::StrMatcher::setSearchstring | ( | std::string && | string_r, |
const Match & | flags_r ) |
Definition at line 319 of file StrMatcher.cc.
const Match & zypp::StrMatcher::flags | ( | ) | const |
The current search flags.
Definition at line 325 of file StrMatcher.cc.
void zypp::StrMatcher::setFlags | ( | const Match & | flags_r | ) |
Set new search flags.
Definition at line 328 of file StrMatcher.cc.
void zypp::StrMatcher::compile | ( | ) | const |
Compile the pattern e.g.
in case of REGEX
.
MatchUnknownModeException | If the Match flag more than one mode bit set. |
MatchInvalidRegexException | If Match::REGEX is set and searchstring is not a valid regular expression. |
Definition at line 297 of file StrMatcher.cc.
bool zypp::StrMatcher::isCompiled | ( | ) | const |
Whether the StrMatcher is already compiled.
Definition at line 300 of file StrMatcher.cc.
bool zypp::StrMatcher::doMatch | ( | const char * | string_r | ) | const |
Return whether string matches.
Compiles the StrMatcher if this was not yet done.
MatchException | Any of the exceptions thrown by StrMatcher::compile. |
Definition at line 303 of file StrMatcher.cc.
|
friend |
Definition at line 331 of file StrMatcher.cc.
|
Stream output.
Definition at line 331 of file StrMatcher.cc.
|
Definition at line 334 of file StrMatcher.cc.
|
Definition at line 402 of file StrMatcher.h.
|
Arbitrary order for std::container.
Definition at line 340 of file StrMatcher.cc.
|
private |
Pointer to implementation.
Definition at line 392 of file StrMatcher.h.