Jpp  18.6.0-rc.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 23 of file JGlob.hh.

Constructor & Destructor Documentation

JSYSTEM::JGlob::JGlob ( )
inline

Default constructor.

Definition at line 29 of file JGlob.hh.

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

Constructor.

Parameters
patternpattern

Definition at line 38 of file JGlob.hh.

39  {
40  (*this)(pattern);
41  }
JSYSTEM::JGlob::JGlob ( const std::vector< std::string > &  buffer)
inline

Constructor.

Parameters
bufferlist of patterns

Definition at line 49 of file JGlob.hh.

50  {
51  (*this)(buffer);
52  }
glob_t buffer
Definition: JGlob.hh:116

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

62  {
63  this->clear();
64 
65  evaluate(pattern);
66 
67  return *this;
68  }
void evaluate(const std::string &pattern)
Process pattern.
Definition: JGlob.hh:96
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 78 of file JGlob.hh.

79  {
80  this->clear();
81 
82  for (const std::string& pattern : buffer) {
83  evaluate(pattern);
84  }
85 
86  return *this;
87  }
void evaluate(const std::string &pattern)
Process pattern.
Definition: JGlob.hh:96
void JSYSTEM::JGlob::evaluate ( const std::string &  pattern)
inlineprivate

Process pattern.

Parameters
patternpattern

Definition at line 96 of file JGlob.hh.

97  {
98  memset(&buffer, 0, sizeof(buffer));
99 
100  const int value = glob(pattern.c_str(), GLOB_TILDE | GLOB_BRACE, NULL, &buffer);
101 
102  if (value == 0) {
103 
104  for(size_t i = 0; i < buffer.gl_pathc; ++i) {
105  this->push_back(buffer.gl_pathv[i]);
106  }
107 
108  } else {
109 
110  this->push_back(pattern);
111  }
112 
113  globfree(&buffer);
114  }
glob_t buffer
Definition: JGlob.hh:116

Member Data Documentation

glob_t JSYSTEM::JGlob::buffer
private

Definition at line 116 of file JGlob.hh.


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