Details | Last modification | View Log | SVN | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 1309 | runge | 1 | /* |
| 2 | * BitBuffer.h |
||
| 3 | * |
||
| 4 | * Created on: Jul 17, 2009 |
||
| 5 | * Author: Mattias Runge |
||
| 6 | */ |
||
| 7 | |||
| 8 | #ifndef BITBUFFER_H_ |
||
| 9 | #define BITBUFFER_H_ |
||
| 10 | |||
| 11 | #include <vector> |
||
| 12 | #include <string> |
||
| 13 | |||
| 14 | namespace atom { |
||
| 15 | namespace utils { |
||
| 16 | |||
| 17 | using namespace std; |
||
| 18 | |||
| 19 | class BitBuffer { |
||
| 20 | public: |
||
| 21 | BitBuffer(unsigned char bytes[], unsigned int length); |
||
| 22 | BitBuffer(vector<unsigned char> bytes); |
||
| 23 | BitBuffer(string value); |
||
| 24 | BitBuffer(); |
||
| 25 | virtual ~BitBuffer(); |
||
| 26 | |||
| 27 | long readInteger(unsigned int length); |
||
| 28 | void writeInteger(unsigned int length, long value); |
||
| 29 | |||
| 30 | unsigned long readUnsignedInteger(unsigned int length); |
||
| 31 | void writeUnsignedInteger(unsigned int length, unsigned long value); |
||
| 32 | |||
| 33 | double readDecimal(unsigned int length, unsigned int scaling); |
||
| 34 | void writeDecimal(unsigned int length, unsigned int scaling, double value); |
||
| 35 | |||
| 36 | bool readBoolean(); |
||
| 37 | void writeBoolean(bool value); |
||
| 38 | |||
| 39 | vector<unsigned char> getAsBytes(); |
||
| 40 | void setFromBytes(vector<unsigned char> bytes); |
||
| 41 | |||
| 42 | string getAsString(); |
||
| 43 | void setFromString(string value); |
||
| 44 | |||
| 45 | private: |
||
| 46 | vector<unsigned char> myBuffer; |
||
| 47 | }; |
||
| 48 | |||
| 49 | } |
||
| 50 | } |
||
| 51 | |||
| 52 | #endif /* BITBUFFER_H_ */ |