| # Gaudi Framework, version v20r2
Generated: 18 Jul 2008

- Main Page
- Namespaces
- Classes
- Files
- Directories
- Related Pages

- Search for |

- Alphabetical List
- Class List
- Class Hierarchy
- Class Members

# Tokenizer::Token Class Reference

`#include <Tokenizer.h>`

Collaboration diagram for Tokenizer::Token:

[legend]
List of all members.

## Detailed Description

Definition of the sub-class Token.

Definition at line 28 of file Tokenizer.h.

## 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.

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

References std::basic_string< _CharT, _Traits, _Alloc >::length(), m_length, m_tag, m_value, and Gaudi::Units::s.

Referenced by Tokenizer::analyse().

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

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

Assignment operator.

Definition at line 19 of file Tokenizer.cpp.

References m_length, m_tag, and m_value.

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

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

Definition at line 50 of file Tokenizer.h.

References m_length, m_tag, and m_value.

    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.

References m_length.

Referenced by Tokenizer::analyse().

    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.

References m_tag.

    00058                                       {
    00059       return m_tag;
    00060     }

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

Access value.

Definition at line 62 of file Tokenizer.h.

References m_value.

    00062                                       {
    00063       return m_value;
    00064     }

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

Resolve value from environment.

Definition at line 27 of file Tokenizer.cpp.

References m_value, and System::resolveEnv().

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

## Member Data Documentation

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

Toke length.

Definition at line 30 of file Tokenizer.h.

Referenced by length(), make(), operator=(), and operator==().

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

Tag variable.

Definition at line 32 of file Tokenizer.h.

Referenced by make(), operator=(), operator==(), and tag().

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

Value variable.

Definition at line 34 of file Tokenizer.h.

Referenced by make(), operator=(), operator==(), resolveValue(), and value().

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

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