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 63 of file defs.hpp.

Constructor & Destructor Documentation

◆ Tokenizer()

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

Definition at line 186 of file time.cpp.

186 :
187 p_string(s),
188 p_delimeters(d),
189 p_idx(p_string.find_first_not_of(p_delimeters))
190{
191}
std::string::size_type p_idx
Definition defs.hpp:76
const char * p_delimeters
Definition defs.hpp:75

Member Function Documentation

◆ next() [1/2]

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

Definition at line 194 of file time.cpp.

195{
196 if(p_idx == std::string::npos) return s_empty;
197 std::string::size_type end_idx = p_string.find_first_of(p_delimeters, p_idx);
198 if(end_idx == std::string::npos) end_idx=p_string.length();
199 std::string token = p_string.substr(p_idx, end_idx - p_idx);
200 p_idx = p_string.find_first_not_of(p_delimeters, end_idx);
201 return token;
202}
static std::string s_empty
Definition defs.hpp:78

◆ next() [2/2]

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

Definition at line 205 of file time.cpp.

206{
207 if(p_idx == std::string::npos) {
208 token.clear();
209 return false;
210 }
211
212 std::string::size_type end_idx = p_string.find_first_of(p_delimeters, p_idx);
213 if(end_idx == std::string::npos) end_idx=p_string.length();
214 token.assign(p_string, p_idx, end_idx - p_idx);
215 p_idx = p_string.find_first_not_of(p_delimeters, end_idx);
216 return true;
217}

Member Data Documentation

◆ p_delimeters

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

Definition at line 75 of file defs.hpp.

◆ p_idx

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

Definition at line 76 of file defs.hpp.

◆ p_string

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

Definition at line 74 of file defs.hpp.

◆ s_empty

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

Definition at line 78 of file defs.hpp.


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