Tokenizer::Token Class Reference

Definition of the sub-class Token. More...

#include </scratch/z5/marcocle/GaudiDocs/lhcb-release/825/GAUDI/GAUDI_v26r3/InstallArea/x86_64-slc6-gcc48-opt/include/GaudiKernel/Tokenizer.h>

Collaboration diagram for Tokenizer::Token:

Public Member Functions

 Token (const Token &copy)
 Copy constructor. More...
 
 Token ()
 Standard constructor. More...
 
void make (const std::string &s, long st, const char *delim, const char *tagBegin, const char *tagEnd, const char *eq, const char *valBegin, const char *valEnd)
 Create token from string. More...
 
virtual ~Token ()
 Standard Destructor. More...
 
Tokenoperator= (const Token &copy)
 Assignment operator. More...
 
bool operator== (const Token &copy) const
 
long length () const
 Total token length. More...
 
const std::string & tag () const
 Acces tag value. More...
 
const std::string & value () const
 Access value. More...
 
void resolveValue ()
 Resolve value from environment. More...
 
 Token (const Token &copy)
 Copy constructor. More...
 
 Token ()
 Standard constructor. More...
 
void make (const std::string &s, long st, const char *delim, const char *tagBegin, const char *tagEnd, const char *eq, const char *valBegin, const char *valEnd)
 Create token from string. More...
 
virtual ~Token ()
 Standard Destructor. More...
 
Tokenoperator= (const Token &copy)
 Assignment operator. More...
 
bool operator== (const Token &copy) const
 
long length () const
 Total token length. More...
 
const std::string & tag () const
 Acces tag value. More...
 
const std::string & value () const
 Access value. More...
 
void resolveValue ()
 Resolve value from environment. More...
 

Private Attributes

long m_length
 Toke length. More...
 
std::string m_tag
 Tag variable. More...
 
std::string m_value
 Value variable. More...
 

Detailed Description

Definition of the sub-class Token.

Definition at line 34 of file Tokenizer.h.

Constructor & Destructor Documentation

Tokenizer::Token::Token ( const Token copy)
inline

Copy constructor.

Definition at line 43 of file Tokenizer.h.

43  : m_length(copy.m_length), m_tag(copy.m_tag), m_value(copy.m_value) {
44  }
std::string m_value
Value variable.
Definition: Tokenizer.h:40
long m_length
Toke length.
Definition: Tokenizer.h:36
std::string m_tag
Tag variable.
Definition: Tokenizer.h:38
Tokenizer::Token::Token ( )
inline

Standard constructor.

Definition at line 46 of file Tokenizer.h.

46  : m_length(0) {
47  }
long m_length
Toke length.
Definition: Tokenizer.h:36
virtual Tokenizer::Token::~Token ( )
inlinevirtual

Standard Destructor.

Definition at line 51 of file Tokenizer.h.

51  {
52  }
Tokenizer::Token::Token ( const Token copy)
inline

Copy constructor.

Definition at line 43 of file Tokenizer.h.

43  : m_length(copy.m_length), m_tag(copy.m_tag), m_value(copy.m_value) {
44  }
std::string m_value
Value variable.
Definition: Tokenizer.h:40
long m_length
Toke length.
Definition: Tokenizer.h:36
std::string m_tag
Tag variable.
Definition: Tokenizer.h:38
Tokenizer::Token::Token ( )
inline

Standard constructor.

Definition at line 46 of file Tokenizer.h.

46  : m_length(0) {
47  }
long m_length
Toke length.
Definition: Tokenizer.h:36
virtual Tokenizer::Token::~Token ( )
inlinevirtual

Standard Destructor.

Definition at line 51 of file Tokenizer.h.

51  {
52  }

Member Function Documentation

long Tokenizer::Token::length ( ) const
inline

Total token length.

Definition at line 60 of file Tokenizer.h.

60  {
61  return m_length;
62  }
long m_length
Toke length.
Definition: Tokenizer.h:36
long Tokenizer::Token::length ( ) const
inline

Total token length.

Definition at line 60 of file Tokenizer.h.

60  {
61  return m_length;
62  }
long m_length
Toke length.
Definition: Tokenizer.h:36
void Tokenizer::Token::make ( const std::string &  s,
long  st,
const char *  delim,
const char *  tagBegin,
const char *  tagEnd,
const char *  eq,
const char *  valBegin,
const char *  valEnd 
)

Create token from string.

void Tokenizer::Token::make ( const std::string &  s,
long  st,
const char *  delim,
const char *  tagBegin,
const char *  tagEnd,
const char *  eq,
const char *  valBegin,
const char *  valEnd 
)

Create token from string.

Definition at line 59 of file Tokenizer.cpp.

