#include <StringParse.h>
Public Member Functions | |
int | intpiece (const int &num) |
int | intpiece (const int &num) |
long | longpiece (const int &num) |
long | longpiece (const int &num) |
float | numpiece (const int &num) |
float | numpiece (const int &num) |
std::string | piece (const int &num) |
std::string | piece (const int &num) |
unsigned | string_size (void) const |
unsigned | string_size (void) const |
StringParse () | |
StringParse (std::string input) | |
StringParse () | |
StringParse (std::string input) | |
~StringParse () | |
~StringParse () | |
Private Attributes | |
std::string | m_lstring |
std::vector< std::string > | m_lsubstring |
std::vector< std::string > | m_lsubstring |
int | m_nword |
std::string | m_past_end |
|
00015 { 00016 m_past_end="?!?"; 00017 m_lstring=input; 00018 m_nword=0; 00019 std::string::size_type pos=0; 00020 std::string::size_type prev_pos=0; 00021 while((pos=input.find_first_of(' ',pos)) != std::string::npos){ 00022 m_lsubstring.push_back(input.substr(prev_pos,pos-prev_pos)); 00023 prev_pos=++pos; 00024 } 00025 // special handling for last substring 00026 m_lsubstring.push_back(input.substr(prev_pos,pos-prev_pos)); 00027 m_nword=m_lsubstring.size(); 00028 }
|
|
|
|
00064 { 00065 }
|
|
|
|
|
|
|
|
|
|
00037 { 00038 if(num <= m_nword){ 00039 int i= atoi(m_lsubstring[num-1].c_str()); 00040 return i; 00041 } 00042 else { 00043 return -1; 00044 } 00045 }
|
|
|
|
00046 { 00047 if(num <= m_nword){ 00048 int i= atol(m_lsubstring[num-1].c_str()); 00049 return i; 00050 } 00051 else { 00052 return -1; 00053 } 00054 }
|
|
|
|
00055 { 00056 if(num <= m_nword){ 00057 float x= atof(m_lsubstring[num-1].c_str()); 00058 return x; 00059 } 00060 else { 00061 return -1.1; 00062 } 00063 }
|
|
|
|
00029 { 00030 if(num <= m_nword){ 00031 return m_lsubstring[num-1]; 00032 } 00033 else { 00034 return m_past_end; 00035 } 00036 }
|
|
|
|
00040 { return m_nword; }
|
|
|
|
|
|
|
|
|
|
|