Stream.h 756 B

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