IPhreeqc
Var.h
Go to the documentation of this file.
1 
4 // Var.h
5 
6 #ifndef __VAR_H_INC
7 #define __VAR_H_INC
8 
9 #include "PHRQ_exports.h"
10 
11 #if defined(R_SO) || defined(NO_NAMELESS_UNION)
12 #define VAR_UNION_NAME u
13 #else
14 #define VAR_UNION_NAME
15 #endif
16 
19 typedef enum {
20  TT_EMPTY = 0,
21  TT_ERROR = 1,
22  TT_LONG = 2,
23  TT_DOUBLE = 3,
24  TT_STRING = 4
25 } VAR_TYPE;
26 
29 typedef enum {
30  VR_OK = 0,
36 } VRESULT;
37 
40 typedef struct {
42  union {
43  long lVal;
44  double dVal;
45  char* sVal;
47  } VAR_UNION_NAME;
48 } VAR;
49 
50 
51 #if defined(__cplusplus)
52 extern "C" {
53 #endif
54 
59 IPQ_DLL_EXPORT char* VarAllocString(const char* pSrc);
60 
66 IPQ_DLL_EXPORT VRESULT VarClear(VAR* pvar);
67 
76 IPQ_DLL_EXPORT VRESULT VarCopy(VAR* pvarDest, const VAR* pvarSrc);
77 
81 IPQ_DLL_EXPORT void VarFreeString(char* pSrc);
82 
86 IPQ_DLL_EXPORT void VarInit(VAR* pvar);
87 
88 #if defined(__cplusplus)
89 }
90 #endif
91 
92 #if defined(__cplusplus)
93 
94 #include <ostream> // std::ostream
95 
96 inline std::ostream& operator<< (std::ostream &os, const VAR_TYPE& vt)
97 {
98  switch(vt)
99  {
100  case TT_EMPTY:
101  os << "TT_EMPTY";
102  break;
103  case TT_ERROR:
104  os << "TT_ERROR";
105  break;
106  case TT_LONG:
107  os << "TT_LONG";
108  break;
109  case TT_DOUBLE:
110  os << "TT_DOUBLE";
111  break;
112  case TT_STRING:
113  os << "TT_STRING";
114  break;
115  default:
116  os << (int)vt;
117  break;
118  }
119  return os;
120 }
121 
122 inline std::ostream& operator<< (std::ostream &os, const VRESULT& vr)
123 {
124  switch(vr)
125  {
126  case VR_OK:
127  os << "VR_OK";
128  break;
129  case VR_OUTOFMEMORY:
130  os << "VR_OUTOFMEMORY";
131  break;
132  case VR_BADVARTYPE:
133  os << "VR_BADVARTYPE";
134  break;
135  case VR_INVALIDARG:
136  os << "VR_INVALIDARG";
137  break;
138  case VR_INVALIDROW:
139  os << "VR_INVALIDROW";
140  break;
141  case VR_INVALIDCOL:
142  os << "VR_INVALIDCOL";
143  break;
144  default:
145  os << (int)vr;
146  break;
147  }
148  return os;
149 }
150 #endif /* __cplusplus */
151 
152 #endif /* __VAR_H_INC */
VAR_TYPE type
Definition: Var.h:41
double dVal
Definition: Var.h:44
Definition: Var.h:31
Definition: Var.h:32
Definition: Var.h:22
IPQ_DLL_EXPORT char * VarAllocString(const char *pSrc)
IPQ_DLL_EXPORT VRESULT VarCopy(VAR *pvarDest, const VAR *pvarSrc)
Definition: Var.h:24
Definition: Var.h:35
Definition: Var.h:20
Datatype used to store SELECTED_OUTPUT values.
Definition: Var.h:40
IPQ_DLL_EXPORT void VarFreeString(char *pSrc)
VRESULT vresult
Definition: Var.h:46
Definition: Var.h:21
char * sVal
Definition: Var.h:45
IPQ_DLL_EXPORT void VarInit(VAR *pvar)
Definition: Var.h:30
Definition: Var.h:23
long lVal
Definition: Var.h:43
VAR_TYPE
Enumeration used to determine the type of data stored in a VAR.
Definition: Var.h:19
Definition: Var.h:33
VRESULT
Enumeration used to return error codes.
Definition: Var.h:29
Definition: Var.h:34
IPQ_DLL_EXPORT VRESULT VarClear(VAR *pvar)