28 #ifndef _util_keyval_keyval_h
29 #define _util_keyval_keyval_h
42 #include <util/class/class.h>
43 #include <util/keyval/keyvalval.h>
74 enum {MaxKeywordLength = 256};
75 enum KeyValError { OK, HasNoValue, WrongType,
76 UnknownKeyword, OperationFailed };
81 void operator=(
const KeyVal&);
90 void seterror(KeyValValue::KeyValValueError err);
134 int count(
const char* =0);
175 int exists(
const char* key,
int i);
176 int count(
const char* key,
int i);
225 int exists(
const char*,
int,
int);
226 int count(
const char*,
int,
int);
235 int intvalue(
const char* key,
int,
int,
237 size_t sizevalue(
const char* key,
int,
int,
247 int count(
int i,
int j);
274 int Va_exists(
const char* key,
int nindex,...);
275 int Va_count(
const char* key,
int nindex,...);
276 int Va_booleanvalue(
const char* key,
int nindex,...);
277 double Va_doublevalue(
const char* key,
int nindex,...);
278 float Va_floatvalue(
const char* key,
int nindex,...);
279 char Va_charvalue(
const char* key,
int nindex,...);
280 int Va_intvalue(
const char* key,
int nindex,...);
281 size_t Va_sizevalue(
const char* key,
int nindex,...);
282 char* Va_pcharvalue(
const char* key,
int nindex,...);
283 std::string Va_stringvalue(
const char* key,
int nindex,...);
290 const char*
errormsg(KeyValError err);
317 std::map<std::string,Ref<KeyValValue> > _map;
333 void assign(
const char* key,
double val);
334 void assignboolean(
const char* key,
int val);
335 void assign(
const char* key,
float val);
336 void assign(
const char* key,
char val);
337 void assign(
const char* key,
int val);
338 void assign(
const char* key,
const char* val);
356 std::map<std::string,Ref<KeyValValue> > _map;
368 virtual const char*
stringrep(
const char *key) = 0;
371 virtual const char*
classname(
const char*);
392 enum { MaxKeyVal = 4 };
468 void setup(
const char*,
int,
int,
int,
int,
int);
469 int getnewprefixkey(
const char*key,
char*newkey);
473 int key_exists(
const char*);
532 void read(
const char*);
534 void read(std::istream&);
ParsedKeyVal()
Create an empty ParsedKeyVal.
int intvalue(const char *key=0, const KeyValValue &def=KeyValValueint())
Returns the int value of key.
Definition: keyvalval.h:87
The KeyVal class is designed to simplify the process of allowing a user to specify keyword/value asso...
Definition: keyval.h:69
int key_exists(const char *)
Ultimately called by exists.
virtual void errortrace(std::ostream &fp=ExEnv::err0())
Write a message to fp describing the error.
int have_unseen()
Return 1 if there were unseen keywords, 0 if there are none, or -1 this keyval doesn't keep track of ...
const char * classname(const char *)
Returns the name of the exact class of the object at the keyword.
int key_exists(const char *)
Ultimately called by exists.
virtual int key_intvalue(const char *key, const KeyValValue &def)
Ultimately called by intvalue.
virtual int have_unseen()
Return 1 if there were unseen keywords, 0 if there are none, or -1 this keyval doesn't keep track of ...
float floatvalue(const char *key=0, const KeyValValue &def=KeyValValuefloat())
Returns the float value of key.
virtual char key_charvalue(const char *key, const KeyValValue &def)
Ultimately called by charvalue.
virtual const char * classname(const char *)
Returns the name of the exact class of the object at the keyword.
Definition: keyvalval.h:148
Definition: keyvalval.h:161
A template class that maintains references counts.
Definition: ref.h:332
Definition: keyvalval.h:123
virtual void dump(std::ostream &fp=ExEnv::err0())
Write a message to fp describing the error.
void print_unseen(std::ostream &fp=ExEnv::out0())
Print keywords that were never looked at, if possible.
const char * stringrep(const char *)
Returns the string representation of the value assigned to key.
void errortrace(std::ostream &fp=ExEnv::err0())
Write a message to fp describing the error.
int booleanvalue(const char *key=0, const KeyValValue &def=KeyValValueboolean())
Returns the boolean value (0 = false, 1 = true) of key.
void dump(std::ostream &fp=ExEnv::err0())
Write a message to fp describing the error.
virtual float key_floatvalue(const char *key, const KeyValValue &def)
Ultimately called by floatvalue.
void parse_string(const char *)
Read input data from the given string.
int exists(const char *)
This takes as its only argument a keyword.
void clear()
Erase all of the stored assignments.
virtual const char * truekeyword(const char *)
Returns a string which is the actual keyword if some sort of variable substitution takes place (neede...
PrefixKeyVal is a KeyVal that searches a different KeyVal using modified keys.
Definition: keyval.h:464
Converts textual information into keyword/value assocations.
Definition: keyval.h:499
Ref< KeyValValue > value(const char *=0, const KeyValValue &def=KeyValValue())
Return the value associated with the keyword.
virtual double key_doublevalue(const char *key, const KeyValValue &def)
Ultimately called by doublevalue.
virtual void print_unseen(std::ostream &fp=ExEnv::out0())
Print keywords that were never looked at, if possible.
virtual Ref< KeyValValue > key_value(const char *, const KeyValValue &def)=0
Ultimately called by value.
virtual std::string key_stringvalue(const char *key, const KeyValValue &def)
Ultimately called by stringvalue.
Ref< DescribedClass > describedclassvalue(const char *key=0, const KeyValValue &def=KeyValValueRefDescribedClass())
Returns a reference to an object of type DescribedClass.
virtual void dump(std::ostream &fp=ExEnv::err0())
Write a message to fp describing the error.
KeyValError error()
Return the current error condition.
void dump(std::ostream &fp=ExEnv::err0())
Write a message to fp describing the error.
static std::ostream & err0()
Return an ostream for error messages that writes from node 0.
Definition: exenv.h:84
Definition: keyvalval.h:75
virtual int key_booleanvalue(const char *, const KeyValValue &def)
Ultimately called by booleanvalue.
virtual char * key_pcharvalue(const char *key, const KeyValValue &def)
Ultimately called by pcharvalue.
Definition: keyvalval.h:111
size_t sizevalue(const char *key=0, const KeyValValue &def=KeyValValuesize())
Returns the size_t value of key.
Definition: keyvalval.h:99
int count(const char *=0)
If the value of a keyword is an array, then return its length.
Ref< KeyValValue > key_value(const char *, const KeyValValue &def)
Ultimately called by value.
Definition: keyvalval.h:40
StringKeyVal is a base class for KeyVal implementations that store all values in a string format.
Definition: keyval.h:352
Definition: keyvalval.h:135
const char * truekeyword(const char *)
Returns a string which is the actual keyword if some sort of variable substitution takes place (neede...
virtual void errortrace(std::ostream &fp=ExEnv::err0())
Write a message to fp describing the error.
virtual int key_exists(const char *)=0
Ultimately called by exists.
This class allows keyval associations to be set up by the program, rather than determined by an exter...
Definition: keyval.h:315
void dump(std::ostream &fp=ExEnv::err0())
Write a message to fp describing the error.
void read(const char *)
Read input data from the given filename.
std::string stringvalue(const char *key=0, const KeyValValue &def=KeyValValuestring())
Returns a string representation of the key's value.
int key_exists(const char *)
Ultimately called by exists.
This takes several KeyVal objects and makes them look like one KeyVal object.
Definition: keyval.h:390
char charvalue(const char *key=0, const KeyValValue &def=KeyValValuechar())
Returns the char value of key.
static void cat_files(const char *, const Ref< KeyVal > &, std::ostream &o)
This is like the ParsedKeyVal(const char*,const Ref<KeyVal>&) ctor, but writes the contents of the fi...
static std::ostream & out0()
Return an ostream that writes from node 0.
virtual int key_count(const char *=0)
Ultimately called by count.
char * pcharvalue(const char *key=0, const KeyValValue &def=KeyValValuepchar())
Returns a copy of the string representation of the key's value.
void errortrace(std::ostream &fp=ExEnv::err0())
Write a message to fp describing the error.
const char * errormsg()
Return a textual representation of the current error.
The base class for all reference counted objects.
Definition: ref.h:194
double doublevalue(const char *key=0, const KeyValValue &def=KeyValValuedouble())
Returns the double value of key.
virtual const char * stringrep(const char *key)=0
Returns the string representation of the value assigned to key.
Definition: keyvalval.h:63
Ref< KeyValValue > key_value(const char *, const KeyValValue &def)
Ultimately called by value.
void errortrace(std::ostream &fp=ExEnv::err0())
Write a message to fp describing the error.
virtual size_t key_sizevalue(const char *key, const KeyValValue &def)
Ultimately called by sizevalue.
virtual Ref< DescribedClass > key_describedclassvalue(const char *key, const KeyValValue &def)
Ultimately called by describedclassvalue.
void verbose(int v)
Control printing of assignments.
Definition: keyval.h:306
int verbose() const
Returns nonzero if assignments are printed.
Definition: keyval.h:308
Ref< KeyValValue > key_value(const char *, const KeyValValue &def)
Ultimately called by value.
void seterror(KeyValError err)
Set the current error condition.
~ParsedKeyVal()
Cleanup, deleting the IPV2 object.
Generated at Sun Jan 26 2020 23:33:04 for MPQC
2.3.1 using the documentation package Doxygen
1.8.16.