Colobot
Functions
ioutils.h File Reference

Functions for binary I/O. More...

#include <iostream>
#include <cstring>
Include dependency graph for ioutils.h:

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 >
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...
 

Detailed Description

Functions for binary I/O.

Function Documentation

template<int N, typename T >
void IOUtils::WriteBinary ( 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

template<int N, typename T >
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

void IOUtils::WriteBinaryBool ( bool  value,
std::ostream &  ostr 
)
inline

Writes a binary 1-byte boolean.

false is 0; true is 1.

bool IOUtils::ReadBinaryBool ( std::istream &  istr)
inline

Reads a binary 1-byte boolean.

0 is false; other values are true.

void IOUtils::WriteBinaryFloat ( float  value,
std::ostream &  ostr 
)
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.

float IOUtils::ReadBinaryFloat ( std::istream &  istr)
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.

template<int N>
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.

template<int N>
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.