Main Page   Namespace List   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

RazorBack::Iovar_ Class Template Reference

Class Iovar_: a template class that represents a variable in an ASCII I/O format. More...

#include <Iovar.hh>

List of all members.

Public Methods

 Iovar_ (const char *Dtok, T_ Defval=T_(0), bool Noc=false, char Eq='=')
 Inits to store a variable with description token Dtok. More...

const string& descr () const
 descr(): returns the description string.

size_t dlen () const
 dlen(): returns the length of the description string.

bool match_descr (const string &Str) const
 match_descr(Str, Nocase): returns true if Str begins with descr(). More...

bool nocase () const
 nocase(): returns true if the description token is case-insensitive.

char eqchar () const
 eqchar(): returns the "equals" char.

const T_& value () const
 Returns the value.

T_ value (const T_ &V)
 Sets the value to V, returns old value.


Protected Methods

istream& read_value (istream &In)
ostream& write_value (ostream &Out) const

Private Attributes

string Descr
bool Nocase
char Eqchar
T_ Value

Friends

istream& operator>> (istream &In, Iovar_< T_ > &Iov)
ostream& operator<< (ostream &Out, const Iovar_< T_ > &Iov)


Detailed Description

template<class T_> class RazorBack::Iovar_

Class Iovar_: a template class that represents a variable in an ASCII I/O format.

Useful for reading and writing program parameters to/from data files. The (regexp-like) format is:-

   (descr_token)(ws)*(ws|(eqchar)(ws)*)(value)
   
   where
   (descr_token) is a string w/o whitespaces, this is the "name"
        of the variable;
   (ws)* denotes zero or more whitespace chars;
   (eqchar) denotes "equal-to" chars like '=' or ':';
   (value) is the value of the variable.
   
Examples:- "Intvar 1", "Intvar:2", "Dblvar = 3.5", "Bool= 1"

NOTE: this class is intended for POD types like int, float, bool etc. only!

Definition at line 67 of file Iovar.hh.


Constructor & Destructor Documentation

template<class T_>
RazorBack::Iovar_<T_>::Iovar_<T_> ( const char * Dtok,
T_ Defval = T_(0),
bool Noc = false,
char Eq = '=' ) [explicit]
 

Inits to store a variable with description token Dtok.

Specification of Dtok is mandatory, the ctor throws a "fatal" Emptyexc_ if Dtok is NULL or "". Defval is the default value of the variable, T_(0) by default. Noc=true if the description token is meant to be case-insensitive, this is false by default (exact match required). Eq (by default '=') is the "equal" character, if you want to omit it, then specify '\0'.


Member Function Documentation

template<class T_>
const string & RazorBack::Iovar_<T_>::descr ( ) const [inline]
 

descr(): returns the description string.

Definition at line 93 of file Iovar.hh.

template<class T_>
size_t RazorBack::Iovar_<T_>::dlen ( ) const [inline]
 

dlen(): returns the length of the description string.

Definition at line 96 of file Iovar.hh.

template<class T_>
bool RazorBack::Iovar_<T_>::match_descr ( const string & Str ) const
 

match_descr(Str, Nocase): returns true if Str begins with descr().

If nocase()==true, then a case-insensitive comparison is done, otherwise (the default) an exact match is required.

template<class T_>
bool RazorBack::Iovar_<T_>::nocase ( ) const [inline]
 

nocase(): returns true if the description token is case-insensitive.

Definition at line 109 of file Iovar.hh.

template<class T_>
char RazorBack::Iovar_<T_>::eqchar ( ) const [inline]
 

eqchar(): returns the "equals" char.

Definition at line 112 of file Iovar.hh.

template<class T_>
const T_ & RazorBack::Iovar_<T_>::value ( ) const [inline]
 

Returns the value.

Definition at line 115 of file Iovar.hh.

template<class T_>
T_ RazorBack::Iovar_<T_>::value ( const T_ & V ) [inline]
 

Sets the value to V, returns old value.

Definition at line 118 of file Iovar.hh.

template<class T_>
istream& RazorBack::Iovar_<T_>::read_value ( istream & In ) [protected]
 

template<class T_>
ostream& RazorBack::Iovar_<T_>::write_value ( ostream & Out ) const [protected]
 


Friends And Related Function Documentation

template<class T_>
istream& operator>> ( istream & In,
Iovar_< T_ > & Iov ) [friend]
 

template<class T_>
ostream& operator<< ( ostream & Out,
const Iovar_< T_ > & Iov ) [friend]
 


Member Data Documentation

template<class T_>
string RazorBack::Iovar_<T_>::Descr [private]
 

Definition at line 72 of file Iovar.hh.

template<class T_>
bool RazorBack::Iovar_<T_>::Nocase [private]
 

Definition at line 73 of file Iovar.hh.

template<class T_>
char RazorBack::Iovar_<T_>::Eqchar [private]
 

Definition at line 74 of file Iovar.hh.

template<class T_>
T_ RazorBack::Iovar_<T_>::Value [private]
 

Definition at line 75 of file Iovar.hh.


The documentation for this class was generated from the following file:
Generated at Wed Aug 21 09:33:41 2002 for The Razorback C++ Library: Miscellaneous by doxygen1.2.6 written by Dimitri van Heesch, © 1997-2001