Stream.h 772 B

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