00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00014 
00015 #ifndef OCTANE_STRINGPARSER_HPP_INCLUDED
00016 #define OCTANE_STRINGPARSER_HPP_INCLUDED
00017 
00018 #include <string>
00019 
00033 class stringparser {
00034 
00035 public:
00038     stringparser(const std::string &_s) : s(_s), idx(0) { ; }
00039 
00043     std::string get_token()
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     }
00057 
00058 private:
00059     const std::string s;
00060     std::string::size_type idx;
00061 };
00062 
00063 #endif // OCTANE_STRINGPARSER_HPP_INCLUDED