Maps SDK for C++ 1.0.0
Loading...
Searching...
No Matches
gem::DataBuffer Class Reference

DataBuffer object. More...

Inheritance diagram for gem::DataBuffer:
Collaboration diagram for gem::DataBuffer:

Public Member Functions

template<typename T>
 DataBuffer (const std::vector< T > &vect)
 Constructor from a vector of type T.
 DataBuffer (const String &str)
 Constructor from string.
 DataBuffer (const std::string &str)
 Constructor from std string.
 DataBuffer (void const *data, size_t size)
 Constructor from data and size.
 DataBuffer (int size)
 Constructor and reserve the given size.
 DataBuffer (const DataBuffer &)=default
 Default copy constructor.
 DataBuffer (DataBuffer &&)=default
 Default move constructor noexcept is deduced.
DataBuffer & operator= (const DataBuffer &data)=default
 Default copy assignment.
DataBuffer & operator= (DataBuffer &&data)=default
 Default move assignment.
bool operator== (DataBuffer const &data) const noexcept
 Comparison operator equal.
bool operator!= (DataBuffer const &data) const noexcept
 Comparison operator not equal.
int size () const noexcept
 Gets the size of the data buffer in bytes.
bool empty () const noexcept
 Check if data buffer is empty.
template<typename TData = void>
const TData * getBytes () const noexcept
 Get const pointer to the bytes in the buffer.
template<typename TData = void>
TData * getBytes () noexcept
 Get pointer to the bytes in the buffer.
int setData (void const *data, int size) noexcept
 Sets the new content for the data buffer.
int reserve (int size) noexcept
 Reserve data size.
String toString () const noexcept
 Convert binary data to base64 string.
DataBuffer & fromString (const String &str) noexcept
 Convert base64 string to binary data.
virtual void attach (void *data, int size) noexcept
 Attach object to binary buffer.

Detailed Description

DataBuffer object.

Implements share-read / copy-on-write Api object over IDataBuffer.

Constructor & Destructor Documentation

◆ DataBuffer() [1/5]

template<typename T>
gem::DataBuffer::DataBuffer ( const std::vector< T > & vect)
inline

Constructor from a vector of type T.

Parameters
[in]vectVector containing initial data to store in the buffer.

◆ DataBuffer() [2/5]

gem::DataBuffer::DataBuffer ( const String & str)
inline

Constructor from string.

Parameters
[in]strString containing initial data to store in the buffer

◆ DataBuffer() [3/5]

gem::DataBuffer::DataBuffer ( const std::string & str)
inline

Constructor from std string.

Parameters
[in]strString containing initial data to store in the buffer

◆ DataBuffer() [4/5]

gem::DataBuffer::DataBuffer ( void const * data,
size_t size )
inline

Constructor from data and size.

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

◆ DataBuffer() [5/5]

gem::DataBuffer::DataBuffer ( int size)
inline

Constructor and reserve the given size.

Parameters
[in]sizeSize in bytes to reserve.

Member Function Documentation

◆ attach()

virtual void gem::DataBuffer::attach ( void * data,
int size )
inlinevirtualnoexcept

Attach object to binary buffer.

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

◆ empty()

bool gem::DataBuffer::empty ( ) const
inlinenoexcept

Check if data buffer is empty.

Returns
True if the buffer is empty, false otherwise.

◆ fromString()

DataBuffer & gem::DataBuffer::fromString ( const String & str)
inlinenoexcept

Convert base64 string to binary data.

Parameters
[in]strString containing the base64 data.
Returns
A reference to the current DataBuffer object, allowing for method chaining.

◆ getBytes() [1/2]

template<typename TData = void>
const TData * gem::DataBuffer::getBytes ( ) const
inlinenoexcept

Get const pointer to the bytes in the buffer.

Template Parameters
TDataThe type of the data to retrieve.
Returns
Pointer to the data, cast to type TData.

◆ getBytes() [2/2]

template<typename TData = void>
TData * gem::DataBuffer::getBytes ( )
inlinenoexcept

Get pointer to the bytes in the buffer.

Template Parameters
TDataThe type of the data to retrieve.
Returns
Pointer to the data, cast to type TData.

◆ operator!=()

bool gem::DataBuffer::operator!= ( DataBuffer const & data) const
inlinenoexcept

Comparison operator not equal.

Parameters
[in]dataAnother DataBuffer object to compare with.
Returns
True if the contents of both DataBuffers are not equal, false otherwise.

◆ operator=() [1/2]

DataBuffer & gem::DataBuffer::operator= ( const DataBuffer & data)
default

Default copy assignment.

Parameters
[in]dataThe DataBuffer object to copy from.
Returns
A reference to this DataBuffer object after copying the data.

◆ operator=() [2/2]

DataBuffer & gem::DataBuffer::operator= ( DataBuffer && data)
default

Default move assignment.

Parameters
[in]dataThe DataBuffer object to move from.
Returns
A reference to this DataBuffer object after the data has been moved. noexcept is deduced

◆ operator==()

bool gem::DataBuffer::operator== ( DataBuffer const & data) const
inlinenoexcept

Comparison operator equal.

Parameters
[in]dataAnother DataBuffer object to compare with.
Returns
True if the contents of both DataBuffers are equal, false otherwise.

◆ reserve()

int gem::DataBuffer::reserve ( int size)
inlinenoexcept

Reserve data size.

Parameters
[in]sizeSize in bytes to reserve.
Returns
An error code indicating the success or failure of the operation.

◆ setData()

int gem::DataBuffer::setData ( void const * data,
int size )
inlinenoexcept

Sets the new content for the data buffer.

Parameters
[in]dataPointer to the data to set.
[in]sizeSize of the data in bytes.
Returns
An error code indicating the success or failure of the operation.

◆ size()

int gem::DataBuffer::size ( ) const
inlinenoexcept

Gets the size of the data buffer in bytes.

Returns
The size of the data buffer.

◆ toString()

String gem::DataBuffer::toString ( ) const
inlinenoexcept

Convert binary data to base64 string.

Convert binary data to a base64 string.

Returns
A string representation of the data buffer.