util::tokenizer Class Reference

Extracts tokens separated by a char from a buffer. More...

#include <util.h>

Inheritance diagram for util::tokenizer:

Inheritance graph
[legend]
Collaboration diagram for util::tokenizer:

Collaboration graph
[legend]

List of all members.

Public Member Functions

size_t count () const
 Return the number of tokens still to be extracted from buffer.
const char * get_original () const
 Return a const pointer to the whole string that is being tokenized.
const char * get_remainder () const
 Return a const char pointer to the rest of buffer still to be tokenized.
bool has_next () const
 Return true if there is at least one more token to be extracted from buffer.
const char * next (char del)
 Extract next token and return a const pointer to it.
const char * next ()
 Extract next token and return a const pointer to it.
 tokenizer (const char *buffer=NULL, char delim= '\t')
 Constructor from an unmodifiable C string.
void tokenizing (const char *buffer=NULL, char delim= '\t')
 Start tokenizing from an unmodifiable C string.
virtual ~tokenizer ()
 Destructor.

Private Attributes

const char * buf
 Pointer to the portion of buffer still to tokenize.
const char * buffer_start
 Pointer to beginning of buffer.
char del
 Token separator.
char * last_token
 Last extracted token.
char * last_token_end
 End of last extracted token.

Static Private Attributes

static const char EMPTY
 An empty buffer.


Detailed Description

Extracts tokens separated by a char from a buffer.

The buffer is a const C string, i.e. a const char*.


Constructor & Destructor Documentation

util::tokenizer::tokenizer ( const char *  buffer = NULL,
char  delim = '\t' 
) [inline]

Constructor from an unmodifiable C string.

Parameters:
buffer a const C string.
delim token separator.

virtual util::tokenizer::~tokenizer (  )  [inline, virtual]

Destructor.


Member Function Documentation

size_t util::tokenizer::count (  )  const [inline]

Return the number of tokens still to be extracted from buffer.

const char* util::tokenizer::get_original (  )  const [inline]

Return a const pointer to the whole string that is being tokenized.

const char* util::tokenizer::get_remainder (  )  const [inline]

Return a const char pointer to the rest of buffer still to be tokenized.

The buffer is stored locally and it is valid until next call to next_token().

bool util::tokenizer::has_next (  )  const [inline]

Return true if there is at least one more token to be extracted from buffer.

const char* util::tokenizer::next ( char  del  )  [inline]

Extract next token and return a const pointer to it.

The token is stored locally and it is valid until next call to next().

Parameters:
del token delimiter
Returns:
NULL if there is no more token.

const char* util::tokenizer::next (  )  [inline]

Extract next token and return a const pointer to it.

The token is stored locally and it is valid until next call to next().

Returns:
NULL if there is no more token.

void util::tokenizer::tokenizing ( const char *  buffer = NULL,
char  delim = '\t' 
) [inline]

Start tokenizing from an unmodifiable C string.

Parameters:
buffer a const C string.
delim token separator.


Member Data Documentation

const char* util::tokenizer::buf [private]

Pointer to the portion of buffer still to tokenize.

const char* util::tokenizer::buffer_start [private]

Pointer to beginning of buffer.

char util::tokenizer::del [private]

Token separator.

const char util::tokenizer::EMPTY [static, private]

An empty buffer.

char* util::tokenizer::last_token [private]

Last extracted token.

char* util::tokenizer::last_token_end [private]

End of last extracted token.


The documentation for this class was generated from the following file:
Generated on Sun Nov 23 14:52:48 2008 for Typing linear constraints by  doxygen 1.5.4