xmscore
1.0
|
Class for reading ASCII files with named card fields. Also includes the ability to embed non-portable compressed binary for integer and Pt3d arrays. More...
Classes | |
class | Impl |
Implementation for DaStreamReader. More... | |
Public Member Functions | |
DaStreamReader (std::istream &a_inStream, bool a_binaryArrays=false) | |
Constructor. More... | |
~DaStreamReader () | |
Destructor. | |
bool | IsBinary () const |
Are array values read as binary? More... | |
bool | ReadNamedLine (const char *a_name) |
Read a line that begins with a name. More... | |
bool | ReadLine (std::string &a_line) |
Read a line from a stream with the following line endings: CR LF, LF, CR, or none. More... | |
bool | ReadStringLine (const char *a_name, std::string &a_val) |
Read a named string value from a line. More... | |
bool | ReadIntLine (const char *a_name, int &a_val) |
Read a named integer value from a line. More... | |
bool | ReadDoubleLine (const char *a_name, double &a_val) |
Read a named double value from a line. More... | |
bool | ReadVecInt (const char *a_name, VecInt &a_vec) |
Read named vector of integers from multiple lines. More... | |
bool | ReadVecDbl (const char *a_name, VecDbl &a_vec) |
Read named vector of doubles from multiple lines. More... | |
bool | ReadVecPt3d (const char *a_name, VecPt3d &a_vec) |
Read named vector of Pt3d from multiple lines. More... | |
bool | Read2StringLine (const char *a_name, std::string &a_val1, std::string &a_val2) |
Read a named pair of words from a line. More... | |
bool | Read3StringLine (const char *a_name, std::string &a_val1, std::string &a_val2, std::string &a_val3) |
Read a named triplet of words from a line. More... | |
bool | Read3DoubleLine (const char *a_name, double &a_val1, double &a_val2, double &a_val3) |
Read a named triplet of doubles from a line. More... | |
bool | ReadString (std::string &a_val) |
Read a white space separated string. More... | |
bool | ReadInt (int &a_val) |
Read an integer value. More... | |
bool | NextLine () |
Go to the next line in the stream. More... | |
bool | ReadBinaryBytes (char *a_dest, long long a_destLength) |
Read binary bytes of a given length from a file. More... | |
bool | LineBeginsWith (const char *a_text) |
Determines if next line read will begin given text. More... | |
Static Public Member Functions | |
static bool | ReadIntFromLine (std::string &a_line, int &a_val) |
Read an integer value from a string. Return the remaining string. More... | |
static bool | ReadStringFromLine (std::string &a_line, std::string &a_val) |
Read a string value from a string. Return the remaining string. More... | |
static bool | ReadDoubleFromLine (std::string &a_line, double &a_val) |
Read a double value from a string. Return the remaining string. More... | |
Private Attributes | |
std::unique_ptr< Impl > | m_impl |
Implementation. | |
Class for reading ASCII files with named card fields. Also includes the ability to embed non-portable compressed binary for integer and Pt3d arrays.
Definition at line 35 of file daStreamIo.h.
|
explicit |
Constructor.
a_inStream | The input stream. |
a_binaryArrays | Should binary arrays be written? |
Definition at line 356 of file daStreamIo.cpp.
bool xms::DaStreamReader::IsBinary | ( | ) | const |
Are array values read as binary?
Definition at line 370 of file daStreamIo.cpp.
References m_impl.
Referenced by ReadVecDbl(), ReadVecInt(), and ReadVecPt3d().
bool xms::DaStreamReader::LineBeginsWith | ( | const char * | a_text | ) |
Determines if next line read will begin given text.
a_text | The text to check for. |
Definition at line 704 of file daStreamIo.cpp.
References xms::daLineBeginsWith(), and m_impl.
Referenced by DaReaderWriterIoUnitTests::testLineBeginsWith().
bool xms::DaStreamReader::NextLine | ( | ) |
Go to the next line in the stream.
Definition at line 653 of file daStreamIo.cpp.
References m_impl, and ReadLine().
Referenced by ReadBinaryBytes(), and DaReaderWriterIoUnitTests::testReadWriteLineParts().
bool xms::DaStreamReader::Read2StringLine | ( | const char * | a_name, |
std::string & | a_val1, | ||
std::string & | a_val2 | ||
) |
Read a named pair of words from a line.
a_name | The expected name before the value. |
a_val1 | The first word. |
a_val2 | The second word. |
Definition at line 556 of file daStreamIo.cpp.
References m_impl.
bool xms::DaStreamReader::Read3DoubleLine | ( | const char * | a_name, |
double & | a_val1, | ||
double & | a_val2, | ||
double & | a_val3 | ||
) |
Read a named triplet of doubles from a line.
a_name | The expected name before the value. |
a_val1 | The first double. |
a_val2 | The second double. |
a_val3 | The third double. |
Definition at line 583 of file daStreamIo.cpp.
References m_impl.
bool xms::DaStreamReader::Read3StringLine | ( | const char * | a_name, |
std::string & | a_val1, | ||
std::string & | a_val2, | ||
std::string & | a_val3 | ||
) |
Read a named triplet of words from a line.
a_name | The expected name before the value. |
a_val1 | The first word. |
a_val2 | The second word. |
a_val3 | The third word. |
Definition at line 568 of file daStreamIo.cpp.
References m_impl.
bool xms::DaStreamReader::ReadBinaryBytes | ( | char * | a_dest, |
long long | a_destLength | ||
) |
Read binary bytes of a given length from a file.
a_dest | The byte array to read to. |
a_destLength | The length of bytes to be read. |
Definition at line 665 of file daStreamIo.cpp.
References m_impl, NextLine(), ReadInt(), and ReadString().
Referenced by ReadVecDbl(), ReadVecInt(), ReadVecPt3d(), and DaReaderWriterIoUnitTests::testReadWriteBinaryArrays().
|
static |
Read a double value from a string. Return the remaining string.
a_line | The string to read from. Returns the remaining string. |
a_val | The value to read. |
Definition at line 625 of file daStreamIo.cpp.
Referenced by DaReaderWriterIoUnitTests::testReadDoubleFromLine().
bool xms::DaStreamReader::ReadDoubleLine | ( | const char * | a_name, |
double & | a_val | ||
) |
Read a named double value from a line.
a_name | The expected name before the value. |
a_val | The double value. |
Definition at line 445 of file daStreamIo.cpp.
References m_impl.
bool xms::DaStreamReader::ReadInt | ( | int & | a_val | ) |
Read an integer value.
a_val | The value read. |
Definition at line 644 of file daStreamIo.cpp.
References m_impl.
Referenced by ReadBinaryBytes(), and DaReaderWriterIoUnitTests::testReadWriteLineParts().
|
static |
Read an integer value from a string. Return the remaining string.
a_line | The string to read from. Returns the remaining string. |
a_val | The value to read. |
Definition at line 596 of file daStreamIo.cpp.
Referenced by DaReaderWriterIoUnitTests::testReadIntFromLine().
bool xms::DaStreamReader::ReadIntLine | ( | const char * | a_name, |
int & | a_val | ||
) |
Read a named integer value from a line.
a_name | The expected name before the value. |
a_val | The integer value. |
Definition at line 435 of file daStreamIo.cpp.
References m_impl.
Referenced by ReadVecDbl(), and ReadVecInt().
bool xms::DaStreamReader::ReadLine | ( | std::string & | a_line | ) |
Read a line from a stream with the following line endings: CR LF, LF, CR, or none.
a_line | The line that was read. |
Definition at line 390 of file daStreamIo.cpp.
References m_impl.
Referenced by NextLine(), DaReaderWriterIoUnitTests::testLineBeginsWith(), and DaReaderWriterIoUnitTests::testReadWriteLine().
bool xms::DaStreamReader::ReadNamedLine | ( | const char * | a_name | ) |
Read a line that begins with a name.
a_name | The expected name before the value. |
Definition at line 379 of file daStreamIo.cpp.
References m_impl.
Referenced by DaReaderWriterIoUnitTests::testReadNamedLine().
bool xms::DaStreamReader::ReadString | ( | std::string & | a_val | ) |
Read a white space separated string.
a_val | The value read. |
Definition at line 634 of file daStreamIo.cpp.
References m_impl.
Referenced by ReadBinaryBytes(), and DaReaderWriterIoUnitTests::testReadWriteLineParts().
|
static |
Read a string value from a string. Return the remaining string.
a_line | The string to read from. Returns the remaining string. |
a_val | The value to read. |
Definition at line 606 of file daStreamIo.cpp.
Referenced by DaReaderWriterIoUnitTests::testReadStringFromLine().
bool xms::DaStreamReader::ReadStringLine | ( | const char * | a_name, |
std::string & | a_val | ||
) |
Read a named string value from a line.
a_name | The expected name before the value. |
a_val | The string value. |
Definition at line 455 of file daStreamIo.cpp.
References m_impl.
bool xms::DaStreamReader::ReadVecDbl | ( | const char * | a_name, |
VecDbl & | a_vec | ||
) |
Read named vector of doubles from multiple lines.
a_name | The expected name before the value. |
a_vec | The vector of doubles. |
Definition at line 487 of file daStreamIo.cpp.
References IsBinary(), m_impl, ReadBinaryBytes(), and ReadIntLine().
bool xms::DaStreamReader::ReadVecInt | ( | const char * | a_name, |
VecInt & | a_vec | ||
) |
Read named vector of integers from multiple lines.
a_name | The expected name before the value. |
a_vec | The vector of integers. |
Definition at line 465 of file daStreamIo.cpp.
References IsBinary(), m_impl, ReadBinaryBytes(), and ReadIntLine().
bool xms::DaStreamReader::ReadVecPt3d | ( | const char * | a_name, |
VecPt3d & | a_vec | ||
) |
Read named vector of Pt3d from multiple lines.
a_name | The expected name before the value. |
a_vec | The vector of Pt3d. |
Definition at line 509 of file daStreamIo.cpp.
References xms::daReadDoubleFromLine(), xms::daReadIntFromLine(), xms::daReadIntLine(), xms::daReadLine(), xms::daReadStringFromLine(), IsBinary(), m_impl, ReadBinaryBytes(), xms::Pt3< T >::x, xms::Pt3< T >::y, and xms::Pt3< T >::z.