CMS 3D CMS Logo

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 mps_fire::i.

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 }
uint16_t size_type
static std::string const input
Definition: EdmProvDump.cc:44

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 AlCaHLTBitMon_ParallelJobs::p.

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
#define begin
Definition: vmac.h:30