71 #if defined(INSTANTIATE_TEMPLATES) 73 #include "../base_class/EST_TNamedEnum.cc" 95 if ((ts.
fread(magic_number,
sizeof(
char),8) != 8) ||
96 (strncmp(magic_number,
"EST_File",8) != 0))
98 if (ts.
seek(pos) != 0) {
99 cerr <<
"Data seek error: Could not set TokenStream to the original position" << endl;
105 v = ts.
get().string();
113 hinfo.
set(
"FileType", v);
116 while ((!ts.
eof()) && (ts.
peek().
string() !=
"EST_Header_End"))
118 k = ts.
get().string();
129 cerr <<
"Unexpected end of EST_File" << endl;
135 if (hinfo.
S(
"DataType") ==
"binary")
147 char magic_number[9];
154 if ((ts.
fread(magic_number,
sizeof(
char),8) != 8) ||
155 (strncmp(magic_number,
"EST_File",8) != 0))
157 if (ts.
seek(pos) != 0) {
158 cerr <<
"Data seek error: Could not set the TokenStream to the original position" << endl;
164 v = ts.
get().string();
175 while ((!ts.
eof()) && (ts.
peek().
string() !=
"EST_Header_End"))
177 k = ts.
get().string();
188 cerr <<
"Unexpected end of EST_File" << endl;
194 if (hinfo.
sval(
"DataType",0) ==
"binary")
EST_TokenStream & get(EST_Token &t)
get next token in stream
int contains(const char *s, ssize_t pos=-1) const
Does it contain this substring?
int fread(void *buff, int size, int nitems) EST_WARN_UNUSED_RESULT
Reading binary data, (don't use peek() immediately beforehand)
EST_FilePos tell(void) const
tell, synonym for filepos
void set(const EST_String &name, int ival)
const EST_String S(const EST_String &path) const
EST_read_status read_est_header(EST_TokenStream &ts, EST_Features &hinfo, bool &ascii, EST_EstFileType &t)
const EST_String & sval(const EST_String &rkey, int m=1) const
EST_Regex RXwhite("[ \n\t\r]+")
White space.
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
const EST_String & string() const
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.
EST_TNamedEnum< EST_EstFileType > EstFileEnums(estfile_names)
int seek(int position)
seek, reposition file pointer