libzypp 17.37.10

zypp::filesystem::Glob Class Reference

Find pathnames matching a pattern. More...

`#include <zypp/Glob.h>`

Inheritance diagram for zypp::filesystem::Glob:

## Classes
class | const_iterator
| Iterate NULL terminated `char*` array. More...

## Public Types
enum | Bits { kErr = GLOB_ERR , kMark = GLOB_MARK , kNoSort = GLOB_NOSORT , kNoCheck = GLOB_NOCHECK , kNoEscape = GLOB_NOESCAPE , kPeriod = GLOB_PERIOD , kAltDirFunc = GLOB_ALTDIRFUNC , kBrace = GLOB_BRACE , kNoMagic = GLOB_NOMAGIC , kTilde = GLOB_TILDE , kOnlyDir = GLOB_ONLYDIR , kTildeCheck = GLOB_TILDE_CHECK }
| Individual bits to combine in Flags. More...
using | size_type = size_t
using | value_type = const char *

## 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())
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
| Glob (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.
| ~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())
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
int | 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.
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.

## Related Symbols
(Note that these are not member symbols.)
std::ostream & | operator<< (std::ostream &str, const Glob &obj)
| Stream output.
std::ostream & | operator<< (std::ostream &str, const Glob::const_iterator &obj)
| Stream output.

## Collecting Glob results to some TOutputIterator
std::list<Pathname> p; Glob::collect( "/bin/a*.dat}", std::back_inserter(p) ); Glob::collect( "/bin/a*{.xml,.xml.gz}", Glob::kBrace, std::back_inserter(p) ); zypp::filesystem::Glob::kBrace @ kBrace Expand "{a,b}" to "a" "b". Definition Glob.h:106 zypp::filesystem::Glob::collect static int collect(const Pathname &pattern_r, TOutputIterator result_r) Write glob result to some OutputIterator. Definition Glob.h:216
Flags | _defaultFlags
scoped_ptr< ::glob_t > | _result
DefaultIntegral< int, 0 > | _lastGlobReturn
template<class TOutputIterator>
static int | collect (const Pathname &pattern_r, TOutputIterator result_r)
| Write glob result to some `OutputIterator`.
template<class TOutputIterator>
static int | collect (const std::string &pattern_r, TOutputIterator result_r)
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
template<class TOutputIterator>
static int | collect (const char *pattern_r, TOutputIterator result_r)
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
template<class TOutputIterator>
static int | collect (const Pathname &pattern_r, Flags flags_r, TOutputIterator result_r)
template<class TOutputIterator>
static int | collect (const std::string &pattern_r, Flags flags_r, TOutputIterator result_r)
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
template<class TOutputIterator>
static int | collect (const char *pattern_r, Flags flags_r, TOutputIterator result_r)
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

## Detailed Description

Find pathnames matching a pattern.

Glob glob( Glob::kBrace );
glob.add( "/somewhere/solverTestcase/ *{.xml,.xml.gz}" );
glob.add( "/somewhere/else/a*" );
for_( it, glob.begin(), glob.end() )
...
zypp::filesystem::Glob::Glob
Glob(Flags flags_r=Flags())
Default ctor optionally taking the default flags.
Definition Glob.h:121
for_
#define for_(IT, BEG, END)
Convenient for-loops using iterator.
Definition Easy.h:27
std::list<Pathname> plist;
Glob::collect( "/somewherre/solverTestcase/ *{.xml,.xml.gz}", Glob::kBrace,
std::back_inserter( plist ) );

See also
  Manual page glob(3)

Definition at line 57 of file Glob.h.

## Member Typedef Documentation

## ◆ size_type

using zypp::filesystem::Glob::size_type = size_t

Definition at line 60 of file Glob.h.

## ◆ value_type

using zypp::filesystem::Glob::value_type = const char *

Definition at line 61 of file Glob.h.

## Member Enumeration Documentation

## ◆ Bits

enum zypp::filesystem::Glob::Bits

Individual bits to combine in Flags.

Enumerator
kErr | Return on read errors.
kMark | Append a slash to each name.
kNoSort | Don't sort the names.
kNoCheck | If nothing matches, return the pattern.
kNoEscape | Backslashes don't quote metacharacters.
kPeriod | Leading ‘.’ can be matched by metachars.
kAltDirFunc | Use gl_opendir et al functions.
kBrace | Expand "{a,b}" to "a" "b".
kNoMagic | If no magic chars, return the pattern.
kTilde | Expand ~user and ~ to home directories.
kOnlyDir | Match only directories.
kTildeCheck | 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

## ◆ Glob() [1/4]

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.

## ◆ Glob() [2/4]

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.

## ◆ Glob() [3/4]

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.

## ◆ Glob() [4/4]

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.

## ◆ ~Glob()

zypp::filesystem::Glob::~Glob | ( |  | ) |
| inline

Dtor.

Definition at line 142 of file Glob.h.

## Member Function Documentation

## ◆ ZYPP_DECLARE_FLAGS()

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

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

## ◆ add() [1/3]

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.

## ◆ add() [2/3]

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.

## ◆ add() [3/3]

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.

## ◆ clear()

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

Clear all results found so far.

defaultFlags remain active.

Definition at line 38 of file Glob.cc.

## ◆ 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.

## ◆ defaultFlags()

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

The default flags passed to `::glob()`.

Definition at line 173 of file Glob.h.

## ◆ setDefaultFlags()

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.

## ◆ lastGlobReturn()

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.

## ◆ empty()

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

Whether matches were found.

Definition at line 189 of file Glob.h.

## ◆ size()

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

The number of matches found so far.

Definition at line 193 of file Glob.h.

## ◆ begin()

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

Iterator pointing to the first result.

Definition at line 197 of file Glob.h.

## ◆ end()

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

Iterator pointing behind the last result.

Definition at line 201 of file Glob.h.

## ◆ collect() [1/6]

template<class TOutputIterator>

int zypp::filesystem::Glob::collect | ( | const Pathname & | pattern_r,
|  | TOutputIterator | result_r )
| inline static

Write glob result to some `OutputIterator`.

Definition at line 216 of file Glob.h.

## ◆ collect() [2/6]

template<class TOutputIterator>

int zypp::filesystem::Glob::collect | ( | const std::string & | pattern_r,
|  | TOutputIterator | 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.

## ◆ collect() [3/6]

template<class TOutputIterator>

int zypp::filesystem::Glob::collect | ( | const char * | pattern_r,
|  | TOutputIterator | 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.

## ◆ collect() [4/6]

template<class TOutputIterator>

int zypp::filesystem::Glob::collect | ( | const Pathname & | pattern_r,
|  | Flags | flags_r,
|  | TOutputIterator | result_r )
| inline static

Definition at line 229 of file Glob.h.

## ◆ collect() [5/6]

template<class TOutputIterator>

int zypp::filesystem::Glob::collect | ( | const std::string & | pattern_r,
|  | Flags | flags_r,
|  | TOutputIterator | 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.

## ◆ collect() [6/6]

template<class TOutputIterator>

int zypp::filesystem::Glob::collect | ( | const char * | pattern_r,
|  | Flags | flags_r,
|  | TOutputIterator | 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.

## Friends And Related Symbol Documentation

## ◆ operator<<() [1/2]

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

Stream output.

Definition at line 53 of file Glob.cc.

## Member Data Documentation

## ◆ _defaultFlags

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

Definition at line 248 of file Glob.h.

## ◆ _result

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

Definition at line 249 of file Glob.h.

## ◆ _lastGlobReturn

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:

- zypp/Glob.h
- zypp/Glob.cc