CMS 3D CMS Logo

Tokenizer Class Reference

Tokenize "input" in a vector<string> at each occurence of "sep". More...

#include <Utilities/General/interface/Tokenizer.h>

List of all members.

Public Types

typedef std::vector< std::string > super

Public Member Functions

void join (std::string &out, const std::string &sep, bool alsoempty=true) const
 Tokenizer (const std::string &sep, const std::string &input, bool alsoempty=true)


Detailed Description

Tokenize "input" in a vector<string> at each occurence of "sep".

Definition at line 9 of file Tokenizer.h.


Member Typedef Documentation

typedef std::vector<std::string> Tokenizer::super

Definition at line 11 of file Tokenizer.h.


Constructor & Destructor Documentation

Tokenizer::Tokenizer ( const std::string &  sep,
const std::string &  input,
bool  alsoempty = true 
)

Definition at line 3 of file Tokenizer.cc.

References i, and j.

00003                                                                                    {
00004   size_type i=0, j=0;
00005   while( (j=input.find(sep,i))!=std::string::npos) {
00006     if (alsoempty || (j>i) ) push_back(input.substr(i,j-i));
00007     i = j+sep.size();
00008   }
00009   if (alsoempty || (i<input.size()) ) push_back(input.substr(i));
00010 }


Member Function Documentation

void Tokenizer::join ( std::string &  out,
const std::string &  sep,
bool  alsoempty = true 
) const

Definition at line 12 of file Tokenizer.cc.

References begin, end, and p.

00012                                                                                  {
00013     for (super::const_iterator p=begin(); p!=end(); p++)
00014       if (alsoempty || (!(*p).empty()) ) { out+=*p; out+=sep;}
00015 }


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:33:41 2009 for CMSSW by  doxygen 1.5.4