![]() |
Diana Software
|
Class for reading and writing ascii text files. More...
Public Member Functions | |
| QASCII () | |
| default constructor More... | |
| QASCII (const QASCII &orig) | |
| copy constructor More... | |
| QASCII (std::string filename) | |
| normal constructor More... | |
| virtual | ~QASCII () |
| destructor More... | |
| bool | Exists () |
| Returns true if the file exists and can be opened. More... | |
| int | NumberOfLines (bool ExcludeComments=true) |
| Returns the number of lines in the file, excluding comments by default. More... | |
| Diana::QVector * | ReadQVector () |
| Reads a text file into a QVector. Text file should contain a list of numbers. More... | |
| Diana::QVector * | ReadQVector (int ColumnNumber, int startline=0, int endline=-1) |
| Reads text data from a particular column into QVector. More... | |
| int | WriteQVector (Diana::QVector outputVector, bool append=false) |
| Writes data from a QVector to a file. More... | |
| int | WriteQVectors (std::vector< Diana::QVector > outputVector, bool append=false) |
| Writes a vector of QVectors, each QVector in a new column. Warning: QVectors of different lengths can be written to the same file, but they may be read back incorrectly! More... | |
| bool | WriteString (std::string outputString, bool append=false) |
| Writes a string to a file. More... | |
| bool | WriteLine (std::string line, bool append=true) |
| Writes a string to a file, terminated with newline. More... | |
| bool | Comment (std::string comment) |
| Writes a comment to a file; begins with '#', terminates with newline. More... | |
| std::string | ReadComment (int commentNumber=0) |
| Reads the nth comment from a file. Comments are lines beginning with '#'. More... | |
| std::string | ReadString (int startline=0, int endline=-1) |
| Reads entire file or subset of file into a string. More... | |
| std::vector< double > | ReadVector () |
| Reads a text file into a vector. Text file should contain a list of numbers. More... | |
| std::vector< double > | ReadVector (int ColumnNumber, int startline=0, int endline=-1) |
| Reads text data from a particular column into a vector. More... | |
| int | WriteVector (std::vector< double > outputVector, bool append=false) |
| Writes data from a vector to a file. More... | |
| int | WriteVector (std::vector< int > outputVector, bool append=false) |
| int | WriteVectors (std::vector< std::vector< double > > outputVector, bool append=false) |
| Writes a vector of vectors, each vector in a new column. Warning: vectors of different lengths can be written to the same file, but they may be read back incorrectly! More... | |
| bool | WriteQTime (Diana::QTime *qt, bool append=true) |
| Writes an object of type QTime. More... | |
| Diana::QTime * | ReadQTime (int startline=0) |
| Reads an object of type QTime. More... | |
| void | DeleteFile () |
| Deletes file from disk. More... | |
| int | FindLine (std::string pattern, int startline=0) |
| Finds a line matching the string pattern. More... | |
Private Attributes | |
| std::string | fFilename |
| Name of the file on disk. More... | |
Class for reading and writing ascii text files.
This class is intended to standardize the reading and writing of temporary data in text files. Currently supports reading and writing QVectors, vectors, and strings. Lines beginning with # are treated as comments.
| QASCII::QASCII | ( | const QASCII & | orig | ) |
| QASCII::QASCII | ( | std::string | filename | ) |
normal constructor
| filename | name of file to be opened |
| bool QASCII::Comment | ( | std::string | comment | ) |
Writes a comment to a file; begins with '#', terminates with newline.
| comment | Comment string to write |
Definition at line 221 of file QASCII.cc.
Referenced by LASCIIGlobalWriter::SetBool(), LASCIIGlobalWriter::SetDouble(), LASCIIGlobalWriter::SetFloat(), LASCIIGlobalWriter::SetInt(), LASCIIGlobalWriter::SetQMatrix(), LASCIIGlobalWriter::SetQObject(), LASCIIGlobalWriter::SetQTime(), LASCIIGlobalWriter::SetQVector(), LASCIIGlobalWriter::SetQVectorC(), and LASCIIGlobalWriter::SetString().
|
inline |
| bool QASCII::Exists | ( | ) |
Returns true if the file exists and can be opened.
Definition at line 38 of file QASCII.cc.
Referenced by LASCIIGlobalWriter::Open(), and LASCIIGlobalReader::Open().
| int QASCII::FindLine | ( | std::string | pattern, |
| int | startline = 0 |
||
| ) |
Finds a line matching the string pattern.
| pattern | Pattern to match |
| startline | Number of line to start from |
Definition at line 441 of file QASCII.cc.
Referenced by LASCIIGlobalReader::GetBool(), LASCIIGlobalReader::GetDouble(), LASCIIGlobalReader::GetFloat(), LASCIIGlobalReader::GetInt(), LASCIIGlobalReader::GetQObject(), and LASCIIGlobalReader::GetString().
| int QASCII::NumberOfLines | ( | bool | ExcludeComments = true | ) |
| string QASCII::ReadComment | ( | int | commentNumber = 0 | ) |
| QTime * QASCII::ReadQTime | ( | int | startline = 0 | ) |
Reads an object of type QTime.
| startline | Number of line to start from |
Definition at line 488 of file QASCII.cc.
References QTime::SetFromStartRunNs(), and QTime::SetStartRunUnix().
Referenced by LASCIIGlobalReader::GetQObject().
| QVector * QASCII::ReadQVector | ( | ) |
Reads a text file into a QVector. Text file should contain a list of numbers.
Definition at line 64 of file QASCII.cc.
References vec.
Referenced by LASCIIGlobalReader::GetQObject().
| QVector * QASCII::ReadQVector | ( | int | ColumnNumber, |
| int | startline = 0, |
||
| int | endline = -1 |
||
| ) |
| string QASCII::ReadString | ( | int | startline = 0, |
| int | endline = -1 |
||
| ) |
Reads entire file or subset of file into a string.
| startline | line to start from |
Definition at line 260 of file QASCII.cc.
Referenced by LASCIIGlobalReader::GetBool(), LASCIIGlobalReader::GetDouble(), LASCIIGlobalReader::GetFloat(), LASCIIGlobalReader::GetInt(), LASCIIGlobalReader::GetQObject(), and LASCIIGlobalReader::GetString().
| vector< double > QASCII::ReadVector | ( | ) |
| vector< double > QASCII::ReadVector | ( | int | ColumnNumber, |
| int | startline = 0, |
||
| int | endline = -1 |
||
| ) |
| bool QASCII::WriteLine | ( | std::string | line, |
| bool | append = true |
||
| ) |
Writes a string to a file, terminated with newline.
| outputString | String to write |
| append | append if true (default), overwrite if false |
Definition at line 209 of file QASCII.cc.
Referenced by LASCIIGlobalWriter::SetBool(), LASCIIGlobalWriter::SetDouble(), LASCIIGlobalWriter::SetFloat(), LASCIIGlobalWriter::SetInt(), and LASCIIGlobalWriter::SetString().
| bool QASCII::WriteQTime | ( | Diana::QTime * | qt, |
| bool | append = true |
||
| ) |
Writes an object of type QTime.
| qt | QTime object to write |
| append | append if true (default), overwrite if false |
Definition at line 469 of file QASCII.cc.
References QTime::GetFromStartRunNs(), and QTime::GetStartRunUnix().
Referenced by LASCIIGlobalWriter::SetQTime().
| int QASCII::WriteQVector | ( | Diana::QVector | outputVector, |
| bool | append = false |
||
| ) |
Writes data from a QVector to a file.
| outputVector | QVector to write |
| append | append if true, overwrite if false (default) |
Definition at line 138 of file QASCII.cc.
Referenced by LASCIIGlobalWriter::SetQVector().
| int QASCII::WriteQVectors | ( | std::vector< Diana::QVector > | outputVector, |
| bool | append = false |
||
| ) |
Writes a vector of QVectors, each QVector in a new column. Warning: QVectors of different lengths can be written to the same file, but they may be read back incorrectly!
| outputVector | vector of QVectors to write |
| append | append if true, overwrite if false (default) |
Definition at line 159 of file QASCII.cc.
Referenced by LASCIIGlobalWriter::SetQMatrix(), and LASCIIGlobalWriter::SetQVectorC().
| bool QASCII::WriteString | ( | std::string | outputString, |
| bool | append = false |
||
| ) |
Writes a string to a file.
| outputString | String to write |
| append | append if true, overwrite if false (default) |
Definition at line 197 of file QASCII.cc.
Referenced by LASCIIGlobalWriter::Open(), and LASCIIGlobalWriter::SetQObject().
| int QASCII::WriteVector | ( | std::vector< double > | outputVector, |
| bool | append = false |
||
| ) |
Writes data from a vector to a file.
| outputVector | vector to write |
| append | append if true, overwrite if false (default) |
| int QASCII::WriteVector | ( | std::vector< int > | outputVector, |
| bool | append = false |
||
| ) |
| int QASCII::WriteVectors | ( | std::vector< std::vector< double > > | outputVector, |
| bool | append = false |
||
| ) |
Writes a vector of vectors, each vector in a new column. Warning: vectors of different lengths can be written to the same file, but they may be read back incorrectly!
| outputVector | vector of vectors to write |
| append | append if true, overwrite if false (default) |
|
private |
Name of the file on disk.
Definition at line 193 of file QASCII.hh.
Referenced by DeleteFile(), and QASCII().