Octane v1.01.20 - The Open Compression Toolkit for C++ http://octane.sourceforge.net/
Homepage | Main | Modules | Class Hierarchy | Compound List | File List | Compound Members | Related Pages

stringparser Class Reference
[Utility]

#include <stringparser.hpp>

List of all members.


Detailed Description

Simple string parser.

Breaks up a string into space-delimited tokens.

The class operates on a copy of the string, to avoid any synchronization issues. This should not be a problem for performance if the string implementation is reference counted.

Definition at line 33 of file stringparser.hpp.

Public Member Functions

 stringparser (const std::string &_s)
 Constructor.

std::string get_token ()
 Get next token from string.


Constructor & Destructor Documentation

stringparser::stringparser const std::string &  _s  )  [inline]
 

Constructor.

Parameters:
_s - the string to parse.

Definition at line 38 of file stringparser.hpp.

00038 : s(_s), idx(0) { ; }


Member Function Documentation

std::string stringparser::get_token  )  [inline]
 

Get next token from string.

Returns:
the next token.
Todo:
should be able to handle quoted tokens.

Definition at line 43 of file stringparser.hpp.

Referenced by OctaneTester::ParseCommand().

00044     {
00045         if (idx == std::string::npos) return "";
00046 
00047         std::string::size_type p = s.find_first_not_of(' ', idx);
00048 
00049         if (p == std::string::npos) return "";
00050 
00051         idx = s.find_first_of(' ', p);
00052 
00053         if (idx == std::string::npos) return s.substr(p);
00054 
00055         return s.substr(p, idx - p);
00056     }


The documentation for this class was generated from the following file:  
Generated on 20 May 2004 by doxygen 1.3.3