CMS 3D CMS Logo

Tokenizer.cc
Go to the documentation of this file.
2 
3 Tokenizer::Tokenizer(const std::string & sep, const std::string & input, bool alsoempty) {
4  size_type i=0, j=0;
5  while( (j=input.find(sep,i))!=std::string::npos) {
6  if (alsoempty || (j>i) ) push_back(input.substr(i,j-i));
7  i = j+sep.size();
8  }
9  if (alsoempty || (i<input.size()) ) push_back(input.substr(i));
10 }
11 
12 void Tokenizer::join(std::string & out, const std::string & sep, bool alsoempty) const {
13  for (super::const_iterator p=begin(); p!=end(); p++)
14  if (alsoempty || (!(*p).empty()) ) { out+=*p; out+=sep;}
15 }
uint16_t size_type
static std::string const input
Definition: EdmProvDump.cc:44
Tokenizer(const std::string &sep, const std::string &input, bool alsoempty=true)
Definition: Tokenizer.cc:3
void join(std::string &out, const std::string &sep, bool alsoempty=true) const
Definition: Tokenizer.cc:12
#define end
Definition: vmac.h:37
#define begin
Definition: vmac.h:30