libzypp  13.10.6
zypp::filesystem::Glob Class Reference

Find pathnames matching a pattern. More...

#include <Glob.h>

Inheritance diagram for zypp::filesystem::Glob:

Classes

class  const_iterator
 Iterate NULL terminated char* array. More...
 

Public Types

enum  Bits {
  _ERR = GLOB_ERR, _MARK = GLOB_MARK, _NOSORT = GLOB_NOSORT, _NOCHECK = GLOB_NOCHECK,
  _NOESCAPE = GLOB_NOESCAPE, _PERIOD = GLOB_PERIOD, _ALTDIRFUNC = GLOB_ALTDIRFUNC, _BRACE = GLOB_BRACE,
  _NOMAGIC = GLOB_NOMAGIC, _TILDE = GLOB_TILDE, _ONLYDIR = GLOB_ONLYDIR, _TILDE_CHECK = GLOB_TILDE_CHECK
}
 Individual bits to combine in Flags. More...
 
typedef size_t size_type
 
typedef const char * value_type
 

Public Member Functions

 ZYPP_DECLARE_FLAGS (Flags, Bits)
 type Flags: Type-safe OR-combination of Bits. More...
 
void clear ()
 Clear all results found so far. More...
 
void reset (Flags flags_r=Flags())
 Clear all results and reset defaultFlags. More...
 
Flags defaultFlags () const
 The default flags passed to ::glob(). More...
 
void setDefaultFlags (Flags flags_r=Flags())
 Set the default flags passed to ::glob(). More...
 
int lastGlobReturn () const
 Returns the value returned by the last call to ::glob(). More...
 
bool empty () const
 Whether matches were found. More...
 
size_type size () const
 The number of matches found so far. More...
 
const_iterator begin () const
 Iterator pointing to the first result. More...
 
const_iterator end () const
 Iterator pointing behind the last result. More...
 

Static Public Member Functions

Collecting Glob results to some _OutputIterator
* std::list<Pathname> p;
* Glob::collect( "/bin/a*.dat}", std::back_inserter(p) );
* Glob::collect( "/bin/a*{.xml,.xml.gz}", Glob::_BRACE, std::back_inserter(p) );
*
template<class _OutputIterator >
static int collect (const Pathname &pattern_r, _OutputIterator result_r)
 Write glob result to some OutputIterator. More...
 
template<class _OutputIterator >
static int collect (const std::string &pattern_r, _OutputIterator result_r)
 
template<class _OutputIterator >
static int collect (const char *pattern_r, _OutputIterator result_r)
 
template<class _OutputIterator >
static int collect (const Pathname &pattern_r, Flags flags_r, _OutputIterator result_r)
 
template<class _OutputIterator >
static int collect (const std::string &pattern_r, Flags flags_r, _OutputIterator result_r)
 
template<class _OutputIterator >
static int collect (const char *pattern_r, Flags flags_r, _OutputIterator result_r)
 

