MPQC  3.0.0-alpha
keyvalval.h
1 //
2 // keyval.h
3 //
4 // Copyright (C) 1997 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_keyvalval_h
29 #define _util_keyval_keyvalval_h
30 
31 #include <string>
32 
33 #include <util/class/class.h>
34 
35 namespace sc {
36 
38 class KeyValValue: public RefCount {
39  public:
40  enum KeyValValueError { OK, WrongType };
41  public:
42  KeyValValue() {}
43  KeyValValue(const KeyValValue&);
44  virtual ~KeyValValue();
45  virtual KeyValValue::KeyValValueError doublevalue(double&) const;
46  virtual KeyValValue::KeyValValueError booleanvalue(int&) const;
47  virtual KeyValValue::KeyValValueError floatvalue(float&) const;
48  virtual KeyValValue::KeyValValueError charvalue(char&) const;
49  virtual KeyValValue::KeyValValueError intvalue(int&) const;
50  virtual KeyValValue::KeyValValueError longvalue(long&) const;
51  virtual KeyValValue::KeyValValueError sizevalue(size_t&) const;
52  DEPRECATED virtual KeyValValue::KeyValValueError pcharvalue(const char*&) const;
53  virtual KeyValValue::KeyValValueError stringvalue(std::string&) const;
54  virtual KeyValValue::KeyValValueError describedclassvalue(Ref<DescribedClass>&) const;
55  virtual void print(std::ostream &o=ExEnv::out0()) const;
56 };
57 std::ostream& operator<<(std::ostream&,const KeyValValue&);
58 
59 
60 
63  private:
64  double _val;
65  public:
66  KeyValValuedouble(): _val(0.0) {}
67  KeyValValuedouble(double v): _val(v) {}
70  KeyValValue::KeyValValueError doublevalue(double&) const;
71  void print(std::ostream &o=ExEnv::out0()) const;
72 };
73 
76  private:
77  int _val;
78  public:
79  KeyValValueboolean(): _val(0) {}
80  KeyValValueboolean(int v): _val(v) {}
83  KeyValValue::KeyValValueError booleanvalue(int&) const;
84  void print(std::ostream &o=ExEnv::out0()) const;
85 };
86 
89  private:
90  float _val;
91  public:
92  KeyValValuefloat(): _val(0.0) {}
93  KeyValValuefloat(float v): _val(v) {}
96  KeyValValue::KeyValValueError floatvalue(float&) const;
97  void print(std::ostream &o=ExEnv::out0()) const;
98 };
99 
102  private:
103  char _val;
104  public:
105  KeyValValuechar(): _val(0) {}
106  KeyValValuechar(char v): _val(v) {}
108  ~KeyValValuechar();
109  KeyValValue::KeyValValueError charvalue(char&) const;
110  void print(std::ostream &o=ExEnv::out0()) const;
111 };
112 
115  private:
116  int _val;
117  public:
118  KeyValValueint(): _val(0) {}
119  KeyValValueint(int v): _val(v) {}
121  ~KeyValValueint();
122  KeyValValue::KeyValValueError intvalue(int&) const;
123  void print(std::ostream &o=ExEnv::out0()) const;
124 };
125 
128  private:
129  long _val;
130  public:
131  KeyValValuelong(): _val(0) {}
132  KeyValValuelong(long v): _val(v) {}
134  ~KeyValValuelong();
135  KeyValValue::KeyValValueError longvalue(long&) const;
136  void print(std::ostream &o=ExEnv::out0()) const;
137 };
138 
141  private:
142  size_t _val;
143  public:
144  KeyValValuesize(): _val(0) {}
145  KeyValValuesize(int v): _val(v) {}
147  ~KeyValValuesize();
148  KeyValValue::KeyValValueError sizevalue(size_t&) const;
149  void print(std::ostream &o=ExEnv::out0()) const;
150 };
151 
154  private:
155  char* _val;
156  public:
157  DEPRECATED KeyValValuepchar(): _val(0) {}
158  DEPRECATED KeyValValuepchar(const char*);
159  DEPRECATED KeyValValuepchar(const KeyValValuepchar&);
160  ~KeyValValuepchar();
161  DEPRECATED KeyValValue::KeyValValueError pcharvalue(const char*&) const;
162  KeyValValue::KeyValValueError stringvalue(std::string&) const;
163  void print(std::ostream &o=ExEnv::out0()) const;
164 };
165 
169  private:
170  // This is used to provide compatibility with KeyValValuepchar:
171  bool _defined;
172  std::string _val;
173  public:
174  KeyValValuestring():_defined(false) {}
175  KeyValValuestring(const std::string&);
179  KeyValValue::KeyValValueError doublevalue(double&) const;
182  KeyValValue::KeyValValueError booleanvalue(int&) const;
184  KeyValValue::KeyValValueError floatvalue(float&) const;
186  KeyValValue::KeyValValueError charvalue(char&) const;
188  KeyValValue::KeyValValueError intvalue(int&) const;
190  KeyValValue::KeyValValueError longvalue(long&) const;
193  KeyValValue::KeyValValueError sizevalue(size_t&) const;
195  DEPRECATED KeyValValue::KeyValValueError pcharvalue(const char*&) const;
196  KeyValValue::KeyValValueError stringvalue(std::string&) const;
197  void print(std::ostream &o=ExEnv::out0()) const;
198 };
199 
202  private:
203  Ref<DescribedClass> _val;
204  public:
209  KeyValValue::KeyValValueError describedclassvalue(Ref<DescribedClass>&) const;
210  void print(std::ostream &o=ExEnv::out0()) const;
211 };
212 
213 }
214 
215 #endif /* _KeyVal_h */
216 
217 // Local Variables:
218 // mode: c++
219 // c-file-style: "CLJ"
220 // End:
sc::KeyValValuestring::sizevalue
KeyValValue::KeyValValueError sizevalue(size_t &) const
Converts the string to size_t.
sc::KeyValValuefloat
Represents a float value.
Definition: keyvalval.h:88
sc::KeyValValuestring
Represents a std::string value.
Definition: keyvalval.h:168
sc::KeyValValueRefDescribedClass
Represents a Ref<DescribedClass> value.
Definition: keyvalval.h:201
sc::Ref
A template class that maintains references counts.
Definition: ref.h:361
sc::KeyValValuesize
Represents a size_t value.
Definition: keyvalval.h:140
sc::KeyValValuestring::booleanvalue
KeyValValue::KeyValValueError booleanvalue(int &) const
Converts the string to boolean.
sc::KeyValValuestring::charvalue
KeyValValue::KeyValValueError charvalue(char &) const
Converts the string to char.
sc::KeyValValuestring::floatvalue
KeyValValue::KeyValValueError floatvalue(float &) const
Converts the string to float.
sc::KeyValValuestring::intvalue
KeyValValue::KeyValValueError intvalue(int &) const
Converts the string to int.
sc::KeyValValuelong
Represents a long value.
Definition: keyvalval.h:127
sc::KeyValValuestring::longvalue
KeyValValue::KeyValValueError longvalue(long &) const
Converts the string to long.
sc::KeyValValueboolean
Represents a boolean value.
Definition: keyvalval.h:75
sc::KeyValValueint
Represents an int value.
Definition: keyvalval.h:114
sc::operator<<
std::vector< unsigned int > operator<<(const GaussianBasisSet &B, const GaussianBasisSet &A)
computes a map from basis functions in A to the equivalent basis functions in B.
sc::KeyValValuechar
Represents a char value.
Definition: keyvalval.h:101
sc::KeyValValuestring::pcharvalue
DEPRECATED KeyValValue::KeyValValueError pcharvalue(const char *&) const
Converts the string to a pointer to char (deprecated).
sc::KeyValValue
Represents the value of a keyword.
Definition: keyvalval.h:38
sc::KeyValValuepchar
Represents a pointer to char value (deprecated, use KeyValValuestring).
Definition: keyvalval.h:153
sc::KeyValValuestring::doublevalue
KeyValValue::KeyValValueError doublevalue(double &) const
Converts the string to double.
sc::ExEnv::out0
static std::ostream & out0()
Return an ostream that writes from node 0.
sc::RefCount
The base class for all reference counted objects.
Definition: ref.h:192
sc::KeyValValuedouble
Represents a double value.
Definition: keyvalval.h:62
sc
Contains all MPQC code up to version 3.
Definition: mpqcin.h:14

Generated at Sun Jan 26 2020 23:24:01 for MPQC 3.0.0-alpha using the documentation package Doxygen 1.8.16.