#include <parser.h>
Public Member Functions | |
CParser (const std::string &str) | |
CParser constructor. | |
~CParser () | |
std::list< CToken * > & | tokens () |
void | _toString (std::string &str) |
void | _removeToken (const std::string &key) |
Private Member Functions | |
char | next_char () |
void | skip_blank () |
bool | end () |
Private Attributes | |
std::list< CToken * > | m_tokens |
char | m_line [1024] |
char | m_key [1024] |
char | m_value [1024] |
char * | m_pt |
CParser class.
Definition at line 37 of file parser.h.
CParser::CParser | ( | const std::string & | str | ) |
CParser constructor.
str | input string |
CParser constructor
str | input string |
Definition at line 31 of file parser.cpp.
{ //copy string unsigned int i; for( i = 0; i < str.length(); i ++ ) { m_line[i] = str.c_str()[i]; } m_line[i] = 0; m_pt = m_line; //while not reaching the end while( !end() ) { skip_blank(); if( end() ) break; //copy key char * pkey = m_key; char ch = next_char(); while( ch != ' ' && ch != '=' && !end() ) { *pkey ++ = ch; ch = next_char(); } if( ch != '=' && ch != ' ') *pkey++ = ch; *pkey = 0; if( ch == ' ' ) { skip_blank(); } if( ch != '=' ) { CToken * tk = new CToken; assert(tk); tk->m_key = std::string( m_key ); m_tokens.push_back( tk ); continue; } if( end() ) break; ch = next_char(); while( ch != '(' ) ch = next_char(); char * pvalue = m_value; while( ch != ')' && !end() ) { *pvalue ++ = ch; ch = next_char(); } *pvalue++ = ch; *pvalue = 0; CToken * tk = new CToken; assert(tk); tk->m_key = std::string( m_key ); tk->m_value = std::string( m_value ); m_tokens.push_back( tk ); } };
CParser::~CParser | ( | ) |
void CParser::_removeToken | ( | const std::string & | key | ) |
Remove the token key=(...) from the current string
key | the key to the token to be removed |
Remove the token with the prescribed key in the token list
Definition at line 153 of file parser.cpp.
void CParser::_toString | ( | std::string & | str | ) |
Convert the list of tokens to a string
str | the output string |
Convert the list of tokens to a string
Definition at line 136 of file parser.cpp.
bool CParser::end | ( | ) | [private] |
verify if we
Whether the end of the string has been reached
Definition at line 128 of file parser.cpp.
{ return ( (*m_pt) == 0 ); };
char CParser::next_char | ( | ) | [private] |
get the next char in the current string
Get the next char in the buffer, move the current pointer to the next position
Definition at line 110 of file parser.cpp.
void CParser::skip_blank | ( | ) | [private] |
skip blank spaces
Skip the blank space in the current position, reach the next non-blank char
Definition at line 120 of file parser.cpp.
std::list<CToken*>& MeshLib::CParser::tokens | ( | ) | [inline] |
char MeshLib::CParser::m_key[1024] [private] |
char MeshLib::CParser::m_line[1024] [private] |
char* MeshLib::CParser::m_pt [private] |
std::list<CToken*> MeshLib::CParser::m_tokens [private] |
char MeshLib::CParser::m_value[1024] [private] |