Jpp 19.3.0-rc.3
the software that should make you happy
Loading...
Searching...
No Matches
JGIZMO::JRootObjectID Class Reference

Auxiliary class to handle file name, ROOT directory and object name. More...

#include <JRootObjectID.hh>

Public Member Functions

 JRootObjectID ()
 Default constructor.
 
 JRootObjectID (const std::string &file_name, const std::string &name)
 Constructor.
 
 JRootObjectID (const std::string &file_name, const std::string &dir, const std::string &name)
 Constructor.
 
 JRootObjectID (const std::string &full_name)
 Constructor.
 
const std::string & getFilename () const
 Get file name.
 
TString getDirectory () const
 Get directory.
 
TString getObjectName () const
 Get object name.
 
TString getFullFilename () const
 Get full file name, including path.
 
TString getFullObjectName () const
 Get full object name, including path.
 
bool is_valid () const
 Check validity.
 
void clear ()
 Clear.
 

Static Public Attributes

static const char LABEL_L_BRACKET = '['
 left bracket for label
 
static const char LABEL_R_BRACKET = ']'
 right bracket for label
 
static const char FILENAME_SEPARATOR = ':'
 file name separator
 
static const char PATHNAME_SEPARATOR = '/'
 path name separator
 

Protected Attributes

std::string file_name
 
std::string directory
 
std::string name
 

Friends

bool operator== (const JRootObjectID &first, const JRootObjectID &second)
 Equal operator for object identifiers.
 
std::istream & operator>> (std::istream &in, JRootObjectID &object)
 Read object identifier from input.
 
std::ostream & operator<< (std::ostream &out, const JRootObjectID &object)
 Write object identifier to output.
 

Detailed Description

Auxiliary class to handle file name, ROOT directory and object name.

The general syntax is as follows:

  <file name>:[<directory/>]<object name>

where <directory> is optional and <object name> may be a regular expression (TRegexp).

Definition at line 36 of file JRootObjectID.hh.

Constructor & Destructor Documentation

◆ JRootObjectID() [1/4]

JGIZMO::JRootObjectID::JRootObjectID ( )
inline

Default constructor.

Definition at line 49 of file JRootObjectID.hh.

50 {}

◆ JRootObjectID() [2/4]

JGIZMO::JRootObjectID::JRootObjectID ( const std::string & file_name,
const std::string & name )
inline

Constructor.

Parameters
file_namefile name
nameobject name

Definition at line 59 of file JRootObjectID.hh.

60 :
62 directory(""),
63 name (name)
64 {}

◆ JRootObjectID() [3/4]

JGIZMO::JRootObjectID::JRootObjectID ( const std::string & file_name,
const std::string & dir,
const std::string & name )
inline

Constructor.

Parameters
file_namefile name
dirdirectory name
nameobject name

Definition at line 74 of file JRootObjectID.hh.

76 :
78 directory(dir),
79 name (name)
80 {}

◆ JRootObjectID() [4/4]

JGIZMO::JRootObjectID::JRootObjectID ( const std::string & full_name)
inline

Constructor.

Parameters
full_namefull object name

Definition at line 88 of file JRootObjectID.hh.

89 {
90 std::istringstream(full_name) >> *this;
91 }

Member Function Documentation

◆ getFilename()

const std::string & JGIZMO::JRootObjectID::getFilename ( ) const
inline

Get file name.

Returns
file name

Definition at line 99 of file JRootObjectID.hh.

100 {
101 return file_name;
102 }

◆ getDirectory()

TString JGIZMO::JRootObjectID::getDirectory ( ) const
inline

Get directory.

Returns
directory

Definition at line 110 of file JRootObjectID.hh.

111 {
112 return TString(directory.c_str());
113 }

◆ getObjectName()

TString JGIZMO::JRootObjectID::getObjectName ( ) const
inline

Get object name.

Returns
object name

Definition at line 121 of file JRootObjectID.hh.

122 {
123 return TString(name.c_str());
124 }

◆ getFullFilename()

TString JGIZMO::JRootObjectID::getFullFilename ( ) const
inline

Get full file name, including path.

Returns
file name

Definition at line 132 of file JRootObjectID.hh.

133 {
134 if (getDirectory() == "")
135 return getFilename();
136 else
138 }
static const char PATHNAME_SEPARATOR
path name separator
TString getDirectory() const
Get directory.
const std::string & getFilename() const
Get file name.

◆ getFullObjectName()

TString JGIZMO::JRootObjectID::getFullObjectName ( ) const
inline

