CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 }
int i
Definition: DBlmapReader.cc:9
uint16_t size_type
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
int j
Definition: DBlmapReader.cc:9
#define end
Definition: vmac.h:38
tuple out
Definition: dbtoconf.py:99
#define begin
Definition: vmac.h:31