xmscore  1.0
daStreamIo.h File Reference
#include <sstream>
#include <xmscore/misc/base_macros.h>
#include <xmscore/misc/boost_defines.h>
#include <xmscore/stl/vector.h>

Go to the source code of this file.

Classes

class  xms::DaStreamReader
 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...
 
class  xms::DaStreamWriter
 Class for writing ASCII files with named card fields. Also includes the ability to embed non-portable compressed binary for integer and Pt3d arrays. More...
 

Functions

bool xms::daReadNamedLine (std::istream &a_inStream, const char *a_name)
 Read a line that begins with a name. More...
 
bool xms::daReadLine (std::istream &a_inStream, std::string &a_line)
 Read a line from a stream with the following line endings: CR LF, LF, CR, or none. More...
 
bool xms::daReadIntLine (std::istream &a_inStream, const char *a_name, int &a_val)
 Read a named integer value from a line. More...
 
bool xms::daReadDoubleLine (std::istream &a_inStream, const char *a_name, double &a_val)
 Read a named double value from a line. More...
 
bool xms::daReadStringLine (std::istream &a_inStream, const char *a_name, std::string &a_val)
 Read a named string value from a line. More...
 
bool xms::daReadVecInt (std::istream &a_inStream, const char *a_name, VecInt &a_vec)
 Read named vector of integers from multiple lines. More...
 
bool xms::daReadVecDbl (std::istream &a_inStream, const char *a_name, VecDbl &a_vec)
 Read named vector of doubles from multiple lines. More...
 
bool xms::daReadVecPt3d (std::istream &a_inStream, const char *a_name, VecPt3d &a_vec)
 Read named vector of Pt3d from multiple lines. More...
 
bool xms::daRead2StringLine (std::istream &a_inStream, const char *a_name, std::string &a_val1, std::string &a_val2)
 Read a named pair of words from a line. More...
 
