gatb.core-API-1.4.2
TokenizerIterator Class Reference

String tokenizer as an Iterator. More...

#include <Tokenizer.hpp>

Inheritance diagram for TokenizerIterator:
Inheritance graph

Public Member Functions

 TokenizerIterator (const char *text, const char *separator)
 
virtual ~TokenizerIterator ()
 
void first ()
 
void next ()
 
bool isDone ()
 
char *& item ()
 
- Public Member Functions inherited from Iterator< char * >
char ** operator-> ()
 
char *& operator* ()
 
void iterate (const Functor &f)
 
virtual void setItem (char *&i)
 
bool get (std::vector< char * > &current)
 
virtual void reset ()
 
virtual void finalize ()
 
virtual std::vector< Iterator< char * > * > getComposition ()
 
- Public Member Functions inherited from SmartPointer
void use ()
 
void forget ()
 
- Public Member Functions inherited from ISmartPointer
virtual ~ISmartPointer ()
 

Additional Inherited Members

- Protected Member Functions inherited from SmartPointer
 SmartPointer ()
 
virtual ~SmartPointer ()
 

Detailed Description

String tokenizer as an Iterator.

Tool for tokenizing strings (like strtok) that follows our Iterator concept.

One should provide both the string to be tokenized and a string holding characters to be considered as separators.

Code sample:

void sample ()
{
// We create a tokenizer with spaces as separators.
TokenizerIterator it ("this is the text to tokenize", " ");
// We loop the iterator
for (it.first(); !it.isDone(); it.next())
{
// We get the current token
char* token = it.currentItem ();
}
}

Constructor & Destructor Documentation

TokenizerIterator ( const char *  text,
const char *  separator 
)

Constructors.

Parameters
text: the string to be tokenized.
separator: the separator characters.
~TokenizerIterator ( )
virtual

Destructor.

Member Function Documentation

void first ( )
virtual

Method that initializes the iteration.

Implements Iterator< char * >.

bool isDone ( )
inlinevirtual

Method telling whether the iteration is finished or not.

Returns
true if iteration is finished, false otherwise.

Implements Iterator< char * >.

char*& item ( )
inlinevirtual

Method that returns the current iterated item. Note that the returned type is the template type.

Returns
the current item in the iteration.

Implements Iterator< char * >.

void next ( )
virtual

Method that goes to the next item in the iteration.

Returns
status of the iteration

Implements Iterator< char * >.


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