Colobot
|
Functions for binary I/O. More...
#include <iostream>
#include <cstring>
Go to the source code of this file.
Functions | |
template<int N, typename T > | |
void | IOUtils::WriteBinary (T value, std::ostream &ostr) |
Writes a binary number to output stream. More... | |
template<int N, typename T > | |
T | IOUtils::ReadBinary (std::istream &istr) |
Reads a binary number from input stream. More... | |
void | IOUtils::WriteBinaryBool (bool value, std::ostream &ostr) |
Writes a binary 1-byte boolean. More... | |
bool | IOUtils::ReadBinaryBool (std::istream &istr) |
Reads a binary 1-byte boolean. More... | |
void | IOUtils::WriteBinaryFloat (float value, std::ostream &ostr) |
Writes a binary 32-bit float to output stream. More... | |
float | IOUtils::ReadBinaryFloat (std::istream &istr) |
Reads a binary 32-bit float from input stream. More... | |
template<int N> | |
void | IOUtils::WriteBinaryString (const std::string &value, std::ostream &ostr) |
Writes a variable binary string to output stream. More... | |
template<int N> | |
std::string | IOUtils::ReadBinaryString (std::istream &istr) |
Reads a variable binary string from output stream. More... | |
Functions for binary I/O.
void IOUtils::WriteBinary | ( | T | value, |
std::ostream & | ostr | ||
) |
Writes a binary number to output stream.
T
is a numeric type (int, unsigned int, etc.) N
is number of bytes Write order is little-endian
T IOUtils::ReadBinary | ( | std::istream & | istr | ) |
Reads a binary number from input stream.
T
is a numeric type (int, unsigned int, etc.) N
is number of bytes Read order is little-endian
|
inline |
Writes a binary 1-byte boolean.
false is 0; true is 1.
|
inline |
Reads a binary 1-byte boolean.
0 is false; other values are true.
|
inline |
Writes a binary 32-bit float to output stream.
Write order is little-endian NOTE: code is probably not portable as there are platforms with other float representations.
|
inline |
Reads a binary 32-bit float from input stream.
Read order is little-endian NOTE: code is probably not portable as there are platforms with other float representations.
void IOUtils::WriteBinaryString | ( | const std::string & | value, |
std::ostream & | ostr | ||
) |
Writes a variable binary string to output stream.
The string is written by first writing string length in N
byte binary number and then the string bytes.
std::string IOUtils::ReadBinaryString | ( | std::istream & | istr | ) |
Reads a variable binary string from output stream.
The string is read by first reading string length in N
byte binary number and then the string bytes.