| 298 | // |
| 299 | //////////////////////////////////////////////////////////////////////////////////// |
| 300 | class tokenizer |
| 301 | { |
| 302 | enum |
| 303 | { |
| 304 | TOKEN_GAP_LEN = 15, |
| 305 | }; |
| 306 | |
| 307 | public: |
| 308 | // Constructors |
| 309 | //-------------- |
| 310 | tokenizer() : mLoc(0) |
| 311 | {} |
| 312 | tokenizer(const char* t, const char* gap) |
| 313 | { |
| 314 | strncpy(mGap, gap, TOKEN_GAP_LEN); // Safe String Copy |
| 315 | mGap[TOKEN_GAP_LEN-1] = 0; // Make Sure We Have A Null Terminated Str |
| 316 | |
| 317 | char* temp = (char*)t; |
| 318 | mLoc = str::tok(temp, mGap); |
| 319 | } |
| 320 | |
| 321 | // Assignment Operator |
| 322 | //--------------------- |
| 323 | void operator= (const tokenizer &t) |
| 324 | { |
| 325 | mLoc = t.mLoc; |
| 326 | str::cpy(mGap, t.mGap); |
| 327 | } |
| 328 | |
| 329 | // Equality Operators |
| 330 | //-------------------- |
| 331 | bool operator==(const tokenizer &t) {return (mLoc==t.mLoc);} |
| 332 | bool operator!=(const tokenizer &t) {return !(operator==(t));} |
| 333 | |
| 334 | |
| 335 | |
| 336 | // DeReference Operator |
| 337 | //---------------------- |
| 338 | const char* operator*() |
| 339 | { |
| 340 | assert(mLoc); |
| 341 | return mLoc; |
| 342 | } |
| 343 | |
| 344 | // Inc & Dec Operators |
| 345 | //-------------------- |
| 346 | void operator++(int) |
| 347 | { |
| 348 | assert(mLoc && mGap[0]); |
| 349 | mLoc = str::tok(NULL, mGap); |
| 350 | } |
| 351 | |
| 352 | // Data |
| 353 | //------ |
| 354 | private: |
| 355 | char* mLoc; |
| 356 | char mGap[TOKEN_GAP_LEN]; |
| 357 | }; |