Loading...
Searching...
No Matches
ioutils.h File Reference

Functions for binary I/O. More...

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

## Functions

template<int N, typename T>
void | IOUtils::WriteBinary (T value, std::ostream &ostr)
| Writes a binary number to output stream.
template<int N, typename T>
T | IOUtils::ReadBinary (std::istream &istr)
| Reads a binary number from input stream.
void | IOUtils::WriteBinaryBool (bool value, std::ostream &ostr)
| Writes a binary 1-byte boolean.
bool | IOUtils::ReadBinaryBool (std::istream &istr)
| Reads a binary 1-byte boolean.
void | IOUtils::WriteBinaryFloat (float value, std::ostream &ostr)
| Writes a binary 32-bit float to output stream.
float | IOUtils::ReadBinaryFloat (std::istream &istr)
| Reads a binary 32-bit float from input stream.
template<int N>
void | IOUtils::WriteBinaryString (const std::string &value, std::ostream &ostr)
| Writes a variable binary string to output stream.
template<int N>
std::string | IOUtils::ReadBinaryString (std::istream &istr)
| Reads a variable binary string from output stream.

## Detailed Description

Functions for binary I/O.

## Function Documentation

## WriteBinary()

template<int N, typename T>

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

## ReadBinary()

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

## WriteBinaryBool()

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

inline

Writes a binary 1-byte boolean.

false is 0; true is 1.

## ReadBinaryBool()

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

inline

Reads a binary 1-byte boolean.

0 is false; other values are true.

## WriteBinaryFloat()

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.

## ReadBinaryFloat()

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.

## WriteBinaryString()

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.

## ReadBinaryString()

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.