51#include "EST_String.h"
53#include "EST_Contents.h"
54#include "EST_Val_defs.h"
56typedef const char *val_type;
58extern val_type val_unset;
59extern val_type val_int;
60extern val_type val_float;
61extern val_type val_string;
79 const int to_int()
const;
80 const float to_flt()
const;
96 {t=val_int; v.ival=i;}
100 {t=val_float; v.fval=f;}
103 EST_Val(
const double d) {t=val_float; v.fval=d;}
111 EST_Val(
const char *s) : t(val_string), sval(s) {};
126 const val_type
type(
void)
const
131 {
if (t==val_int)
return v.ival;
return to_int();}
134 const int I(
void)
const
139 {
if (t==val_float)
return v.fval;
return to_flt();}
142 const float F(
void)
const
147 {
if (t!=val_string) to_str();
return sval;}
163 const void *internal_ptr(
void)
const
164 {
return v.pval->get_contents(); }
199 {
if (t != a.t)
return (1==0);
200 else if (t == val_string)
return (sval == a.sval);
201 else if (t == val_int)
return (v.ival == a.v.ival);
202 else if (t == val_float)
return (v.fval == a.v.fval);
203 else return (internal_ptr() == a.internal_ptr()); }
237 operator int()
const {
return Int(); }
239 operator float()
const {
return Float(); }
245 {
if (a.
type() == val_unset) s <<
"[VAL unset]" ;
246 else if (a.
type() == val_int) s << a.v.ival;
247 else if (a.
type() == val_float) s << a.v.fval;
248 else if (a.
type() == val_string) s << a.sval;
249 else s <<
"[PVAL " << a.
type() <<
"]";
259inline int Int(
const EST_Val &v) {
return v.
Int(); }
261inline float Float(
const EST_Val &v) {
return v.
Float(); }
const EST_String & S(void) const
const float F(void) const
const EST_String & string(void) const
friend ostream & operator<<(ostream &s, const EST_Val &a)
EST_Val & operator=(const char *s)
EST_Val & operator=(const EST_String &s)
EST_Val & operator=(const float f)
const int Int(void) const
const EST_String & string_only(void) const
const EST_String & String(void) const
int operator!=(const EST_Val &a) const
int operator==(const EST_Val &a) const
EST_Val & operator=(const int i)
EST_Val & operator=(const double d)
const val_type type(void) const
const float Float(void) const
EST_Val(const EST_String &s)