This class contains a collection of static functions for reading and writing simple types, in network byte order (MSB first). More...
#include <DwmFileIO.hh>
Static Public Member Functions | |
| static size_t | Read (FILE *f, char &c) |
Reads c from f. | |
| static size_t | Write (FILE *f, char c) |
Writes c to f. | |
| static size_t | Read (FILE *f, uint8_t &c) |
Reads c from f. | |
| static size_t | Write (FILE *f, uint8_t c) |
Writes c to f. | |
| static size_t | Read (FILE *f, bool &b) |
Reads b from f. | |
| static size_t | Write (FILE *f, bool b) |
Writes b to f. | |
| static size_t | Read (FILE *f, int16_t &val) |
Reads val from f, in network byte order (MSB first). | |
| static size_t | Write (FILE *f, int16_t val) |
Writes val to f, in network byte order (MSB first). | |
| static size_t | Read (FILE *f, uint16_t &val) |
Reads val from f, in network byte order (MSB first). | |
| static size_t | Write (FILE *f, uint16_t val) |
Writes val to f, in network byte order (MSB first). | |
| static size_t | Read (FILE *f, int32_t &val) |
Reads val from f, in network byte order (MSB first). | |
| static size_t | Write (FILE *f, int32_t val) |
Writes val to f, in network byte order (MSB first). | |
| static size_t | Read (FILE *f, uint32_t &val) |
Reads val from f, in network byte order (MSB first). | |
| static size_t | Write (FILE *f, uint32_t val) |
Writes val to f, in network byte order (MSB first). | |
| static size_t | Read (FILE *f, int64_t &val) |
Reads val from f, in network byte order (MSB first). | |
| static size_t | Write (FILE *f, const int64_t &val) |
Writes val to f, in network byte order (MSB first). | |
| static size_t | Read (FILE *f, uint64_t &val) |
Reads val from f, in network byte order (MSB first). | |
| static size_t | Write (FILE *f, const uint64_t &val) |
Writes val to f, in network byte order (MSB first). | |
| static size_t | Read (FILE *f, float &val) |
Reads val from f, in IEEE format (see RFC 1832 and/or ANSI/IEEE Standard 754-1985). | |
| static size_t | Write (FILE *f, float val) |
Writes val to f, in IEEE format (see RFC 1832 and/or ANSI/IEEE Standard 754-1985). | |
| static size_t | Read (FILE *f, double &val) |
Reads val from f, in IEEE format (see RFC 1832 and/or ANSI/IEEE Standard 754-1985). | |
| static size_t | Write (FILE *f, const double &val) |
Writes val to f, in IEEE format (see RFC 1832 and/or ANSI/IEEE Standard 754-1985). | |
| static size_t | Read (FILE *f, std::string &s) |
Reads s from f. | |
| static size_t | Write (FILE *f, const std::string &s) |
Writes s to f. | |
| static size_t | Read (FILE *f, FileReadable &val) |
| Wrapper function to read a FileReadable object from a FILE. | |
| static size_t | Read (FILE *f, HasFileRead auto &val) |
Reads val from FILE f, where val meets the requirements of the HasFileRead concept. | |
| static size_t | Write (FILE *f, const FileWritable &val) |
| Wrapper function to write a FileWritable object to a FILE. | |
| static size_t | Write (FILE *f, const HasFileWrite auto &val) |
Writes val to FILE f, where val meets the requirements of the HasFileWrite concept. | |
| template<typename _firstT , typename _secondT > | |
| static size_t | Read (FILE *f, std::pair< _firstT, _secondT > &p) |
| Reads a pair<_firstT,_secondT> from a FILE. | |
| template<typename _firstT , typename _secondT > | |
| static size_t | Write (FILE *f, const std::pair< _firstT, _secondT > &p) |
| Writes a pair<_firstT,_secondT> to a FILE. | |
| template<typename _keyT , typename _valueT , typename _Compare , typename _Alloc > | |
| static size_t | Read (FILE *f, std::map< _keyT, _valueT, _Compare, _Alloc > &m) |
| Reads a map<_keyT,_valueT> from a FILE. | |
| template<typename _keyT , typename _valueT , typename _Compare , typename _Alloc > | |
| static size_t | Write (FILE *f, const std::map< _keyT, _valueT, _Compare, _Alloc > &m) |
| Writes a map<_keyT,_valueT> to a FILE. | |
| template<typename _keyT , typename _valueT , typename _Compare , typename _Alloc > | |
| static size_t | Read (FILE *f, std::multimap< _keyT, _valueT, _Compare, _Alloc > &m) |
| Reads a multimap<_keyT,_valueT> from a FILE. | |
| template<typename _keyT , typename _valueT , typename _Compare , typename _Alloc > | |
| static size_t | Write (FILE *f, const std::multimap< _keyT, _valueT, _Compare, _Alloc > &m) |
| Writes a multimap<_keyT,_valueT> to a FILE. | |
| template<typename _valueT , size_t N> | |
| static size_t | Read (FILE *f, std::array< _valueT, N > &a) |
| Reads an array<_valueT,N> from a FILE. | |
| template<typename _valueT , size_t N> | |
| static size_t | Write (FILE *f, const std::array< _valueT, N > &a) |
| Writes an array<_valueT,N> to a FILE. | |
| template<typename _valueT , typename _Alloc > | |
| static size_t | Read (FILE *f, std::vector< _valueT, _Alloc > &v) |
| Reads a vector<_valueT> from a FILE. | |
| template<typename _valueT , typename _Alloc > | |
| static size_t | Write (FILE *f, const std::vector< _valueT, _Alloc > &v) |
| Writes a vector<_valueT> to a FILE. | |
| template<typename _valueT , typename _Alloc > | |
| static size_t | Read (FILE *f, std::deque< _valueT, _Alloc > &d) |
| Reads a deque<_valueT> from a FILE. | |
| template<typename _valueT , typename _Alloc > | |
| static size_t | Write (FILE *f, const std::deque< _valueT, _Alloc > &d) |
| Writes a deque<_valueT> to a FILE. | |
| template<typename _valueT , typename _Alloc > | |
| static size_t | Read (FILE *f, std::list< _valueT, _Alloc > &l) |
| Reads a list<_valueT> from a FILE. | |
| template<typename _valueT , typename _Alloc > | |
| static size_t | Write (FILE *f, const std::list< _valueT, _Alloc > &l) |
| Writes a list<_valueT> to a FILE. | |
| template<typename _valueT , typename _Compare , typename _Alloc > | |
| static size_t | Read (FILE *f, std::set< _valueT, _Compare, _Alloc > &l) |
| Reads a set<_valueT> from a FILE. | |
| template<typename _valueT , typename _Compare , typename _Alloc > | |
| static size_t | Write (FILE *f, const std::set< _valueT, _Compare, _Alloc > &l) |
| Writes a set<_valueT> to a FILE. | |
| template<typename _valueT , typename _Compare , typename _Alloc > | |
| static size_t | Read (FILE *f, std::multiset< _valueT, _Compare, _Alloc > &l) |
| Reads a multiset<_valueT> from a FILE. | |
| template<typename _valueT , typename _Compare , typename _Alloc > | |
| static size_t | Write (FILE *f, const std::multiset< _valueT, _Compare, _Alloc > &l) |
| Writes a multiset<_valueT> to a FILE. | |
| template<typename... Args> | |
| static size_t | Read (FILE *f, std::tuple< Args... > &t) |
| Reads a tuple from a FILE. Returns 1 on success, 0 on failure. | |
| template<typename... Args> | |
| static size_t | Write (FILE *f, const std::tuple< Args... > &t) |
| Writes a tuple to a FILE. Returns 1 on success, 0 on failure. | |
| static size_t | Read (FILE *fp, std::monostate &sm) |
| Just a dummy helper function for std::variant instances that hold a std::monostate. | |
| static size_t | Write (FILE *fp, const std::monostate &sm) |
| Just a dummy helper function for std::variant instances that hold a std::monostate. | |
| template<typename... Ts> | |
| static size_t | Read (FILE *fp, std::variant< Ts... > &v) |
| Reads a variant from a FILE. Returns 1 on success, 0 on failure. | |
| template<typename... Ts> | |
| static size_t | Write (FILE *fp, const std::variant< Ts... > &v) |
| Writes a variant to a FILE. Returns 1 on success, 0 on failure. | |
| template<typename _keyT , typename _valueT , typename _Hash , typename _Pred , typename _Alloc > | |
| static size_t | Read (FILE *f, std::unordered_map< _keyT, _valueT, _Hash, _Pred, _Alloc > &hm) |
| Reads an unordered_map from a FILE. | |
| template<typename _keyT , typename _valueT , typename _Hash , typename _Pred , typename _Alloc > | |
| static size_t | Write (FILE *f, const std::unordered_map< _keyT, _valueT, _Hash, _Pred, _Alloc > &hm) |
| Writes an unordered_map to a FILE. | |
| template<typename _keyT , typename _valueT , typename _Hash , typename _Pred , typename _Alloc > | |
| static size_t | Read (FILE *f, std::unordered_multimap< _keyT, _valueT, _Hash, _Pred, _Alloc > &hm) |
| Reads an unordered_multimap from a FILE. | |
| template<typename _keyT , typename _valueT , typename _Hash , typename _Pred , typename _Alloc > | |
| static size_t | Write (FILE *f, const std::unordered_multimap< _keyT, _valueT, _Hash, _Pred, _Alloc > &hm) |
| Writes an unordered_multimap to a FILE. | |
| template<typename _valueT , typename _Hash , typename _Pred , typename _Alloc > | |
| static size_t | Read (FILE *f, std::unordered_set< _valueT, _Hash, _Pred, _Alloc > &hm) |
| Reads an unordered_set from a FILE. | |
| template<typename _valueT , typename _Hash , typename _Pred , typename _Alloc > | |
| static size_t | Write (FILE *f, const std::unordered_set< _valueT, _Hash, _Pred, _Alloc > &hm) |
| Writes an unordered_set to a FILE. | |
| template<typename _valueT , typename _Hash , typename _Pred , typename _Alloc > | |
| static size_t | Read (FILE *f, std::unordered_multiset< _valueT, _Hash, _Pred, _Alloc > &hm) |
| Reads an unordered_multiset from a FILE. | |
| template<typename _valueT , typename _Hash , typename _Pred , typename _Alloc > | |
| static size_t | Write (FILE *f, const std::unordered_multiset< _valueT, _Hash, _Pred, _Alloc > &hm) |
| Writes an unordered_multiset to a FILE. | |
| template<typename... Args> | |
| static size_t | ReadV (FILE *f, Args &...args) |
| Reads multiple objects from a FILE. | |
| template<typename... Args> | |
| static size_t | WriteV (FILE *f, const Args &...args) |
| Writes multiple objects to a FILE. | |
This class contains a collection of static functions for reading and writing simple types, in network byte order (MSB first).
It also contains functions to read and write strings. It also contains function templates to read and write STL deques, lists, vectors, maps, multimaps, sets, multisets, unordered_maps, unordered_multimaps, unordered_sets, unordered_multisets, tuples and variants. We use our member functions to handle reading and writing simple types in the containers, and function templates to handle reading and writing other class types. For a user-defined class, the class must implement the FileReadable and FileWritable interfaces, since our function templates simply call out to them. Since templates are static polymorphism, you don't need to inherit from FileReadable and FileWritable, but you must implement the interfaces.
|
static |
Reads b from f.
Returns the number of bytes read (1 on success).
|
static |
Reads c from f.
Returns the number of bytes read (1 on success, 0 on failure).
|
static |
Reads val from f, in IEEE format (see RFC 1832 and/or ANSI/IEEE Standard 754-1985).
Returns the number of bytes read (8 on success).
|
static |
Reads val from f, in IEEE format (see RFC 1832 and/or ANSI/IEEE Standard 754-1985).
Returns the number of bytes read (4 on success).
|
static |
Reads val from f, in network byte order (MSB first).
Returns the number of bytes read (2 on success).
|
static |
Reads val from f, in network byte order (MSB first).
Returns the number of bytes read (4 on success).
|
static |
Reads val from f, in network byte order (MSB first).
Returns the number of bytes read (8 on success).
|
inlinestatic |
Reads an array<_valueT,N> from a FILE.
Returns 1 on success, 0 on failure.

|
inlinestatic |
Reads a deque<_valueT> from a FILE.
Returns 1 on success, 0 on failure.
|
inlinestatic |
Reads a list<_valueT> from a FILE.
Returns 1 on success, 0 on failure.
|
inlinestatic |
Reads a map<_keyT,_valueT> from a FILE.
Returns 1 on success, 0 on failure.
|
inlinestatic |
Reads a multimap<_keyT,_valueT> from a FILE.
Returns 1 on success, 0 on failure.
|
inlinestatic |
Reads a multiset<_valueT> from a FILE.
Returns 1 on success, 0 on failure.
|
inlinestatic |
Reads a pair<_firstT,_secondT> from a FILE.
Returns 1 on success, 0 on failure.

|
inlinestatic |
Reads a set<_valueT> from a FILE.
Returns 1 on success, 0 on failure.
|
static |
Reads s from f.
Since we write strings with a 64-bit length value preceding, and always write the terminating NULL, this function will always return a value of 9 or greater on success.
|
inlinestatic |
Reads an unordered_map from a FILE.
Returns 1 on success, 0 on failure.
|
inlinestatic |
Reads an unordered_multimap from a FILE.
Returns 1 on success, 0 on failure.
|
inlinestatic |
Reads an unordered_multiset from a FILE.
Returns 1 on success, 0 on failure.
|
inlinestatic |
Reads an unordered_set from a FILE.
Returns 1 on success, 0 on failure.
|
inlinestatic |
Reads a vector<_valueT> from a FILE.
Returns 1 on success, 0 on failure.
|
static |
Reads val from f, in network byte order (MSB first).
Returns the number of bytes read (2 on success).
|
static |
Reads val from f, in network byte order (MSB first).
Returns the number of bytes read (4 on success).
|
static |
Reads val from f, in network byte order (MSB first).
Returns the number of bytes read (8 on success).
|
static |
Reads c from f.
Returns the number of bytes read (1 on success).
|
inlinestatic |
Just a dummy helper function for std::variant instances that hold a std::monostate.
This should only be called from our Read() for std::variant (via std::visit()), and does nothing. Returns 1.
|
inlinestatic |
Reads multiple objects from a FILE.
Returns 1 on success, 0 on failure.

|
static |
Writes b to f.
Returns the number of bytes written (1) on success.
|
static |
Writes c to f.
Returns the number of bytes written (1) on success.
|
static |
Writes val to f, in IEEE format (see RFC 1832 and/or ANSI/IEEE Standard 754-1985).
Returns the number of bytes written (8 on success).
|
static |
Writes val to f, in network byte order (MSB first).
Returns the number of bytes written (8) on success.
|
inlinestatic |
Writes an array<_valueT,N> to a FILE.
Returns 1 on success, 0 on failure.

|
inlinestatic |
Writes a deque<_valueT> to a FILE.
Returns 1 on success, 0 on failure.
|
inlinestatic |
Writes a list<_valueT> to a FILE.
Returns 1 on success, 0 on failure.
|
inlinestatic |
Writes a map<_keyT,_valueT> to a FILE.
Returns 1 on success, 0 on failure.
|
inlinestatic |
Writes a multimap<_keyT,_valueT> to a FILE.
Returns 1 on success, 0 on failure.
|
inlinestatic |
Writes a multiset<_valueT> to a FILE.
Returns 1 on success, 0 on failure.
|
inlinestatic |
Writes a pair<_firstT,_secondT> to a FILE.
Returns 1 on success, 0 on failure.

|
inlinestatic |
Writes a set<_valueT> to a FILE.
Returns 1 on success, 0 on failure.
|
static |
Writes s to f.
Returns the number of bytes written. Note that we first write a 64-bit length value, then the string itself (with terminating NULL). Hence a successful write will always return a value of 8 + s.length() + 1.
|
inlinestatic |
Writes an unordered_map to a FILE.
Returns 1 on success, 0 on failure.
|
inlinestatic |
Writes an unordered_multimap to a FILE.
Returns 1 on success, 0 on failure.
|
inlinestatic |
Writes an unordered_multiset to a FILE.
Returns 1 on success, 0 on failure.
|
inlinestatic |
Writes an unordered_set to a FILE.
Returns 1 on success, 0 on failure.
|
inlinestatic |
Writes a vector<_valueT> to a FILE.
Returns 1 on success, 0 on failure.
|
static |
Writes val to f, in network byte order (MSB first).
Returns the number of bytes written (8) on success.
|
static |
Writes val to f, in IEEE format (see RFC 1832 and/or ANSI/IEEE Standard 754-1985).
Returns the number of bytes written (4 on success).
|
static |
Writes val to f, in network byte order (MSB first).
Returns the number of bytes written (2) on success.
|
static |
Writes val to f, in network byte order (MSB first).
Returns the number of bytes written (4) on success.
|
static |
Writes val to f, in network byte order (MSB first).
Returns the number of bytes written (2) on success.
|
static |
Writes val to f, in network byte order (MSB first).
Returns the number of bytes written (4) on success.
|
static |
Writes c to f.
Returns the number of bytes written (1) on success.
|
inlinestatic |
Just a dummy helper function for std::variant instances that hold a std::monostate.
This should only be called from our Write() for std::variant (via std::visit()), and does nothing. Returns 1.
|
inlinestatic |
Writes multiple objects to a FILE.
Returns 1 on success, 0 on failure.
