CMS 3D CMS Logo

Public Types | Public Member Functions

Tokenizer Class Reference

#include <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.

                                                                                   {
  size_type i=0, j=0;
  while( (j=input.find(sep,i))!=std::string::npos) {
    if (alsoempty || (j>i) ) push_back(input.substr(i,j-i));
    i = j+sep.size();
  }
  if (alsoempty || (i<input.size()) ) push_back(input.substr(i));
}

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.

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