Public Member Functions | |
QASCII () | |
default constructor | |
QASCII (const QASCII &orig) | |
copy constructor | |
QASCII (std::string filename) | |
normal constructor | |
virtual | ~QASCII () |
destructor | |
bool | Exists () |
Returns true if the file exists and can be opened. | |
int | NumberOfLines (bool ExcludeComments=true) |
Returns the number of lines in the file, excluding comments by default. | |
QVector * | ReadQVector () |
Reads a text file into a QVector. Text file should contain a list of numbers. | |
QVector * | ReadQVector (int ColumnNumber, int startline=0, int endline=-1) |
Reads text data from a particular column into QVector. | |
int | WriteQVector (QVector outputVector, bool append=false) |
Writes data from a QVector to a file. | |
int | WriteQVectors (std::vector< 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! | |
bool | WriteString (std::string outputString, bool append=false) |
Writes a string to a file. | |
bool | WriteLine (std::string line, bool append=true) |
Writes a string to a file, terminated with newline. | |
bool | Comment (std::string comment) |
Writes a comment to a file; begins with '#', terminates with newline. | |
std::string | ReadComment (int commentNumber=0) |
Reads the nth comment from a file. Comments are lines beginning with '#'. | |
std::string | ReadString (int startline=0, int endline=-1) |
Reads entire file or subset of file into a string. | |
std::vector< double > | ReadVector () |
Reads a text file into a vector. Text file should contain a list of numbers. | |
std::vector< double > | ReadVector (int ColumnNumber, int startline=0, int endline=-1) |
Reads text data from a particular column into a vector. | |
int | WriteVector (std::vector< double > outputVector, bool append=false) |
Writes data from a vector to a file. | |
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! | |
bool | WriteQTime (QTime *qt, bool append=true) |
Writes an object of type QTime. | |
QTime * | ReadQTime (int startline=0) |
Reads an object of type QTime. | |
bool | WriteQRunData (QRunData *qrd, bool append=false) |
Writes an object of type QRunData. | |
QRunData * | ReadQRunData (int startline=0, int endline=-1) |
Reads an object of type QRunData. | |
void | DeleteFile () |
Deletes file from disk. | |
int | FindLine (std::string pattern, int startline=0) |
Finds a line matching the string pattern. | |
Private Attributes | |
std::string | fFilename |
Name of the file on disk. |
QASCII::QASCII | ( | const QASCII & | orig | ) |
QASCII::QASCII | ( | std::string | filename | ) |
normal constructor
filename | name of file to be opened |
int QASCII::NumberOfLines | ( | bool | ExcludeComments = true |
) |
Returns the number of lines in the file, excluding comments by default.
ExcludeComments | if true, comments are excluded from count, else they are counted as lines |
References fFilename.
Referenced by ReadQRunData(), ReadQVector(), ReadString(), and ReadVector().
QVector * QASCII::ReadQVector | ( | int | ColumnNumber, | |
int | startline = 0 , |
|||
int | endline = -1 | |||
) |
Reads text data from a particular column into QVector.
ColumnNumber | Which column to read from. Numbering starts at 0. | |
startline | line to start from | |
endline | line to end at |
References fFilename, and NumberOfLines().
int QASCII::WriteQVector | ( | QVector | outputVector, | |
bool | append = false | |||
) |
int QASCII::WriteQVectors | ( | std::vector< 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) |
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) |
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 |
bool QASCII::Comment | ( | std::string | comment | ) |
Writes a comment to a file; begins with '#', terminates with newline.
comment | Comment string to write |
string QASCII::ReadComment | ( | int | commentNumber = 0 |
) |
Reads the nth comment from a file. Comments are lines beginning with '#'.
commentNumber | Number of comment to read (numbering starts from 0) |
References fFilename.
string QASCII::ReadString | ( | int | startline = 0 , |
|
int | endline = -1 | |||
) |
Reads entire file or subset of file into a string.
startline | line to start from |
References fFilename, and NumberOfLines().
vector< double > QASCII::ReadVector | ( | int | ColumnNumber, | |
int | startline = 0 , |
|||
int | endline = -1 | |||
) |
Reads text data from a particular column into a vector.
ColumnNumber | Which column to read from. Numbering starts from 0. | |
startline | Line to start from | |
endline | Line to end at |
References fFilename, and NumberOfLines().
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) |
Referenced by WriteQRunData().
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) |
bool QASCII::WriteQTime | ( | QTime * | qt, | |
bool | append = true | |||
) |
Writes an object of type QTime.
qt | QTime object to write | |
append | append if true (default), overwrite if false |
References fFilename, QTime::GetFromStartRunNs(), and QTime::GetStartRunUnix().
QTime * QASCII::ReadQTime | ( | int | startline = 0 |
) |
Reads an object of type QTime.
startline | Number of line to start from |
References fFilename, QTime::SetFromStartRunNs(), and QTime::SetStartRunUnix().
bool QASCII::WriteQRunData | ( | QRunData * | qrd, | |
bool | append = false | |||
) |
Writes an object of type QRunData.
qrd | QRunData object to write | |
append | append if true, overwrite if false (default) |
References fFilename, QRunDataBase::GetADC2mV(), QRunDataBase::GetADCMax(), QRunDataBase::GetADCMin(), QRunDataBase::GetChannels(), QRunDataBase::GetDetector(), QRunDataBase::GetDuration(), QRunDataBase::GetNumber(), QRunDataBase::GetNumberOfChannels(), QRunDataBase::GetSamplingFrequency(), QRunDataBase::GetStartTime(), QRunDataBase::GetThermometerChannel(), QRunDataBase::GetType(), and WriteVector().
QRunData * QASCII::ReadQRunData | ( | int | startline = 0 , |
|
int | endline = -1 | |||
) |
Reads an object of type QRunData.
startline | Number of line to start from |
References fFilename, QDbDetector::GetDetectorName(), NumberOfLines(), QRunDataBase::SetADC2mV(), QRunDataBase::SetADCMax(), QRunDataBase::SetADCMin(), QRunDataBase::SetChannels(), QRunDataBase::SetDetector(), QRunDataBase::SetDuration(), QRunDataBase::SetNumber(), QRunDataBase::SetNumberOfChannels(), QRunDataBase::SetSamplingFrequency(), QRunDataBase::SetStartTime(), QRunDataBase::SetThermometerChannel(), QRunDataBase::SetType(), QDbDetector::String2RunType(), and QApolloMonitorDefs::Type.
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 |