1234567891011121314151617181920212223242526272829303132333435363738394041 |
- #ifndef STREAM_H
- #define STREAM_H
- #include <cstddef>
- #include <cstdint>
- #include "common/utils/DataVector.h"
- class Stream
- {
- public:
- Stream();
- Stream(size_t capacity);
- bool readSocket(int socket);
- void sendToSocket(int socket) const;
-
- bool hasData() const;
- bool hasError() const;
- void clearError();
-
- void write(const void* writeData, size_t length);
- void write(const char* writeData);
- void writeUnsignedChar(uint8_t uc);
- void writeUnsignedShort(uint16_t us);
- void writeUnsignedInt(uint32_t ui);
-
- void read(void* buffer, size_t length);
- uint8_t readUnsignedChar();
- uint16_t readUnsignedShort();
- uint32_t readUnsignedInt();
-
- private:
- DataVector data;
- bool error;
- size_t writeIndex;
- size_t readIndex;
- };
- #endif
|