CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Types | Public Member Functions
Tokenizer Class Reference

#include <Tokenizer.h>

Inheritance diagram for Tokenizer:

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.

3  {
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 }
int i
Definition: DBlmapReader.cc:9
uint16_t size_type
static std::string const input
Definition: EdmProvDump.cc:43
int j
Definition: DBlmapReader.cc:9

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, AlCaHLTBitMon_ParallelJobs::p, and cmsHarvester::sep.

12  {
13  for (super::const_iterator p=begin(); p!=end(); p++)
14  if (alsoempty || (!(*p).empty()) ) { out+=*p; out+=sep;}
15 }
#define end
Definition: vmac.h:37
tuple out
Definition: dbtoconf.py:99
#define begin
Definition: vmac.h:30