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

Class of basic buffers for binary data. More...

#include <msgpack_light/details/basic_binary_buffer.h>

Collaboration diagram for msgpack_light::details::basic_binary_buffer:

Public Member Functions

 basic_binary_buffer (basic_binary_buffer &&other) noexcept
 Move constructor.
 basic_binary_buffer (const basic_binary_buffer &other)
 Copy constructor.
 basic_binary_buffer (std::size_t size)
 Constructor.
 ~basic_binary_buffer ()
 Destructor.
const unsigned char * data () const noexcept
 Get the pointer to the buffer.
unsigned char * data () noexcept
 Get the pointer to the buffer.
basic_binary_bufferoperator= (basic_binary_buffer &&other) noexcept
 Move assignment operator.
basic_binary_bufferoperator= (const basic_binary_buffer &other)
 Copy assignment operator.
void resize (std::size_t new_size)
 Change the size of the buffer.
std::size_t size () const noexcept
 Get the size of the buffer.
void swap (basic_binary_buffer &other) noexcept
 Swap with another instance.

Static Private Member Functions

static std::size_t prevent_unsafe_size (std::size_t size)
 Change the input to a size which won't cause implementation-defined behaviors of std::malloc and std::realloc functions.

Private Attributes

unsigned char * buffer_
 Buffer.
std::size_t size_
 Size of the buffer.

Detailed Description

Class of basic buffers for binary data.

Warning
This class is for internal implementations in this library, so omits some checks to avoid undefined behaviors or performance degradation intentionally with an assumption that the user of this class will avoid such conditions.

Definition at line 38 of file basic_binary_buffer.h.

Constructor & Destructor Documentation

◆ basic_binary_buffer() [1/3]

msgpack_light::details::basic_binary_buffer::basic_binary_buffer ( std::size_t size)
inlineexplicit

Constructor.

Parameters
[in]sizeSize of the buffer.

Definition at line 45 of file basic_binary_buffer.h.

◆ basic_binary_buffer() [2/3]

msgpack_light::details::basic_binary_buffer::basic_binary_buffer ( const basic_binary_buffer & other)
inline

Copy constructor.

Parameters
[in]otherInstance to copy from.

Definition at line 59 of file basic_binary_buffer.h.

◆ basic_binary_buffer() [3/3]

msgpack_light::details::basic_binary_buffer::basic_binary_buffer ( basic_binary_buffer && other)
inlinenoexcept

Move constructor.

Parameters
[in,out]otherInstance to move from.

Definition at line 69 of file basic_binary_buffer.h.

◆ ~basic_binary_buffer()

msgpack_light::details::basic_binary_buffer::~basic_binary_buffer ( )
inline

Destructor.

Definition at line 103 of file basic_binary_buffer.h.

Member Function Documentation

◆ data() [1/2]

const unsigned char * msgpack_light::details::basic_binary_buffer::data ( ) const
inlinenodiscardnoexcept

Get the pointer to the buffer.

Returns
Pointer to the buffer.

Definition at line 145 of file basic_binary_buffer.h.

◆ data() [2/2]

unsigned char * msgpack_light::details::basic_binary_buffer::data ( )
inlinenodiscardnoexcept

Get the pointer to the buffer.

Returns
Pointer to the buffer.

Definition at line 138 of file basic_binary_buffer.h.

◆ operator=() [1/2]

basic_binary_buffer & msgpack_light::details::basic_binary_buffer::operator= ( basic_binary_buffer && other)
inlinenoexcept

Move assignment operator.

Parameters
[in,out]otherInstance to move from.
Returns
This instance after move.

Definition at line 95 of file basic_binary_buffer.h.

◆ operator=() [2/2]

basic_binary_buffer & msgpack_light::details::basic_binary_buffer::operator= ( const basic_binary_buffer & other)
inline

Copy assignment operator.

Parameters
[in]otherInstance to copy from.
Returns
This instance after copy.

Definition at line 78 of file basic_binary_buffer.h.

◆ prevent_unsafe_size()

std::size_t msgpack_light::details::basic_binary_buffer::prevent_unsafe_size ( std::size_t size)
inlinestaticnodiscardprivate

Change the input to a size which won't cause implementation-defined behaviors of std::malloc and std::realloc functions.

Parameters
[in]sizeSize.
Returns
Size to use in std::malloc and std::realloc functions.

Definition at line 163 of file basic_binary_buffer.h.

◆ resize()

void msgpack_light::details::basic_binary_buffer::resize ( std::size_t new_size)
inline

Change the size of the buffer.

Parameters
[in]new_sizeNew size of the buffer.
Warning
This function always call std::realloc even when the argument is equal to the current size.

Definition at line 113 of file basic_binary_buffer.h.

◆ size()

std::size_t msgpack_light::details::basic_binary_buffer::size ( ) const
inlinenodiscardnoexcept

Get the size of the buffer.

Returns
Size of the buffer.

Definition at line 152 of file basic_binary_buffer.h.

◆ swap()

void msgpack_light::details::basic_binary_buffer::swap ( basic_binary_buffer & other)
inlinenoexcept

Swap with another instance.

Parameters
[in,out]otherInstance to swap with.

Definition at line 128 of file basic_binary_buffer.h.

Member Data Documentation

◆ buffer_

unsigned char* msgpack_light::details::basic_binary_buffer::buffer_
private

Buffer.

Definition at line 171 of file basic_binary_buffer.h.

◆ size_

std::size_t msgpack_light::details::basic_binary_buffer::size_
private

Size of the buffer.

Definition at line 174 of file basic_binary_buffer.h.


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