59  {
60  long lenTagBeg = ::strlen(tagBeg);
61  long lenTagEnd = ::strlen(tagEnd);
62  long lenValBeg = ::strlen(valBeg);
63  long lenValEnd = ::strlen(valEnd);
64  long lenDelim = ::strlen(delim);
65  long lenEq = ::strlen(eq);
66  long slen = s.length();
67  long start = st;
68  while(::strncmp(s.c_str()+start,delim,lenDelim)==0) start += lenDelim;
69  long posTag = (lenTagBeg>0) ? s.find(tagBeg, start) + lenTagBeg : start;
70  long posDelim = s.find(delim,posTag) > 0 ? s.find(delim,posTag) : slen;
71  long posEq = s.find(eq, posTag) > 0 ? s.find(eq, posTag) : posDelim-posTag;
72  long lenTag = (lenTagEnd>0) ? s.find(tagEnd, posTag)-posTag : (posEq>0) ? (posEq>posTag) ? posEq-posTag : posDelim-posTag : posDelim;
73  posEq = s.find(eq, posTag+lenTag+lenTagEnd)+lenEq;
74  long posVal = (lenValBeg>0) ? s.find(valBeg, posEq)+lenValBeg : posEq;
75  posDelim = (lenDelim>0) ? s.find(delim, posVal+lenValBeg) : slen;
76  long lenVal = (lenValEnd>0) ? s.find(valEnd, posVal)-posVal : ((posDelim>=0) ? posDelim : slen)-posVal;
77 
78  m_tag = m_value = "";
79  // Ooops: Valid tag found:
80  if ( start >= 0 && posTag >= 0 ) {
81  m_tag = s.substr(posTag, lenTag);
82  m_length = posTag+m_tag.length()+lenTagEnd-st;
83  }
84  // Ooops: there is also a value:
85  if ( posVal >= 0 && lenVal >= 0 ) {
86  m_value = s.substr(posVal, lenVal);
87  m_length = posVal+m_value.length()+lenValEnd-st;
88  }
89 
90  if (start + m_length >= long(s.size())) {
91  return;
92  }
93 
94  while(::strncmp(s.c_str()+start+m_length,delim,lenDelim)==0) {
95  m_length += lenDelim;
96  if (start + m_length >= long(s.size())) {
97  return;
98  }
99  }
100 }
std::string m_value
Value variable.
Definition: Tokenizer.h:40
long m_length
Toke length.
Definition: Tokenizer.h:36
std::string m_tag
Tag variable.
Definition: Tokenizer.h:38
string s
Definition: gaudirun.py:244
tuple start
Definition: IOTest.py:88
Tokenizer::Token & Tokenizer::Token::operator= ( const Token copy)

Assignment operator.

Definition at line 20 of file Tokenizer.cpp.

20  {
21  m_length=copy.m_length;
22  m_tag=copy.m_tag;
23  m_value=copy.m_value;
24  return *this;
25 }
std::string m_value
Value variable.
Definition: Tokenizer.h:40
long m_length
Toke length.
Definition: Tokenizer.h:36
std::string m_tag
Tag variable.
Definition: Tokenizer.h:38
Token& Tokenizer::Token::operator= ( const Token copy)

Assignment operator.

bool Tokenizer::Token::operator== ( const Token copy) const
inline

Definition at line 56 of file Tokenizer.h.

56  {
57  return m_tag == copy.m_tag && m_value == copy.m_value && m_length == copy.m_length;
58  }
std::string m_value
Value variable.
Definition: Tokenizer.h:40
long m_length
Toke length.
Definition: Tokenizer.h:36
std::string m_tag
Tag variable.
Definition: Tokenizer.h:38
bool Tokenizer::Token::operator== ( const Token copy) const
inline

Definition at line 56 of file Tokenizer.h.

56  {
57  return m_tag == copy.m_tag && m_value == copy.m_value && m_length == copy.m_length;
58  }
std::string m_value
Value variable.
Definition: Tokenizer.h:40
long m_length
Toke length.
Definition: Tokenizer.h:36
std::string m_tag
Tag variable.
Definition: Tokenizer.h:38
void Tokenizer::Token::resolveValue ( )

Resolve value from environment.

void Tokenizer::Token::resolveValue ( )

Resolve value from environment.

Definition at line 28 of file Tokenizer.cpp.

28  {
29  std::string res;
30  if ( System::resolveEnv(m_value, res).isSuccess() ) {
31  m_value = res;
32  }
33 }
std::string m_value
Value variable.
Definition: Tokenizer.h:40
GAUDI_API StatusCode resolveEnv(const std::string &var, std::string &res, int recusions=124)
Definition: Environment.cpp:51
const std::string& Tokenizer::Token::tag ( ) const
inline

Acces tag value.

Definition at line 64 of file Tokenizer.h.

64  {
65  return m_tag;
66  }
std::string m_tag
Tag variable.
Definition: Tokenizer.h:38
const std::string& Tokenizer::Token::tag ( ) const
inline

Acces tag value.

Definition at line 64 of file Tokenizer.h.

64  {
65  return m_tag;
66  }
std::string m_tag
Tag variable.
Definition: Tokenizer.h:38
const std::string& Tokenizer::Token::value ( ) const
inline

Access value.

Definition at line 68 of file Tokenizer.h.

68  {
69  return m_value;
70  }
std::string m_value
Value variable.
Definition: Tokenizer.h:40
const std::string& Tokenizer::Token::value ( void  ) const
inline

Access value.

Definition at line 68 of file Tokenizer.h.

68  {
69  return m_value;
70  }
std::string m_value
Value variable.
Definition: Tokenizer.h:40

Member Data Documentation

long Tokenizer::Token::m_length
private

Toke length.

Definition at line 36 of file Tokenizer.h.

std::string Tokenizer::Token::m_tag
private

Tag variable.

Definition at line 38 of file Tokenizer.h.

std::string Tokenizer::Token::m_value
private

Value variable.

Definition at line 40 of file Tokenizer.h.


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