Samchon Framework for CPP
1.0.0
|
Binary data class. More...
#include <ByteArray.hpp>
Public Member Functions | |
ByteArray () | |
Default Constructor. More... | |
ByteArray (const ByteArray &) | |
Copy Constructor. More... | |
ByteArray (ByteArray &&) | |
Move Constructor. More... | |
auto | getPosition () const -> size_t |
Get position. More... | |
void | setPosition (size_t) |
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 30 of file ByteArray.hpp.
ByteArray::ByteArray | ( | ) |
ByteArray::ByteArray | ( | const ByteArray & | byteArray | ) |
ByteArray::ByteArray | ( | ByteArray && | byteArray | ) |
auto ByteArray::getPosition | ( | ) | const -> size_t |
Get position.
Get a position represents starting point of bytes to read
Definition at line 46 of file ByteArray.cpp.
References position.
Referenced by samchon::protocol::IWebClientBase::listen(), and samchon::protocol::IClient::listen().
void ByteArray::setPosition | ( | size_t | val | ) |
Set poisition.
Set a position represents starting point of bytes to read
Definition at line 50 of file ByteArray.cpp.
References position.
Referenced by samchon::protocol::IClient::listen().
|
inlinestatic |
Reverse byte ordering.
Creates a copy of data which of byte ordering is reversed.
Definition at line 96 of file ByteArray.hpp.
|
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 121 of file ByteArray.hpp.
Referenced by samchon::protocol::IWebClientBase::listen(), samchon::protocol::IClient::listen(), and samchon::protocol::IWebServer::open().
|
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 152 of file ByteArray.hpp.
Referenced by samchon::protocol::IWebClientBase::listen().
|
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 168 of file ByteArray.hpp.
Referenced by samchon::protocol::IWebClientBase::listen(), and samchon::protocol::IWebClientBase::sendData().
|
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 193 of file ByteArray.hpp.
Referenced by samchon::protocol::IWebServer::open(), samchon::protocol::IWebClientBase::sendData(), and samchon::protocol::service::Client::sendData().
auto ByteArray::compress | ( | ) | const -> ByteArray |
Compress the binary data
.
Generates a binary data compressed from the ByteArray.
The binary data will be compressed by zlib library.
Definition at line 63 of file ByteArray.cpp.
auto ByteArray::decompress | ( | ) | const -> ByteArray |
Decompress the binary data.
Generates a decompressed binary data form the ByteArray.
The binary data will be decompressed by zlib library.
Definition at line 67 of file ByteArray.cpp.
|
private |
Current position of the ByteArray.
.
If you call read, starting pointer will be the position
Definition at line 43 of file ByteArray.hpp.
Referenced by ByteArray(), getPosition(), and setPosition().