Stream
The Stream class is a multi uses class that store a binary stream
Public member functions
Stream();
Stream(const Stream &stream);
Stream(const std::vector<unsigned char> &buffer);
Stream(const std::string &str);
Stream(const char str[], size_t size);
~Stream();
void operator += (const Stream &stream);
void operator += (const unsigned char &data);
void operator += (const std::string &str);
Stream operator = (const Stream &stream);
unsigned char operator[](size_t n);
const std::vector<unsigned char> &getBuffer() const;
size_t size() const;
void clear();
Stream subStream(size_t pos) const;
Stream subStream(size_t pos, size_t len) const;
std::string toString() const;
void setDataCharArray(const char *data, size_t size);
void setDataUInt(unsigned int data);
void setDataUShort(unsigned short data);
void setDataUChar(unsigned char data);
void setDataInt(int data);
void setDataShort(short data);
void setDataChar(char data);
unsigned int getDataUInt();
unsigned short getDataUShort();
unsigned char getDataUChar();
int getDataInt();
short getDataShort();
char getDataChar();Private attributes
Member functions documentation
Constructor
Parameters
stream:The Stream to copybuffer:The buffer to copystr:The string to put as buffersize:The size of the string if needed
operator+=
This operator concat another binary data to the current object
Parameters
stream:The stream to concatdata:The single byte to concatstr:The string that contain binary data to concat
operator=
This operator change the buffer of the current object
Parameters
stream:The source stream
operator[]
This operator return the value at the position n of the buffer
getBuffer
This method return the buffer that contain the binary data
size
This method return the size of the binary data in bytes
clear
This method clear the binary data
subStream
This method return newly constructed Stream object with its value initialized to a copy of a substream of this object.
Parameters
pos:Position of the first byte to put in the substreamlen:The number of byte to includes in the substream
toString
This method return the stream in form of a std::string.
setData
This bunch of methods concat binary data to the Stream object.
Parameters
data:The varable you want to append in the Streamsize:The number of byte you want to append if needed
getData
This bunch of methods extract a binary data from the Stream object and return it
Last updated