MOOS 0.2375
/home/toby/moos-ivp/MOOS-2375-Oct0611/Tools/Graphical/libAlogTools/alogTools/utils.cpp
Go to the documentation of this file.
00001 #include "utils.h"
00002 
00003 using namespace std;
00004 
00005   // This function nicked from
00006   // http://oopweb.com/CPP/Documents/CPPHOWTO/Volume/C++Programming-HOWTO-7.html
00007   void Tokenize(const string& str,
00008                 vector<string>& tokens,
00009                 const string& delimiters)
00010   {
00011       // Skip delimiters at beginning.
00012       string::size_type lastPos = str.find_first_not_of(delimiters, 0);
00013       // Find first "non-delimiter".
00014       string::size_type pos     = str.find_first_of(delimiters, lastPos);
00015 
00016       while (string::npos != pos || string::npos != lastPos)
00017       {
00018           // Found a token, add it to the vector.
00019           tokens.push_back(str.substr(lastPos, pos - lastPos));
00020           // Skip delimiters.  Note the "not_of"
00021           lastPos = str.find_first_not_of(delimiters, pos);
00022           // Find next "non-delimiter"
00023           pos = str.find_first_of(delimiters, lastPos);
00024       }
00025   }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines