Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

vuParser Class Reference

Provides basic parsing functionality. More...

#include <vuParser.h>

Inheritance diagram for vuParser:

Inheritance graph
[legend]
Collaboration diagram for vuParser:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 vuParser ()
 default constructor,
virtual ~vuParser ()
 destructor
virtual void Parse (const char *filename) throw (const char *)
 Parses the given gui script file, and generates the corresponding class.

Protected Member Functions

void readBuffer (const char *filename)
 reads the input file into m_Buffer for processing.
void FixBuffer ()
 Fixes the input buffer by separating the defined tokens.
bool readString (const char *s)
 Try to read a string from the buffer and eats it if it's there.
bool readString (const char *prefix, char *s)
 Try to read a string prefixed by "prefix" from the buffer and eats it if it's there.
bool readNumber (const char *prefix, float &t)
 Try to read a number prefixed by "prefix" from the buffer and eats it if it's there.
bool readToken (char token, bool eat=true)
 Checks the buffer for the token, returning true and eating it up if it's there.
bool finished ()
 Returns true if the input stream is finished.

Protected Attributes

char * m_Buffer
 A copy of the input file contents, with separated tokens.
dword m_Len
 The total length of the buffer.
dword m_Pos
 The reading position within the buffer.

Detailed Description

Provides basic parsing functionality.

The functions of this class have been extracted from the original vuGuiParser to build a general parser base class. This can now be used to derive own parsers for arbitrary use.

Todo:
Add some usefull functionalities to vuParser. readstring, readnumber (also list of numbers should be handled, only written for doubles because they can be converted), ...

Find some way to add the ios::nocreate flag or some equivalent to this code so that we have similar behaviour in IRIX as we do Linux or Windows.

Definition at line 36 of file vuParser.h.


Constructor & Destructor Documentation

vuParser::vuParser  ) 
 

default constructor,

initializes everything to be 0

Definition at line 10 of file vuParser.cpp.

References m_Buffer, m_Len, and m_Pos.

vuParser::~vuParser  )  [virtual]
 

destructor

frees the memory used by the buffer

Definition at line 21 of file vuParser.cpp.


Member Function Documentation

bool vuParser::finished  )  [protected]
 

Returns true if the input stream is finished.

Definition at line 127 of file vuParser.cpp.

References m_Pos.

Referenced by vuGuiParser::ParseControls(), vuGuiParser::ParseList(), vuGuiParser::ParseMethod(), vuGuiParser::ParseSections(), and vuGuiParser::ParseStatement().

void vuParser::FixBuffer  )  [protected]
 

Fixes the input buffer by separating the defined tokens.

Definition at line 63 of file vuParser.cpp.

References dword, m_Buffer, and m_Len.

Referenced by vuTFDesign::Parse().

virtual void vuParser::Parse const char *  filename  )  throw (const char *) [inline, virtual]
 

Parses the given gui script file, and generates the corresponding class.

This function is virtual a reimplementation should start with readBuffer() and FixBuffer() and then continue evaluating the buffer using the provided functions. (which are not yet written <- todo)

Reimplemented in vuTFDesign, vuTFDesign, and vuGuiParser.

Definition at line 54 of file vuParser.h.

void vuParser::readBuffer const char *  filename  )  [protected]
 

reads the input file into m_Buffer for processing.

Definition at line 30 of file vuParser.cpp.

References m_Buffer, and m_Pos.

Referenced by vuTFDesign::Parse().

bool vuParser::readNumber const char *  prefix,
float t
[protected]
 

Try to read a number prefixed by "prefix" from the buffer and eats it if it's there.

Parameters:
t float to copy the read number to

Definition at line 176 of file vuParser.cpp.

References m_Buffer, and m_Pos.

Referenced by vuTFDesign::readColour(), vuTFDesignSpec::readLight(), vuTFDesign::readNComp(), and vuTFDesign::readOpacity().

bool vuParser::readString const char *  prefix,
char *  s
[protected]
 

Try to read a string prefixed by "prefix" from the buffer and eats it if it's there.

Parameters:
s buffer to copy the read string to

Definition at line 153 of file vuParser.cpp.

References m_Buffer, m_Pos, and readString().

Here is the call graph for this function:

bool vuParser::readString const char *  s  )  [protected]
 

Try to read a string from the buffer and eats it if it's there.

Definition at line 135 of file vuParser.cpp.

References m_Buffer, and m_Pos.

Referenced by vuTFDesign::readColour(), vuTFDesignSpec::readLight(), vuTFDesign::readNComp(), vuTFDesign::readOpacity(), and readString().

bool vuParser::readToken char  token,
bool  eat = true
[protected]
 

Checks the buffer for the token, returning true and eating it up if it's there.

Definition at line 113 of file vuParser.cpp.

References m_Buffer, and m_Pos.

Referenced by vuGuiParser::ParseAPIs(), vuGuiParser::ParseControls(), vuGuiParser::ParseList(), vuGuiParser::ParseMethod(), vuGuiParser::ParseSections(), and vuGuiParser::ParseStatement().


Member Data Documentation

char* vuParser::m_Buffer [protected]
 

A copy of the input file contents, with separated tokens.

Definition at line 79 of file vuParser.h.

Referenced by FixBuffer(), readBuffer(), readNumber(), readString(), readToken(), and vuParser().

dword vuParser::m_Len [protected]
 

The total length of the buffer.

Definition at line 81 of file vuParser.h.

Referenced by FixBuffer(), and vuParser().

dword vuParser::m_Pos [protected]
 

The reading position within the buffer.

Definition at line 83 of file vuParser.h.

Referenced by finished(), readBuffer(), readNumber(), readString(), readToken(), and vuParser().


The documentation for this class was generated from the following files:
Generated on Wed Dec 15 21:22:00 2004 for vuVolume by  doxygen 1.3.9.1