DataVector.h 661 B

1234567891011121314151617181920212223242526272829
  1. #ifndef DATAVECTOR_H
  2. #define DATAVECTOR_H
  3. #include <cstddef>
  4. class DataVector final
  5. {
  6. public:
  7. DataVector(size_t capacity = 5 * 1024 * 1024);
  8. DataVector(const DataVector& orig);
  9. DataVector(DataVector&& other);
  10. ~DataVector();
  11. DataVector& operator=(const DataVector& other);
  12. DataVector& operator=(DataVector&& other);
  13. bool read(size_t fromIndex, void* buffer, size_t length) const;
  14. bool write(size_t toIndex, const void* data, size_t length);
  15. bool readSocket(int socket, size_t& readBytes);
  16. void sendToSocket(int socket, size_t toIndex) const;
  17. private:
  18. size_t capacity;
  19. char* data;
  20. };
  21. #endif