Main Page | Modules | Class Hierarchy | Class List | File List | Class Members

ltl::AscFile Class Reference
[MArray ASCII I/O]

Columns based interface to an ASCII data file. More...

#include <ascio.h>

List of all members.

Public Member Functions

Protected Member Functions

Protected Attributes


Detailed Description

Columns based interface to an ASCII data file.

A high level interface class to read columns of data from an ASCII-file Supports arbitrary delimiter characters and whitespace seperated columns. Comments can begin at any point of a line. An arbitrary string can be used for the beginning of the comment.


Constructor & Destructor Documentation

ltl::AscFile::AscFile const string &  fname,
const char  delim = 0,
const string &  comment = "#"
 

Constructs an AsciiFile object.

: in_(fname.c_str()), rows_(0), cols_(0), filename_(fname), delim_(delim), comment_(comment)

Constructs an ltl::AscFile object corresponding to the file fname.


Member Function Documentation

int ltl::AscFile::cols  )  throw (IOException)
 

High level interface to ltl::AscFile::cols_.

Returns the number of columns in the file

void ltl::AscFile::countCols__  )  [protected]
 

Internal function used to count the number of columns.

Counts the cols in the file. Might be expensive on large files, so the function is not called before the information is requested by calling ltl::AscFile::cols().

void ltl::AscFile::countRows__  )  [protected]
 

Internal function used to count the number of rows.

Counts the rows in the file. Might be expensive on large files, so the function is not called before the information is requested by calling ltl::AscFile::rows().

string ltl::AscFile::readColumnFromLine__ const int  col,
const string &  line
[protected]
 

Internal function to extract one column from a given string.

Extracts the col'th column from the string buff, and returns it as a string.

Exceptions:
IOException if an EOF is encountered before the requested colum was read.
IOException if the file cannot be opened.

bool ltl::AscFile::readNextLine__ string &  buf  )  [protected]
 

Internal function used to read on line from the file stream.

Reads the next line from the input stream. The input stream is closed between subsequent calls, and the stream position is saved in the variable ltl::AscFile::filepos_.

int ltl::AscFile::rows  )  throw (IOException)
 

High level interface to ltl::AscFile::rows_.

Returns the number of rows in the file.


Member Data Documentation

int ltl::AscFile::cols_ [protected]
 

Internal storage of the number of columns in the file.

Stores internally the the number of columns in the file. This variable is initialized with 0. The first call to ltl::AscFile::cols() updates the variable with the correct number of columns.

string ltl::AscFile::comment_ [protected]
 

Internal storage of the comment string.

Defaults to '#'.

char ltl::AscFile::delim_ [protected]
 

Internal storage of delimiter character.

Stores internally the column delimiter. If the set to int(0) then it is assumed, that the columns are whitespace delimited, and any number of whitespace characters is treated as one delimiter.

int ltl::AscFile::rows_ [protected]
 

Internal storage of the number of rows in the file.

Stores internally the the number of rows in the file. This variable is initialized with 0. The first call to ltl::AscFile::rows() updates the variable with the correct number of rows.


The documentation for this class was generated from the following file:
Generated on Fri Dec 24 13:32:03 2004 for LTL by doxygen 1.3.4