Jpp  15.0.1-rc.2-highQE
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Private Attributes | List of all members
JSYSTEM::JGlob Struct Reference

Auxiliary class to list files. More...

#include <JGlob.hh>

Inheritance diagram for JSYSTEM::JGlob:
std::vector< std::string >

Public Member Functions

 JGlob ()
 Default constructor. More...
 
 JGlob (const std::string &pattern)
 Constructor. More...
 
const JGloboperator() (const std::string &pattern)
 Get list of files. More...
 

Private Attributes

glob_t buffer
 

Detailed Description

Auxiliary class to list files.

Definition at line 27 of file JGlob.hh.

Constructor & Destructor Documentation

JSYSTEM::JGlob::JGlob ( )
inline

Default constructor.

Definition at line 33 of file JGlob.hh.

34  {}
JSYSTEM::JGlob::JGlob ( const std::string &  pattern)
inline

Constructor.

Parameters
patternpattern

Definition at line 42 of file JGlob.hh.

43  {
44  (*this)(pattern);
45  }

Member Function Documentation

const JGlob& JSYSTEM::JGlob::operator() ( const std::string &  pattern)
inline

Get list of files.

Parameters
patternpattern
Returns
list of files

Definition at line 54 of file JGlob.hh.

55  {
56  this->clear();
57 
58  memset(&buffer, 0, sizeof(buffer));
59 
60  const int value = glob(pattern.c_str(), GLOB_TILDE, NULL, &buffer);
61 
62  if (value != 0) {
63 
64  globfree(&buffer);
65 
66  THROW(JRunTimeException, "glob() failed " << pattern << " error " << value);
67  }
68 
69  for(size_t i = 0; i < buffer.gl_pathc; ++i) {
70  this->push_back(buffer.gl_pathv[i]);
71  }
72 
73  globfree(&buffer);
74 
75  return *this;
76  }
glob_t buffer
Definition: JGlob.hh:79
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:670

Member Data Documentation

glob_t JSYSTEM::JGlob::buffer
private

Definition at line 79 of file JGlob.hh.


The documentation for this struct was generated from the following file: