47 #include <sys/types.h> 58 #include <unordered_map> 59 #include <unordered_set> 100 static std::ostream &
Write(std::ostream & os,
char c);
114 static std::ostream &
Write(std::ostream & os, uint8_t c);
128 static std::ostream &
Write(std::ostream & os,
bool b);
143 static std::ostream &
Write(std::ostream & os, int16_t val);
158 static std::ostream &
Write(std::ostream & os, uint16_t val);
173 static std::ostream &
Write(std::ostream & os, int32_t val);
188 static std::ostream &
Write(std::ostream & os, uint32_t val);
203 static std::ostream &
Write(std::ostream & os,
const int64_t & val);
218 static std::ostream &
Write(std::ostream & os,
const uint64_t & val);
233 static std::ostream &
Write(std::ostream & os,
float val);
248 static std::ostream &
Write(std::ostream & os,
const double & val);
256 return(
sizeof(uint32_t) + s.size());
266 static std::ostream &
Write(std::ostream & os,
const std::string & s);
271 static std::istream &
Read(std::istream & is,
char & c);
276 static std::istream &
Read(std::istream & is, uint8_t & c);
281 static std::istream &
Read(std::istream & is,
bool & b);
287 static std::istream &
Read(std::istream & is, int16_t & val);
293 static std::istream &
Read(std::istream & is, uint16_t & val);
299 static std::istream &
Read(std::istream & is, int32_t & val);
305 static std::istream &
Read(std::istream & is, uint32_t & val);
311 static std::istream &
Read(std::istream & is, int64_t & val);
317 static std::istream &
Read(std::istream & is, uint64_t & val);
323 static std::istream &
Read(std::istream & is,
float & val);
329 static std::istream &
Read(std::istream & is,
double & val);
336 static std::istream &
Read(std::istream & is, std::string & s);
342 static ssize_t
Write(
int fd,
char c);
348 static ssize_t
Write(
int fd, uint8_t c);
354 static ssize_t
Write(
int fd,
bool b);
361 static ssize_t
Write(
int fd, int16_t val);
368 static ssize_t
Write(
int fd, uint16_t val);
375 static ssize_t
Write(
int fd, int32_t val);
382 static ssize_t
Write(
int fd, uint32_t val);
389 static ssize_t
Write(
int fd,
const int64_t & val);
396 static ssize_t
Write(
int fd,
const uint64_t & val);
403 static ssize_t
Write(
int fd,
float val);
410 static ssize_t
Write(
int fd,
const double & val);
419 static ssize_t
Write(
int fd,
const std::string & s);
425 static ssize_t
Read(
int fd,
char & c);
431 static ssize_t
Read(
int fd, uint8_t & c);
437 static ssize_t
Read(
int fd,
bool & b);
443 static ssize_t
Read(
int fd, int16_t & val);
449 static ssize_t
Read(
int fd, uint16_t & val);
455 static ssize_t
Read(
int fd, int32_t & val);
461 static ssize_t
Read(
int fd, uint32_t & val);
467 static ssize_t
Read(
int fd, int64_t & val);
473 static ssize_t
Read(
int fd, uint64_t & val);
480 static ssize_t
Read(
int fd,
float & val);
487 static ssize_t
Read(
int fd,
double & val);
495 static ssize_t
Read(
int fd, std::string & s);
501 static size_t Write(FILE * f,
char c);
507 static size_t Write(FILE * f, uint8_t c);
513 static size_t Write(FILE * f,
bool b);
519 static size_t Write(FILE * f, int16_t val);
525 static size_t Write(FILE * f, uint16_t val);
531 static size_t Write(FILE * f, int32_t val);
537 static size_t Write(FILE * f, uint32_t val);
543 static size_t Write(FILE * f,
const int64_t & val);
549 static size_t Write(FILE * f,
const uint64_t & val);
556 static size_t Write(FILE * f,
float val);
563 static size_t Write(FILE * f,
const double & val);
571 static size_t Write(FILE * f,
const std::string & s);
577 static size_t Read(FILE * f,
char & c);
583 static size_t Read(FILE * f, uint8_t & c);
589 static size_t Read(FILE * f,
bool & b);
595 static size_t Read(FILE * f, int16_t & val);
601 static size_t Read(FILE * f, uint16_t & val);
607 static size_t Read(FILE * f, int32_t & val);
613 static size_t Read(FILE * f, uint32_t & val);
619 static size_t Read(FILE * f, int64_t & val);
625 static size_t Read(FILE * f, uint64_t & val);
632 static size_t Read(FILE * f,
float & val);
639 static size_t Read(FILE * f,
double & val);
646 static size_t Read(FILE * f, std::string & s);
662 return(val.
Write(os));
670 return(val.
Write(fd));
678 return(val.
Write(f));
686 return(val.
Read(is));
694 return(val.
Read(fd));
709 template <
typename _firstT,
typename _secondT>
718 template <
typename _firstT,
typename _secondT>
719 static std::istream &
Read(std::istream & is,
720 std::pair<_firstT, _secondT> & p)
723 if (
Read(is, p.first))
732 template <
typename _firstT,
typename _secondT>
733 static std::ostream &
Write(std::ostream & os,
734 const std::pair<_firstT,_secondT> & p)
737 if (
Write(os, p.first)) {
748 template <
typename _firstT,
typename _secondT>
749 static size_t Read(FILE *f, std::pair<_firstT,_secondT> & p)
753 if (
Read(f, p.first) > 0)
754 if (
Read(f, p.second) > 0)
763 template <
typename _firstT,
typename _secondT>
764 static size_t Write(FILE *f,
const std::pair<_firstT,_secondT> & p)
768 if (
Write(f, p.first) > 0)
769 if (
Write(f, p.second) > 0)
778 template <
typename _firstT,
typename _secondT>
779 static ssize_t
Read(
int fd, std::pair<_firstT, _secondT> & p)
783 ssize_t bytesRead =
Read(fd, p.first);
786 bytesRead =
Read(fd, p.second);
800 template <
typename _firstT,
typename _secondT>
801 static ssize_t
Write(
int fd,
const std::pair<_firstT,_secondT> & p)
805 ssize_t bytesWritten =
Write(fd, p.first);
806 if (bytesWritten > 0) {
808 bytesWritten =
Write(fd, p.second);
809 if (bytesWritten > 0) {
824 template <
typename _keyT,
typename _valueT,
825 typename _Compare,
typename _Alloc>
829 return(ContainerStreamedLength<std::map<_keyT, _valueT, _Compare, _Alloc> >(m));
835 template <
typename _keyT,
typename _valueT,
836 typename _Compare,
typename _Alloc>
837 static std::istream &
Read(std::istream & is,
838 std::map<_keyT, _valueT, _Compare, _Alloc> & m)
840 return(PairAssocContRead<std::map<_keyT, _valueT, _Compare, _Alloc> >(is, m));
846 template <
typename _keyT,
typename _valueT,
847 typename _Compare,
typename _Alloc>
848 static std::ostream &
Write(std::ostream & os,
849 const std::map<_keyT,_valueT, _Compare, _Alloc> & m)
851 return(ContainerWrite<std::map<_keyT,_valueT,_Compare,_Alloc> >(os, m));
858 template <
typename _keyT,
typename _valueT,
859 typename _Compare,
typename _Alloc>
860 static size_t Read(FILE *f, std::map<_keyT, _valueT, _Compare, _Alloc> & m)
862 return(PairAssocContRead<std::map<_keyT, _valueT, _Compare, _Alloc> >(f, m));
869 template <
typename _keyT,
typename _valueT,
870 typename _Compare,
typename _Alloc>
872 Write(FILE *f,
const std::map<_keyT, _valueT, _Compare, _Alloc> & m)
874 return(ContainerWrite<std::map<_keyT,_valueT> >(f, m));
881 template <
typename _keyT,
typename _valueT,
882 typename _Compare,
typename _Alloc>
883 static ssize_t
Read(
int fd, std::map<_keyT, _valueT, _Compare, _Alloc> & m)
885 return(PairAssocContRead<std::map<_keyT, _valueT, _Compare, _Alloc> >(fd, m));
892 template<
typename _keyT,
typename _valueT,
893 typename _Compare,
typename _Alloc>
895 Write(
int fd,
const std::map<_keyT,_valueT,_Compare,_Alloc> & m)
897 return(ContainerWrite<std::map<_keyT,_valueT,_Compare,_Alloc> >(fd, m));
904 template <
typename _keyT,
typename _valueT,
905 typename _Compare,
typename _Alloc>
909 return(ContainerStreamedLength<std::multimap<_keyT,_valueT,_Compare,_Alloc> >(m));
916 template <
typename _keyT,
typename _valueT,
917 typename _Compare,
typename _Alloc>
918 static std::istream &
919 Read(std::istream & is, std::multimap<_keyT,_valueT,_Compare,_Alloc> & m)
921 return(PairAssocContRead<std::multimap<_keyT,_valueT,_Compare,_Alloc> >(is, m));
927 template <
typename _keyT,
typename _valueT,
928 typename _Compare,
typename _Alloc>
929 static std::ostream &
931 const std::multimap<_keyT,_valueT, _Compare, _Alloc> & m)
933 return(ContainerWrite<std::multimap<_keyT,_valueT,_Compare,_Alloc> >(os, m));
940 template <
typename _keyT,
typename _valueT,
941 typename _Compare,
typename _Alloc>
943 Read(FILE *f, std::multimap<_keyT, _valueT, _Compare, _Alloc> & m)
945 return(PairAssocContRead<std::multimap<_keyT,_valueT,_Compare,_Alloc> >(f, m));
952 template <
typename _keyT,
typename _valueT,
953 typename _Compare,
typename _Alloc>
955 Write(FILE *f,
const std::multimap<_keyT,_valueT, _Compare, _Alloc> & m)
957 return(ContainerWrite<std::multimap<_keyT,_valueT,_Compare,_Alloc> >(f, m));
964 template <
typename _keyT,
typename _valueT,
965 typename _Compare,
typename _Alloc>
967 Read(
int fd, std::multimap<_keyT, _valueT, _Compare, _Alloc> & m)
969 return(PairAssocContRead<std::multimap<_keyT,_valueT,_Compare,_Alloc> >(fd, m));
976 template <
typename _keyT,
typename _valueT,
977 typename _Compare,
typename _Alloc>
979 Write(
int fd,
const std::multimap<_keyT,_valueT, _Compare, _Alloc> & m)
981 return(ContainerWrite<std::multimap<_keyT,_valueT,_Compare,_Alloc> >(fd, m));
988 template <
typename _valueT,
typename _Alloc>
991 return(ContainerStreamedLength<std::vector<_valueT, _Alloc> >(v));
997 template <
typename _valueT,
typename _Alloc>
998 static std::istream &
Read(std::istream & is,
999 std::vector<_valueT, _Alloc> & v)
1001 return(ContainerRead<std::vector<_valueT, _Alloc> >(is, v));
1007 template <
typename _valueT,
typename _Alloc>
1008 static std::ostream &
Write(std::ostream & os,
1009 const std::vector<_valueT, _Alloc> & v)
1011 return(ContainerWrite<std::vector<_valueT, _Alloc> >(os, v));
1018 template <
typename _valueT,
typename _Alloc>
1019 static size_t Read(FILE *f, std::vector<_valueT, _Alloc> & v)
1021 return(ContainerRead<std::vector<_valueT, _Alloc> >(f, v));
1028 template <
typename _valueT,
typename _Alloc>
1029 static size_t Write(FILE *f,
const std::vector<_valueT, _Alloc> & v)
1031 return(ContainerWrite<std::vector<_valueT, _Alloc> >(f, v));
1038 template <
typename _valueT,
typename _Alloc>
1039 static ssize_t
Read(
int fd, std::vector<_valueT, _Alloc> & v)
1041 return(ContainerRead<std::vector<_valueT, _Alloc> >(fd, v));
1048 template <
typename _valueT,
typename _Alloc>
1049 static ssize_t
Write(
int fd,
const std::vector<_valueT, _Alloc> & v)
1051 return(ContainerWrite<std::vector<_valueT, _Alloc> >(fd, v));
1058 template <
typename _valueT,
typename _Alloc>
1061 return(ContainerStreamedLength<std::deque<_valueT, _Alloc> >(d));
1067 template <
typename _valueT,
typename _Alloc>
1068 static std::istream &
Read(std::istream & is,
1069 std::deque<_valueT, _Alloc> & d)
1071 return(ContainerRead<std::deque<_valueT, _Alloc> >(is, d));
1077 template <
typename _valueT,
typename _Alloc>
1078 static std::ostream &
Write(std::ostream & os,
1079 const std::deque<_valueT, _Alloc> & d)
1081 return(ContainerWrite<std::deque<_valueT, _Alloc> >(os, d));
1088 template <
typename _valueT,
typename _Alloc>
1089 static size_t Read(FILE *f, std::deque<_valueT, _Alloc> & d)
1091 return(ContainerRead<std::deque<_valueT, _Alloc> >(f, d));
1098 template <
typename _valueT,
typename _Alloc>
1099 static size_t Write(FILE *f,
const std::deque<_valueT, _Alloc> & d)
1101 return(ContainerWrite<std::deque<_valueT, _Alloc> >(f, d));
1108 template <
typename _valueT,
typename _Alloc>
1109 static ssize_t
Read(
int fd, std::deque<_valueT, _Alloc> & d)
1111 return(ContainerRead<std::deque<_valueT, _Alloc> >(fd, d));
1118 template <
typename _valueT,
typename _Alloc>
1119 static ssize_t
Write(
int fd,
const std::deque<_valueT, _Alloc> & d)
1121 return(ContainerWrite<std::deque<_valueT, _Alloc> >(fd, d));
1128 template <
typename _valueT,
typename _Alloc>
1131 return(ContainerStreamedLength<std::list<_valueT, _Alloc> >(l));
1137 template <
typename _valueT,
typename _Alloc>
1138 static std::istream &
Read(std::istream & is,
1139 std::list<_valueT, _Alloc> & l)
1141 return(ContainerRead<std::list<_valueT, _Alloc> >(is, l));
1147 template <
typename _valueT,
typename _Alloc>
1148 static std::ostream &
Write(std::ostream & os,
1149 const std::list<_valueT, _Alloc> & l)
1151 return(ContainerWrite<std::list<_valueT, _Alloc> >(os, l));
1158 template <
typename _valueT,
typename _Alloc>
1159 static size_t Read(FILE *f, std::list<_valueT, _Alloc> & l)
1161 return(ContainerRead<std::list<_valueT, _Alloc> >(f, l));
1168 template <
typename _valueT,
typename _Alloc>
1169 static size_t Write(FILE *f,
const std::list<_valueT, _Alloc> & l)
1171 return(ContainerWrite<std::list<_valueT, _Alloc> >(f, l));
1178 template <
typename _valueT,
typename _Alloc>
1179 static ssize_t
Read(
int fd, std::list<_valueT, _Alloc> & l)
1181 return(ContainerRead<std::list<_valueT, _Alloc> >(fd, l));
1188 template <
typename _valueT,
typename _Alloc>
1189 static ssize_t
Write(
int fd,
const std::list<_valueT, _Alloc> & l)
1191 return(ContainerWrite<std::list<_valueT, _Alloc> >(fd, l));
1198 template <
typename _valueT,
typename _Compare,
typename _Alloc>
1202 return(ContainerStreamedLength<std::set<_valueT, _Compare, _Alloc> >(l));
1208 template <
typename _valueT,
typename _Compare,
typename _Alloc>
1209 static std::istream &
Read(std::istream & is,
1210 std::set<_valueT, _Compare, _Alloc> & l)
1212 return(ContainerRead<std::set<_valueT, _Compare, _Alloc> >(is, l));
1218 template <
typename _valueT,
typename _Compare,
typename _Alloc>
1219 static std::ostream &
Write(std::ostream & os,
1220 const std::set<_valueT, _Compare, _Alloc> & l)
1222 return(ContainerWrite<std::set<_valueT, _Compare, _Alloc> >(os, l));
1229 template <
typename _valueT,
typename _Compare,
typename _Alloc>
1230 static size_t Read(FILE *f, std::set<_valueT, _Compare, _Alloc> & l)
1232 return(ContainerRead<std::set<_valueT, _Compare, _Alloc> >(f, l));
1239 template <
typename _valueT,
typename _Compare,
typename _Alloc>
1240 static size_t Write(FILE *f,
const std::set<_valueT, _Compare, _Alloc> & l)
1242 return(ContainerWrite<std::set<_valueT, _Compare, _Alloc> >(f, l));
1249 template <
typename _valueT,
typename _Compare,
typename _Alloc>
1250 static ssize_t
Read(
int fd, std::set<_valueT, _Compare, _Alloc> & l)
1252 return(ContainerRead<std::set<_valueT, _Compare, _Alloc> >(fd, l));
1259 template <
typename _valueT,
typename _Compare,
typename _Alloc>
1260 static ssize_t
Write(
int fd,
const std::set<_valueT, _Compare, _Alloc> & l)
1262 return(ContainerWrite<std::set<_valueT, _Compare, _Alloc> >(fd, l));
1269 template <
typename _valueT,
typename _Compare,
typename _Alloc>
1273 return(ContainerStreamedLength<std::multiset<_valueT, _Compare, _Alloc> >(l));
1279 template <
typename _valueT,
typename _Compare,
typename _Alloc>
1280 static std::istream &
Read(std::istream & is,
1281 std::multiset<_valueT, _Compare, _Alloc> & l)
1283 return(ContainerRead<std::multiset<_valueT, _Compare, _Alloc> >(is, l));
1289 template <
typename _valueT,
typename _Compare,
typename _Alloc>
1290 static std::ostream &
1292 const std::multiset<_valueT, _Compare, _Alloc> & l)
1294 return(ContainerWrite<std::multiset<_valueT, _Compare, _Alloc> >(os, l));
1301 template <
typename _valueT,
typename _Compare,
typename _Alloc>
1302 static size_t Read(FILE *f, std::multiset<_valueT, _Compare, _Alloc> & l)
1304 return(ContainerRead<std::multiset<_valueT, _Compare, _Alloc> >(f, l));
1311 template <
typename _valueT,
typename _Compare,
typename _Alloc>
1313 Write(FILE *f,
const std::multiset<_valueT, _Compare, _Alloc> & l)
1315 return(ContainerWrite<std::multiset<_valueT, _Compare, _Alloc> >(f, l));
1322 template <
typename _valueT,
typename _Compare,
typename _Alloc>
1323 static ssize_t
Read(
int fd, std::multiset<_valueT, _Compare, _Alloc> & l)
1325 return(ContainerRead<std::multiset<_valueT, _Compare, _Alloc> >(fd, l));
1332 template <
typename _valueT,
typename _Compare,
typename _Alloc>
1334 Write(
int fd,
const std::multiset<_valueT, _Compare, _Alloc> & l)
1336 return(ContainerWrite<std::multiset<_valueT, _Compare, _Alloc> >(fd, l));
1342 template <
typename T,
typename... Args>
1343 static uint32_t VarStreamedLength(
const T & t, Args... args)
1346 if (
sizeof...(Args) > 0)
1347 rc += VarStreamedLength(args...);
1354 template <
typename T,
typename... Args>
1355 static std::ostream & VarWrite(std::ostream & os,
1356 const T & t, Args... args)
1359 if (
sizeof...(Args) > 0)
1367 template <
typename T,
typename... Args>
1368 static std::istream & VarRead(std::istream & is,
1369 const T & t, Args... args)
1372 if (
sizeof...(Args) > 0)
1381 template <
typename T,
typename... Args>
1390 template <
typename T,
typename... Args>
1391 static std::istream &
Read(std::istream & is,
1392 std::tuple<T, Args...> & t)
1394 return(
ReadTuple<std::tuple<T, Args...> >(is, t));
1400 template <
typename T,
typename... Args>
1401 static std::ostream &
Write(std::ostream & os,
1402 const std::tuple<T, Args...> & t)
1404 return(
WriteTuple<std::tuple<T, Args...> >(os, t));
1411 template <
typename T,
typename... Args>
1412 static ssize_t
Read(
int fd, std::tuple<T, Args...> & t)
1414 return(
ReadTuple<std::tuple<T, Args...> >(fd, t));
1421 template <
typename T,
typename... Args>
1422 static ssize_t
Write(
int fd,
const std::tuple<T, Args...> & t)
1424 return(
WriteTuple<std::tuple<T, Args...> >(fd, t));
1430 template <
typename T,
typename... Args>
1431 static size_t Read(FILE *f, std::tuple<T, Args...> & t)
1433 return(
ReadTuple<std::tuple<T, Args...> >(f, t));
1439 template <
typename T,
typename... Args>
1440 static size_t Write(FILE *f,
const std::tuple<T, Args...> & t)
1442 return(
WriteTuple<std::tuple<T, Args...> >(f, t));
1448 template <
typename T>
1451 return(TupleIOHelper<T,std::tuple_size<T>::value-1>::
Read(is, t));
1457 template <
typename T>
1460 return(TupleIOHelper<T,std::tuple_size<T>::value-1>::
Write(os, t));
1466 template <
typename T>
1469 return(TupleIOHelper<T,std::tuple_size<T>::value-1>::
Read(fd, t));
1475 template <
typename T>
1478 return(TupleIOHelper<T,std::tuple_size<T>::value-1>::
Write(fd, t));
1484 template <
typename T>
1487 if (TupleIOHelper<T,std::tuple_size<T>::value-1>::
Read(f, t) > 0)
1495 template <
typename T>
1498 if (TupleIOHelper<T,std::tuple_size<T>::value-1>::
Write(f, t) > 0)
1506 template <
typename T>
1509 return(TupleIOHelper<T,std::tuple_size<T>::value-1>::
StreamedLength(t));
1516 template <
typename _inputIteratorT>
1517 static uint32_t
StreamedLength(_inputIteratorT f, _inputIteratorT l)
1520 for ( ; f != l; ++f)
1528 template <
typename _inputIteratorT>
1529 static std::ostream &
Write(std::ostream & os,
1530 _inputIteratorT f, _inputIteratorT l)
1533 for ( ; f != l; ++f) {
1534 if (!
Write(os, *f)) {
1545 template <
typename _inputIteratorT>
1546 static size_t Write(FILE *file, _inputIteratorT f, _inputIteratorT l)
1550 for ( ; f != l; ++f) {
1551 if (
Write(file, *f) <= 0) {
1564 template <
typename _inputIteratorT>
1565 static ssize_t
Write(
int fd, _inputIteratorT f, _inputIteratorT l)
1569 for ( ; f != l; ++f) {
1570 ssize_t bytesWritten =
Write(fd, *f);
1571 if (bytesWritten > 0) {
1586 template <
typename _containerT>
1587 static uint32_t ContainerStreamedLength(
const _containerT & c)
1589 uint32_t rc =
sizeof(uint32_t);
1591 rc += StreamedLength<typename _containerT::const_iterator>(c.begin(),
1600 template <
typename _containerT>
1601 static std::istream & ContainerRead(std::istream & is,
1607 uint32_t numEntries;
1608 if (
Read(is, numEntries)) {
1609 for (uint32_t i = 0; i < numEntries; ++i) {
1610 typename _containerT::value_type val;
1611 if (!
Read(is, val))
1613 c.insert(c.end(), val);
1624 template <
typename _containerT>
1625 static std::ostream & ContainerWrite(std::ostream & os,
1626 const _containerT & c)
1629 uint32_t numEntries = c.size();
1630 if (
Write(os, numEntries)) {
1632 Write<typename _containerT::const_iterator>(os,
1646 template <
typename _containerT>
1647 static size_t ContainerRead(FILE *f, _containerT & c)
1653 uint32_t numEntries;
1654 if (
Read(f, numEntries)) {
1656 for ( ; i < numEntries; ++i) {
1657 typename _containerT::value_type val;
1658 if (
Read(f, val) > 0)
1659 c.insert(c.end(), val);
1663 if (i == numEntries)
1675 template <
typename _containerT>
1676 static size_t ContainerWrite(FILE *f,
const _containerT & c)
1680 uint32_t numEntries = c.size();
1681 if (
Write(f, numEntries)) {
1683 rc = Write<typename _containerT::const_iterator>(f,
1684 c.begin(), c.end());
1699 template <
typename _containerT>
1700 static ssize_t ContainerRead(
int fd, _containerT & c)
1706 uint32_t numEntries;
1707 ssize_t bytesRead =
Read(fd, numEntries);
1708 if (bytesRead ==
sizeof(numEntries)) {
1710 for (uint32_t i = 0; i < numEntries; ++i) {
1711 typename _containerT::value_type val;
1712 bytesRead =
Read(fd, val);
1713 if (bytesRead > 0) {
1715 c.insert(c.end(), val);
1732 template <
typename _containerT>
1733 static ssize_t ContainerWrite(
int fd,
const _containerT & c)
1737 uint32_t numEntries = c.size();
1738 uint32_t bytesWritten =
Write(fd, numEntries);
1739 if (bytesWritten ==
sizeof(numEntries)) {
1743 Write<typename _containerT::const_iterator>(fd,
1746 if (bytesWritten > 0)
1762 template <
typename _containerT>
1763 static std::istream &
1764 PairAssocContRead(std::istream & is, _containerT & m)
1769 uint32_t numEntries;
1770 if (
Read(is, numEntries)) {
1771 for (uint32_t i = 0; i < numEntries; ++i) {
1772 typename _containerT::key_type key;
1773 if (
Read(is, key)) {
1774 typename _containerT::mapped_type val;
1776 m.insert(
typename _containerT::value_type(key, val));
1793 template <
typename _containerT>
1794 static size_t PairAssocContRead(FILE *f, _containerT & m)
1800 uint32_t numEntries;
1801 if (
Read(f, numEntries)) {
1803 for ( ; i < numEntries; ++i) {
1804 typename _containerT::key_type key;
1805 if (
Read(f, key) > 0) {
1806 typename _containerT::mapped_type val;
1807 if (
Read(f, val) > 0) {
1808 m.insert(
typename _containerT::value_type(key, val));
1818 if (i == numEntries)
1830 template <
typename _containerT>
1831 static ssize_t PairAssocContRead(
int fd, _containerT & m)
1837 uint32_t numEntries;
1838 ssize_t bytesRead =
Read(fd, numEntries);
1839 if (bytesRead ==
sizeof(numEntries)) {
1841 for (uint32_t i = 0; i < numEntries; ++i) {
1842 typename _containerT::key_type key;
1843 bytesRead =
Read(fd, key);
1844 if (bytesRead > 0) {
1846 typename _containerT::mapped_type val;
1847 bytesRead =
Read(fd, val);
1848 if (bytesRead > 0) {
1850 m.insert(
typename _containerT::value_type(key, val));
1871 template <
typename T,
size_t elt>
1872 class TupleIOHelper;
1877 template <
typename T>
1878 class TupleIOHelper<T, 0>
1884 static std::istream &
Read(std::istream & is, T & t)
1886 return(
IO::Read(is, std::get<0>(t)));
1892 static std::ostream &
Write(std::ostream & os,
const T & t)
1901 static ssize_t
Read(
int fd, T & t)
1903 return(
IO::Read(fd, std::get<0>(t)));
1910 static ssize_t
Write(
int fd,
const T & t)
1919 static size_t Read(FILE *f, T & t)
1921 return(
IO::Read(f, std::get<0>(t)));
1928 static size_t Write(FILE *f,
const T & t)
1946 template <
typename T,
size_t elt>
1953 static std::istream &
Read(std::istream & is, T & t)
1955 if (TupleIOHelper<T,elt-1>::Read(is, t))
1963 static std::ostream &
Write(std::ostream & os,
const T & t)
1965 if (TupleIOHelper<T,elt-1>::Write(os, t))
1973 static ssize_t
Read(
int fd, T & t)
1975 ssize_t rc = TupleIOHelper<T,elt-1>::Read(fd, t);
1976 rc +=
IO::Read(fd, std::get<elt>(t));
1983 static ssize_t
Write(
int fd,
const T & t)
1985 ssize_t rc = TupleIOHelper<T,elt-1>::Write(fd, t);
1993 static size_t Read(FILE *f, T & t)
1995 size_t rc = TupleIOHelper<T,elt-1>::Read(f, t);
1997 rc =
IO::Read(f, std::get<elt>(t));
2004 static size_t Write(FILE *f,
const T & t)
2006 size_t rc = TupleIOHelper<T,elt-1>::Write(f, t);
2020 uint32_t rc = TupleIOHelper<T,elt-1>::StreamedLength(t);
2031 template <
typename _keyT,
typename _valueT,
2032 typename _Hash,
typename _Pred,
typename _Alloc>
2034 StreamedLength(
const std::unordered_map<_keyT, _valueT, _Hash, _Pred, _Alloc> & m)
2036 return(ContainerStreamedLength<std::unordered_map<_keyT, _valueT, _Hash, _Pred, _Alloc> >(m));
2043 template <
typename _keyT,
typename _valueT,
2044 typename _Hash,
typename _Pred,
typename _Alloc>
2045 static std::istream &
2047 std::unordered_map<_keyT, _valueT, _Hash, _Pred, _Alloc> & m)
2049 return(PairAssocContRead<std::unordered_map<_keyT, _valueT, _Hash, _Pred, _Alloc> >(is, m));
2056 template <
typename _keyT,
typename _valueT,
2057 typename _Hash,
typename _Pred,
typename _Alloc>
2058 static std::ostream &
2060 const std::unordered_map<_keyT, _valueT, _Hash, _Pred, _Alloc> & m)
2062 return(ContainerWrite<std::unordered_map<_keyT,_valueT,_Hash,_Pred,_Alloc> >(os, m));
2069 template <
typename _keyT,
typename _valueT,
2070 typename _Hash,
typename _Pred,
typename _Alloc>
2072 Read(
int fd, std::unordered_map<_keyT, _valueT, _Hash, _Pred, _Alloc> & m)
2074 return(PairAssocContRead<std::unordered_map<_keyT, _valueT, _Hash, _Pred, _Alloc> >(fd, m));
2081 template<
typename _keyT,
typename _valueT,
2082 typename _Hash,
typename _Pred,
typename _Alloc>
2085 const std::unordered_map<_keyT,_valueT,_Hash,_Pred,_Alloc> & m)
2087 return(ContainerWrite<std::unordered_map<_keyT,_valueT,_Hash,_Pred,_Alloc> >(fd, m));
2094 template<
typename _keyT,
typename _valueT,
typename _Hash,
2095 typename _Pred,
typename _Alloc>
2097 Read(FILE *f, std::unordered_map<_keyT,_valueT,_Hash,_Pred,_Alloc> & hm)
2099 return(PairAssocContRead<std::unordered_map<_keyT,_valueT,_Hash,_Pred,_Alloc> >(f, hm));
2106 template<
typename _keyT,
typename _valueT,
typename _Hash,
2107 typename _Pred,
typename _Alloc>
2109 Write(FILE *f,
const std::unordered_map<_keyT,_valueT,_Hash,_Pred,_Alloc> & hm)
2111 return(ContainerWrite<std::unordered_map<_keyT,_valueT,_Hash,_Pred,_Alloc> >(f, hm));
2121 template <
typename _keyT,
typename _valueT,
2122 typename _Hash,
typename _Pred,
typename _Alloc>
2124 StreamedLength(
const std::unordered_multimap<_keyT, _valueT, _Hash, _Pred, _Alloc> & m)
2126 return(ContainerStreamedLength<std::unordered_multimap<_keyT, _valueT, _Hash, _Pred, _Alloc> >(m));
2133 template <
typename _keyT,
typename _valueT,
2134 typename _Hash,
typename _Pred,
typename _Alloc>
2135 static std::istream &
Read(std::istream & is,
2136 std::unordered_multimap<_keyT, _valueT, _Hash, _Pred, _Alloc> & m)
2138 return(PairAssocContRead<std::unordered_multimap<_keyT, _valueT, _Hash, _Pred, _Alloc> >(is, m));
2145 template <
typename _keyT,
typename _valueT,
2146 typename _Hash,
typename _Pred,
typename _Alloc>
2147 static std::ostream &
2149 const std::unordered_multimap<_keyT, _valueT, _Hash, _Pred, _Alloc> & m)
2151 return(ContainerWrite<std::unordered_multimap<_keyT,_valueT,_Hash,_Pred,_Alloc> >(os, m));
2158 template <
typename _keyT,
typename _valueT,
2159 typename _Hash,
typename _Pred,
typename _Alloc>
2161 Read(
int fd, std::unordered_multimap<_keyT, _valueT, _Hash, _Pred, _Alloc> & m)
2163 return(PairAssocContRead<std::unordered_multimap<_keyT, _valueT, _Hash, _Pred, _Alloc> >(fd, m));
2170 template<
typename _keyT,
typename _valueT,
2171 typename _Hash,
typename _Pred,
typename _Alloc>
2173 Write(
int fd,
const std::unordered_multimap<_keyT,_valueT,_Hash,_Pred,_Alloc> & m)
2175 return(ContainerWrite<std::unordered_multimap<_keyT,_valueT,_Hash,_Pred,_Alloc> >(fd, m));
2182 template<
typename _keyT,
typename _valueT,
typename _Hash,
2183 typename _Pred,
typename _Alloc>
2185 Read(FILE *f, std::unordered_multimap<_keyT,_valueT,_Hash,_Pred,_Alloc> & hm)
2187 return(PairAssocContRead<std::unordered_multimap<_keyT,_valueT,_Hash,_Pred,_Alloc> >(f, hm));
2194 template<
typename _keyT,
typename _valueT,
typename _Hash,
2195 typename _Pred,
typename _Alloc>
2197 Write(FILE *f,
const std::unordered_multimap<_keyT,_valueT,_Hash,_Pred,_Alloc> & hm)
2199 return(ContainerWrite<std::unordered_multimap<_keyT,_valueT,_Hash,_Pred,_Alloc> >(f, hm));
2209 template <
typename _valueT,
typename _Hash,
2210 typename _Pred,
typename _Alloc>
2212 StreamedLength(
const std::unordered_set<_valueT, _Hash, _Pred, _Alloc> & m)
2214 return(ContainerStreamedLength<std::unordered_set<_valueT, _Hash, _Pred, _Alloc> >(m));
2221 template <
typename _valueT,
typename _Hash,
2222 typename _Pred,
typename _Alloc>
2223 static std::istream &
2225 std::unordered_set<_valueT, _Hash, _Pred, _Alloc> & m)
2227 return(ContainerRead<std::unordered_set<_valueT, _Hash, _Pred, _Alloc> >(is, m));
2234 template <
typename _valueT,
typename _Hash,
2235 typename _Pred,
typename _Alloc>
2236 static std::ostream &
2238 const std::unordered_set<_valueT, _Hash, _Pred, _Alloc> & m)
2240 return(ContainerWrite<std::unordered_set<_valueT,_Hash,_Pred,_Alloc> >(os, m));
2247 template <
typename _valueT,
typename _Hash,
2248 typename _Pred,
typename _Alloc>
2250 Read(
int fd, std::unordered_set<_valueT, _Hash, _Pred, _Alloc> & m)
2252 return(ContainerRead<std::unordered_set<_valueT, _Hash, _Pred, _Alloc> >(fd, m));
2259 template<
typename _valueT,
typename _Hash,
2260 typename _Pred,
typename _Alloc>
2262 Write(
int fd,
const std::unordered_set<_valueT,_Hash,_Pred,_Alloc> & m)
2264 return(ContainerWrite<std::unordered_set<_valueT,_Hash,_Pred,_Alloc> >(fd, m));
2271 template<
typename _valueT,
typename _Hash,
2272 typename _Pred,
typename _Alloc>
2274 Read(FILE *f, std::unordered_set<_valueT,_Hash,_Pred,_Alloc> & hm)
2276 return(ContainerRead<std::unordered_set<_valueT,_Hash,_Pred,_Alloc> >(f, hm));
2283 template<
typename _valueT,
typename _Hash,
2284 typename _Pred,
typename _Alloc>
2286 Write(FILE *f,
const std::unordered_set<_valueT,_Hash,_Pred,_Alloc> & hm)
2288 return(ContainerWrite<std::unordered_set<_valueT,_Hash,_Pred,_Alloc> >(f, hm));
2298 template <
typename _valueT,
typename _Hash,
2299 typename _Pred,
typename _Alloc>
2301 StreamedLength(
const std::unordered_multiset<_valueT, _Hash, _Pred, _Alloc> & m)
2303 return(ContainerStreamedLength<std::unordered_multiset<_valueT, _Hash, _Pred, _Alloc> >(m));
2310 template <
typename _valueT,
typename _Hash,
2311 typename _Pred,
typename _Alloc>
2312 static std::istream &
2314 std::unordered_multiset<_valueT, _Hash, _Pred, _Alloc> & m)
2316 return(ContainerRead<std::unordered_multiset<_valueT, _Hash, _Pred, _Alloc> >(is, m));
2323 template <
typename _valueT,
typename _Hash,
2324 typename _Pred,
typename _Alloc>
2325 static std::ostream &
2327 const std::unordered_multiset<_valueT, _Hash, _Pred, _Alloc> & m)
2329 return(ContainerWrite<std::unordered_multiset<_valueT,_Hash,_Pred,_Alloc> >(os, m));
2336 template <
typename _valueT,
typename _Hash,
2337 typename _Pred,
typename _Alloc>
2339 Read(
int fd, std::unordered_multiset<_valueT, _Hash, _Pred, _Alloc> & m)
2341 return(ContainerRead<std::unordered_multiset<_valueT, _Hash, _Pred, _Alloc> >(fd, m));
2348 template<
typename _valueT,
typename _Hash,
2349 typename _Pred,
typename _Alloc>
2351 Write(
int fd,
const std::unordered_multiset<_valueT,_Hash,_Pred,_Alloc> & m)
2353 return(ContainerWrite<std::unordered_multiset<_valueT,_Hash,_Pred,_Alloc> >(fd, m));
2360 template<
typename _valueT,
typename _Hash,
2361 typename _Pred,
typename _Alloc>
2363 Read(FILE *f, std::unordered_multiset<_valueT,_Hash,_Pred,_Alloc> & hm)
2365 return(ContainerRead<std::unordered_multiset<_valueT,_Hash,_Pred,_Alloc> >(f, hm));
2372 template<
typename _valueT,
typename _Hash,
2373 typename _Pred,
typename _Alloc>
2375 Write(FILE *f,
const std::unordered_multiset<_valueT,_Hash,_Pred,_Alloc> & hm)
2377 return(ContainerWrite<std::unordered_multiset<_valueT,_Hash,_Pred,_Alloc> >(f, hm));
2385 #endif // _DWMIO_HH_ static size_t Write(FILE *f, const std::list< _valueT, _Alloc > &l)
Writes a list<_valueT> to a FILE pointer.
Definition: DwmIO.hh:1169
static size_t Read(FILE *f, std::set< _valueT, _Compare, _Alloc > &l)
Reads a set<_valueT> from a FILE pointer.
Definition: DwmIO.hh:1230
static ssize_t ReadTuple(int fd, T &t)
T must be a tuple.
Definition: DwmIO.hh:1467
static ssize_t Write(int fd, const std::set< _valueT, _Compare, _Alloc > &l)
Writes a set<_valueT> to a file descriptor.
Definition: DwmIO.hh:1260
static uint32_t StreamedLength(const std::string &s)
Returns the number of bytes that should be written if we call one of the Write() members for a string...
Definition: DwmIO.hh:254
static uint32_t StreamedLength(bool b)
Returns the number of bytes that would be written if we called one of the Write() members for a bool...
Definition: DwmIO.hh:120
static std::istream & Read(std::istream &is, std::set< _valueT, _Compare, _Alloc > &l)
Reads a set<_valueT> from an istream. Returns the istream.
Definition: DwmIO.hh:1209
static size_t Write(FILE *f, const std::pair< _firstT, _secondT > &p)
Writes a pair<_firstT,_secondT> to a FILE pointer.
Definition: DwmIO.hh:764
static std::istream & Read(std::istream &is, std::map< _keyT, _valueT, _Compare, _Alloc > &m)
Reads a map<_keyT,_valueT> from an istream. Returns the istream.
Definition: DwmIO.hh:837
static ssize_t Read(int fd, std::tuple< T, Args... > &t)
Reads a tuple from a file descriptor.
Definition: DwmIO.hh:1412
Dwm::Writable pure virtual class definition.
static std::ostream & Write(std::ostream &os, const std::multimap< _keyT, _valueT, _Compare, _Alloc > &m)
Writes a multimap<_keyT,_valueT> to an ostream. Returns the ostream.
Definition: DwmIO.hh:930
static ssize_t Read(int fd, std::list< _valueT, _Alloc > &l)
Reads a list<_valueT> from a file descriptor.
Definition: DwmIO.hh:1179
static std::istream & Read(std::istream &is, std::vector< _valueT, _Alloc > &v)
Reads a vector<_valueT> from an istream. Returns the istream.
Definition: DwmIO.hh:998
static size_t WriteTuple(FILE *f, const T &t)
T must be a tuple.
Definition: DwmIO.hh:1496
static size_t Write(FILE *f, const std::deque< _valueT, _Alloc > &d)
Writes a deque<_valueT> to a FILE pointer.
Definition: DwmIO.hh:1099
virtual std::istream & Read(std::istream &is)=0
Read from an istream. Return the istream.
static ssize_t Write(int fd, const std::map< _keyT, _valueT, _Compare, _Alloc > &m)
Writes a map<_keyT,_valueT> to a file descriptor.
Definition: DwmIO.hh:895
Dwm::Readable pure virtual class definition.
static ssize_t Read(int fd, std::unordered_set< _valueT, _Hash, _Pred, _Alloc > &m)
Reads an unordered_set<_valueT> from a file descriptor.
Definition: DwmIO.hh:2250
static size_t Write(FILE *f, const Writable &val)
Wrapper function to write a Writable object to a FILE pointer.
Definition: DwmIO.hh:676
static std::ostream & Write(std::ostream &os, const std::unordered_multimap< _keyT, _valueT, _Hash, _Pred, _Alloc > &m)
Writes a unordered_multimap<_keyT,_valueT> to an ostream.
Definition: DwmIO.hh:2148
virtual std::ostream & Write(std::ostream &os) const =0
Write to an ostream. Return the ostream.
static std::istream & Read(std::istream &is, std::unordered_map< _keyT, _valueT, _Hash, _Pred, _Alloc > &m)
Reads an unordered_map<_keyT,_valueT> from an istream.
Definition: DwmIO.hh:2046
static std::istream & Read(std::istream &is, std::unordered_set< _valueT, _Hash, _Pred, _Alloc > &m)
Reads an unordered_set<_valueT> from an istream.
Definition: DwmIO.hh:2224
static std::istream & Read(std::istream &is, std::pair< _firstT, _secondT > &p)
Reads a pair<_firstT,_secondT> from an istream. Returns the istream.
Definition: DwmIO.hh:719
static ssize_t Write(int fd, const std::list< _valueT, _Alloc > &l)
Writes a list<_valueT> to a file descriptor.
Definition: DwmIO.hh:1189
static size_t Read(FILE *f, std::unordered_multiset< _valueT, _Hash, _Pred, _Alloc > &hm)
Reads an unordered_multiset from a FILE pointer.
Definition: DwmIO.hh:2363
static size_t Read(FILE *f, std::tuple< T, Args... > &t)
Reads a tuple from a FILE. Returns 1 on success, 0 on failure.
Definition: DwmIO.hh:1431
static ssize_t Write(int fd, const std::multimap< _keyT, _valueT, _Compare, _Alloc > &m)
Writes a multimap<_keyT,_valueT> to a file descriptor.
Definition: DwmIO.hh:979
static std::ostream & Write(std::ostream &os, const Writable &val)
Wrapper function to write a Writable object to an ostream.
Definition: DwmIO.hh:660
virtual uint32_t StreamedLength() const =0
Returns the number of bytes that should be written if one of the Write() members is called...
static uint32_t StreamedLength(uint64_t val)
Returns the number of bytes that would be written if we called one of the Write() members for a uint6...
Definition: DwmIO.hh:209
static ssize_t Read(int fd, std::deque< _valueT, _Alloc > &d)
Reads a deque<_valueT> from a file descriptor.
Definition: DwmIO.hh:1109
static ssize_t Write(int fd, const std::pair< _firstT, _secondT > &p)
Writes a pair<_firstT,_secondT> to a file descriptor.
Definition: DwmIO.hh:801
static ssize_t Write(int fd, const Writable &val)
Wrapper function to write a Writable object to a descriptor.
Definition: DwmIO.hh:668
static std::ostream & Write(std::ostream &os, const std::unordered_multiset< _valueT, _Hash, _Pred, _Alloc > &m)
Writes a unordered_multiset<_valueT> to an ostream.
Definition: DwmIO.hh:2326
static std::istream & ReadTuple(std::istream &is, T &t)
T must be a tuple.
Definition: DwmIO.hh:1449
static ssize_t Read(int fd, Readable &val)
Wrapper function to read a Readable object from a descriptor.
Definition: DwmIO.hh:692
static size_t Write(FILE *f, const std::multimap< _keyT, _valueT, _Compare, _Alloc > &m)
Writes a multimap<_keyT,_valueT> to a FILE pointer.
Definition: DwmIO.hh:955
static std::istream & Read(std::istream &is, std::unordered_multiset< _valueT, _Hash, _Pred, _Alloc > &m)
Reads an unordered_multiset<_valueT> from an istream.
Definition: DwmIO.hh:2313
static std::ostream & Write(std::ostream &os, const std::unordered_set< _valueT, _Hash, _Pred, _Alloc > &m)
Writes a unordered_set<_valueT> to an ostream.
Definition: DwmIO.hh:2237
static size_t Read(FILE *f, std::multiset< _valueT, _Compare, _Alloc > &l)
Reads a multiset<_valueT> from a FILE pointer.
Definition: DwmIO.hh:1302
static size_t Read(FILE *f, Readable &val)
Wrapper function to read a Readable object from a FILE pointer.
Definition: DwmIO.hh:700
static ssize_t Read(int fd, std::multimap< _keyT, _valueT, _Compare, _Alloc > &m)
Reads a multimap<_keyT,_valueT> from a file descriptor.
Definition: DwmIO.hh:967
static size_t Write(FILE *f, const std::multiset< _valueT, _Compare, _Alloc > &l)
Writes a multiset<_valueT> to a FILE pointer.
Definition: DwmIO.hh:1313
static uint32_t StreamedLength(int16_t val)
Returns the number of bytes that would be written if we called one of the Write() members for an int1...
Definition: DwmIO.hh:134
static std::ostream & Write(std::ostream &os, char c)
Writes c to os. Returns os.
static uint32_t TupleStreamedLength(const T &t)
T must be a tuple.
Definition: DwmIO.hh:1507
This class contains a collection of static functions for reading and writing simple types...
Definition: DwmIO.hh:85
static size_t ReadTuple(FILE *f, T &t)
T must be a tuple.
Definition: DwmIO.hh:1485
static size_t Read(FILE *f, std::unordered_set< _valueT, _Hash, _Pred, _Alloc > &hm)
Reads an unordered_set from a FILE pointer.
Definition: DwmIO.hh:2274
static size_t Write(FILE *f, const std::set< _valueT, _Compare, _Alloc > &l)
Writes a set<_valueT> to a FILE pointer.
Definition: DwmIO.hh:1240
static uint32_t StreamedLength(uint8_t c)
Returns the number of bytes that would be written if we called Write() for a uint8_t.
Definition: DwmIO.hh:106
static ssize_t Write(int fd, const std::vector< _valueT, _Alloc > &v)
Writes a vector<_valueT> to a file descriptor.
Definition: DwmIO.hh:1049
static uint32_t StreamedLength(const std::multiset< _valueT, _Compare, _Alloc > &l)
Returns the number of bytes that should be written if we call one of the Write() members for a multis...
Definition: DwmIO.hh:1271
static uint32_t StreamedLength(int32_t val)
Returns the number of bytes that would be written if we called one of the Write() members for an int3...
Definition: DwmIO.hh:164
static std::istream & Read(std::istream &is, std::deque< _valueT, _Alloc > &d)
Reads a deque<_valueT> from an istream. Returns the istream.
Definition: DwmIO.hh:1068
static size_t Read(FILE *f, std::list< _valueT, _Alloc > &l)
Reads a list<_valueT> from a FILE pointer.
Definition: DwmIO.hh:1159
static ssize_t Write(int fd, const std::unordered_multiset< _valueT, _Hash, _Pred, _Alloc > &m)
Writes an unordered_multiset<_valueT> to a file descriptor.
Definition: DwmIO.hh:2351
static std::ostream & Write(std::ostream &os, const std::multiset< _valueT, _Compare, _Alloc > &l)
Writes a multiset<_valueT> to an ostream. Returns the ostream.
Definition: DwmIO.hh:1291
static ssize_t Write(int fd, const std::tuple< T, Args... > &t)
Writes a tuple to a file descriptor.
Definition: DwmIO.hh:1422
static uint32_t StreamedLength(const std::pair< _firstT, _secondT > &p)
Returns the number of bytes that should be written if we call one of the Write() members for a pair<_...
Definition: DwmIO.hh:710
static ssize_t Read(int fd, std::unordered_multimap< _keyT, _valueT, _Hash, _Pred, _Alloc > &m)
Reads an unordered_multimap<_keyT,_valueT> from a file descriptor.
Definition: DwmIO.hh:2161
static std::ostream & WriteTuple(std::ostream &os, const T &t)
T must be a tuple.
Definition: DwmIO.hh:1458
static std::istream & Read(std::istream &is, char &c)
Reads c from is. Returns is.
static uint32_t StreamedLength(const std::set< _valueT, _Compare, _Alloc > &l)
Returns the number of bytes that should be written if we call one of the Write() members for a set<_v...
Definition: DwmIO.hh:1200
static uint32_t StreamedLength(uint16_t val)
Returns the number of bytes that would be written if we called one of the Write() members for a uint1...
Definition: DwmIO.hh:149
Definition: DwmBZ2IO.hh:67
static size_t Write(FILE *f, const std::vector< _valueT, _Alloc > &v)
Writes a vector<_valueT> to a FILE pointer.
Definition: DwmIO.hh:1029
static size_t Read(FILE *f, std::multimap< _keyT, _valueT, _Compare, _Alloc > &m)
Reads a multimap<_keyT,_valueT> from a FILE pointer.
Definition: DwmIO.hh:943
static size_t Read(FILE *f, std::deque< _valueT, _Alloc > &d)
Reads a deque<_valueT> from a FILE pointer.
Definition: DwmIO.hh:1089
static ssize_t Write(int fd, const std::multiset< _valueT, _Compare, _Alloc > &l)
Writes a multiset<_valueT> to a file descriptor.
Definition: DwmIO.hh:1334
static uint32_t StreamedLength(const std::deque< _valueT, _Alloc > &d)
Returns the number of bytes that should be written if we call one of the Write() members for a deque<...
Definition: DwmIO.hh:1059
static std::ostream & Write(std::ostream &os, const std::list< _valueT, _Alloc > &l)
Writes a list<_valueT> to an ostream. Returns the ostream.
Definition: DwmIO.hh:1148
static uint32_t StreamedLength(int64_t val)
Returns the number of bytes that would be written if we called one of the Write() members for an int6...
Definition: DwmIO.hh:194
static uint32_t StreamedLength(double val)
Returns the number of bytes that should be written if we call one of the Write() members for a double...
Definition: DwmIO.hh:239
static size_t Read(FILE *f, std::unordered_map< _keyT, _valueT, _Hash, _Pred, _Alloc > &hm)
Reads an unordered_map from a FILE pointer.
Definition: DwmIO.hh:2097
static uint32_t StreamedLength(const Writable &val)
Returns the number of bytes that should be written if we call one of the Write() members for a Writab...
Definition: DwmIO.hh:652
static ssize_t Write(int fd, const std::unordered_set< _valueT, _Hash, _Pred, _Alloc > &m)
Writes an unordered_set<_valueT> to a file descriptor.
Definition: DwmIO.hh:2262
static size_t Read(FILE *f, std::vector< _valueT, _Alloc > &v)
Reads a vector<_valueT> from a FILE pointer.
Definition: DwmIO.hh:1019
static std::istream & Read(std::istream &is, std::multiset< _valueT, _Compare, _Alloc > &l)
Reads a multiset<_valueT> from an istream. Returns the istream.
Definition: DwmIO.hh:1280
static size_t Read(FILE *f, std::unordered_multimap< _keyT, _valueT, _Hash, _Pred, _Alloc > &hm)
Reads an unordered_multimap from a FILE pointer.
Definition: DwmIO.hh:2185
static std::ostream & Write(std::ostream &os, const std::pair< _firstT, _secondT > &p)
Writes a pair<_firstT,_secondT> to an ostream. Returns the ostream.
Definition: DwmIO.hh:733
static ssize_t Write(int fd, const std::unordered_multimap< _keyT, _valueT, _Hash, _Pred, _Alloc > &m)
Writes an unordered_multimap<_keyT,_valueT> to a file descriptor.
Definition: DwmIO.hh:2173
static uint32_t StreamedLength(float val)
Returns the number of bytes that should be written if we call one of the Write() members for a float...
Definition: DwmIO.hh:224
static std::ostream & Write(std::ostream &os, const std::vector< _valueT, _Alloc > &v)
Writes a vector<_valueT> to an ostream. Returns the ostream.
Definition: DwmIO.hh:1008
static std::ostream & Write(std::ostream &os, const std::map< _keyT, _valueT, _Compare, _Alloc > &m)
Writes a map<_keyT,_valueT> to an ostream. Returns the ostream.
Definition: DwmIO.hh:848
static std::istream & Read(std::istream &is, std::tuple< T, Args... > &t)
Reads a tuple from an istream. Returns the istream.
Definition: DwmIO.hh:1391
static size_t Write(FILE *f, const std::unordered_map< _keyT, _valueT, _Hash, _Pred, _Alloc > &hm)
Writes an unordered_map to a FILE pointer.
Definition: DwmIO.hh:2109
static ssize_t Read(int fd, std::unordered_map< _keyT, _valueT, _Hash, _Pred, _Alloc > &m)
Reads an unordered_map<_keyT,_valueT> from a file descriptor.
Definition: DwmIO.hh:2072
This class defines an interface for classes that can write their contents to an ostream, file descriptor or FILE pointer.
Definition: DwmWritable.hh:58
static std::ostream & Write(std::ostream &os, const std::set< _valueT, _Compare, _Alloc > &l)
Writes a set<_valueT> to an ostream. Returns the ostream.
Definition: DwmIO.hh:1219
static uint32_t StreamedLength(char c)
Returns the number of bytes that would be written if we called Write() for a char.
Definition: DwmIO.hh:92
static ssize_t Read(int fd, std::unordered_multiset< _valueT, _Hash, _Pred, _Alloc > &m)
Reads an unordered_multiset<_valueT> from a file descriptor.
Definition: DwmIO.hh:2339
static uint32_t StreamedLength(const std::multimap< _keyT, _valueT, _Compare, _Alloc > &m)
Returns the number of bytes that should be written if we call one of the Write() members for a multim...
Definition: DwmIO.hh:907
static size_t Write(FILE *f, const std::tuple< T, Args... > &t)
Writes a tuple to a FILE. Returns 1 on success, 0 on failure.
Definition: DwmIO.hh:1440
static ssize_t Read(int fd, std::set< _valueT, _Compare, _Alloc > &l)
Reads a set<_valueT> from a file descriptor.
Definition: DwmIO.hh:1250
static size_t Write(FILE *f, const std::map< _keyT, _valueT, _Compare, _Alloc > &m)
Writes a map<_keyT,_valueT> to a FILE pointer.
Definition: DwmIO.hh:872
static uint32_t StreamedLength(const std::map< _keyT, _valueT, _Compare, _Alloc > &m)
Returns the number of bytes that should be written if we call one of the Write() members for a map<_k...
Definition: DwmIO.hh:827
This class defines an interface for classes that can read their contents from an istream, file descriptor or FILE pointer.
Definition: DwmReadable.hh:58
static size_t Write(FILE *f, const std::unordered_multimap< _keyT, _valueT, _Hash, _Pred, _Alloc > &hm)
Writes an unordered_multimap to a FILE pointer.
Definition: DwmIO.hh:2197
static uint32_t StreamedLength(const std::vector< _valueT, _Alloc > &v)
Returns the number of bytes that should be written if we call one of the Write() members for a vector...
Definition: DwmIO.hh:989
static std::istream & Read(std::istream &is, std::multimap< _keyT, _valueT, _Compare, _Alloc > &m)
Reads a multimap<_keyT,_valueT> from an istream.
Definition: DwmIO.hh:919
static uint32_t StreamedLength(const std::tuple< T, Args... > &t)
Returns the number of bytes that should be written if we call one of the Write() members for a tuple...
Definition: DwmIO.hh:1382
static size_t Write(FILE *f, const std::unordered_multiset< _valueT, _Hash, _Pred, _Alloc > &hm)
Writes an unordered_multiset to a FILE pointer.
Definition: DwmIO.hh:2375
static ssize_t Read(int fd, std::map< _keyT, _valueT, _Compare, _Alloc > &m)
Reads a map<_keyT,_valueT> from a file descriptor.
Definition: DwmIO.hh:883
static uint32_t StreamedLength(const std::list< _valueT, _Alloc > &l)
Returns the number of bytes that should be written if we call one of the Write() members for a list<_...
Definition: DwmIO.hh:1129
static ssize_t WriteTuple(int fd, const T &t)
T must be a tuple.
Definition: DwmIO.hh:1476
static std::ostream & Write(std::ostream &os, const std::unordered_map< _keyT, _valueT, _Hash, _Pred, _Alloc > &m)
Writes a unordered_map<_keyT,_valueT> to an ostream.
Definition: DwmIO.hh:2059
static ssize_t Write(int fd, const std::unordered_map< _keyT, _valueT, _Hash, _Pred, _Alloc > &m)
Writes an unordered_map<_keyT,_valueT> to a file descriptor.
Definition: DwmIO.hh:2084
static std::istream & Read(std::istream &is, std::list< _valueT, _Alloc > &l)
Reads a list<_valueT> from an istream. Returns the istream.
Definition: DwmIO.hh:1138
static std::ostream & Write(std::ostream &os, const std::tuple< T, Args... > &t)
Writes a tuple to an ostream. Returns the ostream.
Definition: DwmIO.hh:1401
static ssize_t Read(int fd, std::vector< _valueT, _Alloc > &v)
Reads a vector<_valueT> from a file descriptor.
Definition: DwmIO.hh:1039
static size_t Write(FILE *f, const std::unordered_set< _valueT, _Hash, _Pred, _Alloc > &hm)
Writes an unordered_set to a FILE pointer.
Definition: DwmIO.hh:2286
static size_t Read(FILE *f, std::pair< _firstT, _secondT > &p)
Reads a pair<_firstT,_secondT> from a FILE pointer.
Definition: DwmIO.hh:749
static ssize_t Read(int fd, std::pair< _firstT, _secondT > &p)
Reads a pair<_firstT,_secondT> from a file descriptor.
Definition: DwmIO.hh:779
static ssize_t Read(int fd, std::multiset< _valueT, _Compare, _Alloc > &l)
Reads a multiset<_valueT> from a file descriptor.
Definition: DwmIO.hh:1323
static std::istream & Read(std::istream &is, Readable &val)
Wrapper function to read a Readable object from an istream.
Definition: DwmIO.hh:684
static std::istream & Read(std::istream &is, std::unordered_multimap< _keyT, _valueT, _Hash, _Pred, _Alloc > &m)
Reads an unordered_multimap<_keyT,_valueT> from an istream.
Definition: DwmIO.hh:2135
static std::ostream & Write(std::ostream &os, const std::deque< _valueT, _Alloc > &d)
Writes a deque<_valueT> to an ostream. Returns the ostream.
Definition: DwmIO.hh:1078
static size_t Read(FILE *f, std::map< _keyT, _valueT, _Compare, _Alloc > &m)
Reads a map<_keyT,_valueT> from a FILE pointer.
Definition: DwmIO.hh:860
static ssize_t Write(int fd, const std::deque< _valueT, _Alloc > &d)
Writes a deque<_valueT> to a file descriptor.
Definition: DwmIO.hh:1119
A configure target for dealing with OS differences.
static uint32_t StreamedLength(uint32_t val)
Returns the number of bytes that would be written if we called one of the Write() members for a uint3...
Definition: DwmIO.hh:179