Jpp  18.3.1
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Private 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...
 
 JGlob (const std::vector< std::string > &buffer)
 Constructor. More...
 
const JGloboperator() (const std::string &pattern)
 Get list of files. More...
 
const JGloboperator() (const std::vector< std::string > &buffer)
 Get list of files. More...
 

Private Member Functions

void evaluate (const std::string &pattern)
 Process pattern. 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  }
JSYSTEM::JGlob::JGlob ( const std::vector< std::string > &  buffer)
inline

Constructor.

Parameters
bufferlist of patterns

Definition at line 53 of file JGlob.hh.

54  {
55  (*this)(buffer);
56  }
glob_t buffer
Definition: JGlob.hh:120

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 65 of file JGlob.hh.

66  {
67  this->clear();
68 
69  evaluate(pattern);
70 
71  return *this;
72  }
void evaluate(const std::string &pattern)
Process pattern.
Definition: JGlob.hh:100
const JGlob& JSYSTEM::JGlob::operator() ( const std::vector< std::string > &  buffer)
inline

Get list of files.

Parameters
bufferlist of patterns
Returns
list of files

Definition at line 82 of file JGlob.hh.

83  {
84  this->clear();
85 
86  for (const std::string& pattern : buffer) {
87  evaluate(pattern);
88  }
89 
90  return *this;
91  }
then awk string
void evaluate(const std::string &pattern)
Process pattern.
Definition: JGlob.hh:100
void JSYSTEM::JGlob::evaluate ( const std::string pattern)
inlineprivate

Process pattern.

Parameters
patternpattern

Definition at line 100 of file JGlob.hh.

101  {
102  memset(&buffer, 0, sizeof(buffer));
103 
104  const int value = glob(pattern.c_str(), GLOB_TILDE, NULL, &buffer);
105 
106  if (value != 0) {
107 
108  globfree(&buffer);
109 
110  THROW(JRunTimeException, "glob() failed " << pattern << " error " << value);
111  }
112 
113  for(size_t i = 0; i < buffer.gl_pathc; ++i) {
114  this->push_back(buffer.gl_pathv[i]);
115  }
116 
117  globfree(&buffer);
118  }
glob_t buffer
Definition: JGlob.hh:120
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:712

Member Data Documentation

glob_t JSYSTEM::JGlob::buffer
private

Definition at line 120 of file JGlob.hh.


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