PropaneFileReader Class Reference

A class for retrieving simple INI-style data from tag files. Superceded by PropaneXML. More...

#include <PropaneFileReader.h>

List of all members.

Public Member Functions

 PropaneFileReader (char *filename)
 Construct, opening the reader to a file.
 PropaneFileReader ()
 Construct, opening no file.
virtual ~PropaneFileReader ()
 Destructor.
virtual std::string getString (std::string key)
 Returns a string associated with a key.
virtual int getInteger (std::string key)
 Returns an integer associated with a key.
virtual bool ready ()
 When true, the file is ready for reading.

Protected Member Functions

void reset ()
 Resets the stream position to the start of the file.
bool hasKey (std::string key)
 Checks for the presence of a given key in the file.
std::string getValueForKey (std::string key)
 Returns the string value associated with a key.

Protected Attributes

std::ifstream theFile
 The raw file stream.
bool isReady
 Internal variable holding the readiness of the file stream.


Detailed Description

A class for retrieving simple INI-style data from tag files. Superceded by PropaneXML.


Constructor & Destructor Documentation

PropaneFileReader::PropaneFileReader char *  filename  ) 
 

Construct, opening the reader to a file.

Constructs the file reader around a file. Make sure to check ready() after opening the file to ensure that the process worked.

Parameters:
filename The path to the file (for example, "config.txt")

PropaneFileReader::PropaneFileReader  ) 
 

Construct, opening no file.

Default constructor stub. Does NOTHING.

PropaneFileReader::~PropaneFileReader  )  [virtual]
 

Destructor.

Basic destructor. Closes the file handle, if necessary.


Member Function Documentation

int PropaneFileReader::getInteger std::string  key  )  [virtual]
 

Returns an integer associated with a key.

Get the right-hand integer from a string=integer pair.

Parameters:
key The key/value pair (for example, "key=123")
Returns:
The value part of the key/value pair, or INTEGER_READ_FAILURE if an error occured (such as improper format)

std::string PropaneFileReader::getString std::string  key  )  [virtual]
 

Returns a string associated with a key.

Get the right-hand string from a string=string pair

Parameters:
key The key/value pair (for example, "key=value")
Returns:
The value part of the key/value pair, or STRING_READ_FAILURE otherwise.

std::string PropaneFileReader::getValueForKey std::string  key  )  [protected]
 

Returns the string value associated with a key.

Gets the value for a given key/value pair as a string

Parameters:
key The key/value pair, for example ("foo=bar")
Returns:
The value part of the key/value pair, in untranslated string format. You can run this through atof/atoi to get a floating point number or string respectively.

bool PropaneFileReader::hasKey std::string  key  )  [protected]
 

Checks for the presence of a given key in the file.

Checks to see if the current file contains a key/value pair with a key matching that of the provided one

Parameters:
key the key to search for
Returns:
True if a key/value pair exists for that key, false otherwise.

bool PropaneFileReader::ready  )  [virtual]
 

When true, the file is ready for reading.

Checks if the file is ready for reading

Returns:
True if the file is ready for reading, false otherwise

void PropaneFileReader::reset  )  [protected]
 

Resets the stream position to the start of the file.

Resets the position of the file reader using ostream::seekg.


The documentation for this class was generated from the following files:
Generated on Sun Jan 14 16:49:11 2007 for Propane Injector by  doxygen 1.4.6