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

StringArgs Class Reference

Simple string-based function argument parser using StringParser. More...

#include <stringparser.h>

Collaboration diagram for StringArgs:

Collaboration graph

[legend]
List of all members.

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

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

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

template<classT> T next (const T& default_val)
 Family of parses based on type of the given default. More...

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

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

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

StringArgs recursiveparser ()
 Returns a new parser parsing the substructure of the current argument. More...


Public Attributes

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


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 134 of file stringparser.h.


Constructor & Destructor Documentation

StringArgs::StringArgs ( const StringParser & parser,
StringParser::argptr b,
StringParser::argptr e )
 

Definition at line 143 of file stringparser.h.

StringArgs::StringArgs ( const StringParser & parser,
const string & s )
 

Definition at line 146 of file stringparser.h.

StringArgs::StringArgs ( const StringArgs & other )
 

Copy constructor.

Definition at line 153 of file stringparser.h.

Referenced by recursiveparser().


Member Function Documentation

bool StringArgs::empty ( ) const [inline]
 

Returns true if no arguments remain.

Definition at line 167 of file stringparser.h.

Referenced by ValueGeneratorFactory::create(), lookaheadone(), next(), nextis(), and RetinalObjectStringArgs::vars().

template<classT>
bool StringArgs::lookaheadone ( const T & test_val ) [inline]
 

Returns true if the next argument after this one is equal the given value; rarely needed.

Definition at line 211 of file stringparser.h.

Referenced by RetinalObjectStringArgs::vars().

template<classT>
T * StringArgs::next ( const T & default_val,
T *& ptr ) [inline]
 

Version returning a pointer instead of a value.

Definition at line 186 of file stringparser.h.

template<classT>
T StringArgs::next ( const T & default_val ) [inline]
 

Family of parses based on type of the given default.

Definition at line 174 of file stringparser.h.

Referenced by ValueGeneratorFactory::create(), KernelFactory::create(), NamedValueGenerators::create(), WorldViews::create_object(), RetinalObjectStringArgs::parsed_next(), recursiveparser(), and RetinalObjectStringArgs::vars().

template<classT>
bool StringArgs::nextis ( const T & test_val ) [inline]
 

Consumes only if equal to given value, and returns true if so.

Definition at line 196 of file stringparser.h.

Referenced by ValueGeneratorFactory::create(), and RetinalObjectStringArgs::vars().

bool StringArgs::oneremaining ( ) const [inline]
 

Returns true if exactly one argument remains.

Definition at line 170 of file stringparser.h.

Referenced by ValueGeneratorFactory::create().

StringArgs StringArgs::recursiveparser ( ) [inline]
 

Returns a new parser parsing the substructure of the current argument.

Definition at line 221 of file stringparser.h.

Referenced by NamedValueGenerators::create().


Member Data Documentation

const StringParser & StringArgs::p
 

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

Definition at line 141 of file stringparser.h.


The documentation for this class was generated from the following file:
Generated at Mon Aug 21 00:31:26 2000 for RF-LISSOM by doxygen1.2.1 written by Dimitri van Heesch, © 1997-2000