Stream.h 809 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #ifndef STREAM_H
  2. #define STREAM_H
  3. #include <cstddef>
  4. #include <cstdint>
  5. #include "common/utils/DataVector.h"
  6. class Stream
  7. {
  8. public:
  9. Stream();
  10. Stream(size_t capacity);
  11. bool readSocket(int socket);
  12. void sendToSocket(int socket) const;
  13. bool hasData() const;
  14. bool hasError() const;
  15. void clearError();
  16. void write(const void* writeData, size_t length);
  17. void write(const char* writeData);
  18. void writeUnsignedChar(uint8_t uc);
  19. void writeUnsignedShort(uint16_t us);
  20. void writeUnsignedInt(uint32_t ui);
  21. void read(void* buffer, size_t length);
  22. uint8_t readUnsignedChar();
  23. uint16_t readUnsignedShort();
  24. uint32_t readUnsignedInt();
  25. private:
  26. DataVector data;
  27. bool error;
  28. size_t writeIndex;
  29. size_t readIndex;
  30. };
  31. #endif