BaseTextReader Class Reference
 
 
 
BaseTextReader Class Reference

#include <maxtextfile.h>

Inheritance diagram for BaseTextReader:
MaxHeapOperators Reader ReaderWriter

Class Description

This class is the base for all text file readers.

It declare a common interface to all implementation

Public Member Functions

virtual  ~BaseTextReader ()
virtual unsigned int  ReadCharUTF32 (bool peek=false) const =0
  Reads a single char and returns it's UTF32 representation.
virtual MaxString  ReadChars (size_t nchars) const =0
  Reads characters from the file.
virtual MaxString  ReadLine (size_t nchars=(size_t)-1, bool dontReturnEOL=false) const =0
  Reads a line from the file (or nchars, depending on which one comes first.)
virtual size_t  Position () const =0
  Get the number of characters read so far.
virtual size_t  LineNumber () const =0
  Get the current line number.
virtual Char  ReadChar (bool peek=false) const =0
  Read a character from the file.
virtual size_t  UnreadChar (const Char &c)=0
  Unread a character.
virtual size_t  Seek (long offset, int origin)=0
  Seek inside the stream.
virtual bool  IsFileOpen () const =0
  Returns true if file is open.
virtual bool  IsEndOfFile () const =0
  Returns true if file at the end.

Constructor & Destructor Documentation

virtual ~BaseTextReader ( ) [virtual]

Member Function Documentation

virtual unsigned int ReadCharUTF32 ( bool  peek = false ) const [pure virtual]

Reads a single char and returns it's UTF32 representation.

UTF-32 (or UCS-4) is a protocol to encode Unicode characters that uses exactly 32 bits per Unicode code point. All other Unicode transformation formats use variable-length encodings. The UTF-32 form of a character is a direct representation of its codepoint.

Parameters:
peek - Read a char but does not move the internal pointer to next char.
Returns:
UTF32 character read

Implemented in Reader, and ReaderWriter.

virtual MaxString ReadChars ( size_t  nchars ) const [pure virtual]

Reads characters from the file.

Parameters:
nchars Stop reading after 'nchars' characters or when end of file reached.
Returns:
Characters read.

Implemented in Reader, and ReaderWriter.

virtual MaxString ReadLine ( size_t  nchars = (size_t)-1,
bool  dontReturnEOL = false 
) const [pure virtual]

Reads a line from the file (or nchars, depending on which one comes first.)

Parameters:
nchars Stop reading after 'nchars' characters even if the EOL was not found.
dontReturnEOL By default, this function will returns the line including it's end-of-line character(s) unless you set "dontReturnEOL" to true.
Returns:
Line read.

Implemented in Reader, and ReaderWriter.

virtual size_t Position ( ) const [pure virtual]

Get the number of characters read so far.

Implemented in Reader, and ReaderWriter.

virtual size_t LineNumber ( ) const [pure virtual]

Get the current line number.

Implemented in Reader, and ReaderWriter.

virtual Char ReadChar ( bool  peek = false ) const [pure virtual]

Read a character from the file.

Parameters:
peek Read a char but does not move the internal pointer to next char.
Returns:
Character read.

Implemented in Reader, and ReaderWriter.

virtual size_t UnreadChar ( const Char c ) [pure virtual]

Unread a character.

Put back a character inside the buffer. The data will be re-read next time you call read. This is used internally when parsing max scripts.

Parameters:
c Char to put back in the buffer
Returns:
Number of character written.

Implemented in Reader, and ReaderWriter.

virtual size_t Seek ( long  offset,
int  origin 
) [pure virtual]

Seek inside the stream.

Parameters:
offset The seeks operations are done in number of characters (not bytes).
origin The direction to move. Origin can be one of the following * SEEK_CUR Current position of file pointer. * SEEK_END End of file. * SEEK_SET Beginning of file.
Returns:
Returns the absolute position of the text file. (in chars)

Implemented in Reader, and ReaderWriter.

virtual bool IsFileOpen ( ) const [pure virtual]

Returns true if file is open.

Implemented in Reader, and ReaderWriter.

virtual bool IsEndOfFile ( ) const [pure virtual]

Returns true if file at the end.

Implemented in Reader, and ReaderWriter.