61 if (fvalue.
type() == val_type_feats)
67 outf << fname <<
" () ; ";
101 sprintf(b,
"%g",fvalue.
Float());
116 if (features->list.head() == 0)
119 for (
EST_Litem *p=features->list.head(); p != 0; p=p->
next() )
122 features->list(p).v);
131 for (
EST_Litem *p=features->list.head(); p != 0; p=p->
next() )
133 const EST_String &fname = features->list(p).k;
134 const EST_Val &fvalue = features->list(p).v;
159 sprintf(b,
"%g",fvalue.
Float());
166 else if (fvalue.
type() == val_type_feats)
168 feats(fvalue)->save_sexpr(outf);
185 if (ts.
peek() !=
"(")
187 cerr <<
"load_features: no sexpression found\n";
195 for (; ts.
peek() !=
")"; )
197 if (ts.
peek() !=
"(")
199 cerr <<
"load_features: no sexpression found\n";
203 f = ts.
get().string();
227 cerr <<
"load_features: Unknown Function '" << f <<
"'\n";
228 set_val(f,feature_default_value);
237 cerr <<
"load_features: no sexpression found\n";
243 cerr <<
"load_features: no sexpression found\n";
261 cerr <<
"load_features: unexpected end of file\n";
264 f = ts.
get().string();
276 else if (v.
string() ==
"0")
278 else if ((strchr(
"0123456789-.",v.
string()(0)) !=
NULL) &&
293 cerr <<
"load_features: Unknown Function '" << f <<
"'\n";
294 set_path(f, feature_default_value);
297 else if (v.
string() ==
"()")
302 else if (v !=
"<contents>")
304 if (ts.
peek() ==
";")
309 " missing semicolon in feature list\n";
EST_write_status save_sexpr(ostream &outf) const
save features as s-expression in already opened ostream
EST_Item_featfunc featfunc(const EST_Val &v)
EST_TokenStream & get(EST_Token &t)
get next token in stream
void set_function(const EST_String &name, const EST_String &f)
EST_Val(* EST_Item_featfunc)(class EST_Item *)
int contains(const char *s, ssize_t pos=-1) const
Does it contain this substring?
EST_read_status load_sexpr(EST_TokenStream &ts)
load features from sexpression, contained in already opened EST_TokenStream
EST_Val est_val(const EST_Item_featfunc f)
EST_String get_featname(const EST_Item_featfunc func)
EST_read_status load(EST_TokenStream &ts)
load features from already opened EST_TokenStream
EST_Regex RXdouble("-?\\(\\([0-9]+\\.[0-9]*\\)\\|\\([0-9]+\\)\\|\\(\\.[0-9]+\\)\\)\\([eE][---+]?[0-9]+\\)?")
Floating point number.
const EST_String & whitespace()
int quoted() const
TRUE is token was quoted.
EST_Regex RXint("-?[0-9]+")
Integer.
EST_TKVL< EST_String, EST_Val > * features
val_type val_type_featfunc
The file was written successfully.
EST_TList< EST_TKVI< K, V > > list
Linked list of key-val pairs. Don't use this as it will be made private in the future.
val_type type(void) const
EST_Token & peek(void)
peek at next token
const EST_String & string(void) const
EST_write_status save(ostream &outf) const
save features in already opened ostream
int matches(const char *e, ssize_t pos=0) const
Exactly match this string?
const EST_String & string() const
const EST_String pos_description()
A string describing current position, suitable for error messages.
EST_Item_featfunc get_featfunc(const EST_String &name, int must=0)
EST_String after(int pos, int len=1) const
Part after pos+len.
EST_String quote_string(const EST_String &s, const EST_String "e, const EST_String &escape, int force)
static const EST_String Empty
Constant empty string.
void save_fpair(ostream &outf, const EST_String &fname, const EST_Val &fvalue) const