zypp::filesystem::Glob Class Reference

Find pathnames matching a pattern. More...

#include <Glob.h>

Inheritance diagram for zypp::filesystem::Glob:
[legend]

List of all members.

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.
 Glob (Flags flags_r=Flags())
 Default ctor optionally taking the default flags.
 Glob (const Pathname &pattern_r, Flags flags_r=Flags())
 Ctor adding pathnames matching pattern_r.
 Glob (const std::string &pattern_r, Flags flags_r=Flags())
 Glob (const char *pattern_r, Flags flags_r=Flags())
 ~Glob ()
 Dtor.
int add (const Pathname &pattern_r, Flags flags_r=Flags())
 Add pathnames matching pattern_r to the current result.
int add (const std::string &pattern_r, Flags flags_r=Flags())
int add (const char *pattern_r, Flags flags_r=Flags())
void clear ()
 Clear all results found so far.
void reset (Flags flags_r=Flags())
 Clear all results and reset defaultFlags.
Flags defaultFlags () const
 The default flags passed to glob().
void setDefaultFlags (Flags flags_r=Flags())
 Set the default flags passed to glob().
int lastGlobReturn () const
 Returns the value returned by the last call to glob().
bool empty () const
 Whether matches were found.
size_type size () const
 The number of matches found so far.
const_iterator begin () const
 Iterator pointing to the first result.
const_iterator end () const
 Iterator pointing behind the last result.

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.
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)

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.


Constructor & Destructor Documentation

zypp::filesystem::Glob::Glob ( Flags  flags_r = Flags()  )  [inline]

Default ctor optionally taking the default flags.

The flags passed here are the default for add.

See also:
setDefaultFlags

Definition at line 121 of file Glob.h.

zypp::filesystem::Glob::Glob ( const Pathname pattern_r,
Flags  flags_r = Flags() 
) [inline, explicit]

Ctor adding pathnames matching pattern_r.

The flags passed here are the default for add.

See also:
setDefaultFlags

Definition at line 129 of file Glob.h.

References add().

zypp::filesystem::Glob::Glob ( const std::string &  pattern_r,
Flags  flags_r = Flags() 
) [inline, explicit]

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

References add().

zypp::filesystem::Glob::Glob ( const char *  pattern_r,
Flags  flags_r = Flags() 
) [inline, explicit]

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

References add().

zypp::filesystem::Glob::~Glob (  )  [inline]

Dtor.

Definition at line 142 of file Glob.h.

References _result.


Member Function Documentation

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

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

int zypp::filesystem::Glob::add ( const Pathname pattern_r,
Flags  flags_r = Flags() 
) [inline]

Add pathnames matching pattern_r to the current result.

Any flags passed here override the global default passed to the ctor. GLOB_APPEND is atomatically added to the flags f needed.

This invalidates all iterators.

See also:
setDefaultFlags
Returns:
the value returned by glob().

Definition at line 155 of file Glob.h.

References add(), and zypp::filesystem::Pathname::c_str().

Referenced by add(), and Glob().

int zypp::filesystem::Glob::add ( const std::string &  pattern_r,
Flags  flags_r = Flags() 
) [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 158 of file Glob.h.

References add().

Referenced by add().

int zypp::filesystem::Glob::add ( const char *  pattern_r,
Flags  flags_r = Flags() 
)

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 26 of file Glob.cc.

References _defaultFlags, _lastGlobReturn, and _result.

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

Clear all results found so far.

defaultFlags remain active.

Definition at line 38 of file Glob.cc.

References _lastGlobReturn, and _result.

Referenced by reset().

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

Clear all results and reset defaultFlags.

Definition at line 167 of file Glob.h.

References clear(), and setDefaultFlags().

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

The default flags passed to glob().

Definition at line 173 of file Glob.h.

References _defaultFlags.

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.

References _defaultFlags.

Referenced by reset().

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.

References _lastGlobReturn.

Referenced by collect().

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

Whether matches were found.

Definition at line 189 of file Glob.h.

References _result.

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

The number of matches found so far.

Definition at line 193 of file Glob.h.

References _result.

Referenced by zypp::filesystem::operator<<().

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

Iterator pointing to the first result.

Definition at line 197 of file Glob.h.

References _result.

Referenced by collect(), and zypp::filesystem::operator<<().

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

Iterator pointing behind the last result.

Definition at line 201 of file Glob.h.

Referenced by collect(), and zypp::filesystem::operator<<().

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

Write glob result to some OutputIterator.

Definition at line 216 of file Glob.h.

References zypp::filesystem::Pathname::c_str(), and collect().

Referenced by collect().

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

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.

References collect().

Referenced by collect().

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

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.

References collect().

Referenced by collect().

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

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.

References zypp::filesystem::Pathname::c_str(), and collect().

Referenced by collect().

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

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.

References collect().

Referenced by collect().

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

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.

References begin(), end(), for_, and lastGlobReturn().


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

Definition at line 248 of file Glob.h.

Referenced by add(), defaultFlags(), and setDefaultFlags().

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

Definition at line 249 of file Glob.h.

Referenced by add(), begin(), clear(), empty(), size(), and ~Glob().

Definition at line 250 of file Glob.h.

Referenced by add(), clear(), and lastGlobReturn().


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

doxygen