1 | #ifndef STREAM_H
|
---|
2 | #define STREAM_H
|
---|
3 |
|
---|
4 | #include "NxStream.h"
|
---|
5 |
|
---|
6 | class UserStream : public NxStream
|
---|
7 | {
|
---|
8 | public:
|
---|
9 | UserStream(const char* filename, bool load);
|
---|
10 | virtual ~UserStream();
|
---|
11 |
|
---|
12 | virtual NxU8 readByte() const;
|
---|
13 | virtual NxU16 readWord() const;
|
---|
14 | virtual NxU32 readDword() const;
|
---|
15 | virtual float readFloat() const;
|
---|
16 | virtual double readDouble() const;
|
---|
17 | virtual void readBuffer(void* buffer, NxU32 size) const;
|
---|
18 |
|
---|
19 | virtual NxStream& storeByte(NxU8 b);
|
---|
20 | virtual NxStream& storeWord(NxU16 w);
|
---|
21 | virtual NxStream& storeDword(NxU32 d);
|
---|
22 | virtual NxStream& storeFloat(NxReal f);
|
---|
23 | virtual NxStream& storeDouble(NxF64 f);
|
---|
24 | virtual NxStream& storeBuffer(const void* buffer, NxU32 size);
|
---|
25 |
|
---|
26 | FILE* fp;
|
---|
27 | };
|
---|
28 |
|
---|
29 | class MemoryWriteBuffer : public NxStream
|
---|
30 | {
|
---|
31 | public:
|
---|
32 | MemoryWriteBuffer();
|
---|
33 | virtual ~MemoryWriteBuffer();
|
---|
34 | void clear();
|
---|
35 |
|
---|
36 | virtual NxU8 readByte() const { NX_ASSERT(0); return 0; }
|
---|
37 | virtual NxU16 readWord() const { NX_ASSERT(0); return 0; }
|
---|
38 | virtual NxU32 readDword() const { NX_ASSERT(0); return 0; }
|
---|
39 | virtual float readFloat() const { NX_ASSERT(0); return 0.0f;}
|
---|
40 | virtual double readDouble() const { NX_ASSERT(0); return 0.0; }
|
---|
41 | virtual void readBuffer(void* buffer, NxU32 size) const { NX_ASSERT(0); }
|
---|
42 |
|
---|
43 | virtual NxStream& storeByte(NxU8 b);
|
---|
44 | virtual NxStream& storeWord(NxU16 w);
|
---|
45 | virtual NxStream& storeDword(NxU32 d);
|
---|
46 | virtual NxStream& storeFloat(NxReal f);
|
---|
47 | virtual NxStream& storeDouble(NxF64 f);
|
---|
48 | virtual NxStream& storeBuffer(const void* buffer, NxU32 size);
|
---|
49 |
|
---|
50 | NxU32 currentSize;
|
---|
51 | NxU32 maxSize;
|
---|
52 | NxU8* data;
|
---|
53 | };
|
---|
54 |
|
---|
55 | class MemoryReadBuffer : public NxStream
|
---|
56 | {
|
---|
57 | public:
|
---|
58 | MemoryReadBuffer(const NxU8* data);
|
---|
59 | virtual ~MemoryReadBuffer();
|
---|
60 |
|
---|
61 | virtual NxU8 readByte() const;
|
---|
62 | virtual NxU16 readWord() const;
|
---|
63 | virtual NxU32 readDword() const;
|
---|
64 | virtual float readFloat() const;
|
---|
65 | virtual double readDouble() const;
|
---|
66 | virtual void readBuffer(void* buffer, NxU32 size) const;
|
---|
67 |
|
---|
68 | virtual NxStream& storeByte(NxU8 b) { NX_ASSERT(0); return *this; }
|
---|
69 | virtual NxStream& storeWord(NxU16 w) { NX_ASSERT(0); return *this; }
|
---|
70 | virtual NxStream& storeDword(NxU32 d) { NX_ASSERT(0); return *this; }
|
---|
71 | virtual NxStream& storeFloat(NxReal f) { NX_ASSERT(0); return *this; }
|
---|
72 | virtual NxStream& storeDouble(NxF64 f) { NX_ASSERT(0); return *this; }
|
---|
73 | virtual NxStream& storeBuffer(const void* buffer, NxU32 size) { NX_ASSERT(0); return *this; }
|
---|
74 |
|
---|
75 | mutable const NxU8* buffer;
|
---|
76 | };
|
---|
77 |
|
---|
78 | #endif |
---|