cpp-msgpack-light 0.3.0
A light library to serialize MessagePack.
Loading...
Searching...
No Matches
msgpack_light::binary Class Reference

Class of binary data. More...

#include <msgpack_light/binary.h>

Collaboration diagram for msgpack_light::binary:

Public Member Functions

 binary ()
 Constructor.
 binary (binary_view data)
 Constructor.
 binary (const std::vector< unsigned char > &data)
 Constructor.
 binary (const unsigned char *data, std::size_t size)
 Constructor.
 binary (std::initializer_list< unsigned char > data)
 Constructor.
 binary (std::size_t size)
 Constructor.
 binary (std::string_view data_string)
 Constructor.
void append (const unsigned char *data, std::size_t size)
 Append another binary data.
std::size_t capacity () const noexcept
 Get the size of the internal buffer for data.
const unsigned char * data () const noexcept
 Get the pointer to the data.
unsigned char * data () noexcept
 Get the pointer to the data.
bool operator!= (const binary &other) const noexcept
 Compare with another instance.
binaryoperator+= (const binary &other)
 Append another binary data.
bool operator== (const binary &other) const noexcept
 Compare with another instance.
unsigned char operator[] (std::size_t index) const noexcept
 Access to a byte.
unsigned char & operator[] (std::size_t index) noexcept
 Access to a byte.
void reserve (std::size_t size)
 Change the size of the internal buffer.
void resize (std::size_t size)
 Change the size of this data.
std::size_t size () const noexcept
 Get the size of the data.

Private Attributes

details::basic_binary_buffer buffer_
 Buffer.
std::size_t size_
 Size.

Detailed Description

Class of binary data.

Definition at line 129 of file binary.h.

Constructor & Destructor Documentation

◆ binary() [1/7]

msgpack_light::binary::binary ( )
inline

Constructor.

Create empty data.

Definition at line 136 of file binary.h.

◆ binary() [2/7]

msgpack_light::binary::binary ( std::size_t size)
inlineexplicit

Constructor.

Create a buffer with uninitialized data.

Parameters
[in]sizeSize of the buffer.

Definition at line 145 of file binary.h.

◆ binary() [3/7]

msgpack_light::binary::binary ( const unsigned char * data,
std::size_t size )
inline

Constructor.

Parameters
[in]dataPointer to the data.
[in]sizeSize of the data.

Definition at line 153 of file binary.h.

◆ binary() [4/7]

msgpack_light::binary::binary ( binary_view data)
inlineexplicit

Constructor.

Parameters
[in]dataData.

Definition at line 165 of file binary.h.

◆ binary() [5/7]

msgpack_light::binary::binary ( const std::vector< unsigned char > & data)
inlineexplicit

Constructor.

Parameters
[in]dataData.

Definition at line 172 of file binary.h.

◆ binary() [6/7]

msgpack_light::binary::binary ( std::initializer_list< unsigned char > data)
inline

Constructor.

Parameters
[in]dataData.

Definition at line 180 of file binary.h.

◆ binary() [7/7]

msgpack_light::binary::binary ( std::string_view data_string)
inlineexplicit

Constructor.

Note
This function accepts hex expression of data written with numeric characters from 0 to 9 and uppercase characters from A to F.
Warning
Current implementation doesn't accept lowercase characters from a to f.
Parameters
[in]data_stringHex expression of data.

Definition at line 195 of file binary.h.

Member Function Documentation

◆ append()

void msgpack_light::binary::append ( const unsigned char * data,
std::size_t size )
inline

Append another binary data.

Parameters
[in]dataPointer to the appended data.
[in]sizeSize of the appended data.

Definition at line 257 of file binary.h.

◆ capacity()

std::size_t msgpack_light::binary::capacity ( ) const
inlinenodiscardnoexcept

Get the size of the internal buffer for data.

Returns
Size of the internal buffer.

Definition at line 327 of file binary.h.

◆ data() [1/2]

const unsigned char * msgpack_light::binary::data ( ) const
inlinenodiscardnoexcept

Get the pointer to the data.

Returns
Pointer to the data.

Definition at line 311 of file binary.h.

◆ data() [2/2]

unsigned char * msgpack_light::binary::data ( )
inlinenodiscardnoexcept

Get the pointer to the data.

Returns
Pointer to the data.

Definition at line 304 of file binary.h.

◆ operator!=()

bool msgpack_light::binary::operator!= ( const binary & other) const
inlinenodiscardnoexcept

Compare with another instance.

Parameters
[in]otherAnother instance.
Return values
trueTwo instances are not equal.
falseTwo instances are equal.

Definition at line 350 of file binary.h.

◆ operator+=()

binary & msgpack_light::binary::operator+= ( const binary & other)
inline

Append another binary data.

Parameters
[in]otherAnother binary data to append.
Returns
This.

Definition at line 274 of file binary.h.

◆ operator==()

bool msgpack_light::binary::operator== ( const binary & other) const
inlinenodiscardnoexcept

Compare with another instance.

Parameters
[in]otherAnother instance.
Return values
trueTwo instances are equal.
falseTwo instances are not equal.

Definition at line 338 of file binary.h.

◆ operator[]() [1/2]

unsigned char msgpack_light::binary::operator[] ( std::size_t index) const
inlinenodiscardnoexcept

Access to a byte.

Parameters
[in]indexIndex of the byte.
Returns
Value of the byte.

Definition at line 295 of file binary.h.

◆ operator[]() [2/2]

unsigned char & msgpack_light::binary::operator[] ( std::size_t index)
inlinenodiscardnoexcept

Access to a byte.

Parameters
[in]indexIndex of the byte.
Returns
Reference to the byte.

Definition at line 285 of file binary.h.

◆ reserve()

void msgpack_light::binary::reserve ( std::size_t size)
inline

Change the size of the internal buffer.

This function preserves the existing data and its size.

Parameters
[in]sizeNew size.

Definition at line 245 of file binary.h.

◆ resize()

void msgpack_light::binary::resize ( std::size_t size)
inline

Change the size of this data.

This function preserves the existing data. Additional bytes will be left uninitialized.

Parameters
[in]sizeNew size.

Definition at line 231 of file binary.h.

◆ size()

std::size_t msgpack_light::binary::size ( ) const
inlinenodiscardnoexcept

Get the size of the data.

Returns
Size of the data.

Definition at line 320 of file binary.h.

Member Data Documentation

◆ buffer_

details::basic_binary_buffer msgpack_light::binary::buffer_
private

Buffer.

Definition at line 356 of file binary.h.

◆ size_

std::size_t msgpack_light::binary::size_
private

Size.

Definition at line 359 of file binary.h.


The documentation for this class was generated from the following file: