2 docCopyright("Steve Dekorte", 2004)
3 docLicense("BSD revised")
4 docDescription("A Binary Stream, supports tagged items.")
7 #ifndef BSTREAM_DEFINED
8 #define BSTREAM_DEFINED 1
12 #include "BStreamTag.h"
18 //typedef struct UArray UArray;
24 unsigned char ownsUArray
;
28 unsigned char *typeBuf
;
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
);
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
);
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
);
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
);
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
);