Subversion Repositories HomeAutomation

Rev

Rev 1326 | Details | Compare with Previous | 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>
1322 runge 13
#include "types.h"
1309 runge 14
 
15
namespace atom {
1319 runge 16
namespace message {
1309 runge 17
 
18
using namespace std;
19
 
20
class BitBuffer {
21
public:
1322 runge 22
    BitBuffer(byte_list bytes);
1309 runge 23
    BitBuffer();
24
    virtual ~BitBuffer();
25
 
1322 runge 26
    byte_list getAsBytes();
1328 runge 27
    void setFromBytes(byte_list bytes);
1309 runge 28
 
1328 runge 29
    unsigned int getSize();
30
    unsigned int getPointer();
1323 runge 31
    void incrementPointer(unsigned int steps);
32
    void clear();
33
 
1326 runge 34
    void read(unsigned int length, long & value);
35
    void read(unsigned int length, unsigned long & value);
36
    void read(unsigned int length, bool & value);
1309 runge 37
 
1326 runge 38
    void write(unsigned int length, long value);
39
    void write(unsigned int length, unsigned long value);
40
    void write(unsigned int length, bool value);
1309 runge 41
 
42
private:
1328 runge 43
    bit_list myBits;
44
    unsigned int myPointer;
45
 
46
    bool readBit();
47
    void writeBit(bool value);
1309 runge 48
};
49
 
50
}
51
}
52
 
53
#endif /* BITBUFFER_H_ */