Model Railroad System  2.2.2
Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
Parsers::ParseFile Class Referenceabstract

Virtual base class for file-based parsers. More...

#include <ParseFile.h>

Inheritance diagram for Parsers::ParseFile:
Parsers::LayoutFile Parsers::MRRXtrkCad

Public Member Functions

const char * SourceFile () const
 Return the name of the source file. More...
 
 ParseFile (const char *filename)
 Constructor. More...
 
virtual ~ParseFile ()
 Destructor. More...
 
int ProcessFile (ostream &err)
 open file and parse it. More...
 

Protected Member Functions

virtual int Parse ()=0
 The parser itself, supplied by derived classes. More...
 
virtual void ParseError (const char *)=0
 The parser's error handler, supplied by derived classes. More...
 

Protected Attributes

char * lp
 Input line buffer pointer. More...
 
FILE * fp
 Input file pointer. More...
 
int source_line
 Source line number. More...
 
char line_buffer [buffersize]
 Input line buffer. More...
 
ostream * errorstream
 Stream for error reporting. More...
 
char * source_file
 Name of the source file. More...
 

Static Protected Attributes

static const int buffersize = 1024
 Size of line buffer. More...
 

Detailed Description

Virtual base class for file-based parsers.

Contains all of the base level input and error output support members.

Author
Robert Heller <heller@deepsoft.com>

Constructor & Destructor Documentation

◆ ParseFile()

Parsers::ParseFile::ParseFile ( const char *  filename)
inline

Constructor.

Make a local copy of the source file name, Other members are initialized.

References fp, lp, source_file, and source_line.

◆ ~ParseFile()

virtual Parsers::ParseFile::~ParseFile ( )
inlinevirtual

Destructor.

Free up memory.

References source_file.

Member Function Documentation

◆ Parse()

virtual int Parsers::ParseFile::Parse ( )
protectedpure virtual

The parser itself, supplied by derived classes.

Implemented in Parsers::LayoutFile.

◆ ParseError()

virtual void Parsers::ParseFile::ParseError ( const char *  )
protectedpure virtual

The parser's error handler, supplied by derived classes.

Implemented in Parsers::LayoutFile.

◆ ProcessFile()

int Parsers::ParseFile::ProcessFile ( ostream &  err)

open file and parse it.

Parameters
errOutput string to write error messages to.

◆ SourceFile()

const char* Parsers::ParseFile::SourceFile ( ) const
inline

Return the name of the source file.

References source_file.

Member Data Documentation

◆ buffersize

const int Parsers::ParseFile::buffersize = 1024
staticprotected

Size of line buffer.

◆ errorstream

ostream* Parsers::ParseFile::errorstream
protected

Stream for error reporting.

◆ fp

FILE* Parsers::ParseFile::fp
protected

Input file pointer.

Referenced by ParseFile().

◆ line_buffer

char Parsers::ParseFile::line_buffer[buffersize]
protected

Input line buffer.

◆ lp

char* Parsers::ParseFile::lp
protected

Input line buffer pointer.

Referenced by ParseFile().

◆ source_file

char* Parsers::ParseFile::source_file
protected

Name of the source file.

Referenced by ParseFile(), SourceFile(), and ~ParseFile().

◆ source_line

int Parsers::ParseFile::source_line
protected

Source line number.

Used for error reporting.

Referenced by ParseFile().