bool xms::daRead3StringLine (std::istream &a_inStream, 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 xms::daRead3DoubleLine (std::istream &a_inStream, const char *a_name, double &a_val1, double &a_val2, double &a_val3)
 Read a named triplet of doubles from a line. More...
 
bool xms::daReadIntFromLine (std::string &a_line, int &a_val)
 Read an integer value from a string. Return the remaining string. More...
 
bool xms::daReadStringFromLine (std::string &a_line, std::string &a_val)
 Read a string value from a string. Return the remaining string. More...
 
bool xms::daReadDoubleFromLine (std::string &a_line, double &a_val)
 Read a double value from a string. Return the remaining string. More...
 
bool xms::daLineBeginsWith (std::istream &a_inStream, const std::string &a_text)
 Determines if next line read will begin given text. More...
 
void xms::daWriteVecInt (std::ostream &a_outStream, const char *a_name, const VecInt &a_vec)
 Write a named vector of integers to several lines. More...
 
void xms::daWriteVecDbl (std::ostream &a_outStream, const char *a_name, const VecDbl &a_vec)
 Write a named vector of doubles to multiple lines. More...
 
void xms::daWriteVecPt3d (std::ostream &a_outStream, const char *a_name, const VecPt3d &a_points)
 Write a named vector of Pt3d to multiple lines. More...
 
void xms::daWriteIntLine (std::ostream &a_outStream, const char *a_name, int a_val)
 Write a named integer value to a line. More...
 
void xms::daWriteDoubleLine (std::ostream &a_outStream, const char *a_name, double a_val)
 Write a named double line value. More...
 
void xms::daWrite3DoubleLine (std::ostream &a_outStream, const char *a_name, const double &a_val1, const double &a_val2, const double &a_val3)
 Write a named triplet of doubles to a line. More...
 
void xms::daWriteLine (std::ostream &a_outStream, const std::string &a_line)
 Write a given line to a stream. More...
 
void xms::daWriteStringLine (std::ostream &a_outStream, const char *a_name, const std::string &a_val)
 Write a named word line. More...
 
void xms::daWrite2StringLine (std::ostream &a_outStream, const char *a_name, const std::string &a_val1, const std::string &a_val2)
 Write a named pair of words to a line. More...
 
void xms::daWrite3StringLine (std::ostream &a_outStream, const char *a_name, const std::string &a_val1, const std::string &a_val2, const std::string &a_val3)
 Write a named triplet of words to a line. More...
 

Detailed Description

Definition in file daStreamIo.h.

Function Documentation

◆ daLineBeginsWith()

bool xms::daLineBeginsWith ( std::istream &  a_inStream,
const std::string &  a_text 
)

Determines if next line read will begin given text.

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

Definition at line 1204 of file daStreamIo.cpp.

References xms::daLineBeginsWith(), and xms::daReadLine().

Referenced by xms::daLineBeginsWith(), xms::DaStreamReader::LineBeginsWith(), and DaStreamIoUnitTests::testLineBeginsWith().

◆ daRead2StringLine()

bool xms::daRead2StringLine ( std::istream &  a_inStream,
const char *  a_name,
std::string &  a_val1,
std::string &  a_val2 
)

Read a named pair of words from a line.

Parameters
a_inStreamThe stream to read from.
a_nameThe expected name before the value.
a_val1The first word.
a_val2The second word.
Returns
True if no errors.

Definition at line 1118 of file daStreamIo.cpp.

References xms::daRead2StringLine().

Referenced by xms::daRead2StringLine(), and DaStreamIoUnitTests::testReadWrite2StringLine().

◆ daRead3DoubleLine()

bool xms::daRead3DoubleLine ( std::istream &  a_inStream,
const char *  a_name,
double &  a_val1,
double &  a_val2,
double &  a_val3 
)

Read a named triplet of doubles from a line.

Parameters
a_inStreamThe stream to read from.
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 1151 of file daStreamIo.cpp.

References xms::daRead3DoubleLine().

Referenced by xms::daRead3DoubleLine(), and DaStreamIoUnitTests::testReadWrite3DoubleLine().

◆ daRead3StringLine()

bool xms::daRead3StringLine ( std::istream &  a_inStream,
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_inStreamThe stream to read from.
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 1134 of file daStreamIo.cpp.

References xms::daRead3StringLine().

Referenced by xms::daRead3StringLine(), and DaStreamIoUnitTests::testReadWrite3StringLine().

◆ daReadDoubleFromLine()

bool xms::daReadDoubleFromLine ( std::string &  a_line,
double &  a_val 
)

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 1194 of file daStreamIo.cpp.

References xms::daReadDoubleFromLine().

Referenced by xms::daReadDoubleFromLine(), xms::daReadVecPt3d(), xms::DaStreamReader::ReadVecPt3d(), and DaStreamIoUnitTests::testReadDoubleFromLine().

◆ daReadDoubleLine()

bool xms::daReadDoubleLine ( std::istream &  a_inStream,
const char *  a_name,
double &  a_val 
)

Read a named double value from a line.

Parameters
a_inStreamThe stream to read from.
a_nameThe expected name before the value.
a_valThe double value.
Returns
True if no errors.

Definition at line 1035 of file daStreamIo.cpp.

References xms::daReadDoubleLine().

Referenced by xms::daReadDoubleLine(), and DaStreamIoUnitTests::testReadWriteDoubleLine().

◆ daReadIntFromLine()

bool xms::daReadIntFromLine ( std::string &  a_line,
int &  a_val 
)

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 1165 of file daStreamIo.cpp.

References xms::daReadIntFromLine().

Referenced by xms::daReadIntFromLine(), xms::daReadVecPt3d(), xms::DaStreamReader::ReadVecPt3d(), and DaStreamIoUnitTests::testReadIntFromLine().

◆ daReadIntLine()

bool xms::daReadIntLine ( std::istream &  a_inStream,
const char *  a_name,
int &  a_val 
)

Read a named integer value from a line.

Parameters
a_inStreamThe stream to read from.
a_nameThe expected name before the value.
a_valThe integer value.
Returns
True if no errors.

Definition at line 1024 of file daStreamIo.cpp.

References xms::daReadIntLine().

Referenced by xms::daReadIntLine(), xms::daReadVecPt3d(), xms::DaStreamReader::ReadVecPt3d(), and DaStreamIoUnitTests::testReadWriteIntLine().

◆ daReadLine()

bool xms::daReadLine ( std::istream &  a_inStream,
std::string &  a_line 
)

Read a line from a stream with the following line endings: CR LF, LF, CR, or none.

Parameters
a_inStreamThe stream to read from.
a_lineThe line that was read.
Returns
True if no errors.

Definition at line 978 of file daStreamIo.cpp.

References xms::daReadLine().

Referenced by xms::daLineBeginsWith(), xms::daReadLine(), xms::daReadVecPt3d(), xms::DaStreamReader::ReadVecPt3d(), DaStreamIoUnitTests::testLineBeginsWith(), and DaStreamIoUnitTests::testReadWriteLine().

◆ daReadNamedLine()

bool xms::daReadNamedLine ( std::istream &  a_inStream,
const char *  a_name 
)

Read a line that begins with a name.

Parameters
a_inStreamThe stream to read from.
a_nameThe expected name before the value.
Returns
True if no errors.

Definition at line 966 of file daStreamIo.cpp.

References xms::daReadNamedLine().

Referenced by xms::daReadNamedLine(), and DaStreamIoUnitTests::testReadNamedLine().

◆ daReadStringFromLine()

bool xms::daReadStringFromLine ( std::string &  a_line,
std::string &  a_val 
)

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 1175 of file daStreamIo.cpp.

References xms::daReadStringFromLine().

Referenced by xms::daReadStringFromLine(), xms::daReadVecPt3d(), xms::DaStreamReader::ReadVecPt3d(), and DaStreamIoUnitTests::testReadStringFromLine().

◆ daReadStringLine()

bool xms::daReadStringLine ( std::istream &  a_inStream,
const char *  a_name,
std::string &  a_val 
)

Read a named string value from a line.

Parameters
a_inStreamThe stream to read from.
a_nameThe expected name before the value.
a_valThe string value.
Returns
True if no errors.

Definition at line 1046 of file daStreamIo.cpp.

References xms::daReadStringLine().

Referenced by xms::daReadStringLine(), and DaStreamIoUnitTests::testReadWriteStringLine().

◆ daReadVecDbl()

bool xms::daReadVecDbl ( std::istream &  a_inStream,
const char *  a_name,
VecDbl a_vec 
)

Read named vector of doubles from multiple lines.

Parameters
a_inStreamThe stream to read from.
a_nameThe expected name before the value.
a_vecThe vector of doubles.
Returns
True if no errors.

Definition at line 1068 of file daStreamIo.cpp.

References xms::daReadVecDbl().

Referenced by xms::daReadVecDbl(), and DaStreamIoUnitTests::testReadWriteVecDbl().

◆ daReadVecInt()

bool xms::daReadVecInt ( std::istream &  a_inStream,
const char *  a_name,
VecInt a_vec 
)

Read named vector of integers from multiple lines.

Parameters
a_inStreamThe stream to read from.
a_nameThe expected name before the value.
a_vecThe vector of integers.
Returns
True if no errors.

Definition at line 1057 of file daStreamIo.cpp.

References xms::daReadVecInt().

Referenced by xms::daReadVecInt(), and DaStreamIoUnitTests::testReadWriteVecInt().

◆ daReadVecPt3d()

bool xms::daReadVecPt3d ( std::istream &  a_inStream,
const char *  a_name,
VecPt3d a_vec 
)

Read named vector of Pt3d from multiple lines.

Parameters
a_inStreamThe stream to read from.
a_nameThe expected name before the value.
a_vecThe vector of Pt3d.
Returns
True if no errors.

Definition at line 1079 of file daStreamIo.cpp.

References xms::daReadDoubleFromLine(), xms::daReadIntFromLine(), xms::daReadIntLine(), xms::daReadLine(), xms::daReadStringFromLine(), xms::daReadVecPt3d(), xms::Pt3< T >::x, xms::Pt3< T >::y, and xms::Pt3< T >::z.

Referenced by xms::daReadVecPt3d(), and DaStreamIoUnitTests::testReadWriteVecPt3d().

◆ daWrite2StringLine()

void xms::daWrite2StringLine ( std::ostream &  a_outStream,
const char *  a_name,
const std::string &  a_val1,
const std::string &  a_val2 
)

Write a named pair of words to a line.

Parameters
a_outStreamThe stream to write too.
a_nameThe name to be written before the value.
a_val1The first word.
a_val2The second word.

Definition at line 1279 of file daStreamIo.cpp.

References xms::daWrite2StringLine().

Referenced by xms::daWrite2StringLine(), DaStreamIoUnitTests::testReadWrite2StringLine(), and xms::DaStreamWriter::Write2StringLine().

◆ daWrite3DoubleLine()

void xms::daWrite3DoubleLine ( std::ostream &  a_outStream,
const char *  a_name,
const double &  a_val1,
const double &  a_val2,
const double &  a_val3 
)

Write a named triplet of doubles to a line.

Parameters
a_outStreamThe stream to write too.
a_nameThe name to be written before the value.
a_val1The first double.
a_val2The second double.
a_val3The third double.

Definition at line 1310 of file daStreamIo.cpp.

References xms::daWrite3DoubleLine(), and xms::STRstd().

Referenced by xms::daWrite3DoubleLine(), DaStreamIoUnitTests::testReadWrite3DoubleLine(), and xms::DaStreamWriter::Write3DoubleLine().

◆ daWrite3StringLine()

void xms::daWrite3StringLine ( std::ostream &  a_outStream,
const char *  a_name,
const std::string &  a_val1,
const std::string &  a_val2,
const std::string &  a_val3 
)

Write a named triplet of words to a line.

Parameters
a_outStreamThe stream to write too.
a_nameThe name to be written before the value.
a_val1The first word.
a_val2The second word.
a_val3The third word.

Definition at line 1294 of file daStreamIo.cpp.

References xms::daWrite3StringLine().

Referenced by xms::daWrite3StringLine(), DaStreamIoUnitTests::testReadWrite3StringLine(), and xms::DaStreamWriter::Write3StringLine().

◆ daWriteDoubleLine()

void xms::daWriteDoubleLine ( std::ostream &  a_outStream,
const char *  a_name,
double  a_val 
)

Write a named double line value.

Parameters
a_outStreamThe stream to write too.
a_nameThe name to be written before the value.
a_valThe double value to write.

Definition at line 1241 of file daStreamIo.cpp.

References xms::daWriteDoubleLine(), and xms::STRstd().

Referenced by xms::daWriteDoubleLine(), DaStreamIoUnitTests::testReadWriteDoubleLine(), and xms::DaStreamWriter::WriteDoubleLine().

◆ daWriteIntLine()

void xms::daWriteIntLine ( std::ostream &  a_outStream,
const char *  a_name,
int  a_val 
)

Write a named integer value to a line.

Parameters
a_outStreamThe stream to write too.
a_nameThe name to be written before the value.
a_valThe integer value.

Definition at line 1325 of file daStreamIo.cpp.

References xms::daWriteIntLine().

Referenced by xms::daWriteIntLine(), DaStreamIoUnitTests::testReadWriteIntLine(), and xms::DaStreamWriter::WriteIntLine().

◆ daWriteLine()

void xms::daWriteLine ( std::ostream &  a_outStream,
const std::string &  a_line 
)

Write a given line to a stream.

Parameters
a_outStreamThe stream to write too.
a_lineThe line of text to be written.

Definition at line 1231 of file daStreamIo.cpp.

References xms::daWriteLine().

Referenced by xms::daWriteLine(), DaStreamIoUnitTests::testReadWriteLine(), and xms::DaStreamWriter::WriteLine().

◆ daWriteStringLine()

void xms::daWriteStringLine ( std::ostream &  a_outStream,
const char *  a_name,
const std::string &  a_val 
)

Write a named word line.

Parameters
a_outStreamThe stream to write too.
a_nameThe name to be written before the value.
a_valThe word.

Definition at line 1253 of file daStreamIo.cpp.

References xms::daWriteStringLine().

Referenced by xms::daWriteStringLine(), DaStreamIoUnitTests::testReadWriteStringLine(), and xms::DaStreamWriter::WriteStringLine().

◆ daWriteVecDbl()

void xms::daWriteVecDbl ( std::ostream &  a_outStream,
const char *  a_name,
const VecDbl a_vec 
)

Write a named vector of doubles to multiple lines.

Parameters
a_outStreamThe stream to write too.
a_nameThe name to be written before the value.
a_vecThe vector of doubles.

Definition at line 1335 of file daStreamIo.cpp.

References xms::daWriteVecDbl(), and xms::STRstd().

Referenced by xms::daWriteVecDbl(), DaStreamIoUnitTests::testReadWriteVecDbl(), and xms::DaStreamWriter::WriteVecDbl().

◆ daWriteVecInt()

void xms::daWriteVecInt ( std::ostream &  a_outStream,
const char *  a_name,
const VecInt a_vec 
)

Write a named vector of integers to several lines.

Parameters
a_outStreamThe stream to write too.
a_nameThe name to be written before the value.
a_vecThe vector of integers.

Definition at line 1263 of file daStreamIo.cpp.

References xms::daWriteVecInt().

Referenced by xms::daWriteVecInt(), DaStreamIoUnitTests::testReadWriteVecInt(), and xms::DaStreamWriter::WriteVecInt().

◆ daWriteVecPt3d()

void xms::daWriteVecPt3d ( std::ostream &  a_outStream,
const char *  a_name,
const VecPt3d a_points 
)

Write a named vector of Pt3d to multiple lines.

Parameters
a_outStreamThe stream to write too.
a_nameThe name to be written before the value.
a_pointsThe vector of Pt3d.

Definition at line 1351 of file daStreamIo.cpp.

References xms::daWriteVecPt3d(), xms::STRstd(), xms::Pt3< T >::x, xms::Pt3< T >::y, and xms::Pt3< T >::z.

Referenced by xms::daWriteVecPt3d(), DaStreamIoUnitTests::testReadWriteVecPt3d(), and xms::DaStreamWriter::WriteVecPt3d().