51 #include "EST_String.h"
52 #include "EST_error.h"
53 #include "EST_Contents.h"
54 #include "EST_Val_defs.h"
56 typedef const char *val_type;
58 extern val_type val_unset;
59 extern val_type val_int;
60 extern val_type val_float;
61 extern val_type val_string;
84 const int to_int()
const;
85 const float to_flt()
const;
101 {t=val_int; v.ival=i;}
105 {t=val_float; v.fval=f;}
108 EST_Val(
const double d) {t=val_float; v.fval=d;}
116 EST_Val(
const char *s) : t(val_string), sval(s) {};
131 const val_type
type(
void)
const
136 {
if (t==val_int)
return v.ival;
return to_int();}
139 const int I(
void)
const
144 {
if (t==val_float)
return v.fval;
return to_flt();}
147 const float F(
void)
const
152 {
if (t!=val_string) to_str();
return sval;}
168 const void *internal_ptr(
void)
const
169 {
return v.pval->get_contents(); }
204 {
if (t != a.t)
return (1==0);
205 else if (t == val_string)
return (sval == a.sval);
206 else if (t == val_int)
return (v.ival == a.v.ival);
207 else if (t == val_float)
return (v.fval == a.v.fval);
208 else return (internal_ptr() == a.internal_ptr()); }
242 operator int()
const {
return Int(); }
244 operator float()
const {
return Float(); }
250 {
if (a.
type() == val_unset) s <<
"[VAL unset]" ;
251 else if (a.
type() == val_int) s << a.v.ival;
252 else if (a.
type() == val_float) s << a.v.fval;
253 else if (a.
type() == val_string) s << a.sval;
254 else s <<
"[PVAL " << a.
type() <<
"]";
265 inline int Int(
const EST_Val &v) {
return v.
Int(); }
267 inline float Float(
const EST_Val &v) {
return v.
Float(); }
EST_Val & operator=(const EST_String &s)
const int Int(void) const
EST_Val(const EST_String &s)
const float Float(void) const
const val_type type(void) const
friend ostream & operator<<(ostream &s, const EST_Val &a)
EST_Val & operator=(const double d)
int operator==(const EST_Val &a) const
const EST_String & string(void) const
EST_Val & operator=(const char *s)
const EST_String & string_only(void) const
const EST_String & String(void) const
const EST_String & S(void) const
const float F(void) const
EST_Val & operator=(const int i)
EST_Val & operator=(const float f)
int operator!=(const EST_Val &a) const