Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

StringArgs Class Reference

#include <stringparser.h>

Collaboration diagram for StringArgs:

Collaboration graph
[legend]
List of all members.

Detailed Description

Simple string-based function argument parser using StringParser.

An argument of this type is good for a function which constructs an object from a string specification. If you're starting with a simple string, you can use the string constructor below; otherwise (e.g. if starting with a pre-segmented vector of strings) use the iterator-based constructor. An object from this class can be passed around as a reference argument to various other classes, each of whom can consume some of the tokens until all are gone.

To consume a token, supply to next() a default value of the type you would like returned; this value will be returned if no arguments remain. Even if no default is meaningful, supply one anyway but first check that the arglist is not empty(), which will ensure that the default is not used.

Definition at line 158 of file stringparser.h.

Public Methods

 StringArgs (const StringParser &parser, StringParser::argptr b, StringParser::argptr e)
 StringArgs (const StringParser &parser, const string &s)
 StringArgs (const StringArgs &other)
 Copy constructor.

bool empty () const
 Returns true if no arguments remain.

bool oneremaining () const
 Returns true if exactly one argument remains.

template<class T> T top (const T &default_val) const
 Family of parses based on type of the given default.

void skip ()
 Consumes the current argument.

template<class T> T next (const T &default_val)
 Same as top() but consumes the current argument.

template<class T> T * next (const T &default_val, T *&ptr)
 Version returning a pointer instead of a value.

template<class T> bool nextis (const T &test_val)
 Consumes only if equal to given value, and returns true if so.

template<class T> bool lookaheadone (const T &test_val) const
 Returns true if the next argument after this one is equal the given value; rarely needed.

StringArgs recursiveparser ()
 Consumes the current argument as a string and returns a new parser parsing the substructure of it, i.e.

StringArgs recursiveparser (const string s) const
 Returns a new parser parsing the given string.

string stringrep () const
 Returns a string representation of the remaining arguments.


Public Attributes

const StringParserp
 Provided as a public service to those needing a parser; avoid if possible.


Member Function Documentation

StringArgs StringArgs::recursiveparser   [inline]
 

Consumes the current argument as a string and returns a new parser parsing the substructure of it, i.e.

arguments within that string.

Definition at line 263 of file stringparser.h.

References next().

Referenced by NamedValueGenerators::create(), and NeuralRegionMap::measure_stimulus_map().

template<class T>
T StringArgs::top const T &    default_val const [inline]
 

Family of parses based on type of the given default.

Returns the first argument (or the default) without modifying the state.

Definition at line 199 of file stringparser.h.

References empty(), and StringParser::parse().

Referenced by RetinalObjectStringArgs::vars().


The documentation for this class was generated from the following file:
Generated on Mon Jan 20 02:37:24 2003 for RF-LISSOM by doxygen1.3-rc2