Gaudi Framework, version v23r0

Home   Generated: Mon Jan 30 2012
Public Member Functions | Private Attributes

Tokenizer::Token Class Reference

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

#include <Tokenizer.h>

Collaboration diagram for Tokenizer::Token:
Collaboration graph
[legend]

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.
Tokenoperator= (const Token &copy)
 Assignment operator.
bool operator== (const Token &copy) const
long length () const
 Total token length.
const std::stringtag () const
 Acces tag value.
const std::stringvalue () 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.

                              : m_length(copy.m_length), m_tag(copy.m_tag), m_value(copy.m_value)  {
    }
Tokenizer::Token::Token (  ) [inline]

Standard constructor.

Definition at line 40 of file Tokenizer.h.

             : m_length(0)  {
    }
virtual Tokenizer::Token::~Token (  ) [inline, virtual]

Standard Destructor.

Definition at line 45 of file Tokenizer.h.

                        {
    }

Member Function Documentation

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

Total token length.

Definition at line 54 of file Tokenizer.h.

                            {
      return m_length;
    }
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.

                                                                                                                                                                           {
  long lenTagBeg   = ::strlen(tagBeg);
  long lenTagEnd   = ::strlen(tagEnd);
  long lenValBeg   = ::strlen(valBeg);
  long lenValEnd   = ::strlen(valEnd);
  long lenDelim    = ::strlen(delim);
  long lenEq       = ::strlen(eq);
  long slen        = s.length();
  long start       = st;
  while(::strncmp(s.c_str()+start,delim,lenDelim)==0) start += lenDelim;
  long posTag      = (lenTagBeg>0) ? s.find(tagBeg, start) + lenTagBeg : start;
  long posDelim    = s.find(delim,posTag) > 0 ? s.find(delim,posTag) : slen;
  long posEq       = s.find(eq, posTag)   > 0 ? s.find(eq, posTag) : posDelim-posTag;
  long lenTag      = (lenTagEnd>0)   ? s.find(tagEnd, posTag)-posTag : (posEq>0) ? (posEq>posTag) ? posEq-posTag : posDelim-posTag : posDelim;
  posEq            = s.find(eq, posTag+lenTag+lenTagEnd)+lenEq;
  long posVal      = (lenValBeg>0)   ? s.find(valBeg, posEq)+lenValBeg : posEq;
  posDelim         = (lenDelim>0)    ? s.find(delim, posVal+lenValBeg) : slen;
  long lenVal      = (lenValEnd>0)   ? s.find(valEnd, posVal)-posVal : ((posDelim>=0) ? posDelim : slen)-posVal;

  m_tag = m_value  = "";
  // Ooops: Valid tag found:
  if ( start  >= 0 && posTag >= 0 )   {
    m_tag    = s.substr(posTag, lenTag);
    m_length = posTag+m_tag.length()+lenTagEnd-st;
  }
  // Ooops: there is also a value:
  if ( posVal >= 0 && lenVal >= 0 )   {
    m_value  = s.substr(posVal, lenVal);
    m_length = posVal+m_value.length()+lenValEnd-st;
  }
  while(::strncmp(s.c_str()+start+m_length,delim,lenDelim)==0) m_length += lenDelim;
}
Tokenizer::Token & Tokenizer::Token::operator= ( const Token copy )

Assignment operator.

Definition at line 21 of file Tokenizer.cpp.

                                                               {
  m_length=copy.m_length;
  m_tag=copy.m_tag;
  m_value=copy.m_value;
  return *this;
}
bool Tokenizer::Token::operator== ( const Token copy ) const [inline]

Definition at line 50 of file Tokenizer.h.

                                                  {
      return m_tag == copy.m_tag, m_value == copy.m_value && m_length == copy.m_length;
    }
void Tokenizer::Token::resolveValue (  )

Resolve value from environment.

Definition at line 29 of file Tokenizer.cpp.

                                   {
  std::string res;
  if ( System::resolveEnv(m_value, res).isSuccess() )  {
    m_value = res;
  }
}
const std::string& Tokenizer::Token::tag (  ) const [inline]

Acces tag value.

Definition at line 58 of file Tokenizer.h.

                                      {
      return m_tag;
    }
const std::string& Tokenizer::Token::value (  ) const [inline]

Access value.

Definition at line 62 of file Tokenizer.h.

                                      {
      return m_value;
    }

Member Data Documentation

Toke length.

Definition at line 30 of file Tokenizer.h.

Tag variable.

Definition at line 32 of file Tokenizer.h.

Value variable.

Definition at line 34 of file Tokenizer.h.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines

Generated at Mon Jan 30 2012 13:53:24 for Gaudi Framework, version v23r0 by Doxygen version 1.7.2 written by Dimitri van Heesch, © 1997-2004