#include <matrix-stream.h>
Inheritance diagram for MatrixStreamReader:
Public Types | |
typedef Field::Element | Element |
Public Methods | |
virtual const char * | getName () const=0 |
virtual bool | isSparse () const=0 |
MatrixStreamError | init (istream *, MatrixStream< Field > *) |
MatrixStreamError | nextTriple (int &, int &, Element &) |
MatrixStreamError | saveNext () |
MatrixStreamError | getRows (int &) |
MatrixStreamError | getColumns (int &) |
virtual int | getLineNumber () const |
virtual | ~MatrixStreamReader () |
Protected Methods | |
bool | readWhiteSpace (bool allowBreaks=false) |
bool | readSomeWhiteSpace (bool allowBreaks=false) |
bool | readWhiteSpace (int &breaks, bool allowBreaks=true) |
bool | readSomeWhiteSpace (int &breaks, bool allowBreaks=true) |
bool | readBreaks (int breaks=1) |
bool | readUntil (char c, stringstream *ss=NULL, int limit=-1) |
vector< char * >::const_iterator | readUntil (const vector< char * > &cm, stringstream *ss=NULL, int limit=-1) |
bool | readElement (Element &x) |
template<class Object> bool | readObject (Object &o) |
bool | moreData () |
void | saveTriple (int m, int n, const Element &v) |
virtual MatrixStreamError | nextTripleImpl (int &, int &, Element &)=0 |
virtual MatrixStreamError | initImpl ()=0 |
MatrixStreamReader () | |
Protected Attributes | |
istream * | sin |
MatrixStream< Field > * | ms |
int | lineNumber |
int | _m |
int | _n |
bool | atEnd |
|
Reimplemented in DenseReader, MapleDense1Reader, MapleSparse1Reader, MatrixMarketReader, SMSReader, and SparseRowReader. |
|
A protected constructor that is called automatically when subclasses are instantiated. |
|
Virtual destructor. |
|
Get the number of columns in this matrix, store it in the given int. |
|
Get the line number that this reader is currently on. |
|
Get a unique string describing this format. Implemented in DenseReader, MapleDense1Reader, MapleSparse1Reader, MatrixMarketReader, SMSReader, and SparseRowReader. |
|
Get the number of rows in this matrix, store it in the given int. |
|
Initialize this MatrixStreamReader. Calls the initImpl method of the subclass. |
|
Read the beginning (header) of the matrix from the stream and attempt to determine if it is of this reader's type.
Implemented in DenseReader, MatrixMarketReader, SMSReader, and SparseRowReader. |
|
Determine if this format is sparse or dense.
Implemented in DenseReader, MapleDense1Reader, MapleSparse1Reader, MatrixMarketReader, SMSReader, and SparseRowReader. |
|
Try and get more data from the underlying input stream. Should be called when an EOF is reached on input.
|
|
Get the next triple of row index, column index, value and store it into the three referenced variables. Uses the nextTripleImpl method of the subclass. |
|
Read the next triple of row index, column index, value and store it in the given references.
Implemented in DenseReader, MatrixMarketReader, SMSReader, and SparseRowReader. |
|
Read up to breaks breaks. Reading will stop on the first non-whitespace character or first newline after breaks newlines. After a successful call, there will be at least one character available on the stream.
|
|
Read a field element. Uses the read method of the field for the parent MatrixStream object.
|
|
Read any object. Uses the overloaded stream extraction operator>>, which must be defined for this type.
|
|
Read white space. Does not require that any white space characters be read. After a successful call, there will be at least one character available on the stream.
|
|
Read white space. Does not require that any white space characters be read. After a successful call, there will be at least one character available on the stream.
|
|
Read until an unmatched character.
|
|
Read up to a given character.
|
|
Read white space. Function returns true if and only if at least one character of white space is read. After a successful call, there will be at least one character available on the stream.
|
|
Read white space. Function returns true if and only if at least one character of white space is read. After a successful call, there will be at least one character available on the stream.
|
|
Reads the next triple from the subclass nextTripleImpl method and saves it to the savedTriples queue rather than returning it. The error returned is that given from the subclass method. |
|
Save the triple (m,n,v) onto the savedTriples queue. |
|
The number of rows in the matrix. This will be set by default to -1. Its value should not be set to a meaningful number until the reader is confident in the number of rows in the matrix. |
|
Number of columns in the matrix. Similar requirements as _m above. |
|
Indicates that the end of the matrix has been reached; no more calls to nextTripleImpl will be made once this value is true. This will automatically be set to true if nextTripleImple returns END_OF_MATRIX. |
|
The lineNumber is recorded in case the user wants to know at which line an error occurs. This will be updated automatically by any of the read methods below if they encounter breaks; it is up to the subclasses to increment lineNumber if they read any newline characters independently. |
|
A pointer to the MatrixStream that is using this reader. Useful to get an instance of the field via ms->getField(). |
|
The stream that provides the data to the reader. NOTE: subclasses should NOT use this stream directly except for one-byte reading as in sin->get(). This stream only contains a portion of the matrix data; this data must be replentished with calls to moreData(). If at all possible use sin->get() only and use the various read... methods below to read data. |