![]() |
|
|
Generated: 18 Jul 2008 |
#include <Tokenizer.h>
Collaboration diagram for Tokenizer::Token:

Definition at line 28 of file Tokenizer.h.
Public Member Functions | |
| Token (const Token ©) | |
| 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 ©) |
| Assignment operator. | |
| bool | operator== (const Token ©) 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. | |
| Tokenizer::Token::Token | ( | const Token & | copy | ) | [inline] |
| Tokenizer::Token::Token | ( | ) | [inline] |
| virtual Tokenizer::Token::~Token | ( | ) | [inline, virtual] |
| 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 | ) |
| bool Tokenizer::Token::operator== | ( | const Token & | copy | ) | const [inline] |
| 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 }
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().