Public Attributes

 __pad0__: _defaultFlags( flags_r ) {} explicit Glob( const Pathname & pattern_r
 Default ctor optionally taking the default flags. More...
 
Flags flags_r
 

Private Attributes

Flags _defaultFlags
 
scoped_ptr< ::glob_t > _result
 
DefaultIntegral< int, 0 > _lastGlobReturn
 

Related Functions

(Note that these are not member functions.)

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

Detailed Description

Find pathnames matching a pattern.

* Glob glob( Glob::_BRACE );
* glob.add( "/somewhere/solverTestcase/ *{.xml,.xml.gz}" );
* glob.add( "/somewhere/else/a*" );
* for_( it, glob.begin(), glob.end() )
* ...
*
* std::list<Pathname> plist;
* Glob::collect( "/somewherre/solverTestcase/ *{.xml,.xml.gz}", Glob::_BRACE,
* std::back_inserter( plist ) );
*
See Also
Manual page glob(3)

Definition at line 57 of file Glob.h.

Member Typedef Documentation

Definition at line 60 of file Glob.h.

Definition at line 61 of file Glob.h.

Member Enumeration Documentation

Individual bits to combine in Flags.

Enumerator
_ERR 

Return on read errors.

_MARK 

Append a slash to each name.

_NOSORT 

Don't sort the names.

_NOCHECK 

If nothing matches, return the pattern.

_NOESCAPE 

Backslashes don't quote metacharacters.

_PERIOD 

Leading `.' can be matched by metachars.

_ALTDIRFUNC 

Use gl_opendir et al functions.

_BRACE 

Expand "{a,b}" to "a" "b".

_NOMAGIC 

If no magic chars, return the pattern.

_TILDE 

Expand ~user and ~ to home directories.

_ONLYDIR 

Match only directories.

_TILDE_CHECK 

Like GLOB_TILDE but return an error if the user name is not available.

Definition at line 95 of file Glob.h.

Member Function Documentation

zypp::filesystem::Glob::ZYPP_DECLARE_FLAGS ( Flags  ,
Bits   
)

type Flags: Type-safe OR-combination of Bits.

void zypp::filesystem::Glob::clear ( )

Clear all results found so far.

defaultFlags remain active.

Definition at line 38 of file Glob.cc.

void zypp::filesystem::Glob::reset ( Flags  flags_r = Flags())
inline

Clear all results and reset defaultFlags.

Definition at line 167 of file Glob.h.

Flags zypp::filesystem::Glob::defaultFlags ( ) const
inline

The default flags passed to ::glob().

Definition at line 173 of file Glob.h.

void zypp::filesystem::Glob::setDefaultFlags ( Flags  flags_r = Flags())
inline

Set the default flags passed to ::glob().

Definition at line 177 of file Glob.h.

int zypp::filesystem::Glob::lastGlobReturn ( ) const
inline

Returns the value returned by the last call to ::glob().

Zero on successful completion. Otherwise GLOB_NOSPACE or GLOB_ABORTED or GLOB_NOMATCH.

Definition at line 184 of file Glob.h.

bool zypp::filesystem::Glob::empty ( ) const
inline

Whether matches were found.

Definition at line 189 of file Glob.h.

size_type zypp::filesystem::Glob::size ( ) const
inline

The number of matches found so far.

Definition at line 193 of file Glob.h.

const_iterator zypp::filesystem::Glob::begin ( ) const
inline

Iterator pointing to the first result.

Definition at line 197 of file Glob.h.

const_iterator zypp::filesystem::Glob::end ( ) const
inline

Iterator pointing behind the last result.

Definition at line 201 of file Glob.h.

template<class _OutputIterator >
static int zypp::filesystem::Glob::collect ( const Pathname pattern_r,
_OutputIterator  result_r 
)
inlinestatic

Write glob result to some OutputIterator.

Definition at line 216 of file Glob.h.

template<class _OutputIterator >
static int zypp::filesystem::Glob::collect ( const std::string &  pattern_r,
_OutputIterator  result_r 
)
inlinestatic

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 220 of file Glob.h.

template<class _OutputIterator >
static int zypp::filesystem::Glob::collect ( const char *  pattern_r,
_OutputIterator  result_r 
)
inlinestatic

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 224 of file Glob.h.

template<class _OutputIterator >
static int zypp::filesystem::Glob::collect ( const Pathname pattern_r,
Flags  flags_r,
_OutputIterator  result_r 
)
inlinestatic

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 229 of file Glob.h.

template<class _OutputIterator >
static int zypp::filesystem::Glob::collect ( const std::string &  pattern_r,
Flags  flags_r,
_OutputIterator  result_r 
)
inlinestatic

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 233 of file Glob.h.

template<class _OutputIterator >
static int zypp::filesystem::Glob::collect ( const char *  pattern_r,
Flags  flags_r,
_OutputIterator  result_r 
)
inlinestatic

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 237 of file Glob.h.

Friends And Related Function Documentation

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

Stream output

Definition at line 53 of file Glob.cc.

Member Data Documentation

zypp::filesystem::Glob::__pad0__

Default ctor optionally taking the default flags.

The flags passed here are the default for add.

See Also
setDefaultFlags

Definition at line 129 of file Glob.h.

Flags zypp::filesystem::Glob::flags_r
Initial value:
= Flags() )
{ add( pattern_r, flags_r ); }
explicit Glob( const std::string & pattern_r, Flags flags_r = Flags() )
{ add( pattern_r, flags_r ); }
explicit Glob( const char * pattern_r, Flags flags_r = Flags() )
{ add( pattern_r, flags_r ); }
~Glob()
{ if ( _result ) ::globfree( &(*_result) ); }
int add( const Pathname & pattern_r, Flags flags_r = Flags() )
{ return add( pattern_r.c_str(), flags_r ); }
int add( const std::string & pattern_r, Flags flags_r = Flags() )
{ return add( pattern_r.c_str(), flags_r ); }
int add( const char * pattern_r, Flags flags_r = Flags() )

Definition at line 129 of file Glob.h.

Flags zypp::filesystem::Glob::_defaultFlags
private

Definition at line 248 of file Glob.h.

scoped_ptr< ::glob_t> zypp::filesystem::Glob::_result
private

Definition at line 249 of file Glob.h.

DefaultIntegral<int,0> zypp::filesystem::Glob::_lastGlobReturn
private

Definition at line 250 of file Glob.h.


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