In file ../include/EST_Token.h:

class EST_TokenStream

A class that allows the reading of EST_Tokens from a file stream, pipe or string.

Public Methods

[more] EST_TokenStream ()
[more] ~EST_TokenStream ()
will close file if appropriate for type
[more] stream access functions

[more]EST_TokenStream& get (EST_Token &t)
get next token in stream
[more]EST_Token& get ()
get next token in stream
[more] get the next token which must be the argument.
[more]EST_Token get_upto (const EST_String &s)
get up to s in stream as a single token
[more]EST_Token get_upto_eoln (void)
get up to s in end of line as a single token
[more]EST_Token& peek (void)
peek at next token
[more]int fread (void* buff, int size, int nitems)
Reading binary data, (don't use peek() immediately beforehand)

[more] stream initialization functions

[more]void set_WhiteSpaceChars (const EST_String &ws)
set which characters are to be treated as whitespace
[more]void set_SingleCharSymbols (const EST_String &sc)
set which characters are to be treated as single character symbols
[more]void set_PunctuationSymbols (const EST_String &ps)
set which characters are to be treated as (post) punctuation
[more]void set_PrePunctuationSymbols (const EST_String &ps)
set which characters are to be treated as (post) punctuation
[more]void set_quotes (char q, char e)
set characters to be used as quotes and escape, and set quote mode
[more]int quoted_mode (void)
query quote mode

[more] miscellaneous

[more]int linenum (void) const
returns line number of EST_TokenStream
[more]int eof ()
end of file
[more]int eoln ()
end of line
[more]int filepos (void) const
current file position in EST_TokenStream
[more]int tell (void) const
tell, synonym for filepos
[more]int seek (int position)
seek, reposition file pointer
[more]int restart (void)
Reset to start of file/string
[more]const EST_String pos_description ()
A string describing current position, suitable for error messages
[more]const EST_String filename () const
The originating filename (if there is one)
[more]FILE* filedescriptor ()
For the people who *need* the actual description (if possible)
[more]EST_TokenStream& operator >> (EST_Token &p)
[more]EST_TokenStream& operator >> (EST_String &p)

Public

[more]


Documentation

A class that allows the reading of EST_Tokens from a file stream, pipe or string. It automatically tokenizes a file based on user definable whitespace and punctuation.

The definitions of whitespace and punctuation are user definable. Also support for single character symbols is included. Single character symbols always are treated as individual tokens irrespective of their white space context. Also a quote mode can be used to read uqoted tokens.

The setting of whitespace, pre and post punctuation, single character symbols and quote mode must be down (immediately) after opening the stream.

There is no unget but peek provides look ahead of one token.

Note there is an interesting issue about what to do about the last whitespace in the file. Should it be ignored or should it be attached to a token with a name string of length zero. In unquoted mode the eof() will return TRUE if the next token name is empty (the mythical last token). In quoted mode the last must be returned so eof will not be raised.

o EST_TokenStream()

o ~EST_TokenStream()
will close file if appropriate for type

o

oint open(const EST_String &filename)
open a EST_TokenStream for a file

oint open(FILE* ofp, int close_when_finished)
open a EST_TokenStream for an already opened file

oint open(istream &newis)
open a EST_TokenStream for an already open istream

oint open_string(const EST_String &newbuffer)
open a EST_TokenStream for string rather than a file

ovoid close(void)
Close stream

o stream access functions

oEST_TokenStream& get(EST_Token &t)
get next token in stream

oEST_Token& get()
get next token in stream

o get the next token which must be the argument.

oEST_Token get_upto(const EST_String &s)
get up to s in stream as a single token

oEST_Token get_upto_eoln(void)
get up to s in end of line as a single token

oEST_Token& peek(void)
peek at next token

oint fread(void* buff, int size, int nitems)
Reading binary data, (don't use peek() immediately beforehand)

o stream initialization functions

ovoid set_WhiteSpaceChars(const EST_String &ws)
set which characters are to be treated as whitespace

ovoid set_SingleCharSymbols(const EST_String &sc)
set which characters are to be treated as single character symbols

ovoid set_PunctuationSymbols(const EST_String &ps)
set which characters are to be treated as (post) punctuation

ovoid set_PrePunctuationSymbols(const EST_String &ps)
set which characters are to be treated as (post) punctuation

ovoid set_quotes(char q, char e)
set characters to be used as quotes and escape, and set quote mode

oint quoted_mode(void)
query quote mode

o miscellaneous
Friends:
ostream& operator <<(ostream& s, EST_TokenStream &p)

oint linenum(void) const
returns line number of EST_TokenStream

oint eof()
end of file

oint eoln()
end of line

oint filepos(void) const
current file position in EST_TokenStream

oint tell(void) const
tell, synonym for filepos

oint seek(int position)
seek, reposition file pointer

oint restart(void)
Reset to start of file/string

oconst EST_String pos_description()
A string describing current position, suitable for error messages

oconst EST_String filename() const
The originating filename (if there is one)

oFILE* filedescriptor()
For the people who *need* the actual description (if possible)

oEST_TokenStream& operator >>(EST_Token &p)

oEST_TokenStream& operator >>(EST_String &p)


This class has no child classes.
Author:
Alan W Black (awb@cstr.ed.ac.uk): April 1996

Alphabetic index HTML hierarchy of classes or Java


This page is part of the Edinburgh Speech Tools Library documentation
Copyright University of Edinburgh 1997
Contact: speech_tools@cstr.ed.ac.uk