Get full object name, including path.

Returns
object name

Definition at line 146 of file JRootObjectID.hh.

147 {
148 if (getDirectory() == "")
149 return getObjectName();
150 else
152 }
TString getObjectName() const
Get object name.

◆ is_valid()

bool JGIZMO::JRootObjectID::is_valid ( ) const
inline

Check validity.

Returns
true if valid ROOT object identifier; else false

Definition at line 160 of file JRootObjectID.hh.

161 {
162 return (file_name != "" &&
163 name != "");
164 }

◆ clear()

void JGIZMO::JRootObjectID::clear ( )
inline

Clear.

Definition at line 169 of file JRootObjectID.hh.

170 {
171 file_name.clear();
172 directory.clear();
173 name .clear();
174 }

Friends And Related Symbol Documentation

◆ operator==

bool operator== ( const JRootObjectID & first,
const JRootObjectID & second )
friend

Equal operator for object identifiers.

Parameters
firstfirst object identifier
secondsecond object identifier
Returns
true if first and second object identifier are equal; else false

Definition at line 184 of file JRootObjectID.hh.

185 {
186 return (first.getFilename() == second.getFilename() &&
187 first.getDirectory() == second.getDirectory() &&
188 first.getObjectName() == second.getObjectName());
189 }

◆ operator>>

std::istream & operator>> ( std::istream & in,
JRootObjectID & object )
friend

Read object identifier from input.

Parameters
ininput stream
objectobject identifier
Returns
input stream

Definition at line 199 of file JRootObjectID.hh.

200 {
201 using namespace std;
202
203 object.clear();
204
205 string buffer;
206
207 for (int bracket = 0; in.peek() != EOF; ) {
208
209 const char c = (char) in.get();
210
211 if (c == LABEL_L_BRACKET) {
212
213 ++bracket;
214
215 } else if (c == LABEL_R_BRACKET) {
216
217 --bracket;
218
219 } else if (isspace(c)) {
220
221 if (bracket <= 0) {
222 break;
223 }
224 }
225
226 buffer.push_back(c);
227 }
228
229 size_t pos = buffer.find(FILENAME_SEPARATOR);
230
231 if (pos != string::npos) {
232
233 object.file_name = buffer.substr(0, pos);
234 object.name = buffer.substr(pos + 1);
235
236 pos = object.name.rfind(PATHNAME_SEPARATOR);
237
238 if (pos != string::npos) {
239
240 object.directory = object.name.substr(0, pos);
241 object.name = object.name.substr(pos + 1);
242 }
243
244 } else if (!buffer.empty()) {
245
246 throw JParseError("JRootObjectID error parsing " + buffer);
247 }
248
249 return in;
250 }
static const char LABEL_L_BRACKET
left bracket for label
static const char LABEL_R_BRACKET
right bracket for label
static const char FILENAME_SEPARATOR
file name separator

◆ operator<<

std::ostream & operator<< ( std::ostream & out,
const JRootObjectID & object )
friend

Write object identifier to output.

Parameters
outoutput stream
objectobject identifier
Returns
output stream

Definition at line 260 of file JRootObjectID.hh.

261 {
262 return out << object.getFilename() << FILENAME_SEPARATOR << object.getFullObjectName();
263 }

Member Data Documentation

◆ LABEL_L_BRACKET

const char JGIZMO::JRootObjectID::LABEL_L_BRACKET = '['
static

left bracket for label

Definition at line 40 of file JRootObjectID.hh.

◆ LABEL_R_BRACKET

const char JGIZMO::JRootObjectID::LABEL_R_BRACKET = ']'
static

right bracket for label

Definition at line 41 of file JRootObjectID.hh.

◆ FILENAME_SEPARATOR

const char JGIZMO::JRootObjectID::FILENAME_SEPARATOR = ':'
static

file name separator

Definition at line 42 of file JRootObjectID.hh.

◆ PATHNAME_SEPARATOR

const char JGIZMO::JRootObjectID::PATHNAME_SEPARATOR = '/'
static

path name separator

Definition at line 43 of file JRootObjectID.hh.

◆ file_name

std::string JGIZMO::JRootObjectID::file_name
protected

Definition at line 266 of file JRootObjectID.hh.

◆ directory

std::string JGIZMO::JRootObjectID::directory
protected

Definition at line 267 of file JRootObjectID.hh.

◆ name

std::string JGIZMO::JRootObjectID::name
protected

Definition at line 268 of file JRootObjectID.hh.


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