libzypp  11.13.5
zypp::StrMatcher Class Reference

String matching (STRING|SUBSTRING|GLOB|REGEX). More...

#include <StrMatcher.h>

Inheritance diagram for zypp::StrMatcher:

List of all members.

Classes

class  Impl
 StrMatcher implementation. More...

Public Types

typedef MatchException Exception

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 (const std::string &search_r, const Match &flags_r)
 Ctor taking string and Match flags.
 StrMatcher (const std::string &search_r, const Match::Mode &flags_r)
 Ctor taking string and Match::Mode.
 StrMatcher (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 Matchflags () 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 Member Functions

friend base::SafeBool () const
bool boolTest () const
- Private Member Functions inherited from zypp::base::SafeBool< StrMatcher >
 operator bool_type () const
 ~SafeBool ()

Private Attributes

RWCOW_pointer< Impl_pimpl
 Pointer to implementation.

Friends

std::ostream & operator<< (std::ostream &str, const StrMatcher &obj)

Related Functions

(Note that these are not member functions.)

std::ostream & operator<< (std::ostream &str, const StrMatcher &obj)
bool operator== (const StrMatcher &lhs, const StrMatcher &rhs)
bool operator!= (const StrMatcher &lhs, const StrMatcher &rhs)
bool operator< (const StrMatcher &lhs, const StrMatcher &rhs)

Detailed Description

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.

StrMatcher matches( "foo", Match::SUBSTRING );
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 302 of file StrMatcher.h.


Member Typedef Documentation

Definition at line 307 of file StrMatcher.h.


Constructor & Destructor Documentation

zypp::StrMatcher::StrMatcher ( )

Default ctor matches nothing.

Definition at line 259 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 263 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 267 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 271 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 275 of file StrMatcher.cc.


Member Function Documentation

template<class _Tp >
bool zypp::StrMatcher::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 344 of file StrMatcher.h.

bool zypp::StrMatcher::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 347 of file StrMatcher.h.

const std::string & zypp::StrMatcher::searchstring ( ) const

The current searchstring.

Definition at line 288 of file StrMatcher.cc.

void zypp::StrMatcher::setSearchstring ( const std::string &  string_r)

Set a new searchstring.

Definition at line 291 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 294 of file StrMatcher.cc.

const Match & zypp::StrMatcher::flags ( ) const

The current search flags.

Definition at line 300 of file StrMatcher.cc.

void zypp::StrMatcher::setFlags ( const Match flags_r)

Set new search flags.

Definition at line 303 of file StrMatcher.cc.

void zypp::StrMatcher::compile ( ) const

Compile the pattern e.g.

in case of REGEX.

Exceptions:
MatchUnknownModeExceptionIf the Match flag more than one mode bit set.
MatchInvalidRegexExceptionIf Match::REGEX is set and searchstring is not a valid regular expression.

Definition at line 279 of file StrMatcher.cc.

bool zypp::StrMatcher::isCompiled ( ) const

Whether the StrMatcher is already compiled.

Definition at line 282 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.

Exceptions:
MatchExceptionAny of the exceptions thrown by StrMatcher::compile.

Definition at line 285 of file StrMatcher.cc.

zypp::StrMatcher::base::SafeBool ( ) const
private
bool zypp::StrMatcher::boolTest ( ) const
inlineprivate

Definition at line 386 of file StrMatcher.h.


Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  str,
const StrMatcher obj 
)
friend

Definition at line 306 of file StrMatcher.cc.

std::ostream & operator<< ( std::ostream &  str,
const StrMatcher obj 
)
related

Stream output

Definition at line 306 of file StrMatcher.cc.

bool operator== ( const StrMatcher lhs,
const StrMatcher rhs 
)
related

Definition at line 309 of file StrMatcher.cc.

bool operator!= ( const StrMatcher lhs,
const StrMatcher rhs 
)
related

Definition at line 401 of file StrMatcher.h.

bool operator< ( const StrMatcher lhs,
const StrMatcher rhs 
)
related

Arbitrary order for std::container.

Definition at line 315 of file StrMatcher.cc.


Member Data Documentation

RWCOW_pointer<Impl> zypp::StrMatcher::_pimpl
private

Pointer to implementation.

Definition at line 391 of file StrMatcher.h.


The documentation for this class was generated from the following files: