Geogram
Version 1.9.1
A programming library of geometric algorithms
|
Binary stream base class. More...
#include <geogram/basic/b_stream.h>
Classes | |
struct | ItemSize |
Size selector. More... | |
Public Member Functions | |
void | set_stream_endian (int stream_endian) |
Sets the stream endianness. More... | |
int | stream_endian () const |
Gets the stream endianness. More... | |
int | machine_endian () const |
Gets the current architecture's endianness. More... | |
bool | has_record_markers () const |
Checks support for record markers. More... | |
void | set_has_record_markers (bool b) |
Enables/disables support for record markers. More... | |
Static Public Attributes | |
static const int | GEO_LITTLE_ENDIAN = 0 |
static const int | GEO_BIG_ENDIAN = 1 |
Protected Member Functions | |
BinaryStream (int stream_endian=GEO_BIG_ENDIAN) | |
Base constructor. More... | |
void | detect_machine_endian () |
Detects the current architecture's endianness. | |
Protected Attributes | |
bool | swapped_ |
Binary stream base class.
A characteristic of processors named endian corresponds to the way they store numbers. A little endian processor stores less significant bytes first, and a big endian processor stores most significant bytes first.
Most Unix machines are big endian, except those having a DEC Alpha processor. Intel processors are little endian. This causes portability problems for binary files to be exchanged between machines of the two types. The classes BinaryInputStream and BinaryOutputStream make it possible to deal with this problem.
We have not used XDR because XDR assumes that the external format is always big endian, which would have prevented us to read files from PC softwares (such as 3DS binary files).
Definition at line 76 of file b_stream.h.
|
protected |
Base constructor.
This constructor initializes the base class common to BinaryInputStream and BinaryOutputStream. It sets the stream endianness and detects the current architecture's endianness
[in] | stream_endian | the endianness of the stream:
|
|
inline |
Checks support for record markers.
Definition at line 116 of file b_stream.h.
|
inline |
Gets the current architecture's endianness.
GEO_LITTLE_ENDIAN
if the architecture is little-endian, GEO_BIG_ENDIAN
if the architecture is big-endian. Definition at line 108 of file b_stream.h.
|
inline |
Enables/disables support for record markers.
Some FORTRAN files have their records surrounded by two integers and some not. This function enables BinaryStream to read such FORTRAN files. Default value is true.
Definition at line 127 of file b_stream.h.
void GEO::BinaryStream::set_stream_endian | ( | int | stream_endian | ) |
Sets the stream endianness.
This affects how the integer and floating point values will be stored in the stream.
[in] | stream_endian | the endianness of the stream:
|
|
inline |
Gets the stream endianness.
GEO_LITTLE_ENDIAN
if the stream is little-endian, GEO_BIG_ENDIAN
if the stream is big-endian. Definition at line 99 of file b_stream.h.
|
static |
Constant to use to specify big-endian streams
Definition at line 82 of file b_stream.h.
|
static |
Constant to use to specify little-endian streams
Definition at line 79 of file b_stream.h.
|
protected |
True if stream needs swapping
Definition at line 159 of file b_stream.h.