votca 2024-dev
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Private Attributes | List of all members
votca::tools::Tokenizer Class Reference

break string into words More...

#include <tokenizer.h>

Collaboration diagram for votca::tools::Tokenizer:
Collaboration graph
[legend]

Public Types

using iterator = boost::tokenizer< boost::char_separator< char > >::iterator
 

Public Member Functions

 Tokenizer (const std::string &str, const char *separators)
 startup tokenization
 
 Tokenizer (const std::string &str, const std::string &separators)
 
iterator begin ()
 iterator to first element
 
iterator end ()
 end iterator
 
template<class T = std::string>
std::vector< T > ToVector ()
 store all words in a vector of type T, does type conversion.
 

Private Attributes

std::unique_ptr< boost::tokenizer< boost::char_separator< char > > > tok_
 
std::string str_
 

Detailed Description

break string into words

This class wraps boost::tokenizer to break a string into words. A list of delimeters can be freely choosen.

Definition at line 72 of file tokenizer.h.

Member Typedef Documentation

◆ iterator

using votca::tools::Tokenizer::iterator = boost::tokenizer<boost::char_separator<char> >::iterator

Definition at line 74 of file tokenizer.h.

Constructor & Destructor Documentation

◆ Tokenizer() [1/2]

votca::tools::Tokenizer::Tokenizer ( const std::string &  str,
const char *  separators 
)
inline

startup tokenization

Parameters
strstring to break up
separatorslist of separators

After initialization,the words can be accessed using the iterator interface or directly transferred to a vector ToVector of ConvertToVector.

Definition at line 85 of file tokenizer.h.

◆ Tokenizer() [2/2]

votca::tools::Tokenizer::Tokenizer ( const std::string &  str,
const std::string &  separators 
)
inline

Definition at line 90 of file tokenizer.h.

Member Function Documentation

◆ begin()

iterator votca::tools::Tokenizer::begin ( )
inline

iterator to first element

Returns
begin iterator

Definition at line 97 of file tokenizer.h.

◆ end()

iterator votca::tools::Tokenizer::end ( )
inline

end iterator

Returns
end iterator

Definition at line 102 of file tokenizer.h.

◆ ToVector()

template<class T = std::string>
std::vector< T > votca::tools::Tokenizer::ToVector ( )
inline

store all words in a vector of type T, does type conversion.

Returns
storage vector

Definition at line 109 of file tokenizer.h.

Member Data Documentation

◆ str_

std::string votca::tools::Tokenizer::str_
private

Definition at line 119 of file tokenizer.h.

◆ tok_

std::unique_ptr<boost::tokenizer<boost::char_separator<char> > > votca::tools::Tokenizer::tok_
private

Definition at line 118 of file tokenizer.h.


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