#include <AttrMatcher.h>
Classes | |
struct | Impl |
AttrMatcher implementation. More... | |
Public Types | |
typedef MatchException | Exception |
Public Member Functions | |
AttrMatcher () | |
Default ctor matches nothing. | |
AttrMatcher (const std::string &search_r) | |
Ctor from string matches in Match::STRING mode per default. | |
AttrMatcher (const std::string &search_r, const Match &flags_r) | |
Ctor taking string and Match flags. | |
AttrMatcher (const std::string &search_r, const Match::Mode &flags_r) | |
Ctor taking string and Match::Mode. | |
AttrMatcher (const std::string &search_r, int flags_r) | |
Low level interface wraps flags into Match. | |
template<class _Tp > | |
bool | operator() (const _Tp &string_r) const |
Return whether string matches. | |
bool | operator() (const char *string_r) const |
const std::string & | searchstring () const |
The current searchstring. | |
void | setSearchstring (const std::string &string_r) |
Set a new searchstring. | |
void | setSearchstring (const std::string &string_r, const Match &flags_r) |
Set a new searchstring and flags. | |
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 AttrMatcher is already compiled. | |
bool | doMatch (const char *string_r) const |
Return whether string matches. | |
Private Member Functions | |
friend | base::SafeBool () const |
bool | boolTest () const |
Private Attributes | |
RWCOW_pointer< Impl > | _pimpl |
Pointer to implementation. | |
Friends | |
std::ostream & | operator<< (std::ostream &str, const AttrMatcher &obj) |
Related Functions | |
(Note that these are not member functions.) | |
bool | operator== (const AttrMatcher &lhs, const AttrMatcher &rhs) |
bool | operator!= (const AttrMatcher &lhs, const AttrMatcher &rhs) |
bool | operator< (const AttrMatcher &lhs, const AttrMatcher &rhs) |
Used by e.g. PoolQuery and LookupAttr for queries, but it can also be used for matching arbitrary strings.
AttrMatcher matches( "foo" ); for_( it, stringlist.begin(), stringlist().end() ) { if ( matches( *it ) ) cout << *it << " has substring 'foo'" << endl; }
Those flags are always set: REG_EXTENDED | REG_NOSUB | REG_NEWLINE
Definition at line 312 of file AttrMatcher.h.
Definition at line 317 of file AttrMatcher.h.
zypp::sat::AttrMatcher::AttrMatcher | ( | ) |
zypp::sat::AttrMatcher::AttrMatcher | ( | const std::string & | search_r | ) |
Ctor from string matches in Match::STRING mode per default.
Definition at line 270 of file AttrMatcher.cc.
zypp::sat::AttrMatcher::AttrMatcher | ( | const std::string & | search_r, | |
const Match & | flags_r | |||
) |
zypp::sat::AttrMatcher::AttrMatcher | ( | 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 278 of file AttrMatcher.cc.
zypp::sat::AttrMatcher::AttrMatcher | ( | const std::string & | search_r, | |
int | flags_r | |||
) |
bool zypp::sat::AttrMatcher::operator() | ( | const _Tp & | string_r | ) | const [inline] |
Return whether string matches.
You can use it with any class that impements c_str
. (std::string
, Pathname, IdString, ...). NULL
never matches.
Definition at line 354 of file AttrMatcher.h.
References doMatch().
bool zypp::sat::AttrMatcher::operator() | ( | const char * | string_r | ) | const [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 357 of file AttrMatcher.h.
References doMatch().
const std::string & zypp::sat::AttrMatcher::searchstring | ( | ) | const |
The current searchstring.
Definition at line 295 of file AttrMatcher.cc.
References _pimpl.
Referenced by zypp::sat::LookupAttr::Impl::begin(), boolTest(), zypp::sat::operator<(), and zypp::sat::operator==().
void zypp::sat::AttrMatcher::setSearchstring | ( | const std::string & | string_r | ) |
void zypp::sat::AttrMatcher::setSearchstring | ( | const std::string & | string_r, | |
const Match & | flags_r | |||
) |
const Match & zypp::sat::AttrMatcher::flags | ( | ) | const |
The current search flags.
Definition at line 307 of file AttrMatcher.cc.
References _pimpl.
Referenced by zypp::sat::LookupAttr::Impl::begin(), zypp::sat::operator<(), and zypp::sat::operator==().
void zypp::sat::AttrMatcher::setFlags | ( | const Match & | flags_r | ) |
void zypp::sat::AttrMatcher::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 286 of file AttrMatcher.cc.
References _pimpl.
Referenced by zypp::sat::LookupAttr::Impl::setAttrMatcher().
bool zypp::sat::AttrMatcher::isCompiled | ( | ) | const |
Whether the AttrMatcher is already compiled.
Definition at line 289 of file AttrMatcher.cc.
References _pimpl.
bool zypp::sat::AttrMatcher::doMatch | ( | const char * | string_r | ) | const |
Return whether string matches.
Compiles the AttrMatcher if this was not yet done.
MatchException | Any of the exceptions thrown by AttrMatcher::compile. |
Definition at line 292 of file AttrMatcher.cc.
References _pimpl.
Referenced by operator()().
zypp::sat::AttrMatcher::base::SafeBool | ( | ) | const [private] |
bool zypp::sat::AttrMatcher::boolTest | ( | ) | const [inline, private] |
std::ostream & operator<< | ( | std::ostream & | str, | |
const AttrMatcher & | obj | |||
) | [friend] |
Stream output
Definition at line 318 of file AttrMatcher.cc.
bool operator== | ( | const AttrMatcher & | lhs, | |
const AttrMatcher & | rhs | |||
) | [related] |
Definition at line 323 of file AttrMatcher.cc.
bool operator!= | ( | const AttrMatcher & | lhs, | |
const AttrMatcher & | rhs | |||
) | [related] |
Definition at line 412 of file AttrMatcher.h.
bool operator< | ( | const AttrMatcher & | lhs, | |
const AttrMatcher & | rhs | |||
) | [related] |
Arbitrary order for std::container.
Definition at line 329 of file AttrMatcher.cc.
RWCOW_pointer<Impl> zypp::sat::AttrMatcher::_pimpl [private] |
Pointer to implementation.
Definition at line 401 of file AttrMatcher.h.
Referenced by compile(), doMatch(), flags(), isCompiled(), zypp::sat::operator<<(), searchstring(), setFlags(), and setSearchstring().