20 #include <boost/archive/iterators/base64_from_binary.hpp> 21 #include <boost/archive/iterators/binary_from_base64.hpp> 22 #include <boost/archive/iterators/transform_width.hpp> 23 #include <boost/unordered_map.hpp> 47 const int MAX_BLOCK_SIZE = 1024 * 32;
59 Impl(std::istream& a_inStream,
bool a_binaryArrays)
78 Impl(std::ostream& a_outStream,
bool a_binaryArrays)
79 : m_outStream(a_outStream)
86 int m_blockSize = MAX_BLOCK_SIZE;
99 int32_t iCompress(
const char* a_source, int32_t a_sourceLength,
char* a_dest, int32_t a_destLength)
101 auto compressedLength =
static_cast<uLong
>(a_destLength);
102 auto result = compress2(reinterpret_cast<Bytef*>(a_dest), &compressedLength,
103 reinterpret_cast<const Bytef*>(a_source),
104 static_cast<uLong>(a_sourceLength), Z_BEST_SPEED);
111 return static_cast<int32_t
>(compressedLength);
116 bool iUncompress(
const char* a_source, int32_t a_sourceLength,
char* a_dest, int32_t a_destLength)
118 auto uncompressedLength =
static_cast<uLong
>(a_destLength);
119 bool success = uncompress(reinterpret_cast<Bytef*>(a_dest), &uncompressedLength,
120 reinterpret_cast<const Bytef*>(a_source),
121 static_cast<uLong>(a_sourceLength)) == Z_OK;
122 success = success &&
static_cast<int32_t
>(uncompressedLength) == a_destLength;
134 int32_t iBase64EncodeSize(int32_t a_sourceLength)
136 unsigned long length = ((4U *
static_cast<unsigned long>(a_sourceLength) / 3U) + 3U) & ~3U;
137 return static_cast<int32_t
>(length);
142 int32_t iBase64Encode(
const char* a_source, int32_t a_sourceLength,
char* a_dest)
144 using namespace boost::archive::iterators;
145 typedef base64_from_binary<transform_width<const char*, 6, 8>> base64_text;
147 const char* srcBegin = a_source;
148 const char* srcEnd = srcBegin + a_sourceLength;
149 char* destBegin = a_dest;
150 char* destIterator = a_dest;
151 for (
auto it = base64_text(srcBegin); it != base64_text(srcEnd); ++it)
152 *destIterator++ = *it;
155 auto encodedLength = int32_t(destIterator - destBegin);
156 return encodedLength;
161 int32_t iBase64Decode(
const char* a_source, int32_t a_sourceLength,
char* a_dest)
163 using namespace boost::archive::iterators;
164 typedef transform_width<binary_from_base64<const char*>, 8, 6> base64_dec;
166 int32_t size = a_sourceLength;
167 if (size && a_source[size - 1] ==
'=')
170 if (size && a_source[size - 1] ==
'=')
176 char* destBegin = a_dest;
177 char* destIterator = a_dest;
178 auto base64Begin = base64_dec(a_source);
179 auto base64End = base64_dec(a_source + size);
180 for (
auto it = base64Begin; it != base64End; ++it)
181 *destIterator++ = *it;
183 auto decodedLength = int32_t(destIterator - destBegin);
184 return decodedLength;
196 bool iReadLineToSStream(std::istream& a_inStream,
const char* a_name, std::stringstream& a_ss)
202 auto position = line.find(a_name);
203 if (position == std::string::npos)
207 for (
size_t i = 0; i < position; ++i)
209 if (!isspace(line[i]))
215 std::replace(line.begin(), line.end(),
',',
' ');
216 a_ss.str(line.substr(position));
225 template <
typename _T>
226 bool iReadLineValue(std::istream& a_inStream, _T& a_val)
231 std::stringstream ss;
243 template <
typename _T>
244 bool iReadVector(std::istream& a_inStream,
const char* a_name, std::vector<_T>& a_vec)
250 for (
int ii = 0; ii < size; ++ii)
253 if (!iReadLineValue(a_inStream, val))
255 a_vec.push_back(val);
266 template <
typename _T>
267 bool iReadValue(std::istream& a_inStream,
const char* a_name, _T& a_d1)
269 std::stringstream ss;
270 if (!iReadLineToSStream(a_inStream, a_name, ss))
286 template <
typename _T>
287 bool iRead3Values(std::istream& a_inStream,
const char* a_name, _T& d1, _T& d2, _T& d3)
289 std::stringstream ss;
290 if (!iReadLineToSStream(a_inStream, a_name, ss))
307 template <
typename _T>
308 bool iRead2Values(std::istream& a_inStream,
const char* a_name, _T& d1, _T& d2)
310 std::stringstream ss;
311 if (!iReadLineToSStream(a_inStream, a_name, ss))
325 template <
typename _T>
326 bool iReadValueFromLine(std::string& a_line, _T& a_val)
328 std::string line = a_line;
329 std::string stringValue;
333 std::istringstream inStream(stringValue);
336 if (inStream.fail() || !inStream.eof())
357 :
m_impl(new
Impl(a_inStream, a_binaryArrays))
372 return m_impl->m_binaryArrays;
381 std::stringstream ss;
382 return iReadLineToSStream(
m_impl->m_inStream, a_name, ss);
400 std::istream::sentry se(
m_impl->m_inStream,
true);
401 std::streambuf* sb =
m_impl->m_inStream.rdbuf();
405 int c = sb->sbumpc();
408 return !!
m_impl->m_inStream;
413 if (sb->sgetc() ==
'\n')
415 return !!
m_impl->m_inStream;
418 if (c == std::streambuf::traits_type::eof())
422 m_impl->m_inStream.setstate(std::ios::eofbit);
423 return !!
m_impl->m_inStream;
426 a_line +=
static_cast<char>(c);
437 return iReadValue(
m_impl->m_inStream, a_name, a_val);
447 return iReadValue(
m_impl->m_inStream, a_name, a_val);
457 return iReadValue(
m_impl->m_inStream, a_name, a_val);
475 ReadBinaryBytes(reinterpret_cast<char*>(&a_vec[0]), size *
sizeof(VecInt::value_type));
479 return iReadVector(
m_impl->m_inStream, a_name, a_vec);
497 ReadBinaryBytes(reinterpret_cast<char*>(&a_vec[0]), size *
sizeof(VecDbl::value_type));
501 return iReadVector(
m_impl->m_inStream, a_name, a_vec);
519 ReadBinaryBytes(reinterpret_cast<char*>(&a_vec[0]), size *
sizeof(VecPt3d::value_type));
525 std::string pointLine;
526 std::string pointValue;
527 for (
int i = 0; i < size; ++i)
533 success = success && pointValue ==
"POINT";
534 int readPointIdx = -1;
536 success = success && readPointIdx ==
static_cast<int>(i);
539 success = success && daReadDoubleFromLine(pointLine, pt.
y);
540 success = success && daReadDoubleFromLine(pointLine, pt.
z);
558 return iRead2Values(
m_impl->m_inStream, a_name, a_val1, a_val2);
573 return iRead3Values(
m_impl->m_inStream, a_name, a_val1, a_val2, a_val3);
588 return iRead3Values(
m_impl->m_inStream, a_name, a_val1, a_val2, a_val3);
598 return iReadValueFromLine(a_line, a_val);
608 std::istringstream inStream(a_line);
612 size_t position = inStream.tellg();
613 if (position != std::string::npos)
614 a_line = inStream.str().substr(position);
627 return iReadValueFromLine(a_line, a_val);
636 m_impl->m_inStream >> a_val;
637 return !
m_impl->m_inStream.fail();
646 m_impl->m_inStream >> a_val;
647 return !
m_impl->m_inStream.fail();
657 return !
m_impl->m_inStream.fail();
667 auto maxCompressedLength =
static_cast<int32_t
>(compressBound(MAX_BLOCK_SIZE));
668 int32_t maxEncodeLength = iBase64EncodeSize(maxCompressedLength);
669 std::unique_ptr<char[]> compressed(
new char[maxCompressedLength]);
670 std::unique_ptr<char[]> encoded(
new char[maxEncodeLength + 1]);
672 while (a_destLength > 0)
675 std::string blockString;
676 int32_t encodedLength;
684 m_impl->m_inStream.read(encoded.get(), encodedLength);
687 auto compressedLength = iBase64Decode(encoded.get(), encodedLength, compressed.get());
690 if (!iUncompress(compressed.get(), compressedLength, a_dest, blockLength))
693 a_dest += blockLength;
694 a_destLength -= blockLength;
721 :
m_impl(new
Impl(a_outStream, a_binaryArrays))
736 return m_impl->m_binaryArrays;
782 m_impl->m_outStream << a_name <<
' ' << a_vec.size() <<
'\n';
785 a_vec.size() *
sizeof(VecInt::value_type));
801 m_impl->m_outStream << a_name <<
' ' << a_vec.size() <<
'\n';
804 a_vec.size() *
sizeof(VecDbl::value_type));
820 m_impl->m_outStream << a_name <<
' ' << a_points.size() <<
'\n';
821 if (!a_points.empty())
823 a_points.size() *
sizeof(VecPt3d::value_type));
837 const std::string& a_val1,
838 const std::string& a_val2)
850 const std::string& a_val1,
851 const std::string& a_val2,
852 const std::string& a_val3)
864 const double& a_val1,
865 const double& a_val2,
866 const double& a_val3)
876 m_impl->m_outStream << a_string;
884 m_impl->m_outStream <<
' ' << a_val;
893 for (
int i = 0; i < a_numValues; ++i)
894 m_impl->m_outStream <<
' ' << *a_values++;
902 m_impl->m_outStream <<
' ' << a_val;
909 m_impl->m_outStream <<
'\n';
919 auto maxCompressedLength =
static_cast<int32_t
>(compressBound(
m_impl->m_blockSize));
920 int32_t maxEncodeLength = iBase64EncodeSize(maxCompressedLength);
921 std::unique_ptr<char[]> compressed(
new char[maxCompressedLength]);
922 std::unique_ptr<char[]> encoded(
new char[maxEncodeLength + 1]);
924 while (a_sourceLength > 0)
927 int32_t blockLength = a_sourceLength <
m_impl->m_blockSize
928 ?
static_cast<int32_t
>(a_sourceLength)
930 int32_t compressedLength =
931 iCompress(a_source, blockLength, compressed.get(), maxCompressedLength);
932 if (compressedLength < 0)
934 a_sourceLength -= blockLength;
935 a_source += blockLength;
938 int32_t encodedLength = iBase64Encode(compressed.get(), compressedLength, encoded.get());
945 m_impl->m_outStream.write(encoded.get(), encodedLength);
957 m_impl->m_blockSize = a_blockSize > MAX_BLOCK_SIZE ? MAX_BLOCK_SIZE : a_blockSize;
968 std::stringstream ss;
969 return iReadLineToSStream(a_inStream, a_name, ss);
978 bool daReadLine(std::istream& a_inStream, std::string& a_line)
988 std::istream::sentry se(a_inStream,
true);
989 std::streambuf* sb = a_inStream.rdbuf();
993 int c = sb->sbumpc();
1001 if (sb->sgetc() ==
'\n')
1003 return !!a_inStream;
1006 if (c == std::streambuf::traits_type::eof())
1010 a_inStream.setstate(std::ios::eofbit);
1011 return !!a_inStream;
1026 return iReadValue(a_inStream, a_name, a_val);
1037 return iReadValue(a_inStream, a_name, a_val);
1048 return iReadValue(a_inStream, a_name, a_val);
1059 return iReadVector(a_inStream, a_name, a_vec);
1070 return iReadVector(a_inStream, a_name, a_vec);
1086 a_vec.reserve(size);
1087 std::string pointLine;
1088 std::string pointValue;
1089 for (
int i = 0; i < size; ++i)
1095 success = success && pointValue ==
"POINT";
1096 int readPointIdx = -1;
1098 success = success && readPointIdx == (int)i;
1101 success = success && daReadDoubleFromLine(pointLine, pt.
y);
1102 success = success && daReadDoubleFromLine(pointLine, pt.
z);
1105 a_vec.push_back(pt);
1120 std::string& a_val1,
1121 std::string& a_val2)
1123 return iRead2Values(a_inStream, a_name, a_val1, a_val2);
1136 std::string& a_val1,
1137 std::string& a_val2,
1138 std::string& a_val3)
1140 return iRead3Values(a_inStream, a_name, a_val1, a_val2, a_val3);
1157 return iRead3Values(a_inStream, a_name, a_val1, a_val2, a_val3);
1167 return iReadValueFromLine(a_line, a_val);
1177 std::istringstream inStream(a_line);
1179 if (inStream.fail())
1181 size_t position = inStream.tellg();
1182 if (position != std::string::npos)
1183 a_line = inStream.str().substr(position);
1196 return iReadValueFromLine(a_line, a_val);
1206 auto streamPosition = a_inStream.tellg();
1207 bool foundText =
false;
1211 foundText = line.find(a_text) == 0;
1214 a_inStream.seekg(streamPosition);
1224 a_outStream << a_name <<
'\n';
1231 void daWriteLine(std::ostream& a_outStream,
const std::string& a_line)
1233 a_outStream << a_line <<
'\n';
1244 a_outStream << a_name <<
' ' <<
STRstd(a_val) <<
'\n';
1255 a_outStream << a_name <<
' ' << a_val <<
'\n';
1265 size_t size = a_vec.size();
1266 a_outStream << a_name <<
' ' << size <<
'\n';
1267 for (
auto val : a_vec)
1269 a_outStream <<
" " << val <<
'\n';
1281 const std::string& a_val1,
1282 const std::string& a_val2)
1284 a_outStream << a_name <<
' ' << a_val1 <<
' ' << a_val2 <<
'\n';
1296 const std::string& a_val1,
1297 const std::string& a_val2,
1298 const std::string& a_val3)
1300 a_outStream << a_name <<
' ' << a_val1 <<
' ' << a_val2 <<
' ' << a_val3 <<
'\n';
1312 const double& a_val1,
1313 const double& a_val2,
1314 const double& a_val3)
1316 a_outStream << a_name <<
' ' <<
STRstd(a_val1) <<
' ' <<
STRstd(a_val2) <<
' ' <<
STRstd(a_val3)
1327 a_outStream << a_name <<
' ' << a_val <<
'\n';
1338 size_t size = a_vec.size();
1339 a_outStream << a_name <<
' ' << size <<
'\n';
1340 for (
auto val : a_vec)
1342 a_outStream <<
" " <<
STRstd(val) <<
'\n';
1354 a_outStream << a_name <<
' ' << a_points.size() <<
'\n';
1358 for (
size_t i = 0; i < a_points.size(); ++i)
1360 const Pt3d& point = a_points[i];
1361 std::string sx(
STRstd(point.
x));
1362 std::string sy(
STRstd(point.
y));
1363 std::string sz(
STRstd(point.
z));
1364 a_outStream <<
" POINT " << i <<
' ' << sx <<
' ' << sy <<
' ' << sz <<
'\n';
1379 using namespace xms;
1391 std::string lineEndingsInput =
1396 std::istringstream inStream(lineEndingsInput);
1407 std::ostringstream outputStream;
1408 daWriteLine(outputStream,
"daWriteLine version 1.0");
1409 std::string expected =
"daWriteLine version 1.0\n";
1410 std::string found = outputStream.str();
1411 TS_ASSERT_EQUALS(expected, found);
1413 std::istringstream inputStream(outputStream.str());
1416 expected =
"daWriteLine version 1.0";
1417 TS_ASSERT_EQUALS(expected, value);
1420 std::string lineEndingsInput =
1425 std::istringstream endingsIn(lineEndingsInput);
1427 TS_ASSERT_EQUALS(
"Windows Line", value);
1429 TS_ASSERT_EQUALS(
"Unix Line", value);
1431 TS_ASSERT_EQUALS(
"Mac Line", value);
1433 TS_ASSERT_EQUALS(
"Last Line", value);
1440 std::ostringstream outputStream;
1441 const char* name =
"LINE_NAME";
1442 std::string expectedValue =
"VALUE";
1444 std::string expected =
"LINE_NAME VALUE\n";
1445 std::string found = outputStream.str();
1446 TS_ASSERT_EQUALS(expected, found);
1448 std::istringstream inputStream(outputStream.str());
1449 std::string foundValue;
1451 TS_ASSERT_EQUALS(expectedValue, foundValue);
1458 std::ostringstream outputStream;
1459 const char* name =
"LINE_NAME";
1460 std::string expectedValue1 =
"VALUE1";
1461 std::string expectedValue2 =
"VALUE2";
1463 std::string expected =
"LINE_NAME VALUE1 VALUE2\n";
1464 std::string found = outputStream.str();
1465 TS_ASSERT_EQUALS(expected, found);
1467 std::istringstream inputStream(outputStream.str());
1468 std::string foundValue1;
1469 std::string foundValue2;
1471 TS_ASSERT_EQUALS(expectedValue1, foundValue1);
1472 TS_ASSERT_EQUALS(expectedValue2, foundValue2);
1479 std::ostringstream outputStream;
1480 const char* name =
"LINE_NAME";
1481 std::string expectedValue1 =
"VALUE1";
1482 std::string expectedValue2 =
"VALUE2";
1483 std::string expectedValue3 =
"VALUE3";
1484 daWrite3StringLine(outputStream, name, expectedValue1, expectedValue2, expectedValue3);
1485 std::string expected =
"LINE_NAME VALUE1 VALUE2 VALUE3\n";
1486 std::string found = outputStream.str();
1487 TS_ASSERT_EQUALS(expected, found);
1489 std::istringstream inputStream(outputStream.str());
1490 std::string foundValue1;
1491 std::string foundValue2;
1492 std::string foundValue3;
1493 TS_ASSERT(
daRead3StringLine(inputStream, name, foundValue1, foundValue2, foundValue3));
1494 TS_ASSERT_EQUALS(expectedValue1, foundValue1);
1495 TS_ASSERT_EQUALS(expectedValue2, foundValue2);
1496 TS_ASSERT_EQUALS(expectedValue3, foundValue3);
1507 line =
"1 -1 A 2.0 B 4";
1509 TS_ASSERT_EQUALS(1, intValue);
1510 TS_ASSERT_EQUALS(
" -1 A 2.0 B 4", line);
1513 line =
" -1 A 2.0 B 4";
1515 TS_ASSERT_EQUALS(-1, intValue);
1516 TS_ASSERT_EQUALS(
" A 2.0 B 4", line);
1519 line =
" A 2.0 B 4";
1522 TS_ASSERT_EQUALS(-1, intValue);
1523 TS_ASSERT_EQUALS(
" A 2.0 B 4", line);
1526 line =
" A 2.0 B 4";
1529 TS_ASSERT_EQUALS(-1, intValue);
1530 TS_ASSERT_EQUALS(
" A 2.0 B 4", line);
1536 TS_ASSERT_EQUALS(-1, intValue);
1537 TS_ASSERT_EQUALS(
"", line);
1547 std::string stringValue;
1548 line =
"value1 value2 3";
1550 TS_ASSERT_EQUALS(
"value1", stringValue);
1551 TS_ASSERT_EQUALS(
" value2 3", line);
1554 line =
" value2 value3";
1556 TS_ASSERT_EQUALS(
"value2", stringValue);
1557 TS_ASSERT_EQUALS(
" value3", line);
1562 TS_ASSERT_EQUALS(
"3", stringValue);
1563 TS_ASSERT_EQUALS(
"", line);
1569 TS_ASSERT_EQUALS(
"3", stringValue);
1570 TS_ASSERT_EQUALS(
"", line);
1581 line =
"1.1 -1.0e-3 3";
1583 TS_ASSERT_EQUALS(1.1, doubleValue);
1584 TS_ASSERT_EQUALS(
" -1.0e-3 3", line);
1587 line =
" -1.0e-3 3";
1589 TS_ASSERT_EQUALS(-1.0e-3, doubleValue);
1590 TS_ASSERT_EQUALS(
" 3", line);
1595 TS_ASSERT_EQUALS(3, doubleValue);
1596 TS_ASSERT_EQUALS(
"", line);
1602 TS_ASSERT_EQUALS(3, doubleValue);
1603 TS_ASSERT_EQUALS(
"", line);
1610 std::ostringstream outputStream;
1611 const char* name =
"LINE_NAME";
1612 const int expect = 22;
1614 std::string outputExpected =
"LINE_NAME 22\n";
1615 std::string outputFound = outputStream.str();
1616 TS_ASSERT_EQUALS(outputExpected, outputFound);
1618 std::istringstream inputStream(outputStream.str());
1621 TS_ASSERT_EQUALS(expect, found);
1628 std::ostringstream outputStream;
1629 const char* name =
"LINE_NAME";
1630 const double expect1 = 1.123e-20;
1631 const double expect2 = 2.0;
1634 std::string outputExpected =
"LINE_NAME 1.123e-20\nLINE_NAME 2.0\n";
1635 std::string outputFound = outputStream.str();
1636 TS_ASSERT_EQUALS(outputExpected, outputFound);
1638 std::istringstream inputStream(outputStream.str());
1641 TS_ASSERT_EQUALS(expect1, found);
1643 TS_ASSERT_EQUALS(expect2, found);
1650 std::ostringstream outputStream;
1651 const char* name =
"LINE_NAME";
1652 const double expect1 = 560770.5;
1653 const double expect2 = 70055.4;
1654 const double expect3 = 22.3;
1656 std::string outputExpected =
"LINE_NAME 560770.5 70055.4 22.3\n";
1657 std::string outputFound = outputStream.str();
1658 TS_ASSERT_EQUALS(outputExpected, outputFound);
1660 std::istringstream inputStream(outputStream.str());
1665 TS_ASSERT_EQUALS(expect1, found1);
1666 TS_ASSERT_EQUALS(expect2, found2);
1667 TS_ASSERT_EQUALS(expect3, found3);
1674 std::ostringstream outputStream;
1675 const char* name =
"VECTOR_NAME";
1676 const VecInt expect = {1, 2, 3};
1678 std::string outputExpected =
1683 std::string outputFound = outputStream.str();
1684 TS_ASSERT_EQUALS(outputExpected, outputFound);
1686 std::istringstream inputStream(outputStream.str());
1689 TS_ASSERT_EQUALS(expect, found);
1696 std::ostringstream outputStream;
1697 const char* name =
"VECTOR_NAME";
1698 const VecDbl expect = {1.0, 2.2e-20, 3.3};
1700 std::string outputExpected =
1705 std::string outputFound = outputStream.str();
1706 TS_ASSERT_EQUALS(outputExpected, outputFound);
1708 std::istringstream inputStream(outputStream.str());
1711 TS_ASSERT_EQUALS(expect, found);
1718 std::ostringstream outputStream;
1719 const char* name =
"VECTOR_NAME";
1722 {2.1, 2.2, 2.3e-20},
1725 std::string outputExpected =
1727 " POINT 0 1.0 1.2 1.3\n" 1728 " POINT 1 2.1 2.2 2.3e-20\n";
1729 std::string outputFound = outputStream.str();
1730 TS_ASSERT_EQUALS(outputExpected, outputFound);
1732 std::istringstream inputStream(outputStream.str());
1735 TS_ASSERT_EQUALS(expect, found);
1742 const char* inputText =
1744 " POINT 0 1.1 1.2 1.3\n" 1745 " POINT 1 2.1 2.2 2.3\n";
1746 std::istringstream inputStream(inputText);
1750 TS_ASSERT_EQUALS(
"VECTOR_NAME 2", line);
1753 TS_ASSERT_EQUALS(
" POINT 0 1.1 1.2 1.3", line);
1756 TS_ASSERT_EQUALS(
" POINT 1 2.1 2.2 2.3", line);
1768 std::string lineEndingsInput =
1773 std::istringstream inStream(lineEndingsInput);
1785 std::ostringstream outputStream;
1787 writer.
WriteLine(
"daWriteLine version 1.0");
1788 std::string expected =
"daWriteLine version 1.0\n";
1789 std::string found = outputStream.str();
1790 TS_ASSERT_EQUALS(expected, found);
1792 std::istringstream inputStream(outputStream.str());
1795 reader.ReadLine(value);
1796 expected =
"daWriteLine version 1.0";
1797 TS_ASSERT_EQUALS(expected, value);
1800 std::string lineEndingsInput =
1805 std::istringstream endingsIn(lineEndingsInput);
1808 TS_ASSERT_EQUALS(
"Windows Line", value);
1810 TS_ASSERT_EQUALS(
"Unix Line", value);
1812 TS_ASSERT_EQUALS(
"Mac Line", value);
1814 TS_ASSERT_EQUALS(
"Last Line", value);
1821 std::ostringstream outputStream;
1823 const char* name =
"LINE_NAME";
1824 std::string expectedValue =
"VALUE";
1826 std::string expected =
"LINE_NAME VALUE\n";
1827 std::string found = outputStream.str();
1828 TS_ASSERT_EQUALS(expected, found);
1830 std::istringstream inputStream(outputStream.str());
1832 std::string foundValue;
1833 TS_ASSERT(reader.ReadStringLine(name, foundValue));
1834 TS_ASSERT_EQUALS(expectedValue, foundValue);
1841 std::ostringstream outputStream;
1843 const char* name =
"LINE_NAME";
1844 std::string expectedValue1 =
"VALUE1";
1845 std::string expectedValue2 =
"VALUE2";
1847 std::string expected =
"LINE_NAME VALUE1 VALUE2\n";
1848 std::string found = outputStream.str();
1849 TS_ASSERT_EQUALS(expected, found);
1851 std::istringstream inputStream(outputStream.str());
1853 std::string foundValue1;
1854 std::string foundValue2;
1855 TS_ASSERT(reader.Read2StringLine(name, foundValue1, foundValue2));
1856 TS_ASSERT_EQUALS(expectedValue1, foundValue1);
1857 TS_ASSERT_EQUALS(expectedValue2, foundValue2);
1864 std::ostringstream outputStream;
1866 const char* name =
"LINE_NAME";
1867 std::string expectedValue1 =
"VALUE1";
1868 std::string expectedValue2 =
"VALUE2";
1869 std::string expectedValue3 =
"VALUE3";
1870 writer.
Write3StringLine(name, expectedValue1, expectedValue2, expectedValue3);
1871 std::string expected =
"LINE_NAME VALUE1 VALUE2 VALUE3\n";
1872 std::string found = outputStream.str();
1873 TS_ASSERT_EQUALS(expected, found);
1875 std::istringstream inputStream(outputStream.str());
1877 std::string foundValue1;
1878 std::string foundValue2;
1879 std::string foundValue3;
1880 TS_ASSERT(reader.Read3StringLine(name, foundValue1, foundValue2, foundValue3));
1881 TS_ASSERT_EQUALS(expectedValue1, foundValue1);
1882 TS_ASSERT_EQUALS(expectedValue2, foundValue2);
1883 TS_ASSERT_EQUALS(expectedValue3, foundValue3);
1892 std::string line =
"1 -1 A 2.0 B 4";
1894 TS_ASSERT_EQUALS(1, intValue);
1895 TS_ASSERT_EQUALS(
" -1 A 2.0 B 4", line);
1898 line =
" -1 A 2.0 B 4";
1900 TS_ASSERT_EQUALS(-1, intValue);
1901 TS_ASSERT_EQUALS(
" A 2.0 B 4", line);
1904 line =
" A 2.0 B 4";
1907 TS_ASSERT_EQUALS(-1, intValue);
1908 TS_ASSERT_EQUALS(
" A 2.0 B 4", line);
1911 line =
" A 2.0 B 4";
1914 TS_ASSERT_EQUALS(-1, intValue);
1915 TS_ASSERT_EQUALS(
" A 2.0 B 4", line);
1921 TS_ASSERT_EQUALS(-1, intValue);
1922 TS_ASSERT_EQUALS(
"", line);
1930 std::string stringValue;
1931 std::string line =
"value1 value2 3";
1933 TS_ASSERT_EQUALS(
"value1", stringValue);
1934 TS_ASSERT_EQUALS(
" value2 3", line);
1937 line =
" value2 value3";
1939 TS_ASSERT_EQUALS(
"value2", stringValue);
1940 TS_ASSERT_EQUALS(
" value3", line);
1945 TS_ASSERT_EQUALS(
"3", stringValue);
1946 TS_ASSERT_EQUALS(
"", line);
1952 TS_ASSERT_EQUALS(
"3", stringValue);
1953 TS_ASSERT_EQUALS(
"", line);
1962 std::string line =
"1.1 -1.0e-3 3";
1964 TS_ASSERT_EQUALS(1.1, doubleValue);
1965 TS_ASSERT_EQUALS(
" -1.0e-3 3", line);
1968 line =
" -1.0e-3 3";
1970 TS_ASSERT_EQUALS(-1.0e-3, doubleValue);
1971 TS_ASSERT_EQUALS(
" 3", line);
1976 TS_ASSERT_EQUALS(3, doubleValue);
1977 TS_ASSERT_EQUALS(
"", line);
1983 TS_ASSERT_EQUALS(3, doubleValue);
1984 TS_ASSERT_EQUALS(
"", line);
1991 std::ostringstream outputStream;
1993 const char* name =
"LINE_NAME";
1994 const int expect = 22;
1996 std::string outputExpected =
"LINE_NAME 22\n";
1997 std::string outputFound = outputStream.str();
1998 TS_ASSERT_EQUALS(outputExpected, outputFound);
2000 std::istringstream inputStream(outputStream.str());
2003 TS_ASSERT(reader.ReadIntLine(name, found));
2004 TS_ASSERT_EQUALS(expect, found);
2011 std::ostringstream outputStream;
2013 const char* name =
"LINE_NAME";
2014 const double expect = 22.1;
2016 std::string outputExpected =
"LINE_NAME 22.1\n";
2017 std::string outputFound = outputStream.str();
2018 TS_ASSERT_EQUALS(outputExpected, outputFound);
2020 std::istringstream inputStream(outputStream.str());
2023 TS_ASSERT(reader.ReadDoubleLine(name, found));
2024 TS_ASSERT_EQUALS(expect, found);
2031 std::ostringstream outputStream;
2033 const char* name =
"LINE_NAME";
2034 const double expect1 = 22.1;
2035 const double expect2 = 22.2;
2036 const double expect3 = 22.3;
2038 std::string outputExpected =
"LINE_NAME 22.1 22.2 22.3\n";
2039 std::string outputFound = outputStream.str();
2040 TS_ASSERT_EQUALS(outputExpected, outputFound);
2042 std::istringstream inputStream(outputStream.str());
2047 TS_ASSERT(reader.Read3DoubleLine(name, found1, found2, found3));
2048 TS_ASSERT_EQUALS(expect1, found1);
2049 TS_ASSERT_EQUALS(expect2, found2);
2050 TS_ASSERT_EQUALS(expect3, found3);
2057 std::ostringstream outputStream;
2059 const char* name =
"VECTOR_NAME";
2060 const VecInt expect = {1, 2, 3};
2062 std::string outputExpected =
2067 std::string outputFound = outputStream.str();
2068 TS_ASSERT_EQUALS(outputExpected, outputFound);
2070 std::istringstream inputStream(outputStream.str());
2073 TS_ASSERT(reader.ReadVecInt(name, found));
2074 TS_ASSERT_EQUALS(expect, found);
2081 std::ostringstream outputStream;
2083 const char* name =
"VECTOR_NAME";
2084 const VecDbl expect = {1.1, 2.2, 3.3};
2086 std::string outputExpected =
2091 std::string outputFound = outputStream.str();
2092 TS_ASSERT_EQUALS(outputExpected, outputFound);
2094 std::istringstream inputStream(outputStream.str());
2097 TS_ASSERT(reader.ReadVecDbl(name, found));
2098 TS_ASSERT_EQUALS(expect, found);
2105 std::ostringstream outputStream;
2107 const char* name =
"VECTOR_NAME";
2113 std::string outputExpected =
2115 " POINT 0 1.1 1.2 1.3\n" 2116 " POINT 1 2.1 2.2 2.3\n";
2117 std::string outputFound = outputStream.str();
2118 TS_ASSERT_EQUALS(outputExpected, outputFound);
2120 std::istringstream inputStream(outputStream.str());
2123 TS_ASSERT(reader.ReadVecPt3d(name, found));
2124 TS_ASSERT_EQUALS(expect, found);
2131 std::ostringstream outputStream;
2132 bool useBinaryArrays =
true;
2134 const char* name =
"VECTOR_NAME";
2136 std::iota(expect.begin(), expect.end(), 0);
2139 std::istringstream inputStream(outputStream.str());
2142 TS_ASSERT(reader.ReadVecInt(name, found));
2143 TS_ASSERT_EQUALS(expect, found);
2150 std::ostringstream outputStream;
2151 bool useBinaryArrays =
true;
2153 const char* name =
"VECTOR_NAME";
2156 for (
auto& e : expect)
2160 std::istringstream inputStream(outputStream.str());
2163 TS_ASSERT(reader.ReadVecDbl(name, found));
2164 TS_ASSERT_EQUALS(expect, found);
2171 std::ostringstream outputStream;
2172 bool useBinaryArrays =
true;
2174 const char* name =
"VECTOR_NAME";
2177 for (
auto& e : expect)
2179 e =
Pt3d(count, count + 1, count + 2);
2184 std::istringstream inputStream(outputStream.str());
2187 TS_ASSERT(reader.ReadVecPt3d(name, found));
2188 TS_ASSERT_EQUALS(expect, found);
2195 std::ostringstream outputStream;
2198 TS_ASSERT_EQUALS(
"STRING_ONE", outputStream.str());
2200 TS_ASSERT_EQUALS(
"STRING_ONE 0", outputStream.str());
2202 TS_ASSERT_EQUALS(
"STRING_ONE 0 STRING_TWO", outputStream.str());
2203 int ints[] = {1, 2, 3};
2205 TS_ASSERT_EQUALS(
"STRING_ONE 0 STRING_TWO 1 2 3", outputStream.str());
2207 TS_ASSERT_EQUALS(
"STRING_ONE 0 STRING_TWO 1 2 3\n", outputStream.str());
2209 std::istringstream inputStream(
"STRING_ONE 0\n1 STRING_TWO");
2214 TS_ASSERT_EQUALS(
"STRING_ONE", s)
2216 TS_ASSERT_EQUALS(0, i);
2220 TS_ASSERT_EQUALS(1, i);
2222 TS_ASSERT_EQUALS(
"STRING_TWO", s)
2231 std::iota(outValues.begin(), outValues.end(), 0);
2232 long long lengthInBytes = (
long long)outValues.size() *
sizeof(VecInt::value_type);
2233 std::ostringstream output;
2237 std::string text = output.str();
2238 std::string expectedText =
2239 "BINARY_BLOCK 74 120\n" 2240 "eAENw4UNwDAAAKDO3d3+f3OQEEIIkbGJqZm5haWVtY2tnb2Do5Ozi6ubu4enl7ePr58/RrQBtA\n" 2241 "BINARY_BLOCK 78 120\n" 2242 "eAENw4UNwzAAALBcUuaVGf7/a7bkKIQQm5iamVtYWlnb2Nr5s3dwdHJ2cXVz9/D08vbx9fMPILsFOA\n" 2243 "BINARY_BLOCK 78 120\n" 2244 "eAENw4UNwzAAALAcVuaVGf5/ZLbkKIQQm5iamVtYWlnb2Nr5s3dwdHJ2cXVz9/D08vbx9fMP+rMIvA\n" 2245 "BINARY_BLOCK 76 120\n" 2246 "eAENw4UNwzAAALDcWeaVGd6fLTkKIcQmpmbmFpZW1ja2dv7sHRydnF1c3dw9PL28fXz9/APUugxA\n" 2247 "BINARY_BLOCK 76 120\n" 2248 "eAENw4UNwzAAALCcXeaVGf6dLTkKIcQmpmbmFpZW1ja2dv7sHRydnF1c3dw9PL28fXz9/AOuwQ/E\n" 2249 "BINARY_BLOCK 78 120\n" 2250 "eAENw4UNwzAAALD8f0CZV2Z4cLbkKIQQm5iamVtYWlnb2Nr5s3dwdHJ2cXVz9/D08vbx9fMPiMgTSA\n" 2251 "BINARY_BLOCK 78 120\n" 2252 "eAENw4UNwzAAALD8f0+ZV2b4aLbkKIQQm5iamVtYWlnb2Nr5s3dwdHJ2cXVz9/D08vbx9fMPYs8WzA\n" 2253 "BINARY_BLOCK 78 120\n" 2254 "eAENw4UNwzAAALD8f16ZV2Z4YbbkKIQQm5iamVtYWlnb2Nr5s3dwdHJ2cXVz9/D08vbx9fMPPNYaUA\n" 2255 "BINARY_BLOCK 74 120\n" 2256 "eAENw4UNwDAAAKDO/f83524k0IcQBkcnZxdXN3cPTy9vH18/Q4SxiamZuYWllbWNrZ0/dFUP4g\n" 2257 "BINARY_BLOCK 82 120\n" 2258 "eAENw4URg0AAALBnAbRIkeJS2H8/krvEUQiJqZm5hR9LK2sbv7Z29g7+HJ2cXVzd3D08vfx7+/gCs5IDdg\n" 2259 "BINARY_BLOCK 82 120\n" 2260 "eAENw4URg0AAALBnH7RIkeJS2H8hkrvEUQiJqZm5hR9LK2sbv7Z29g7+HJ2cXVzd3D08vfx7+/gCjZkG+g\n" 2261 "BINARY_BLOCK 82 120\n" 2262 "eAENw4URg0AAALBnPbRIkeJS2H8DkrvEUQiJqZm5hR9LK2sbv7Z29g7+HJ2cXVzd3D08vfx7+/gCZ6AKfg\n" 2263 "BINARY_BLOCK 79 120\n" 2264 "eAENwwUOg0AAALDjt+iQIcNl8G/apHEUQmJqZm7hx9LK2savrZ29gz9HJ2cXVzd3D08v/94+vkGnDgI\n" 2265 "BINARY_BLOCK 79 120\n" 2266 "eAENwwUOg0AAALDj8+iQIcNl8FHapHEUQmJqZm7hx9LK2savrZ29gz9HJ2cXVzd3D08v/94+vhuuEYY\n" 2267 "BINARY_BLOCK 82 120\n" 2268 "eAENw4URg0AAALBn/zXQIkWKS2EzkrvEUQiJqZm5hR9LK2sbv7Z29g7+HJ2cXVzd3D08vfx7+/gC9aYVCg\n" 2269 "BINARY_BLOCK 82 120\n" 2270 "eAENw4URg0AAALBn/63QIkWKS2EVkrvEUQiJqZm5hR9LK2sbv7Z29g7+HJ2cXVzd3D08vfx7+/gCz60Yjg\n" 2271 "BINARY_BLOCK 63 80\n" 2272 "eAENwwESQCAAALD8/5NEkUj0Advd5imExejqZjK7e1g8rV7eNh+7r5/DH/dqElM\n";
2273 TS_ASSERT_EQUALS(expectedText, text);
2275 std::istringstream input(expectedText);
2278 TS_ASSERT(reader.
ReadBinaryBytes((
char*)&inValues[0], lengthInBytes));
2279 TS_ASSERT_EQUALS(outValues, inValues);
2286 const char* inputText =
2288 " POINT 0 1.1 1.2 1.3\n" 2289 " POINT 1 2.1 2.2 2.3\n";
2290 std::istringstream inputStream(inputText);
2295 TS_ASSERT_EQUALS(
"VECTOR_NAME 2", line);
2298 TS_ASSERT_EQUALS(
" POINT 0 1.1 1.2 1.3", line);
2301 TS_ASSERT_EQUALS(
" POINT 1 2.1 2.2 2.3", line);
Class for reading ASCII files with named card fields. Also includes the ability to embed non-portable...
void daWriteVecPt3d(std::ostream &a_outStream, const char *a_name, const VecPt3d &a_points)
Write a named vector of Pt3d to multiple lines.
#define XM_LOG(A, B)
Log message which can have a log type (Debug, Stackable, Gui).
bool IsBinary() const
Are array values written as binary?
bool 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.
std::vector< int > VecInt
short rename
bool daReadStringLine(std::istream &a_inStream, const char *a_name, std::string &a_val)
Read a named string value from a line.
void testReadWriteDoubleLine()
Test daWriteDoubleLine and daReadDoubleLine.
bool ReadString(std::string &a_val)
Read a white space separated string.
void testReadNamedLine()
Test daReadNamedLine.
void daWriteLine(std::ostream &a_outStream, const std::string &a_line)
Write a given line to a stream.
void SetBinaryBlockSize(int a_blockSize)
Set the block size to use when writing binary arrays.
void testReadStringFromLine()
Test ReadStringFromLine.
void Write3StringLine(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.
std::string STRstd(double a_value, int a_n, int width, int flags)
Get a properly formatted string from a double.
bool ReadVecDbl(const char *a_name, VecDbl &a_vec)
Read named vector of doubles from multiple lines.
void daWriteDoubleLine(std::ostream &a_outStream, const char *a_name, double a_val)
Write a named double line value.
std::vector< double > VecDbl
short rename
bool m_binaryArrays
Should binary arrays be read?
void testReadWrite3StringLine()
Test daWrite3StringLine and daRead3StringLine.
void daWriteVecInt(std::ostream &a_outStream, const char *a_name, const VecInt &a_vec)
Write a named vector of integers to several lines.
std::istream & m_inStream
The input stream.
bool 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.
void AppendInts(const int *a_vals, int a_numVals)
Append a list of integer values to the end of a line of text.
void daWriteIntLine(std::ostream &a_outStream, const char *a_name, int a_val)
Write a named integer value to a line.
void WriteIntLine(const char *a_name, int a_val)
Write a named integer value to a line.
std::unique_ptr< Impl > m_impl
Implementation.
bool ReadInt(int &a_val)
Read an integer value.
void daWriteStringLine(std::ostream &a_outStream, const char *a_name, const std::string &a_val)
Write a named word line.
void testLineBeginsWith()
Test DaStreamReader::LineBeginsWith.
bool daReadVecDbl(std::istream &a_inStream, const char *a_name, VecDbl &a_vec)
Read named vector of doubles from multiple lines.
void testReadIntFromLine()
Test ReadIntFromLine.
bool daReadNamedLine(std::istream &a_inStream, const char *a_name)
Read a line that begins with a name.
void testReadWriteBinaryArrays()
Test reading and writing a binary array.
When constructed std::cout will temporarily output 2-digit exponents for floating point numbers...
void Write2StringLine(const char *a_name, const std::string &a_val1, const std::string &a_val2)
Write a named pair of words to a line.
void testReadWriteLine()
Test daWriteLine and daReadLine.
bool IsBinary() const
Are array values read as binary?
void WriteStringLine(const char *a_name, const std::string &a_val)
Write a named word line.
void testReadWriteIntLine()
Test WriteIntLine and ReadIntLine.
bool ReadIntLine(const char *a_name, int &a_val)
Read a named integer value from a line.
bool ReadStringLine(const char *a_name, std::string &a_val)
Read a named string value from a line.
bool 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.
void testReadIntFromLine()
Test daReadIntFromLine.
void 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.
bool daReadVecInt(std::istream &a_inStream, const char *a_name, VecInt &a_vec)
Read named vector of integers from multiple lines.
void WriteDoubleLine(const char *a_name, double a_val)
Write a named double line value.
static bool ReadDoubleFromLine(std::string &a_line, double &a_val)
Read a double value from a string. Return the remaining string.
bool ReadLine(std::string &a_line)
Read a line from a stream with the following line endings: CR LF, LF, CR, or none.
bool ReadDoubleLine(const char *a_name, double &a_val)
Read a named double value from a line.
void testReadWrite2StringLine()
Test daWrite2StringLine and daRead2StringLine.
void testReadWriteStringLine()
Test daWriteStringLine and daReadStringLine.
void WriteString(const char *a_string)
Write a string value to the stream.
void testReadWriteDoubleLine()
Test WriteDoubleLine and ReadDoubleLine.
void EndLine()
Add return to move to the next line of text.
std::unique_ptr< Impl > m_impl
Implementation.
bool daReadIntLine(std::istream &a_inStream, const char *a_name, int &a_val)
Read a named integer value from a line.
bool ReadVecInt(const char *a_name, VecInt &a_vec)
Read named vector of integers from multiple lines.
void testReadWriteVecDbl()
Test daWriteVecDbl and daReadVecDbl.
void testReadNamedLine()
Test ReadNamedLine.
bool ReadNamedLine(const char *a_name)
Read a line that begins with a name.
bool Read3DoubleLine(const char *a_name, double &a_val1, double &a_val2, double &a_val3)
Read a named triplet of doubles from a line.
void testReadWriteVecPt3d()
Test WriteVecPt3d and ReadVecPt3d.
void testReadWrite2StringLine()
Test Write2StringLine and Read2StringLine.
void testReadWriteVecInt()
Test WriteVecInt and ReadVecInt.
void WriteLine(const std::string &a_line)
Write a given line to a stream.
bool m_binaryArrays
Should binary arrays be written?
bool daReadDoubleLine(std::istream &a_inStream, const char *a_name, double &a_val)
Read a named double value from a line.
void testReadWriteLineParts()
Test function that read and write parts of a line.
Implementation for DaStreamReader.
void testReadWriteIntLine()
Test daWriteIntLine and daReadIntLine.
bool daLineBeginsWith(std::istream &a_inStream, const std::string &a_text)
Determines if next line read will begin given text.
void testReadWriteBinaryVecDbl()
Test binary WriteVecDbl and binary ReadVecDbl.
bool daReadStringFromLine(std::string &a_line, std::string &a_val)
Read a string value from a string. Return the remaining string.
void testReadDoubleFromLine()
Test daReadDoubleFromLine.
void AppendString(const std::string &a_val)
Append a string to the end of a line of text.
bool ReadBinaryBytes(char *a_dest, long long a_destLength)
Read binary bytes of a given length from a file.
static bool ReadIntFromLine(std::string &a_line, int &a_val)
Read an integer value from a string. Return the remaining string.
void Write3DoubleLine(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.
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.
void WriteVecInt(const char *a_name, const VecInt &a_vec)
Write a named vector of integers to several lines.
void 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.
void testReadWriteVecPt3d()
Test daWriteVecPt3d and daReadVecPt3d.
~DaStreamWriter()
Destructor.
DaStreamReader(std::istream &a_inStream, bool a_binaryArrays=false)
Constructor.
bool LineBeginsWith(const char *a_text)
Determines if next line read will begin given text.
void daWriteNamedLine(std::ostream &a_outStream, const char *a_name)
Write a given line to a stream.
void testLineBeginsWith()
Test DaStreamReader::LineBeginsWith.
void WriteVecPt3d(const char *a_name, const VecPt3d &a_points)
Write a named vector of Pt3d to multiple lines.
void AppendInt(int a_val)
Append an integer value to the end of a line of text.
std::ostream & m_outStream
The output stream.
void testReadWriteBinaryVecInt()
Test binary WriteVecInt and binary ReadVecInt.
void testReadWriteLine()
Test WriteLine and ReadLine.
void testReadWriteBinaryVecPt3d()
Test binary WriteVecPt3d and binary ReadVecPt3d.
static bool ReadStringFromLine(std::string &a_line, std::string &a_val)
Read a string value from a string. Return the remaining string.
void testReadWrite3DoubleLine()
Test daWrite3DoubleLine and daRead3DoubleLine.
Impl(std::istream &a_inStream, bool a_binaryArrays)
DaStreamWriter(std::ostream &a_outStream, bool a_binaryArrays=false)
Constructor.
Implementation for DaStreamWriter.
void testReadWrite3DoubleLine()
Test Write3DoubleLine and Read3DoubleLine.
bool ReadVecPt3d(const char *a_name, VecPt3d &a_vec)
Read named vector of Pt3d from multiple lines.
bool WriteBinaryBytes(const char *a_source, long long a_sourceLength)
Write binary bytes of a given length to the stream.
void daWriteVecDbl(std::ostream &a_outStream, const char *a_name, const VecDbl &a_vec)
Write a named vector of doubles to multiple lines.
void testReadStringFromLine()
Test daReadStringFromLine.
Functions and macros for assertion and checking for errors.
Routines for creating and writing to logs and stacking errors.
void testReadWriteVecDbl()
Test WriteVecDbl and ReadVecDbl.
Impl(std::ostream &a_outStream, bool a_binaryArrays)
void testReadWriteVecInt()
Test daWriteVecInt and daReadVecInt.
void testReadDoubleFromLine()
Test ReadDoubleFromLine.
bool 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.
bool NextLine()
Go to the next line in the stream.
bool daReadDoubleFromLine(std::string &a_line, double &a_val)
Read a double value from a string. Return the remaining string.
void WriteVecDbl(const char *a_name, const VecDbl &a_vec)
Write a named vector of doubles to multiple lines.
Class for writing ASCII files with named card fields. Also includes the ability to embed non-portable...
bool daReadVecPt3d(std::istream &a_inStream, const char *a_name, VecPt3d &a_vec)
Read named vector of Pt3d from multiple lines.
bool Read2StringLine(const char *a_name, std::string &a_val1, std::string &a_val2)
Read a named pair of words from a line.
Critical error message for the user.
void testReadWriteStringLine()
Test WriteStringLine and ReadStringLine.
~DaStreamReader()
Destructor.
void testReadWrite3StringLine()
Test Write3StringLine and Read3StringLine.
void 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.
bool daReadIntFromLine(std::string &a_line, int &a_val)
Read an integer value from a string. Return the remaining string.
std::vector< Pt3d > VecPt3d
short rename