BIE::RecordInputStream_Ascii Class Reference

Reads record input streams from ascii files. More...

#include <RecordStream_Ascii.h>

Inheritance diagram for BIE::RecordInputStream_Ascii:
Collaboration diagram for BIE::RecordInputStream_Ascii:

List of all members.

Public Member Functions

 RecordInputStream_Ascii (RecordType *type, string filename)
 Open the file with the specified name, and create an input stream using the record type provided.
 RecordInputStream_Ascii (RecordType *type, istream *asciistream)
 Create an input stream using the type provided by the caller and the (already open) input stream.
 RecordInputStream_Ascii (string filename)
 Open the file with the specified name, and extract the type information from a tag at the beginning of the file.
 RecordInputStream_Ascii (istream *asciistream)
 Create an input stream using the (already open) input stream.
 ~RecordInputStream_Ascii ()
 Destructor: Closes the file stream if it was opened by this class and close has not been called already.
bool nextRecord ()
 Reads next record from file and puts the values in the record buffer.
bool eos ()
 Returns true if the end of the ascii file/stream has been reached.
bool error ()
 Returns true if an error occured while reading this file/stream.
string toString ()
 Returns a string representation of the stream.

Friends

class boost::serialization::access


Detailed Description

Reads record input streams from ascii files.

The format of these files is as follows:

  • Each record is specified on its own line.
  • Field values are separated by either a space or a tab
  • Strings are enclosed in double quotes. Escape sequences are used to include a newline or double quote in a string:
    represents a newline, \" represents a double quote. \ is used for a backslash, and \t is available for tab. For example: "Name: \"Galaxy\"\n"
  • Boolean values are specified using either '1' or '0'.
  • Integers are specified in base ten, and can optionally use a sign (+ or -) Conversion is performed using the strtol library function. Values in the file which cause overflow or underflow will result in a FileFormatException.
  • Reals are specified in fixed decimal or scientific form. Both NaN and InF (case insensitive and optionally signed) are permitted values. As with integers, values in the file which cause overflow or underflow will result in a FileFormatException. Conversion (including any rounding) is performed using the library function strtod.
  • Comments are formatted in a script like fashion using '#' - everything on a line after a # is a comment.

Where files include a type descriptor, it is expected at the very beginning of the file in the following format:

<type tag> ::= <field> [field]* <newline> <field> ::= <type> <name> <newline> <type> ::= string | int | real | bool (In upper or lower case) <name> ::= a string in the format described above.

Example: string "hole name" int "hole number" real "average score" bool "double green"

"Road" 17 4.567 0 "Bobby Jones" 10 3.98 1 "Hole 0'Cross" 13 4.12 1

See also:
RecordOutputStream_Ascii TODO Implement close method properly.

Constructor & Destructor Documentation

BIE::RecordInputStream_Ascii::RecordInputStream_Ascii ( istream *  asciistream  ) 

Create an input stream using the (already open) input stream.

and extract the type information from the current point in the stream.

BIE::RecordInputStream_Ascii::~RecordInputStream_Ascii (  ) 

Destructor: Closes the file stream if it was opened by this class and close has not been called already.

Deletes all dynamically created objects.


Member Function Documentation

bool BIE::RecordInputStream_Ascii::nextRecord (  )  [virtual]

Reads next record from file and puts the values in the record buffer.

Returns true if the operation was successful.

Reimplemented from BIE::RecordInputStream.


The documentation for this class was generated from the following file:

Send suggestions, questions, and feedback to WEINBERG at ASTRO dot UMASS dot EDU.
Documentation generated at Fri Mar 26 00:35:13 2010 by doxygen