#include <Parse.h>
Public Member Functions | |
Parse () | |
Parse (const std::string &) | |
Parse (const std::string &, const std::string &) | |
Parse (const std::string &, const std::string &, short) | |
~Parse () | |
short | issplit (char) |
void | getsplit (void) |
void | getsplit (std::string &) |
std::string | getword (void) |
void | getword (std::string &) |
void | getword (std::string &, std::string &, int) |
std::string | getrest () |
void | getrest (std::string &) |
long | getvalue (void) |
void | setbreak (char) |
int | getwordlen (void) |
int | getrestlen (void) |
void | enablebreak (char c) |
void | disablebreak (char c) |
void | getline (void) |
void | getline (std::string &) |
size_t | getptr (void) |
void | EnableQuote (bool b) |
Private Attributes | |
std::string | pa_the_str |
std::string | pa_splits |
std::string | pa_ord |
size_t | pa_the_ptr |
char | pa_breakchar |
char | pa_enable |
char | pa_disable |
short | pa_nospace |
bool | pa_quote |
Parse.h - parse a string
Written: 1999-Feb-10 grymse@alhem.net
Definition at line 35 of file Parse.h.
|
Definition at line 40 of file Parse.cpp.
00041 :pa_the_str("") 00042 ,pa_splits("") 00043 ,pa_ord("") 00044 ,pa_the_ptr(0) 00045 ,pa_breakchar(0) 00046 ,pa_enable(0) 00047 ,pa_disable(0) 00048 ,pa_nospace(0) 00049 ,pa_quote(false) 00050 { 00051 } |
|
Definition at line 53 of file Parse.cpp.
00054 :pa_the_str(s) 00055 ,pa_splits("") 00056 ,pa_ord("") 00057 ,pa_the_ptr(0) 00058 ,pa_breakchar(0) 00059 ,pa_enable(0) 00060 ,pa_disable(0) 00061 ,pa_nospace(0) 00062 ,pa_quote(false) 00063 { 00064 } |
|
Definition at line 66 of file Parse.cpp.
00067 :pa_the_str(s) 00068 ,pa_splits(sp) 00069 ,pa_ord("") 00070 ,pa_the_ptr(0) 00071 ,pa_breakchar(0) 00072 ,pa_enable(0) 00073 ,pa_disable(0) 00074 ,pa_nospace(0) 00075 ,pa_quote(false) 00076 { 00077 } |
|
Definition at line 79 of file Parse.cpp.
00080 :pa_the_str(s) 00081 ,pa_splits(sp) 00082 ,pa_ord("") 00083 ,pa_the_ptr(0) 00084 ,pa_breakchar(0) 00085 ,pa_enable(0) 00086 ,pa_disable(0) 00087 ,pa_nospace(1) 00088 ,pa_quote(false) 00089 { 00090 } |
|
Definition at line 93 of file Parse.cpp.
00094 { 00095 } |
|
Definition at line 58 of file Parse.h. References pa_disable.
00058 { 00059 pa_disable = c; 00060 } |
|
Definition at line 55 of file Parse.h. References pa_enable.
00055 { 00056 pa_enable = c; 00057 } |
|
Definition at line 64 of file Parse.h. References pa_quote.
00064 { pa_quote = b; } |
|
Definition at line 328 of file Parse.cpp. References getline(), and pa_ord.
|
|
Definition at line 306 of file Parse.cpp. References pa_ord, pa_the_ptr, and pa_the_str. Referenced by getline().
00307 { 00308 size_t x; 00309 00310 // while (C && (C == 13 || C == 10)) 00311 // pa_the_ptr++; 00312 x = pa_the_ptr; 00313 while (C && C != 13 && C != 10) 00314 pa_the_ptr++; 00315 /* 00316 char tmp[4096]; 00317 strncpy(tmp,pa_the_str.c_str() + x,pa_the_ptr - x); 00318 tmp[pa_the_ptr - x] = 0; 00319 pa_ord = tmp; 00320 */ 00321 pa_ord = (x < pa_the_str.size()) ? pa_the_str.substr(x,pa_the_ptr - x) : ""; 00322 if (C == 13) 00323 pa_the_ptr++; 00324 if (C == 10) 00325 pa_the_ptr++; 00326 } |
|
Definition at line 63 of file Parse.h. References pa_the_ptr.
00063 { return pa_the_ptr; } |
|
Definition at line 255 of file Parse.cpp. References C, issplit(), pa_the_ptr, and pa_the_str.
00256 { 00257 while (C && (C == ' ' || C == 9 || issplit(C))) 00258 pa_the_ptr++; 00259 s = (pa_the_ptr < pa_the_str.size()) ? pa_the_str.substr(pa_the_ptr) : ""; 00260 } |
|
Definition at line 246 of file Parse.cpp. References C, issplit(), pa_the_ptr, and pa_the_str.
00247 { 00248 std::string s; 00249 while (C && (C == ' ' || C == 9 || issplit(C))) 00250 pa_the_ptr++; 00251 s = (pa_the_ptr < pa_the_str.size()) ? pa_the_str.substr(pa_the_ptr) : ""; 00252 return s; 00253 } |
|
Definition at line 295 of file Parse.cpp. References C, issplit(), pa_the_ptr, and pa_the_str.
00296 { 00297 int y = pa_the_ptr,len; 00298 00299 while (C && (C == ' ' || C == 9 || issplit(C))) 00300 pa_the_ptr++; 00301 len = strlen(pa_the_str.c_str() + pa_the_ptr); 00302 pa_the_ptr = y; 00303 return len; 00304 } |
|
Definition at line 231 of file Parse.cpp. References getsplit(), and pa_ord.
00232 { 00233 Parse::getsplit(); 00234 s = pa_ord; 00235 } |
|
Definition at line 107 of file Parse.cpp. References issplit(), pa_ord, pa_the_ptr, and pa_the_str. Referenced by getsplit().
00108 { 00109 size_t x; 00110 00111 if (C == '=') 00112 { 00113 x = pa_the_ptr++; 00114 } else 00115 { 00116 while (C && (issplit(C))) 00117 pa_the_ptr++; 00118 x = pa_the_ptr; 00119 while (C && !issplit(C) && C != '=') 00120 pa_the_ptr++; 00121 } 00122 if (x == pa_the_ptr && C == '=') 00123 pa_the_ptr++; 00124 // 00125 /* 00126 char tmp[4096]; 00127 strncpy(tmp,pa_the_str.c_str() + x,pa_the_ptr - x); 00128 tmp[pa_the_ptr - x] = 0; 00129 pa_ord = tmp; 00130 */ 00131 pa_ord = (x < pa_the_str.size()) ? pa_the_str.substr(x,pa_the_ptr - x) : ""; 00132 } |
|
Definition at line 262 of file Parse.cpp. References getword(), and pa_ord.
00263 { 00264 Parse::getword(); 00265 return atol(pa_ord.c_str()); 00266 } |
|
Definition at line 237 of file Parse.cpp. References getword(), and pa_ord.
00238 { 00239 Parse::getword(); 00240 s = ""; 00241 while (s.size() + pa_ord.size() < (size_t)l) 00242 s += fill; 00243 s += pa_ord; 00244 } |
|
Definition at line 226 of file Parse.cpp. References getword().
00227 { 00228 s = Parse::getword(); 00229 } |
|
Definition at line 134 of file Parse.cpp. References C, DEB, issplit(), pa_breakchar, pa_disable, pa_enable, pa_nospace, pa_ord, pa_quote, pa_the_ptr, and pa_the_str. Referenced by getvalue(), getword(), SimpleParser::preprocessor(), BaseParser::preprocessor(), and read_makefile().
00135 { 00136 size_t x; 00137 int disabled = 0; 00138 int quote = 0; 00139 int rem = 0; 00140 00141 if (pa_nospace) 00142 { 00143 while (C && issplit(C)) 00144 pa_the_ptr++; 00145 x = pa_the_ptr; 00146 while (C && !issplit(C) && (C != pa_breakchar || !pa_breakchar || disabled)) 00147 { 00148 if (pa_breakchar && C == pa_disable) 00149 disabled = 1; 00150 if (pa_breakchar && C == pa_enable) 00151 disabled = 0; 00152 if (pa_quote && C == '"') 00153 quote = 1; 00154 pa_the_ptr++; 00155 while (quote && C && C != '"') 00156 { 00157 pa_the_ptr++; 00158 } 00159 if (pa_quote && C == '"') 00160 { 00161 pa_the_ptr++; 00162 } 00163 quote = 0; 00164 } 00165 } else 00166 { 00167 if (C == pa_breakchar && pa_breakchar) 00168 { 00169 x = pa_the_ptr++; 00170 rem = 1; 00171 } else 00172 { 00173 while (C && (C == ' ' || C == 9 || C == 13 || C == 10 || issplit(C))) 00174 pa_the_ptr++; 00175 x = pa_the_ptr; 00176 DEB(printf("Split starts at %d\n",x);) 00177 while (C && C != ' ' && C != 9 && C != 13 && C != 10 && !issplit(C) && 00178 (C != pa_breakchar || !pa_breakchar || disabled)) 00179 { 00180 DEB(printf("Char '%c'\n",C);) 00181 if (pa_breakchar && C == pa_disable) 00182 disabled = 1; 00183 if (pa_breakchar && C == pa_enable) 00184 disabled = 0; 00185 if (pa_quote && C == '"') 00186 { 00187 quote = 1; 00188 pa_the_ptr++; 00189 while (quote && C && C != '"') 00190 { 00191 pa_the_ptr++; 00192 } 00193 if (pa_quote && C == '"') 00194 { 00195 pa_the_ptr++; 00196 } 00197 } 00198 else 00199 pa_the_ptr++; 00200 quote = 0; 00201 } 00202 pa_the_ptr++; 00203 rem = 1; 00204 } 00205 if (x == pa_the_ptr && C == pa_breakchar && pa_breakchar) 00206 pa_the_ptr++; 00207 } 00208 // 00209 /* 00210 char tmp[4096]; 00211 strncpy(tmp,pa_the_str.c_str() + x,pa_the_ptr - x); 00212 tmp[pa_the_ptr - x - rem] = 0; 00213 pa_ord = tmp; 00214 */ 00215 if (x < pa_the_str.size()) 00216 { 00217 pa_ord = pa_the_str.substr(x,pa_the_ptr - x - rem); 00218 } 00219 else 00220 { 00221 pa_ord = ""; 00222 } 00223 return pa_ord; 00224 } |
|
Definition at line 273 of file Parse.cpp. References C, issplit(), pa_breakchar, and pa_the_ptr.
00274 { 00275 size_t x,y = pa_the_ptr,len; 00276 00277 if (C == pa_breakchar && pa_breakchar) 00278 { 00279 x = pa_the_ptr++; 00280 } else 00281 { 00282 while (C && (C == ' ' || C == 9 || C == 13 || C == 10 || issplit(C))) 00283 pa_the_ptr++; 00284 x = pa_the_ptr; 00285 while (C && C != ' ' && C != 9 && C != 13 && C != 10 && !issplit(C) && (C != pa_breakchar || !pa_breakchar)) 00286 pa_the_ptr++; 00287 } 00288 if (x == pa_the_ptr && C == pa_breakchar && pa_breakchar) 00289 pa_the_ptr++; 00290 len = pa_the_ptr - x; 00291 pa_the_ptr = y; 00292 return len; 00293 } |
|
Definition at line 99 of file Parse.cpp. References pa_splits. Referenced by getrest(), getrestlen(), getsplit(), getword(), and getwordlen().
|
|
Definition at line 268 of file Parse.cpp. References pa_breakchar.
00269 { 00270 pa_breakchar = c; 00271 } |
|
Definition at line 71 of file Parse.h. Referenced by getword(), getwordlen(), and setbreak(). |
|
Definition at line 73 of file Parse.h. Referenced by disablebreak(), and getword(). |
|
Definition at line 72 of file Parse.h. Referenced by enablebreak(), and getword(). |
|
Definition at line 74 of file Parse.h. Referenced by getword(). |
|
Definition at line 69 of file Parse.h. Referenced by getline(), getsplit(), getvalue(), and getword(). |
|
Definition at line 75 of file Parse.h. Referenced by EnableQuote(), and getword(). |
|
Definition at line 68 of file Parse.h. Referenced by issplit(). |
|
Definition at line 70 of file Parse.h. Referenced by getline(), getptr(), getrest(), getrestlen(), getsplit(), getword(), and getwordlen(). |
|
Definition at line 67 of file Parse.h. Referenced by getline(), getrest(), getrestlen(), getsplit(), and getword(). |