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

Reader< T > Class Template Reference

A semi-generic parser class for reading files formatted similiarly to .obj and .mtl files. More...

Inheritance diagram for Reader< T >:

Inheritance graph
[legend]
List of all members.

Public Member Functions

 Reader ()
bool read (istream &in, T *object)
void add_reader_function (const string &name, bool(*func)(istream &, T *))
bool was_successful () const

Private Types

typedef map< string, bool(*)(istream &, T *)> reader_map_t

Private Member Functions

Parsing Functions
string get_next_token (istream &in)
 Skips over comments until it finds a whitespace delimited token.
void ignore_element (istream &in)
 Skips over the next element in the stream in including any comments and line continuations.
void extract_line (istream &in, string &line)
 Extracts an entire line from the stream in and puts it in the string line. This function will collapse multiple lines into one if there are line continuations.

Private Attributes

bool read_succeeded
reader_map_t reader_map

Detailed Description

template<typename T>
class Reader< T >

A semi-generic parser class for reading files formatted similiarly to .obj and .mtl files.

A parser class that reads files that are formatted such that each line starts with an identifying token that is followed by data. Blank lines, comments starting with the '#' character, and line continuations with the '\' character are also allowed.

Exactly what actions are performed for each token are customizable using registered callback functions.

The class is templated on a type which is passed as an additional parameter to each callback function. Typically, this type will be the type of a class which has all of the callback functions as static members.

Definition at line 64 of file objreader.C.


Member Typedef Documentation

template<typename T>
typedef map<string, bool (*)(istream&, T*)> Reader< T >::reader_map_t [private]
 

Definition at line 84 of file objreader.C.


Constructor & Destructor Documentation

template<typename T>
Reader< T >::Reader  )  [inline]
 

Definition at line 68 of file objreader.C.


Member Function Documentation

template<typename T>
void Reader< T >::add_reader_function const string name,
bool(*)(istream &, T *)  func
 

Definition at line 154 of file objreader.C.

References Reader< T >::reader_map.

Referenced by MTLReader::MTLReader(), and OBJReaderImpl::OBJReaderImpl().

template<typename T>
void Reader< T >::extract_line istream &  in,
string line
[private]
 

Extracts an entire line from the stream in and puts it in the string line. This function will collapse multiple lines into one if there are line continuations.

Definition at line 221 of file objreader.C.

Referenced by Reader< T >::read().

template<typename T>
string Reader< T >::get_next_token istream &  in  )  [private]
 

Skips over comments until it finds a whitespace delimited token.

Returns:
The token if one is found. Otherwise the empty string.

Definition at line 169 of file objreader.C.

References eat_line().

Referenced by Reader< T >::read().

template<typename T>
void Reader< T >::ignore_element istream &  in  )  [private]
 

Skips over the next element in the stream in including any comments and line continuations.

Definition at line 197 of file objreader.C.

References eat_line().

Referenced by Reader< T >::read().

template<typename T>
bool Reader< T >::read istream &  in,
T *  object
 

Definition at line 102 of file objreader.C.

References Reader< T >::extract_line(), Reader< T >::get_next_token(), Reader< T >::ignore_element(), Reader< T >::read_succeeded, and Reader< T >::reader_map.

Referenced by OBJReaderImpl::read(), and MTLReader::read().

template<typename T>
bool Reader< T >::was_successful  )  const [inline]
 

Definition at line 77 of file objreader.C.


Member Data Documentation

template<typename T>
bool Reader< T >::read_succeeded [private]
 

Definition at line 82 of file objreader.C.

Referenced by Reader< T >::read(), and Reader< OBJReaderImpl >::was_successful().

template<typename T>
reader_map_t Reader< T >::reader_map [private]
 

Definition at line 85 of file objreader.C.

Referenced by Reader< T >::add_reader_function(), and Reader< T >::read().


The documentation for this class was generated from the following file:
Generated on Mon Sep 18 11:46:58 2006 for jot by  doxygen 1.4.4