Nebula
Loading...
Searching...
No Matches
binaryreader.h
Go to the documentation of this file.
1#pragma once
2//------------------------------------------------------------------------------
16#include "io/streamreader.h"
17#if !__OSX__
18#include "math/vec2.h"
19#include "math/vec4.h"
20#include "math/vec3.h"
21#include "math/mat4.h"
22#endif
23#include "util/guid.h"
24#include "util/blob.h"
25#include "system/byteorder.h"
26
27//------------------------------------------------------------------------------
28namespace IO
29{
31{
33public:
37 virtual ~BinaryReader();
39 void SetMemoryMappingEnabled(bool b);
41 bool IsMemoryMappingEnabled() const;
47 virtual bool Open();
49 virtual void Close();
51 char ReadChar();
53 unsigned char ReadUChar();
55 short ReadShort();
57 unsigned short ReadUShort();
59 int ReadInt();
61 unsigned int ReadUInt();
63 long long ReadInt64();
65 unsigned long long ReadUInt64();
67 float ReadFloat();
73 double ReadDouble();
75 bool ReadBool();
78 #if !__OSX__
87 #endif
101 void ReadRawData(void* ptr, SizeT numBytes);
102
103public:
105 unsigned char* mapCursor;
106 unsigned char* mapEnd;
109};
110
111//------------------------------------------------------------------------------
114inline void
119
120//------------------------------------------------------------------------------
123inline bool
125{
126 return this->enableMapping;
127}
128
129//------------------------------------------------------------------------------
132inline void
137
138//------------------------------------------------------------------------------
143{
144 return this->byteOrder.GetFromByteOrder();
145}
146
147} // namespace IO
148//------------------------------------------------------------------------------
A friendly interface to read binary data from a stream.
Definition binaryreader.h:31
__DeclareClass(BinaryReader)
bool isMapped
Definition binaryreader.h:108
virtual bool Open()
begin reading from the stream
Definition binaryreader.cc:43
bool IsMemoryMappingEnabled() const
return true if memory mapping is enabled
Definition binaryreader.h:124
float ReadFloatFromUnsignedNormalizedUByte2()
read a compressed float value from the stream, lossy and needed to be in the range of 0....
Definition binaryreader.cc:276
Math::vec3 ReadVec3()
read a vector from the stream, (x,y,z,0.0)
Definition binaryreader.cc:444
void SetStreamByteOrder(System::ByteOrder::Type byteOrder)
set the stream byte order (default is host byte order)
Definition binaryreader.h:133
unsigned long long ReadUInt64()
read a 64-bit unsigned int from the stream
Definition binaryreader.cc:223
System::ByteOrder::Type GetStreamByteOrder() const
get the stream byte order
Definition binaryreader.h:142
float ReadFloat()
read a float value from the stream
Definition binaryreader.cc:244
Util::Guid ReadGuid()
read a guid
Definition binaryreader.cc:387
Math::vec4 ReadVec4()
read a vec4 from the stream
Definition binaryreader.cc:422
unsigned int ReadUInt()
read a 32-bit unsigned int from the stream
Definition binaryreader.cc:181
unsigned char * mapEnd
Definition binaryreader.h:106
virtual void Close()
end reading from the stream
Definition binaryreader.cc:68
Util::Array< float > ReadFloatArray()
read a float array from the stream
Definition binaryreader.cc:494
Math::mat4 ReadMat4()
read a mat4 from the stream
Definition binaryreader.cc:471
Util::String ReadString()
read a string from the stream
Definition binaryreader.cc:329
long long ReadInt64()
read a 64-bit int from the stream
Definition binaryreader.cc:202
Util::Array< bool > ReadBoolArray()
read a bool array from the stream
Definition binaryreader.cc:578
Util::Array< uint > ReadUIntArray()
read an int array from the stream
Definition binaryreader.cc:546
unsigned char ReadUChar()
read an 8-bit unsigned character from the stream
Definition binaryreader.cc:99
Util::Blob ReadBlob()
read a blob of data
Definition binaryreader.cc:365
int ReadInt()
read a 32-bit int from the stream
Definition binaryreader.cc:160
BinaryReader()
constructor
Definition binaryreader.cc:19
virtual ~BinaryReader()
destructor
Definition binaryreader.cc:31
unsigned short ReadUShort()
read a 16-bit unsigned short from the stream
Definition binaryreader.cc:139
bool enableMapping
Definition binaryreader.h:107
float ReadFloatFromNormalizedUByte2()
read a compressed float value from the stream, lossy and needed to be in the range of -1....
Definition binaryreader.cc:265
double ReadDouble()
read a double value from the stream
Definition binaryreader.cc:287
char ReadChar()
read an 8-bit char from the stream
Definition binaryreader.cc:80
void SetMemoryMappingEnabled(bool b)
call before Open() to enable memory mapping (if stream supports mapping)
Definition binaryreader.h:115
void ReadRawData(void *ptr, SizeT numBytes)
read raw data
Definition binaryreader.cc:604
short ReadShort()
read a 16-bit short from the stream
Definition binaryreader.cc:118
System::ByteOrder byteOrder
Definition binaryreader.h:104
Util::Array< int > ReadIntArray()
read an int array from the stream
Definition binaryreader.cc:520
unsigned char * mapCursor
Definition binaryreader.h:105
Math::vec2 ReadFloat2()
read a vec2 from the stream
Definition binaryreader.cc:398
bool ReadBool()
read a bool value from the stream
Definition binaryreader.cc:308
Stream reader classes provide a specialized read-interface for a stream.
Definition streamreader.h:24
Provides information and methods to help with byte ordering issues.
Definition byteorder.h:33
void SetFromByteOrder(Type fromByteOrder)
set from-byte-order
Definition byteorder.h:113
Type
Definition byteorder.h:37
Type GetFromByteOrder() const
get from-byte-order
Definition byteorder.h:122
Nebula's dynamic array class.
Definition array.h:60
The Util::Blob class encapsulates a chunk of raw memory into a C++ object which can be copied,...
Definition blob.h:22
Implements a GUID.
Instances of wrapped stream classes.
Definition orientation.cc:10
A 4x4 single point precision float matrix.
Definition mat4.h:47
A 2-component float vector class.
Definition vec2.h:21
A 3D vector.
Definition vec3.h:39
A 4D vector.
Definition vec4.h:24
Nebula's universal string class.
Definition String.cs:8
int SizeT
Definition types.h:49