bpp-core3
3.0.0
|
A tokenizer for strings. More...
#include <Bpp/Text/StringTokenizer.h>
Public Member Functions | |
StringTokenizer (const std::string &s, const std::string &delimiters=" \t\n\f\r", bool solid=false, bool allowEmptyTokens=false) | |
Build a new StringTokenizer from a string. More... | |
virtual | ~StringTokenizer () |
StringTokenizer () | |
const std::string & | nextToken () |
Get the next available token. If no token is availbale, throw an Exception. More... | |
bool | hasMoreToken () const |
Tell if some tokens are still available. More... | |
size_t | numberOfRemainingTokens () const |
Tell how many tokens are available. More... | |
const std::string & | getToken (size_t pos) const |
Get a particular token. More... | |
const std::deque< std::string > & | getTokens () const |
Retrieve all tokens. More... | |
void | removeEmptyTokens () |
remove all empty token from the current position. More... | |
std::string | unparseRemainingTokens () const |
Protected Attributes | |
std::deque< std::string > | tokens_ |
Where the tokens are stored. More... | |
std::deque< std::string > | splits_ |
size_t | currentPosition_ |
the current position in the token list. More... | |
A tokenizer for strings.
Splits a string according to a given (set of) delimiter(s).
Definition at line 58 of file StringTokenizer.h.
StringTokenizer::StringTokenizer | ( | const std::string & | s, |
const std::string & | delimiters = " \t\n\f\r" , |
||
bool | solid = false , |
||
bool | allowEmptyTokens = false |
||
) |
Build a new StringTokenizer from a string.
s | The string to parse. |
delimiters | Chars that must be considered as delimiters. |
solid | If true, delimiters is considered as a single bloc delimiter. |
allowEmptyTokens | Tell if empty tokens are allowed or should be ignored. |
Definition at line 48 of file StringTokenizer.cpp.
|
inlinevirtual |
Definition at line 79 of file StringTokenizer.h.
|
inline |
Definition at line 82 of file StringTokenizer.h.
|
inline |
Get a particular token.
Do not move the iterator.
pos | The index of the token. |
Definition at line 121 of file StringTokenizer.h.
References tokens_.
|
inline |
Retrieve all tokens.
Definition at line 128 of file StringTokenizer.h.
References tokens_.
Referenced by bpp::Table< T >::addColumn(), bpp::Table< T >::addRow(), bpp::Table< T >::read(), and bpp::DataTable::read().
|
inline |
Tell if some tokens are still available.
Definition at line 101 of file StringTokenizer.h.
References currentPosition_, and tokens_.
Referenced by bpp::ParameterList::getMatchingParameterNames(), bpp::ApplicationTools::getMatrixParameter(), bpp::NumCalcApplicationTools::getVector(), bpp::ApplicationTools::matchingParameters(), bpp::NestedStringTokenizer::nextToken(), nextToken(), and bpp::BppODiscreteDistributionFormat::readDiscreteDistribution().
|
inline |
Get the next available token. If no token is availbale, throw an Exception.
Definition at line 91 of file StringTokenizer.h.
References currentPosition_, hasMoreToken(), and tokens_.
Referenced by bpp::ParameterList::getMatchingParameterNames(), bpp::ApplicationTools::getMatrixParameter(), bpp::NumCalcApplicationTools::getVector(), bpp::ApplicationTools::getVectorParameter(), bpp::ApplicationTools::matchingParameters(), and bpp::BppODiscreteDistributionFormat::readDiscreteDistribution().
|
inline |
Tell how many tokens are available.
Definition at line 111 of file StringTokenizer.h.
References currentPosition_, and tokens_.
Referenced by bpp::ApplicationTools::getMatrixParameter(), bpp::ApplicationTools::getVectorOfVectorsParameter(), bpp::ApplicationTools::getVectorParameter(), and unparseRemainingTokens().
void StringTokenizer::removeEmptyTokens | ( | ) |
remove all empty token from the current position.
Definition at line 103 of file StringTokenizer.cpp.
References currentPosition_, and tokens_.
std::string StringTokenizer::unparseRemainingTokens | ( | ) | const |
Definition at line 112 of file StringTokenizer.cpp.
References currentPosition_, numberOfRemainingTokens(), splits_, and tokens_.
|
protected |
the current position in the token list.
Definition at line 66 of file StringTokenizer.h.
Referenced by hasMoreToken(), bpp::NestedStringTokenizer::nextToken(), nextToken(), numberOfRemainingTokens(), removeEmptyTokens(), and unparseRemainingTokens().
|
protected |
Definition at line 63 of file StringTokenizer.h.
Referenced by StringTokenizer(), and unparseRemainingTokens().
|
protected |
Where the tokens are stored.
Definition at line 62 of file StringTokenizer.h.
Referenced by getToken(), getTokens(), hasMoreToken(), bpp::NestedStringTokenizer::NestedStringTokenizer(), bpp::NestedStringTokenizer::nextToken(), nextToken(), numberOfRemainingTokens(), removeEmptyTokens(), StringTokenizer(), and unparseRemainingTokens().