edits
[iotcloud.git] / version2 / src / C / ByteBuffer.h
1 #ifndef BYTEBUFFER_H
2 #define BYTEBUFFER_H
3 #include "common.h"
4
5 class ByteBuffer {
6 public:
7         void put(char c);
8         void putInt(int32_t l);
9         void putLong(int64_t l);
10         void put(Array<char> *array);
11         int64_t getLong();
12         int32_t getInt();
13         char get();
14         void get(Array<char> *array);
15         void position(int32_t newPosition);
16         void releaseArray() {buffer = NULL;}
17         Array<char> *array();
18         ~ByteBuffer() {if (buffer != NULL) delete buffer;}
19         
20  private:
21         ByteBuffer(Array<char> *array);
22         friend ByteBuffer *ByteBuffer_wrap(Array<char> *array);
23         friend ByteBuffer *ByteBuffer_allocate(uint size);
24         Array<char> *buffer;
25         uint offset;
26 };
27 ByteBuffer *ByteBuffer_wrap(Array<char> *array);
28 ByteBuffer *ByteBuffer_allocate(uint size);
29 #endif