34
34
/* Date : May 1996 */
35
35
/*-----------------------------------------------------------------------*/
37
/* A egenric container class, originally for ints floats and string now */
37
/* A generic container class, originally for ints floats and string now */
38
38
/* extended for some others, eventually allow run addition of new types */
39
39
/* "built-in" types (i.e. ones explicitly mentioned in this file) may */
40
40
/* be accessed by member functions, objects added at run time may only */
41
41
/* be accessed by functions */
43
43
/* This is so similar to the LISP class in SIOD it could be viewed as a */
44
/* little embarassing, but this is done without a cons cell heap or gc */
44
/* little embarrassing, but this is done without a cons cell heap or gc */
45
45
/* which may or may not be a good thing. */
47
47
/*=======================================================================*/
103
103
EST_Val(const double d) {t=val_float; v.fval=d;}
105
105
/** Copy constructor for a string*/
106
EST_Val(const EST_String &s) {t=val_string; sval = s;}
106
// EST_Val(const EST_String &s) {t=val_string; sval = s;}
107
EST_Val(const EST_String &s) : t(val_string), sval(s) {};
108
109
/** Copy constructor for a string literal*/
109
EST_Val(const char *s) {t=val_string; sval = s;}
110
// EST_Val(const char *s) {t=val_string; sval = s;}
111
EST_Val(const char *s) : t(val_string), sval(s) {};
112
113
EST_Val(val_type type,void *p, void (*f)(void *));
133
134
const int I(void) const
134
135
{ return Int(); }
136
/** returns the value, cast as an float */
137
/** returns the value, cast as a float */
137
138
const float Float(void) const
138
139
{if (t==val_float) return v.fval; return to_flt();}
140
/** returns the value, cast as an float */
141
/** returns the value, cast as a float */
141
142
const float F(void) const
142
143
{ return Float(); }
144
/** returns the value, cast as an string */
145
/** returns the value, cast as a string */
145
146
const EST_String &String(void) const
146
147
{if (t!=val_string) to_str(); return sval;}
148
/** returns the value, cast as an string */
149
/** returns the value, cast as a string */
149
150
const EST_String &string(void) const
150
151
{return String();}
152
/** returns the value, cast as an string */
153
/** returns the value, cast as a string */
153
154
const EST_String &S(void) const
154
155
{return String();}
156
/** returns the value, cast as an string */
157
/** returns the value, cast as a string */
157
158
const EST_String &string_only(void) const {return sval;}
253
254
inline const char *error_name(const EST_Val val) { return (EST_String)val;}
256
256
// For consistency with other (user-defined) types in val
258
inline EST_String String(const EST_Val &v) { return v.string(); }
259
257
inline EST_Val est_val(const EST_String s) { return EST_Val(s); }
260
258
inline EST_Val est_val(const char *s) { return EST_Val(s); }
261
259
inline int Int(const EST_Val &v) { return v.Int(); }