Subversion Repositories HomeAutomation

Rev

Rev 1323 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | SVN | RSS feed

  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. #include "types.h"
  14.  
  15. namespace atom {
  16. namespace message {
  17.  
  18. using namespace std;
  19.  
  20. class BitBuffer {
  21. public:
  22.     BitBuffer(unsigned char bytes[], unsigned int length);
  23.     BitBuffer(byte_list bytes);
  24.     BitBuffer();
  25.     virtual ~BitBuffer();
  26.  
  27.     byte_list getAsBytes();
  28.     void setFromBytes(vector<unsigned char> bytes);
  29.  
  30.     void incrementPointer(unsigned int steps);
  31.     void clear();
  32.  
  33.     void read(unsigned int length, long & value);
  34.     void read(unsigned int length, unsigned long & value);
  35.     void read(unsigned int length, bool & value);
  36.  
  37.     void write(unsigned int length, long value);
  38.     void write(unsigned int length, unsigned long value);
  39.     void write(unsigned int length, bool value);
  40.  
  41. private:
  42.     byte_list myBuffer;
  43. };
  44.  
  45. }
  46. }
  47.  
  48. #endif /* BITBUFFER_H_ */
  49.