xmscore  1.0
xms::DaStreamReader Class Reference

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< Implm_impl
 Implementation.
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ DaStreamReader()

xms::DaStreamReader::DaStreamReader ( std::istream &  a_inStream,
bool  a_binaryArrays = false 
)
explicit

Constructor.

Parameters
a_inStreamThe input stream.
a_binaryArraysShould binary arrays be written?

Definition at line 356 of file daStreamIo.cpp.

Member Function Documentation

◆ IsBinary()

bool xms::DaStreamReader::IsBinary ( ) const

Are array values read as binary?

Returns
If the array values will be read as binary.

Definition at line 370 of file daStreamIo.cpp.

References m_impl.

Referenced by ReadVecDbl(), ReadVecInt(), and ReadVecPt3d().

◆ LineBeginsWith()

bool xms::DaStreamReader::LineBeginsWith ( const char *  a_text)

Determines if next line read will begin given text.

Parameters
a_textThe text to check for.
Returns
True if next line begins with given string.

Definition at line 704 of file daStreamIo.cpp.

References xms::daLineBeginsWith(), and m_impl.

Referenced by DaReaderWriterIoUnitTests::testLineBeginsWith().

◆ NextLine()

bool xms::DaStreamReader::NextLine ( )

Go to the next line in the stream.

Returns
True if no errors.

Definition at line 653 of file daStreamIo.cpp.

References m_impl, and ReadLine().

Referenced by ReadBinaryBytes(), and DaReaderWriterIoUnitTests::testReadWriteLineParts().

◆ Read2StringLine()

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.

Parameters
a_nameThe expected name before the value.
a_val1The first word.
a_val2The second word.
Returns
True if no errors.

Definition at line 556 of file daStreamIo.cpp.

References m_impl.

◆ Read3DoubleLine()

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.

Parameters
a_nameThe expected name before the value.
a_val1The first double.
a_val2The second double.
a_val3The third double.
Returns
True if no errors.

Definition at line 583 of file daStreamIo.cpp.

References m_impl.

◆ Read3StringLine()

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.

Parameters
a_nameThe expected name before the value.
a_val1The first word.
a_val2The second word.
a_val3The third word.
Returns
True if no errors.

Definition at line 568 of file daStreamIo.cpp.

References m_impl.

◆ ReadBinaryBytes()

bool xms::DaStreamReader::ReadBinaryBytes ( char *  a_dest,
long long  a_destLength 
)

Read binary bytes of a given length from a file.

Parameters
a_destThe byte array to read to.
a_destLengthThe length of bytes to be read.
Returns
True if no errors.

Definition at line 665 of file daStreamIo.cpp.

References m_impl, NextLine(), ReadInt(), and ReadString().

Referenced by ReadVecDbl(), ReadVecInt(), ReadVecPt3d(), and DaReaderWriterIoUnitTests::testReadWriteBinaryArrays().

◆ ReadDoubleFromLine()

bool xms::DaStreamReader::ReadDoubleFromLine ( std::string &  a_line,
double &  a_val 
)
static

Read a double value from a string. Return the remaining string.

Parameters
a_lineThe string to read from. Returns the remaining string.
a_valThe value to read.
Returns
True if no errors.

Definition at line 625 of file daStreamIo.cpp.

Referenced by DaReaderWriterIoUnitTests::testReadDoubleFromLine().

◆ ReadDoubleLine()

bool xms::DaStreamReader::ReadDoubleLine ( const char *  a_name,
double &  a_val 
)

Read a named double value from a line.

Parameters
a_nameThe expected name before the value.
a_valThe double value.
Returns
True if no errors.

Definition at line 445 of file daStreamIo.cpp.

References m_impl.

◆ ReadInt()

bool xms::DaStreamReader::ReadInt ( int &  a_val)

Read an integer value.

Parameters
a_valThe value read.
Returns
True if no errors.

Definition at line 644 of file daStreamIo.cpp.

References m_impl.

Referenced by ReadBinaryBytes(), and DaReaderWriterIoUnitTests::testReadWriteLineParts().

