Samchon Framework for CPP
1.0.0
|
Binary data class. More...
#include <ByteArray.hpp>
Public Member Functions | |
ByteArray () | |
Default Constructor. More... | |
ByteArray (const ByteArray &obj) | |
Copy Constructor. More... | |
ByteArray (ByteArray &&obj) | |
Move Constructor. More... | |
auto | get_position () const -> size_t |
Get position. More... | |
void | set_position (size_t val) |
Set poisition. More... | |
template<typename T > | |
auto | read () const -> T |
Read data. More... | |
template<typename T > | |
auto | readReversely () const -> T |
Read a reversed data. More... | |
template<typename T > | |
void | write (const T &val) |
Write a data. More... | |
template<typename T > | |
void | writeReversely (const T &val) |
Write a data. More... | |
auto | compress () const -> ByteArray |
Compress the binary data . More... | |
auto | decompress () const -> ByteArray |
Decompress the binary data. More... | |
Static Public Member Functions | |
template<typename T > | |
static auto | reverse (const T &val) -> T |
Reverse byte ordering. More... | |
Private Attributes | |
size_t | position |
Current position of the ByteArray. . More... | |
Binary data class.
ByteArray is the standard class for handling binary data in Samchon Framework.
ByteArray provides methods for reading and writing binary data.
In addition, zlib compression and decompression are supported.
ByteArray is a class only for advanced developer who can access data on byte level as the reason of:
If you're not trying to use ByteArray as the reason of what I've mentioned but only for representing entity data, I recomment you to use Entity instead.
Definition at line 29 of file ByteArray.hpp.
|
inline |
Default Constructor.
Definition at line 53 of file ByteArray.hpp.
|
inline |
Copy Constructor.
Definition at line 61 of file ByteArray.hpp.
|
inline |
|
inline |
Get position.
Get a position represents starting point of bytes to read
Definition at line 98 of file ByteArray.hpp.
References position.
|
inline |
Set poisition.
Set a position represents starting point of bytes to read
Definition at line 108 of file ByteArray.hpp.
References position.
|
inlinestatic |
Reverse byte ordering.
Creates a copy of data which of byte ordering is reversed.
Definition at line 125 of file ByteArray.hpp.
Referenced by readReversely(), and writeReversely().
|
inline |
Read data.
Reads a data(_Ty) from (starting) position of the ByteArray and adds the position following the size.
_Ty | A type of data to be returned |
exception | out of range |
Definition at line 150 of file ByteArray.hpp.
References position.
|
inline |
Read a reversed data.
Reads data(_Ty) from (starting) position of the ByteArray, which byte ordering is reversed, from the ByteArray and adds the position following the size.
_Ty | A type of data to be returned |
exception | out of range |
Definition at line 181 of file ByteArray.hpp.
References reverse().
|
inline |
Write a data.
Writes a data(_Ty) to tail of the ByteArray
_Ty | A type of data to write |
val | Something to write on ByteArray |
Definition at line 197 of file ByteArray.hpp.
Referenced by samchon::protocol::WebCommunicator::sendData(), and writeReversely().
|
inline |
Write a data.
Writes a data(_Ty), which byte order is reversed, to tail of the ByteArray
_Ty | A type of data to write |
val | Something to write on ByteArray |
Definition at line 222 of file ByteArray.hpp.
References reverse(), and write().
Referenced by samchon::protocol::WebCommunicator::sendData(), and samchon::protocol::Communicator::sendData().
|
inline |
Compress the binary data
.
Generates a binary data compressed from the ByteArray.
The binary data will be compressed by zlib library.
Definition at line 239 of file ByteArray.hpp.
|
inline |
Decompress the binary data.
Generates a decompressed binary data form the ByteArray.
The binary data will be decompressed by zlib library.
Definition at line 253 of file ByteArray.hpp.
|
private |
Current position of the ByteArray.
.
If you call read, starting pointer will be the position
Definition at line 42 of file ByteArray.hpp.
Referenced by ByteArray(), get_position(), read(), and set_position().