#include <Iovar.hh>
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) |
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.
NOTE: this class is intended for POD types like int, float, bool etc. only!
Definition at line 67 of file Iovar.hh.
|
||||||||||
|
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'. |
|
||||
|
descr(): returns the description string.
|
|
||||
|
dlen(): returns the length of the description string.
|
|
||||
|
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. |
|
||||
|
nocase(): returns true if the description token is case-insensitive.
|
|
||||
|
eqchar(): returns the "equals" char.
|
|
||||
|
Returns the value.
|
|
||||
|
Sets the value to V, returns old value.
|
|
||||
|
|
|
||||
|
|
|
||||||
|
|
|
||||||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
1.2.6 written by Dimitri van Heesch,
© 1997-2001