Jpp 19.3.0-rc.2
the software that should make you happy
Loading...
Searching...
No Matches
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.
 
 JGlob (const std::string &pattern)
 Constructor.
 
 JGlob (const std::vector< std::string > &buffer)
 Constructor.
 
const JGloboperator() (const std::string &pattern)
 Get list of files.
 
const JGloboperator() (const std::vector< std::string > &buffer)
 Get list of files.
 

Private Member Functions

void evaluate (const std::string &pattern)
 Process pattern.
 

Private Attributes

glob_t buffer
 

Detailed Description

Auxiliary class to list files.

Definition at line 23 of file JGlob.hh.

Constructor & Destructor Documentation

◆ JGlob() [1/3]

JSYSTEM::JGlob::JGlob ( )
inline

Default constructor.

Definition at line 29 of file JGlob.hh.

30 {}

◆ JGlob() [2/3]

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

Constructor.

Parameters
patternpattern

Definition at line 38 of file JGlob.hh.

39 {
40 (*this)(pattern);
41 }

◆ JGlob() [3/3]

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

◆ operator()() [1/2]

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

◆ operator()() [2/2]

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 }

◆ evaluate()

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 }

Member Data Documentation

◆ buffer

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: