Advertisement
Guest User

buffer.h

a guest
Nov 5th, 2016
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.88 KB | None | 0 0
  1. #ifndef BUFFER_H
  2. #define BUFFER_H
  3.  
  4. class Buffer
  5. {
  6.     public:
  7.         Buffer(long long _size);
  8.         virtual ~Buffer();
  9.  
  10.         long long Size();
  11.         long long Read();
  12.         long long Written();
  13.         long long RemainingSpace(); // you cannot write past the limit of the buffer
  14.         long long RemainingData(); // you cannot read if there is nothing written
  15.         void Reset(); // when you want to reuse the buffer just reset it
  16.         unsigned char* GetArray(); // returns the pointer to the underlying array
  17.  
  18.         bool tryWriteFloat(float);
  19.         bool tryWriteDouble(double);
  20.  
  21.         bool tryReadFloat(float&);
  22.         bool tryReadDouble(double&);
  23.  
  24.     private:
  25.         unsigned char* buffer;
  26.         long long size = 0;
  27.         long long read = 0; // how much was read
  28.         long long written = 0; // how much was written
  29. };
  30.  
  31. #endif // BUFFER_H
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement