bitbuffer.h 552 B

1234567891011121314151617181920212223242526
  1. #ifndef NULLSOFT_UTILITY_BITBUFFER_H
  2. #define NULLSOFT_UTILITY_BITBUFFER_H
  3. #include <stddef.h>
  4. #ifdef _WIN32
  5. #include <stddef.h>
  6. #else
  7. #include <inttypes.h>
  8. #endif
  9. class BitBuffer
  10. {
  11. public:
  12. BitBuffer();
  13. void WriteBit(char bit);
  14. void WriteBits(uintptr_t num, size_t bitlen);
  15. void WriteBytes(void *buffer, size_t bytes);
  16. void WriteByte(unsigned char byte);
  17. unsigned char *Get() { return buffer; }
  18. size_t GetLength() { return length; }
  19. private:
  20. void Resize(size_t newlen);
  21. unsigned char *buffer;
  22. size_t length;
  23. size_t bits;
  24. };
  25. #endif