◆ ReadIntFromLine()

bool xms::DaStreamReader::ReadIntFromLine ( std::string &  a_line,
int &  a_val 
)
static

Read an integer value from a string. Return the remaining string.

Parameters
a_lineThe string to read from. Returns the remaining string.
a_valThe value to read.
Returns
True if no errors.

Definition at line 596 of file daStreamIo.cpp.

Referenced by DaReaderWriterIoUnitTests::testReadIntFromLine().

◆ ReadIntLine()

bool xms::DaStreamReader::ReadIntLine ( const char *  a_name,
int &  a_val 
)

Read a named integer value from a line.

Parameters
a_nameThe expected name before the value.
a_valThe integer value.
Returns
True if no errors.

Definition at line 435 of file daStreamIo.cpp.

References m_impl.

Referenced by ReadVecDbl(), and ReadVecInt().

◆ ReadLine()

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.

Parameters
a_lineThe line that was read.
Returns
True if no errors.

Definition at line 390 of file daStreamIo.cpp.

References m_impl.

Referenced by NextLine(), DaReaderWriterIoUnitTests::testLineBeginsWith(), and DaReaderWriterIoUnitTests::testReadWriteLine().

◆ ReadNamedLine()

bool xms::DaStreamReader::ReadNamedLine ( const char *  a_name)

Read a line that begins with a name.

Parameters
a_nameThe expected name before the value.
Returns
True if no errors.

Definition at line 379 of file daStreamIo.cpp.

References m_impl.

Referenced by DaReaderWriterIoUnitTests::testReadNamedLine().

◆ ReadString()

bool xms::DaStreamReader::ReadString ( std::string &  a_val)

Read a white space separated string.

Parameters
a_valThe value read.
Returns
True if no errors.

Definition at line 634 of file daStreamIo.cpp.

References m_impl.

Referenced by ReadBinaryBytes(), and DaReaderWriterIoUnitTests::testReadWriteLineParts().

◆ ReadStringFromLine()

bool xms::DaStreamReader::ReadStringFromLine ( std::string &  a_line,
std::string &  a_val 
)
static

Read a string value from a string. Return the remaining string.

Parameters
a_lineThe string to read from. Returns the remaining string.
a_valThe value to read.
Returns
True if no errors.

Definition at line 606 of file daStreamIo.cpp.

Referenced by DaReaderWriterIoUnitTests::testReadStringFromLine().

◆ ReadStringLine()

bool xms::DaStreamReader::ReadStringLine ( const char *  a_name,
std::string &  a_val 
)

Read a named string value from a line.

Parameters
a_nameThe expected name before the value.
a_valThe string value.
Returns
True if no errors.

Definition at line 455 of file daStreamIo.cpp.

References m_impl.

◆ ReadVecDbl()

bool xms::DaStreamReader::ReadVecDbl ( const char *  a_name,
VecDbl a_vec 
)

Read named vector of doubles from multiple lines.

Parameters
a_nameThe expected name before the value.
a_vecThe vector of doubles.
Returns
True if no errors.

Definition at line 487 of file daStreamIo.cpp.

References IsBinary(), m_impl, ReadBinaryBytes(), and ReadIntLine().

◆ ReadVecInt()

bool xms::DaStreamReader::ReadVecInt ( const char *  a_name,
VecInt a_vec 
)

Read named vector of integers from multiple lines.

Parameters
a_nameThe expected name before the value.
a_vecThe vector of integers.
Returns
True if no errors.

Definition at line 465 of file daStreamIo.cpp.

References IsBinary(), m_impl, ReadBinaryBytes(), and ReadIntLine().

◆ ReadVecPt3d()

bool xms::DaStreamReader::ReadVecPt3d ( const char *  a_name,
VecPt3d a_vec 
)

Read named vector of Pt3d from multiple lines.

Parameters
a_nameThe expected name before the value.
a_vecThe vector of Pt3d.
Returns
True if no errors.

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.


The documentation for this class was generated from the following files: