| # Gaudi Framework, version v21r10p1 |

Home |  | Generated: 29 Jul 2010

# Tokenizer::Token Class Reference

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

`#include <Tokenizer.h>`

List of all members.

## Public Member Functions
| Token (const Token &copy)
| Copy constructor.
| Token ()
| Standard constructor.
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.
virtual | ~Token ()
| Standard Destructor.
Token & | operator= (const Token &copy)
| Assignment operator.
bool | operator== (const Token &copy) const
long | length () const
| Total token length.
const std::string & | tag () const
| Acces tag value.
const std::string & | value () const
| Access value.
void | resolveValue ()
| Resolve value from environment.
## Private Attributes
long | m_length
| Toke length.
std::string | m_tag
| Tag variable.
std::string | m_value
| Value variable.

## Detailed Description

Definition of the sub-class Token.

Definition at line 28 of file Tokenizer.h.

## Constructor & Destructor Documentation

Tokenizer::Token::Token | ( | const Token & | copy | ) | `[inline]`

Copy constructor.

Definition at line 37 of file Tokenizer.h.

    00037                               : m_length(copy.m_length), m_tag(copy.m_tag), m_value(copy.m_value)  {
    00038     }

Tokenizer::Token::Token | ( |  | ) | `[inline]`

Standard constructor.

Definition at line 40 of file Tokenizer.h.

    00040              : m_length(0)  {
    00041     }

virtual Tokenizer::Token::~Token | ( |  | ) | `[inline, virtual]`

Standard Destructor.

Definition at line 45 of file Tokenizer.h.

    00045                         {
    00046     }

## Member Function Documentation

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 60 of file Tokenizer.cpp.

    00060                                                                                                                                                                            {
    00061   long lenTagBeg   = ::strlen(tagBeg);
    00062   long lenTagEnd   = ::strlen(tagEnd);
    00063   long lenValBeg   = ::strlen(valBeg);
    00064   long lenValEnd   = ::strlen(valEnd);
    00065   long lenDelim    = ::strlen(delim);
    00066   long lenEq       = ::strlen(eq);
    00067   long slen        = s.length();
    00068   long start       = st;
    00069   while(::strncmp(s.c_str()+start,delim,lenDelim)==0) start += lenDelim;
    00070   long posTag      = (lenTagBeg>0) ? s.find(tagBeg, start) + lenTagBeg : start;
    00071   long posDelim    = s.find(delim,posTag) > 0 ? s.find(delim,posTag) : slen;
    00072   long posEq       = s.find(eq, posTag)   > 0 ? s.find(eq, posTag) : posDelim-posTag;
    00073   long lenTag      = (lenTagEnd>0)   ? s.find(tagEnd, posTag)-posTag : (posEq>0) ? (posEq>posTag) ? posEq-posTag : posDelim-posTag : posDelim;
    00074   posEq            = s.find(eq, posTag+lenTag+lenTagEnd)+lenEq;
    00075   long posVal      = (lenValBeg>0)   ? s.find(valBeg, posEq)+lenValBeg : posEq;
    00076   posDelim         = (lenDelim>0)    ? s.find(delim, posVal+lenValBeg) : slen;
    00077   long lenVal      = (lenValEnd>0)   ? s.find(valEnd, posVal)-posVal : ((posDelim>=0) ? posDelim : slen)-posVal;
    00078
    00079   m_tag = m_value  = "";
    00080   // Ooops: Valid tag found:
    00081   if ( start  >= 0 && posTag >= 0 )   {
    00082     m_tag    = s.substr(posTag, lenTag);
    00083     m_length = posTag+m_tag.length()+lenTagEnd-st;
    00084   }
    00085   // Ooops: there is also a value:
    00086   if ( posVal >= 0 && lenVal >= 0 )   {
    00087     m_value  = s.substr(posVal, lenVal);
    00088     m_length = posVal+m_value.length()+lenValEnd-st;
    00089   }
    00090   while(::strncmp(s.c_str()+start+m_length,delim,lenDelim)==0) m_length += lenDelim;
    00091 }

Tokenizer::Token & Tokenizer::Token::operator= | ( | const Token & | copy | ) |

Assignment operator.

Definition at line 21 of file Tokenizer.cpp.

    00021                                                                {
    00022   m_length=copy.m_length;
    00023   m_tag=copy.m_tag;
    00024   m_value=copy.m_value;
    00025   return *this;
    00026 }

bool Tokenizer::Token::operator== | ( | const Token & | copy | ) | const`[inline]`

Definition at line 50 of file Tokenizer.h.

    00050                                                   {
    00051       return m_tag == copy.m_tag, m_value == copy.m_value && m_length == copy.m_length;
    00052     }

long Tokenizer::Token::length | ( |  | ) | const`[inline]`

Total token length.

Definition at line 54 of file Tokenizer.h.

    00054                             {
    00055       return m_length;
    00056     }

const std::string& Tokenizer::Token::tag | ( |  | ) | const`[inline]`

Acces tag value.

Definition at line 58 of file Tokenizer.h.

    00058                                       {
    00059       return m_tag;
    00060     }

const std::string& Tokenizer::Token::value | ( |  | ) | const`[inline]`

Access value.

Definition at line 62 of file Tokenizer.h.

    00062                                       {
    00063       return m_value;
    00064     }

void Tokenizer::Token::resolveValue | ( |  | ) |

Resolve value from environment.

Definition at line 29 of file Tokenizer.cpp.

    00029                                    {
    00030   std::string res;
    00031   if ( System::resolveEnv(m_value, res).isSuccess() )  {
    00032     m_value = res;
    00033   }
    00034 }

## Member Data Documentation

long Tokenizer::Token::m_length`[private]`

Toke length.

Definition at line 30 of file Tokenizer.h.

std::string Tokenizer::Token::m_tag`[private]`

Tag variable.

Definition at line 32 of file Tokenizer.h.

std::string Tokenizer::Token::m_value`[private]`

Value variable.

Definition at line 34 of file Tokenizer.h.

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

- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v21r10p1/GaudiKernel/GaudiKernel/Tokenizer.h
- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v21r10p1/GaudiKernel/src/Lib/Tokenizer.cpp