DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
dunedaq::oks::Oks::Tokenizer Class Reference

String tokenizer. More...

#include <defs.hpp>

Public Member Functions

 Tokenizer (const std::string &s, const char *separator)
 
const std::string next ()
 
bool next (std::string &)
 

Private Attributes

std::string p_string
 
const char * p_delimeters
 
std::string::size_type p_idx
 

Static Private Attributes

static std::string s_empty
 

Detailed Description

String tokenizer.

Definition at line 58 of file defs.hpp.

Constructor & Destructor Documentation

◆ Tokenizer()

dunedaq::oks::Oks::Tokenizer::Tokenizer ( const std::string & s,
const char * separator )

Definition at line 181 of file time.cpp.

181 :
182 p_string(s),
183 p_delimeters(d),
184 p_idx(p_string.find_first_not_of(p_delimeters))
185{
186}
std::string::size_type p_idx
Definition defs.hpp:71
const char * p_delimeters
Definition defs.hpp:70

Member Function Documentation

◆ next() [1/2]

const std::string dunedaq::oks::Oks::Tokenizer::next ( )

Definition at line 189 of file time.cpp.

190{
191 if(p_idx == std::string::npos) return s_empty;
192 std::string::size_type end_idx = p_string.find_first_of(p_delimeters, p_idx);
193 if(end_idx == std::string::npos) end_idx=p_string.length();
194 std::string token = p_string.substr(p_idx, end_idx - p_idx);
195 p_idx = p_string.find_first_not_of(p_delimeters, end_idx);
196 return token;
197}
static std::string s_empty
Definition defs.hpp:73

◆ next() [2/2]

bool dunedaq::oks::Oks::Tokenizer::next ( std::string & token)

Definition at line 200 of file time.cpp.

201{
202 if(p_idx == std::string::npos) {
203 token.clear();
204 return false;
205 }
206
207 std::string::size_type end_idx = p_string.find_first_of(p_delimeters, p_idx);
208 if(end_idx == std::string::npos) end_idx=p_string.length();
209 token.assign(p_string, p_idx, end_idx - p_idx);
210 p_idx = p_string.find_first_not_of(p_delimeters, end_idx);
211 return true;
212}

Member Data Documentation

◆ p_delimeters

const char* dunedaq::oks::Oks::Tokenizer::p_delimeters
private

Definition at line 70 of file defs.hpp.

◆ p_idx

std::string::size_type dunedaq::oks::Oks::Tokenizer::p_idx
private

Definition at line 71 of file defs.hpp.

◆ p_string

std::string dunedaq::oks::Oks::Tokenizer::p_string
private

Definition at line 69 of file defs.hpp.

◆ s_empty

std::string dunedaq::oks::Oks::Tokenizer::s_empty
staticprivate

Definition at line 73 of file defs.hpp.


The documentation for this class was generated from the following files: