13 #ifndef G3D_BinaryInput_h
14 #define G3D_BinaryInput_h
18 # pragma warning(push)
19 # pragma warning( disable : 4127 )
26 #include <sys/types.h>
43 #if defined(G3D_WINDOWS) || defined(G3D_LINUX)
46 #define G3D_ALLOW_UNALIGNED_WRITES
158 const std::string& filename,
160 bool compressed =
false);
189 bool compressed =
false,
190 bool copyMemory =
true);
242 if (m_alreadyRead > 0 || m_bufferLength < m_length) {
243 throw "Cannot getCArray for a huge file";
255 if ((m_pos < 0) || (m_pos > m_bufferLength)) {
271 return m_buffer[m_pos++];
280 return ((
uint8*)m_buffer)[m_pos++];
293 out[0] = m_buffer[m_pos - 1];
294 out[1] = m_buffer[m_pos - 2];
297 #ifdef G3D_ALLOW_UNALIGNED_WRITES
298 return *(
uint16*)(&m_buffer[m_pos - 2]);
301 out[0] = m_buffer[m_pos - 2];
302 out[1] = m_buffer[m_pos - 1];
320 out[0] = m_buffer[m_pos - 1];
321 out[1] = m_buffer[m_pos - 2];
322 out[2] = m_buffer[m_pos - 3];
323 out[3] = m_buffer[m_pos - 4];
326 #ifdef G3D_ALLOW_UNALIGNED_WRITES
327 return *(
uint32*)(&m_buffer[m_pos - 4]);
330 out[0] = m_buffer[m_pos - 4];
331 out[1] = m_buffer[m_pos - 3];
332 out[2] = m_buffer[m_pos - 2];
333 out[3] = m_buffer[m_pos - 1];
418 return m_pos + m_alreadyRead <
m_length;
432 # define DECLARE_READER(ucase, lcase)\
433 void read##ucase(lcase* out, int64 n);\
434 void read##ucase(std::vector<lcase>& out, int64 n);\
435 void read##ucase(Array<lcase>& out, int64 n);
448 # undef DECLARE_READER
455 # pragma warning(pop)
unorm8
Definition: unorm8.h:33
int8_t int8
Definition: Define.h:148
int16_t int16
Definition: g3dmath.h:165
int64_t int64
Definition: Define.h:145
double float64
Definition: g3dmath.h:173
int8_t int8
Definition: g3dmath.h:163
static unorm16 fromBits(uint16 b)
Definition: unorm16.h:43
uint64_t uint64
Definition: g3dmath.h:170
#define debugAssertM(exp, message)
Definition: debugAssert.h:161
uint16_t uint16
Definition: g3dmath.h:166
short Int16
Definition: bzlib_private.h:46
float float32
Definition: g3dmath.h:172
int32_t int32
Definition: Define.h:146
uint32_t uint32
Definition: Define.h:150
unsigned int UInt32
Definition: bzlib_private.h:45
uint64_t uint64
Definition: Define.h:149
uint16_t uint16
Definition: Define.h:151
G3DEndian
The order in which the bytes of an integer are stored on a machine.
Definition: System.h:48
int64_t int64
Definition: g3dmath.h:169
uint8_t uint8
Definition: g3dmath.h:164
int Int32
Definition: bzlib_private.h:44
int32_t int32
Definition: g3dmath.h:167
uint8_t uint8
Definition: Define.h:152
int16_t int16
Definition: Define.h:147
uint32_t uint32
Definition: g3dmath.h:168
unsigned short UInt16
Definition: bzlib_private.h:47