Sample: cleaning up Inheritance
[io/quag.git] / libs / basekit / source / BStream.h
blobca185f2ad34c75b4f701bc96825b9a2d6bd735f6
1 /*
2 docCopyright("Steve Dekorte", 2004)
3 docLicense("BSD revised")
4 docDescription("A Binary Stream, supports tagged items.")
5 */
7 #ifndef BSTREAM_DEFINED
8 #define BSTREAM_DEFINED 1
10 #include "Common.h"
11 #include "UArray.h"
12 #include "BStreamTag.h"
14 #ifdef __cplusplus
15 extern "C" {
16 #endif
18 //typedef struct UArray UArray;
20 typedef struct
22 UArray *ba;
23 size_t index;
24 unsigned char ownsUArray;
25 UArray *tmp;
26 UArray *errorBa;
27 int flipEndian;
28 unsigned char *typeBuf;
29 } BStream;
32 #define BStream_ba_(self, v) self->ba = v;
33 #define BStream_ba(self) (self->ba)
35 #define BStream_index_(self, v) self->index = v;
36 #define BStream_index(self) (self->index)
38 #define BStream_ownsUArray_(self, v) self->ownsUArray = v;
39 #define BStream_ownsUArray(self) (self->ownsUArray)
41 #define BStream_tmp_(self, v) self->tmp = v;
42 #define BStream_tmp(self) (self->tmp)
44 #define BStream_errorBa_(self, v) self->errorBa = v;
45 #define BStream_errorBa(self) (self->errorBa)
47 #define BStream_flipEndian_(self, v) self->flipEndian = v;
48 #define BStream_flipEndian(self) (self->flipEndian)
50 #define BStream_typeBuf_(self, v) self->typeBuf = v;
51 #define BStream_typeBufs(self) (self->typeBuf)
54 BASEKIT_API BStream *BStream_new(void);
55 BASEKIT_API BStream *BStream_clone(BStream *self);
56 BASEKIT_API void BStream_free(BStream *self);
58 BASEKIT_API char *BStream_errorString(BStream *self);
59 BASEKIT_API void BStream_setUArray_(BStream *self, UArray *ba);
60 BASEKIT_API void BStream_setData_length_(BStream *self, unsigned char *data, size_t length);
61 BASEKIT_API UArray *BStream_byteArray(BStream *self);
62 BASEKIT_API void BStream_empty(BStream *self);
63 BASEKIT_API int BStream_isEmpty(BStream *self);
65 // writing --------------------------------------
67 BASEKIT_API void BStream_writeByte_(BStream *self, unsigned char v);
69 BASEKIT_API void BStream_writeUint8_(BStream *self, uint8_t v);
70 BASEKIT_API void BStream_writeUint32_(BStream *self, uint32_t v);
71 BASEKIT_API void BStream_writeInt32_(BStream *self, int32_t v);
72 #if !defined(__SYMBIAN32__)
73 BASEKIT_API void BStream_writeInt64_(BStream *self, int64_t v);
74 #endif
75 BASEKIT_API void BStream_writeDouble_(BStream *self, double v);
76 BASEKIT_API void BStream_writeData_length_(BStream *self, const unsigned char *data, size_t length);
77 BASEKIT_API void BStream_writeCString_(BStream *self, const char *s);
78 BASEKIT_API void BStream_writeUArray_(BStream *self, UArray *ba);
80 // reading --------------------------------------
82 BASEKIT_API unsigned char BStream_readByte(BStream *self);
84 BASEKIT_API uint8_t BStream_readUint8(BStream *self);
85 BASEKIT_API uint32_t BStream_readUint32(BStream *self);
86 BASEKIT_API int32_t BStream_readInt32(BStream *self);
87 #if !defined(__SYMBIAN32__)
88 BASEKIT_API int64_t BStream_readInt64(BStream *self);
89 #endif
90 BASEKIT_API double BStream_readDouble(BStream *self);
91 BASEKIT_API uint8_t *BStream_readDataOfLength_(BStream *self, size_t length);
92 BASEKIT_API void BStream_readUArray_(BStream *self, UArray *b);
93 BASEKIT_API UArray *BStream_readUArray(BStream *self);
94 BASEKIT_API const char *BStream_readCString(BStream *self);
96 // tagged writing --------------------------------------
98 BASEKIT_API void BStream_writeTaggedUint8_(BStream *self, uint8_t v);
99 BASEKIT_API void BStream_writeTaggedUint32_(BStream *self, uint32_t v);
100 BASEKIT_API void BStream_writeTaggedInt32_(BStream *self, int32_t v);
101 #if !defined(__SYMBIAN32__)
102 BASEKIT_API void BStream_writeTaggedInt64_(BStream *self, int64_t v);
103 #endif
104 BASEKIT_API void BStream_writeTaggedDouble_(BStream *self, double v);
105 BASEKIT_API void BStream_writeTaggedData_length_(BStream *self, const unsigned char *data, size_t length);
106 BASEKIT_API void BStream_writeTaggedCString_(BStream *self, const char *s);
107 BASEKIT_API void BStream_writeTaggedUArray_(BStream *self, UArray *ba);
109 // tagged reading --------------------------------------
111 BASEKIT_API uint8_t BStream_readTaggedUint8(BStream *self);
112 BASEKIT_API uint32_t BStream_readTaggedUint32(BStream *self);
113 BASEKIT_API int32_t BStream_readTaggedInt32(BStream *self);
114 #if !defined(__SYMBIAN32__)
115 BASEKIT_API int64_t BStream_readTaggedInt64(BStream *self);
116 #endif
117 BASEKIT_API double BStream_readTaggedDouble(BStream *self);
118 BASEKIT_API void BStream_readTaggedUArray_(BStream *self, UArray *b);
119 BASEKIT_API UArray *BStream_readTaggedUArray(BStream *self);
120 BASEKIT_API const char *BStream_readTaggedCString(BStream *self);
122 BASEKIT_API void BStream_show(BStream *self);
124 #ifdef __cplusplus
126 #endif
127 #endif