2
#include "EStdStringTokenizer.h"
3
//#include <iostream> // only for debuggering
5
enum quoteEnum { NO_QUOTE=0, SINGLE_QUOTE, DOUBLE_QUOTE };
7
todo: implement a map<char,int> to count opening/closing quotes so i can add support
8
for open/close { } without having to add to the enum, add if(), etc.
9
map['\''] = 0. increment on an opener, decrement on a closer.
13
EStdStringTokenizer::EStdStringTokenizer()
17
void EStdStringTokenizer::tokenize( const string &str, const string & sep )
19
const string::size_type ssize = str.size();
20
if ( ssize == 0 ) return;
23
this->m_list.push( str ); // += str;
26
if( string::npos == str.find_first_of( sep ) )
28
this->m_list.push( str ); // += str;
32
int quoted = NO_QUOTE;
36
for( string::size_type pos = 0; (pos < ssize); pos++ )
40
if ( (chat == '\"' ) && !quoted)
42
quoted = DOUBLE_QUOTE;
45
else if ( ( chat == '\'') && !quoted)
47
quoted = SINGLE_QUOTE;
50
else if ( ( (chat == '\"') && (quoted == DOUBLE_QUOTE) )
52
( (chat == '\'') && (quoted == SINGLE_QUOTE) ) )
60
for( string::size_type i = 0; i < sep.size(); i++ )
64
m_list.push( mystr ); // += mystr;
72
if( addit ) mystr += chat;
74
if( ! mystr.empty() ) m_list.push( mystr ); // += mystr;
79
EStdStringTokenizer::hasMoreTokens() const
81
return ! this->m_list.empty();
84
EStdStringTokenizer::nextToken()
86
string foo = this->m_list.front();
91
EStdStringTokenizer::~EStdStringTokenizer()