40 #include "EST_FileType.h"
41 #include "EST_TNamedEnum.h"
42 #include "EST_Token.h"
43 #include "EST_Option.h"
44 #include "EST_Features.h"
49 { est_file_none, {
"None" }},
50 { est_file_track, {
"Track",
"track" }},
51 { est_file_wave, {
"wave" }},
52 { est_file_label, {
"label" }},
53 { est_file_utterance, {
"utterance" }},
54 { est_file_fmatrix, {
"fmatrix" }},
55 { est_file_fvector, {
"fvector" }},
56 { est_file_dmatrix, {
"dmatrix" }},
57 { est_file_dvector, {
"dvector" }},
58 { est_file_feature_data, {
"feature_data" }},
59 { est_file_fst, {
"fst" }},
60 { est_file_ngram, {
"ngram" }},
61 { est_file_index, {
"index" }},
62 { est_file_f_catalogue, {
"f_catalogue" }},
63 { est_file_unknown, {
"unknown" }},
64 { est_file_none, {
"None" }},
69 #if defined(INSTANTIATE_TEMPLATES)
71 #include "../base_class/EST_TNamedEnum.cc"
83 bool &ascii, EST_EstFileType &t)
93 if ((ts.
fread(magic_number,
sizeof(
char),8) != 8) ||
94 (strncmp(magic_number,
"EST_File",8) != 0))
100 v = ts.
get().string();
101 t = EstFileEnums.token(v);
103 if (t == est_file_none)
107 t = est_file_unknown;
108 hinfo.
set(
"FileType", v);
111 while ((!ts.
eof()) && (ts.
peek().string() !=
"EST_Header_End"))
113 k = ts.
get().string();
117 v = v.
after(RXwhite);
124 cerr <<
"Unexpected end of EST_File" << endl;
125 return misc_read_error;
130 if (hinfo.
S(
"DataType") ==
"binary")
139 bool &ascii, EST_EstFileType &t)
142 char magic_number[9];
149 if ((ts.
fread(magic_number,
sizeof(
char),8) != 8) ||
150 (strncmp(magic_number,
"EST_File",8) != 0))
156 v = ts.
get().string();
157 t = EstFileEnums.token(v);
159 if (t == est_file_none)
163 t = est_file_unknown;
167 while ((!ts.
eof()) && (ts.
peek().string() !=
"EST_Header_End"))
169 k = ts.
get().string();
173 v = v.
after(RXwhite);
180 cerr <<
"Unexpected end of EST_File" << endl;
181 return misc_read_error;
186 if (hinfo.
sval(
"DataType",0) ==
"binary")
EST_TokenStream & get(EST_Token &t)
get next token in stream
int fread(void *buff, int size, int nitems) EST_WARN_UNUSED_RESULT
Reading binary data, (don't use peek() immediately beforehand)
int tell(void) const
tell, synonym for filepos
void set(const EST_String &name, int ival)
const EST_String S(const EST_String &path) const
const EST_String & sval(const EST_String &rkey, int m=1) const
EST_Token & peek(void)
peek at next token
int add_item(const K &rkey, const V &rval, int no_search=0)
add key-val pair to list
int contains(const char *s, int pos=-1) const
Does it contain this substring?
EST_Token get_upto_eoln(void)
get up to { s} in end of line as a single token.
EST_String after(int pos, int len=1) const
Part after pos+len.
int seek(int position)
seek, reposition file pointer