MPQC 3.0.0-alpha
Loading...
Searching...
No Matches
keyval.h
1//
2// keyval.h
3//
4// Copyright (C) 1996 Limit Point Systems, Inc.
5//
6// Author: Curtis Janssen <cljanss@limitpt.com>
7// Maintainer: LPS
8//
9// This file is part of the SC Toolkit.
10//
11// The SC Toolkit is free software; you can redistribute it and/or modify
12// it under the terms of the GNU Library General Public License as published by
13// the Free Software Foundation; either version 2, or (at your option)
14// any later version.
15//
16// The SC Toolkit is distributed in the hope that it will be useful,
17// but WITHOUT ANY WARRANTY; without even the implied warranty of
18// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19// GNU Library General Public License for more details.
20//
21// You should have received a copy of the GNU Library General Public License
22// along with the SC Toolkit; see the file COPYING.LIB. If not, write to
23// the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
24//
25// The U.S. Government is granted a limited license as per AL 91-7.
26//
27
28#ifndef _util_keyval_keyval_h
29#define _util_keyval_keyval_h
30
31#include <iostream>
32#include <string>
33#include <map>
34#include <vector>
35
36#include <string.h>
37#include <stdlib.h>
38#include <stdarg.h>
39
40#include <util/class/class.h>
41#include <util/misc/scexception.h>
42#include <util/keyval/keyvalval.h>
43
44namespace sc {
45
69class KeyVal: public RefCount {
70 // these classes need to directly access the key_value member
71 friend class AggregateKeyVal;
72 friend class PrefixKeyVal;
73 public:
74 enum {MaxKeywordLength = 256};
75 enum KeyValError { OK, HasNoValue, WrongType,
76 UnknownKeyword, OperationFailed };
77 private:
78 KeyValError errcod;
79 // do not allow a copy constructor or assignment
80 KeyVal(const KeyVal&);
81 void operator=(const KeyVal&);
82 protected:
83 int verbose_;
84
85 KeyVal();
86
88 void seterror(KeyValError err);
90 void seterror(KeyValValue::KeyValValueError err);
91
93 virtual int key_exists(const char*) = 0;
95 virtual int key_count(const char* =0);
97 virtual Ref<KeyValValue> key_value(const char*,
98 const KeyValValue& def) = 0;
100 virtual int key_booleanvalue(const char*,const KeyValValue& def);
102 virtual double key_doublevalue(const char* key,const KeyValValue& def);
104 virtual float key_floatvalue(const char* key,const KeyValValue& def);
106 virtual char key_charvalue(const char* key,const KeyValValue& def);
108 virtual int key_intvalue(const char* key,const KeyValValue& def);
110 virtual long key_longvalue(const char* key,const KeyValValue& def);
112 virtual size_t key_sizevalue(const char* key,const KeyValValue& def);
114 DEPRECATED virtual char* key_pcharvalue(const char* key,const KeyValValue& def);
116 virtual std::string key_stringvalue(const char* key,
117 const KeyValValue& def);
120 const KeyValValue& def);
121
122 public:
123 virtual ~KeyVal();
124
125 // For nonindexed things. If a subclass defines one of these,
126 // then the overloaded functions will be hidden. The key_... functions
127 // should be overridden instead.
128
131 int exists(const char*);
136 int count(const char* =0);
138 Ref<KeyValValue> value(const char* key = 0,
139 const KeyValValue& def=KeyValValue());
141 int booleanvalue(const char* key = 0,
142 const KeyValValue& def=KeyValValueboolean());
144 double doublevalue(const char* key = 0,
145 const KeyValValue& def=KeyValValuedouble());
147 float floatvalue(const char* key = 0,
148 const KeyValValue& def=KeyValValuefloat());
150 char charvalue(const char* key = 0,
151 const KeyValValue& def=KeyValValuechar());
153 int intvalue(const char* key = 0,
154 const KeyValValue& def=KeyValValueint());
156 long longvalue(const char* key = 0,
157 const KeyValValue& def=KeyValValuelong());
159 size_t sizevalue(const char* key = 0,
160 const KeyValValue& def=KeyValValuesize());
164 DEPRECATED char* pcharvalue(const char* key = 0,
165 const KeyValValue& def=KeyValValuestring());
167 std::string stringvalue(const char* key = 0,
168 const KeyValValue& def=KeyValValuestring());
175 virtual const char* classname(const char*);
176
181
190 int exists(const char* key,int i);
191 int count(const char* key,int i);
192 int booleanvalue(const char* key,int i,
193 const KeyValValue& def=KeyValValueboolean());
194 double doublevalue(const char* key,int i,
195 const KeyValValue& def=KeyValValuedouble());
196 float floatvalue(const char* key,int i,
197 const KeyValValue& def=KeyValValuefloat());
198 char charvalue(const char* key,int i,
199 const KeyValValue& def=KeyValValuechar());
200 int intvalue(const char* key,int i,
201 const KeyValValue& def=KeyValValueint());
202 long longvalue(const char* key,int i,
203 const KeyValValue& def=KeyValValuelong());
204 size_t sizevalue(const char* key,int i,
205 const KeyValValue& def=KeyValValuesize());
206 DEPRECATED char* pcharvalue(const char* key,int i,
207 const KeyValValue& def=KeyValValuestring());
208 std::string stringvalue(const char* key,int i,
209 const KeyValValue& def=KeyValValuestring());
210 Ref<DescribedClass> describedclassvalue(const char* key,int,
212
213 int exists(int i);
214 int count(int i);
215 int booleanvalue(int i,
216 const KeyValValue& def=KeyValValueboolean());
217 double doublevalue(int i,
218 const KeyValValue& def=KeyValValuedouble());
219 float floatvalue(int i,
220 const KeyValValue& def=KeyValValuefloat());
221 char charvalue(int i,
222 const KeyValValue& def=KeyValValuechar());
223 int intvalue(int i,
224 const KeyValValue& def=KeyValValueint());
225 long longvalue(int i,
226 const KeyValValue& def=KeyValValuelong());
227 size_t sizevalue(int i,
228 const KeyValValue& def=KeyValValuesize());
229 DEPRECATED char* pcharvalue(int i,
230 const KeyValValue& def=KeyValValuestring());
231 std::string stringvalue(int i,
232 const KeyValValue& def=KeyValValuestring());
236
244 int exists(const char*,int,int);
245 int count(const char*,int,int);
246 int booleanvalue(const char*,int,int,
247 const KeyValValue& def=KeyValValueboolean());
248 double doublevalue(const char* key,int,int,
249 const KeyValValue& def=KeyValValuedouble());
250 float floatvalue(const char* key,int,int,
251 const KeyValValue& def=KeyValValuefloat());
252 char charvalue(const char* key,int,int,
253 const KeyValValue& def=KeyValValuechar());
254 int intvalue(const char* key,int,int,
255 const KeyValValue& def=KeyValValueint());
256 long longvalue(const char* key,int,int,
257 const KeyValValue& def=KeyValValuelong());
258 size_t sizevalue(const char* key,int,int,
259 const KeyValValue& def=KeyValValuesize());
260 DEPRECATED char* pcharvalue(const char* key,int,int,
261 const KeyValValue& def=KeyValValuestring());
262 std::string stringvalue(const char* key,int,int,
263 const KeyValValue& def=KeyValValuestring());
264 Ref<DescribedClass> describedclassvalue(const char* key,int,int,
266
267 int exists(int i,int j);
268 int count(int i,int j);
269 int booleanvalue(int i,int j,
270 const KeyValValue& def=KeyValValueboolean());
271 double doublevalue(int i,int j,
272 const KeyValValue& def=KeyValValuedouble());
273 float floatvalue(int i,int j,
274 const KeyValValue& def=KeyValValuefloat());
275 char charvalue(int i,int j,
276 const KeyValValue& def=KeyValValuechar());
277 int intvalue(int i,int j,
278 const KeyValValue& def=KeyValValueint());
279 long longvalue(int i,int j,
280 const KeyValValue& def=KeyValValuelong());
281 size_t sizevalue(int i,int j,
282 const KeyValValue& def=KeyValValuesize());
283 DEPRECATED char* pcharvalue(int i,int j,
284 const KeyValValue& def=KeyValValuestring());
285 std::string stringvalue(int i,int j,
286 const KeyValValue& def=KeyValValuestring());
290
297 int Va_exists(const char* key,int nindex,...);
298 int Va_count(const char* key,int nindex,...);
299 int Va_booleanvalue(const char* key,int nindex,...);
300 double Va_doublevalue(const char* key,int nindex,...);
301 float Va_floatvalue(const char* key,int nindex,...);
302 char Va_charvalue(const char* key,int nindex,...);
303 int Va_intvalue(const char* key,int nindex,...);
304 long Va_longvalue(const char* key,int nindex,...);
305 size_t Va_sizevalue(const char* key,int nindex,...);
306 DEPRECATED char* Va_pcharvalue(const char* key,int nindex,...);
307 std::string Va_stringvalue(const char* key,int nindex,...);
308 Ref<DescribedClass> Va_describedclassvalue(const char* key,int nindex,...);
310
312 KeyValError error();
314 const char* errormsg(KeyValError err);
316 const char* errormsg();
318 virtual void errortrace(std::ostream&fp=ExEnv::err0());
320 virtual void dump(std::ostream&fp=ExEnv::err0());
321
323 virtual void print_unseen(std::ostream&fp=ExEnv::out0());
327 virtual int have_unseen();
328
330 void verbose(int v) { verbose_ = v; }
332 int verbose() const { return verbose_; }
333};
334
335
336
340class AssignedKeyVal: public KeyVal {
341 private:
342 typedef std::map<std::string,Ref<KeyValValue> > _map_t;
343 _map_t _map;
344 // do not allow a copy constructor or assignment
346 void operator=(const AssignedKeyVal&);
347 protected:
348 int key_exists(const char*);
350 const KeyValValue& def);
351 public:
354
358 void assign(const char* key, const Ref<KeyValValue>& val);
359 void assign(const char* key, double val);
360 void assignboolean(const char* key, int val);
361 void assign(const char* key, float val);
362 void assign(const char* key, char val);
363 void assign(const char* key, int val);
364 void assign(const char* key, long val);
365 void assign(const char* key, const char* val);
366 void assign(const char* key, const std::string& val);
367 void assign(const char* key, const Ref<DescribedClass>& val);
369
370 const char* classname(const char*);
371
373 void clear();
374
377 void print(std::ostream& os = ExEnv::out0()) const;
378
379 template <typename ValueType>
380 static Ref<AssignedKeyVal> instance(const char* key, const ValueType& value) {
381 Ref<AssignedKeyVal> result;
382 result->assign(key,value);
383 return result;
384 }
385};
386
392class StringKeyVal: public KeyVal {
393 private:
394 // once a described class is found it is kept here so
395 // multiple references to it return the same instance
396 std::map<std::string,Ref<KeyValValue> > _map;
397 // do not allow a copy constructor or assignment
399 void operator=(const StringKeyVal&);
400 protected:
401 StringKeyVal();
402 int key_exists(const char*);
404 const KeyValValue& def);
405 public:
406 virtual ~StringKeyVal();
408 virtual std::string stringrep(const char *key) = 0;
411 virtual const char* classname(const char*);
415 virtual const char* truekeyword(const char*);
416
421 virtual void errortrace(std::ostream&fp=ExEnv::err0());
422 virtual void dump(std::ostream&fp=ExEnv::err0());
424};
425
431class AggregateKeyVal : public KeyVal {
432 private:
433 enum { MaxKeyVal = 4 };
434 Ref<KeyVal> kv[MaxKeyVal];
435 Ref<KeyVal> getkeyval(const char*key);
436 // do not allow a copy constructor or assignment
438 void operator=(const AggregateKeyVal&);
439 protected:
440 int key_exists(const char*);
442 const KeyValValue& def);
443 public:
451 AggregateKeyVal(const Ref<KeyVal>& keyval1);
452 AggregateKeyVal(const Ref<KeyVal>& keyval1,const Ref<KeyVal>& keyval2);
453 AggregateKeyVal(const Ref<KeyVal>& keyval1,const Ref<KeyVal>& keyval2,
454 const Ref<KeyVal>& keyval3);
455 AggregateKeyVal(const Ref<KeyVal>& keyval1,const Ref<KeyVal>& keyval2,
456 const Ref<KeyVal>& keyval3, const Ref<KeyVal>& keyval4);
459
460 const char* classname(const char*);
461 void errortrace(std::ostream&fp=ExEnv::err0());
462 void dump(std::ostream&fp=ExEnv::err0());
463};
464
508class PrefixKeyVal : public KeyVal {
509 private:
510 char* prefix;
511 Ref<KeyVal> keyval;
512 void setup(const char*,int,int,int,int,int);
513 int getnewprefixkey(const char*key,char*newkey);
514 // do not allow a copy constructor or assignment
516 void operator=(const PrefixKeyVal&);
517 int key_exists(const char*);
518 Ref<KeyValValue> key_value(const char*,
519 const KeyValValue& def);
520 public:
524 PrefixKeyVal(const Ref<KeyVal>&,int i);
525 PrefixKeyVal(const Ref<KeyVal>&,int i,int j);
526 PrefixKeyVal(const Ref<KeyVal>&,int i,int j,int k);
527 PrefixKeyVal(const Ref<KeyVal>&,int i,int j,int k,int l);
528 PrefixKeyVal(const Ref<KeyVal>&,const char*prefix);
529 PrefixKeyVal(const Ref<KeyVal>&,const char*prefix,int i);
530 PrefixKeyVal(const Ref<KeyVal>&,const char*prefix,int i,int j);
531 PrefixKeyVal(const Ref<KeyVal>&,const char*prefix,int i,int j,int k);
532 PrefixKeyVal(const Ref<KeyVal>&,const char*prefix,int i,int j,int k,int l);
535
536 const char* classname(const char*);
537 void errortrace(std::ostream&fp=ExEnv::err0());
538 void dump(std::ostream&fp=ExEnv::err0());
539};
540
541class IPV2;
547 private:
548 int nfile;
549 char**file;
550 int nfp;
551 IPV2* ipv2;
552 // do not allow a copy constructor or assignment
554 void operator=(const ParsedKeyVal&);
555 public:
559 ParsedKeyVal(const char*file);
561 ParsedKeyVal(std::istream&s);
570 ParsedKeyVal(const char*,const Ref<KeyVal>&);
573
576 static void cat_files(const char*,const Ref<KeyVal>&,std::ostream &o);
577
579 void read(const char*);
581 void read(const std::string &);
583 void read(std::istream&);
585 void parse_string(const std::string&);
586
590 std::string stringrep(const char*);
591 const char* classname(const char*);
592 const char* truekeyword(const char*);
593 void errortrace(std::ostream&fp=ExEnv::err0());
594 void dump(std::ostream&fp=ExEnv::err0());
595 void print_unseen(std::ostream&fp=ExEnv::out0());
598};
599
600namespace detail {
602 template <typename T> struct GetValue;
603 template <> struct GetValue<bool> {
604 static bool eval(const Ref<KeyVal>& kv, const char* key, int i) {
605 return kv->booleanvalue(key, i);
606 }
607 static bool eval(const Ref<KeyVal>& kv, const char* key, int i, int j) {
608 return kv->booleanvalue(key, i, j);
609 }
610 };
611 template <> struct GetValue<double> {
612 static double eval(const Ref<KeyVal>& kv, const char* key, int i) {
613 return kv->doublevalue(key, i);
614 }
615 static double eval(const Ref<KeyVal>& kv, const char* key, int i, int j) {
616 return kv->doublevalue(key, i, j);
617 }
618 };
619 template <> struct GetValue<float> {
620 static float eval(const Ref<KeyVal>& kv, const char* key, int i) {
621 return kv->floatvalue(key, i);
622 }
623 static float eval(const Ref<KeyVal>& kv, const char* key, int i, int j) {
624 return kv->floatvalue(key, i, j);
625 }
626 };
627 template <> struct GetValue<int> {
628 static int eval(const Ref<KeyVal>& kv, const char* key, int i) {
629 return kv->intvalue(key, i);
630 }
631 static int eval(const Ref<KeyVal>& kv, const char* key, int i, int j) {
632 return kv->intvalue(key, i, j);
633 }
634 };
635 template <> struct GetValue<long> {
636 static long eval(const Ref<KeyVal>& kv, const char* key, int i) {
637 return kv->longvalue(key, i);
638 }
639 static long eval(const Ref<KeyVal>& kv, const char* key, int i, int j) {
640 return kv->longvalue(key, i, j);
641 }
642 };
643 template <> struct GetValue<std::size_t> {
644 static std::size_t eval(const Ref<KeyVal>& kv, const char* key, int i) {
645 return kv->sizevalue(key, i);
646 }
647 static std::size_t eval(const Ref<KeyVal>& kv, const char* key, int i, int j) {
648 return kv->sizevalue(key, i, j);
649 }
650 };
651 template <> struct GetValue<char> {
652 static char eval(const Ref<KeyVal>& kv, const char* key, int i) {
653 return kv->charvalue(key, i);
654 }
655 static char eval(const Ref<KeyVal>& kv, const char* key, int i, int j) {
656 return kv->charvalue(key, i, j);
657 }
658 };
659 template <> struct GetValue<std::string> {
660 static std::string eval(const Ref<KeyVal>& kv, const char* key, int i) {
661 return kv->stringvalue(key, i);
662 }
663 static std::string eval(const Ref<KeyVal>& kv, const char* key, int i, int j) {
664 return kv->stringvalue(key, i, j);
665 }
666 };
667}
668
672class Keyword {
673 public:
674 Keyword(const Ref<KeyVal>& kv,
675 const std::string& key) : kv_(kv), key_(key) {}
676
677 const Ref<KeyVal>& keyval() const { return kv_; }
678 const std::string& key() const { return key_; }
679
682 template <typename Value, typename Alloc>
683 Keyword& operator>>(std::vector<Value,Alloc>& vec) {
684 const std::size_t n = kv_->count(key_.c_str());
685 vec.resize(n);
686 for(std::size_t i=0; i<n; ++i) {
687 vec[i] = detail::GetValue<Value>::eval(kv_, key_.c_str(), i);
688 }
689 return *this;
690 }
691
694 template <typename Key, typename Compare, typename Alloc>
695 Keyword& operator>>(std::set<Key, Compare, Alloc>& c) {
696 const std::size_t n = kv_->count(key_.c_str());
697 for(std::size_t i=0; i<n; ++i) {
698 c.insert( detail::GetValue<Key>::eval(kv_, key_.c_str(), i) );
699 }
700 return *this;
701 }
702
705 template <typename Key, typename Data, typename Compare, typename Alloc>
706 Keyword& operator>>(std::map<Key, Data, Compare, Alloc>& c) {
707 const std::size_t n = kv_->count(key_.c_str());
708 for(std::size_t i=0; i<n; ++i) {
709 if (kv_->count(key_.c_str(),i) != 2) {
710 std::ostringstream oss;
711 oss << key_ << ":" << i;
712 throw sc::InputError("invalid std::map specification in KeyVal",
713 __FILE__, __LINE__,
714 oss.str().c_str());
715 }
716 Key k = detail::GetValue<Key>::eval(kv_, key_.c_str(), i, 0);
717 Data d = detail::GetValue<Data>::eval(kv_, key_.c_str(), i, 1);
718 c.insert(std::make_pair(k,d));
719 }
720 return *this;
721 }
722
723 private:
724 Ref<KeyVal> kv_;
725 std::string key_;
726};
727
728}
729
730#endif /* _KeyVal_h */
731
732// Local Variables:
733// mode: c++
734// c-file-style: "CLJ"
735// End:
This takes several KeyVal objects and makes them look like one KeyVal object.
Definition keyval.h:431
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.
void errortrace(std::ostream &fp=ExEnv::err0())
Write a message to fp describing the error.
void dump(std::ostream &fp=ExEnv::err0())
Write a message to fp describing the error.
Ref< KeyValValue > key_value(const char *, const KeyValValue &def)
Ultimately called by value.
This class allows keyval associations to be set up by the program, rather than determined by an exter...
Definition keyval.h:340
Ref< KeyValValue > key_value(const char *, const KeyValValue &def)
Ultimately called by value.
void print(std::ostream &os=ExEnv::out0()) const
void clear()
Erase all of the stored assignments.
int key_exists(const char *)
Ultimately called by exists.
const char * classname(const char *)
Returns the name of the exact class of the object at the keyword.
static std::ostream & out0()
Return an ostream that writes from node 0.
static std::ostream & err0()
Return an ostream for error messages that writes from node 0.
Definition exenv.h:87
Definition ipv2.h:78
This is thrown when invalid input is provided.
Definition scexception.h:153
Represents a Ref<DescribedClass> value.
Definition keyvalval.h:201
Represents the value of a keyword.
Definition keyvalval.h:38
Represents a boolean value.
Definition keyvalval.h:75
Represents a char value.
Definition keyvalval.h:101
Represents a double value.
Definition keyvalval.h:62
Represents a float value.
Definition keyvalval.h:88
Represents an int value.
Definition keyvalval.h:114
Represents a long value.
Definition keyvalval.h:127
Represents a size_t value.
Definition keyvalval.h:140
Represents a std::string value.
Definition keyvalval.h:168
The KeyVal class is designed to simplify the process of allowing a user to specify keyword/value asso...
Definition keyval.h:69
virtual Ref< KeyValValue > key_value(const char *, const KeyValValue &def)=0
Ultimately called by value.
Ref< DescribedClass > describedclassvalue(const char *key=0, const KeyValValue &def=KeyValValueRefDescribedClass())
Returns a reference to an object of type DescribedClass.
char charvalue(const char *key=0, const KeyValValue &def=KeyValValuechar())
Returns the char value of key.
int intvalue(const char *key=0, const KeyValValue &def=KeyValValueint())
Returns the int value of key.
virtual float key_floatvalue(const char *key, const KeyValValue &def)
Ultimately called by floatvalue.
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 ...
virtual int key_booleanvalue(const char *, const KeyValValue &def)
Ultimately called by booleanvalue.
virtual char key_charvalue(const char *key, const KeyValValue &def)
Ultimately called by charvalue.
long longvalue(const char *key=0, const KeyValValue &def=KeyValValuelong())
Returns the long value of key.
const char * errormsg()
Return a textual representation of the current error.
std::string stringvalue(const char *key=0, const KeyValValue &def=KeyValValuestring())
Returns a string representation of the key's value.
virtual size_t key_sizevalue(const char *key, const KeyValValue &def)
Ultimately called by sizevalue.
virtual const char * classname(const char *)
Returns the name of the exact class of the object at the keyword.
Ref< KeyValValue > value(const char *key=0, const KeyValValue &def=KeyValValue())
Return the value associated with the keyword.
virtual int key_intvalue(const char *key, const KeyValValue &def)
Ultimately called by intvalue.
void seterror(KeyValValue::KeyValValueError err)
Set the current error condition.
const char * errormsg(KeyValError err)
Return a textual representation of err.
int verbose() const
Returns nonzero if assignments are printed.
Definition keyval.h:332
float floatvalue(const char *key=0, const KeyValValue &def=KeyValValuefloat())
Returns the float value of key.
virtual void dump(std::ostream &fp=ExEnv::err0())
Write a message to fp describing the error.
DEPRECATED char * pcharvalue(const char *key=0, const KeyValValue &def=KeyValValuestring())
Returns a copy of the string representation of the key's value.
KeyValError error()
Return the current error condition.
virtual Ref< DescribedClass > describedclass(const char *classname)
Returns a reference to an object of type DescribedClass using the top level keywords of this KeyVal.
int count(const char *=0)
If the value of a keyword is an array, then return its length.
virtual void print_unseen(std::ostream &fp=ExEnv::out0())
Print keywords that were never looked at, if possible.
virtual void errortrace(std::ostream &fp=ExEnv::err0())
Write a message to fp describing the error.
virtual std::string key_stringvalue(const char *key, const KeyValValue &def)
Ultimately called by stringvalue.
void verbose(int v)
Control printing of assignments.
Definition keyval.h:330
int exists(const char *)
This takes as its only argument a keyword.
virtual Ref< DescribedClass > key_describedclassvalue(const char *key, const KeyValValue &def)
Ultimately called by describedclassvalue.
virtual double key_doublevalue(const char *key, const KeyValValue &def)
Ultimately called by doublevalue.
virtual long key_longvalue(const char *key, const KeyValValue &def)
Ultimately called by longvalue.
int booleanvalue(const char *key=0, const KeyValValue &def=KeyValValueboolean())
Returns the boolean value (0 = false, 1 = true) of key.
virtual int key_count(const char *=0)
Ultimately called by count.
double doublevalue(const char *key=0, const KeyValValue &def=KeyValValuedouble())
Returns the double value of key.
virtual DEPRECATED char * key_pcharvalue(const char *key, const KeyValValue &def)
Ultimately called by pcharvalue.
virtual int key_exists(const char *)=0
Ultimately called by exists.
size_t sizevalue(const char *key=0, const KeyValValue &def=KeyValValuesize())
Returns the size_t value of key.
void seterror(KeyValError err)
Set the current error condition.
Provides convenient way to fill standard containers from KeyVal.
Definition keyval.h:672
Keyword & operator>>(std::set< Key, Compare, Alloc > &c)
fills up std::set using KeyVal object of the following form key = [ key0 key1 key2 ....
Definition keyval.h:695
Keyword & operator>>(std::vector< Value, Alloc > &vec)
fills up std::vector using KeyVal object of the following form key = [ value0 value1 value2 ....
Definition keyval.h:683
Keyword & operator>>(std::map< Key, Data, Compare, Alloc > &c)
fills up std::map using KeyVal object of the following form key = [ [key0 value0] [key1 value1] [key2...
Definition keyval.h:706
Converts textual information into keyword/value assocations.
Definition keyval.h:546
void parse_string(const std::string &)
Read input data from the given string.
void read(const char *)
Read input data from the given filename.
void read(const std::string &)
Read input data from the given filename.
void read(std::istream &)
Read input data from the given stream.
int have_unseen()
Return 1 if there were unseen keywords, 0 if there are none, or -1 this keyval doesn't keep track of ...
ParsedKeyVal()
Create an empty ParsedKeyVal.
const char * classname(const char *)
Returns the name of the exact class of the object at the keyword.
void dump(std::ostream &fp=ExEnv::err0())
Write a message to fp describing the error.
ParsedKeyVal(IPV2 *)
Use the given IPV2* object.
ParsedKeyVal(const char *file)
Parse the given input file.
void print_unseen(std::ostream &fp=ExEnv::out0())
Print keywords that were never looked at, if possible.
void errortrace(std::ostream &fp=ExEnv::err0())
Write a message to fp describing the error.
ParsedKeyVal(const char *, const Ref< KeyVal > &)
This ctor is given a string which is used to form keywords that are sought in the keyval argument.
const char * truekeyword(const char *)
Returns a string which is the actual keyword if some sort of variable substitution takes place (neede...
ParsedKeyVal(std::istream &s)
Read input from s.
~ParsedKeyVal()
Cleanup, deleting the IPV2 object.
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...
std::string stringrep(const char *)
Returns the string representation of the value assigned to key.
PrefixKeyVal is a KeyVal that searches a different KeyVal using modified keys.
Definition keyval.h:508
void errortrace(std::ostream &fp=ExEnv::err0())
Write a message to fp describing the error.
const char * classname(const char *)
Returns the name of the exact class of the object at the keyword.
void dump(std::ostream &fp=ExEnv::err0())
Write a message to fp describing the error.
The base class for all reference counted objects.
Definition ref.h:192
A template class that maintains references counts.
Definition ref.h:361
StringKeyVal is a base class for KeyVal implementations that store all values in a string format.
Definition keyval.h:392
virtual void dump(std::ostream &fp=ExEnv::err0())
Write a message to fp describing the error.
virtual 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 const char * classname(const char *)
Returns the name of the exact class of the object at the keyword.
virtual std::string stringrep(const char *key)=0
Returns the string representation of the value assigned to key.
Ref< KeyValValue > key_value(const char *, const KeyValValue &def)
Ultimately called by value.
int key_exists(const char *)
Ultimately called by exists.
Contains all MPQC code up to version 3.
Definition mpqcin.h:14
STL namespace.
GetValue(keyval, key, i) grabs the value corresponding to key.
Definition keyval.h:602

Generated at Wed Sep 25 2024 02:45:30 for MPQC 3.0.0-alpha using the documentation package Doxygen 1.12.0.