bpp-core3  3.0.0
bpp::NestedStringTokenizer Class Reference

An improved tokenizer for strings. More...

#include <Bpp/Text/NestedStringTokenizer.h>

+ Inheritance diagram for bpp::NestedStringTokenizer:
+ Collaboration diagram for bpp::NestedStringTokenizer:

Public Member Functions

 NestedStringTokenizer (const std::string &s, const std::string &open, const std::string &end, const std::string &delimiters=" \\", bool solid=false)
 Build a new StringTokenizer from a string. More...
 
virtual ~NestedStringTokenizer ()
 
const std::string & nextToken ()
 Get the next available token. If no token is availbale, throw an Exception. More...
 
std::string unparseRemainingTokens () const
 This function is not supported for nested tokenizers. 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...
 

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

Detailed Description

An improved tokenizer for strings.

Splits a string according to a given (set of) delimiter(s). Delimiters in certains blocks ({}, [], etc) are ignored.

Definition at line 24 of file NestedStringTokenizer.h.

Constructor & Destructor Documentation

◆ NestedStringTokenizer()

NestedStringTokenizer::NestedStringTokenizer ( const std::string &  s,
const std::string &  open,
const std::string &  end,
const std::string &  delimiters = " \t\n\f\r",
bool  solid = false 
)

Build a new StringTokenizer from a string.

Parameters
sThe string to parse.
openOpening block.
endEnding block.
delimitersChars that must be considered as delimiters.
solidIf true, delimiters is considered as a single bloc delimiter.

Definition at line 15 of file NestedStringTokenizer.cpp.

References bpp::TextTools::count(), and bpp::StringTokenizer::tokens_.

◆ ~NestedStringTokenizer()

virtual bpp::NestedStringTokenizer::~NestedStringTokenizer ( )
inlinevirtual

Definition at line 39 of file NestedStringTokenizer.h.

References nextToken().

Member Function Documentation

◆ getToken()

const std::string& bpp::StringTokenizer::getToken ( size_t  pos) const
inlineinherited

Get a particular token.

Do not move the iterator.

Parameters
posThe index of the token.
Returns
the token at position 'pos'.

Definition at line 84 of file StringTokenizer.h.

Referenced by bpp::NumCalcApplicationTools::seqFromString().

◆ getTokens()

const std::deque<std::string>& bpp::StringTokenizer::getTokens ( ) const
inlineinherited

◆ hasMoreToken()

◆ nextToken()

const std::string & NestedStringTokenizer::nextToken ( )

Get the next available token. If no token is availbale, throw an Exception.

Returns
The next token if there is one.

Definition at line 114 of file NestedStringTokenizer.cpp.

References bpp::StringTokenizer::currentPosition_, bpp::StringTokenizer::hasMoreToken(), and bpp::StringTokenizer::tokens_.

Referenced by bpp::ApplicationTools::getVectorOfVectorsParameter(), bpp::ApplicationTools::getVectorParameter(), and ~NestedStringTokenizer().

◆ numberOfRemainingTokens()

size_t bpp::StringTokenizer::numberOfRemainingTokens ( ) const
inlineinherited

◆ removeEmptyTokens()

void StringTokenizer::removeEmptyTokens ( )
inherited

remove all empty token from the current position.

Definition at line 65 of file StringTokenizer.cpp.

References bpp::StringTokenizer::currentPosition_, and bpp::StringTokenizer::tokens_.

Referenced by bpp::StringTokenizer::getTokens().

◆ unparseRemainingTokens()

std::string bpp::NestedStringTokenizer::unparseRemainingTokens ( ) const
inline

This function is not supported for nested tokenizers.

Returns
An empty string.

Definition at line 56 of file NestedStringTokenizer.h.

Member Data Documentation

◆ currentPosition_

size_t bpp::StringTokenizer::currentPosition_
protectedinherited

◆ splits_

std::deque<std::string> bpp::StringTokenizer::splits_
protectedinherited

◆ tokens_

std::deque<std::string> bpp::StringTokenizer::tokens_
protectedinherited

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