LibUDB 1.0
Loading...
Searching...
No Matches
UDBElement Class Reference

The UDBElement class. More...

#include <UDBElement.h>

Public Member Functions

 UDBElement (const UDBElement &other)
 UDBElement (UDBElement &&other)
UDBElementoperator= (const UDBElement &other)
 operator =
UDBElementoperator= (UDBElement &&other)
 operator =
bool operator== (const UDBElement &other) const
 operator ==
bool operator!= (const UDBElement &other) const
 operator !=
void writeToBuffer (std::vector< char > &buf)
size_t readFromBuffer (const std::vector< char > &buf, const size_t &start_pos)
size_t calculateWriteSize ()
void shrinkToFit ()

Public Attributes

std::string id
 Elements identification value (if any).
std::string content
 Elements content (if any).
std::vector< UDBElementsubelements
 Elements subelement (if any).

Detailed Description

The UDBElement class.

This class is suitable for database elements keeping.

Constructor & Destructor Documentation

◆ UDBElement() [1/2]

UDBElement::UDBElement ( const UDBElement & other)

Copy constructor.

Parameters
otherUDBElement to be copied.

◆ UDBElement() [2/2]

UDBElement::UDBElement ( UDBElement && other)

Move constructor.

Parameters
otherUDBElement to be moved.

Member Function Documentation

◆ calculateWriteSize()

size_t UDBElement::calculateWriteSize ( )

Calculates quantity of bytes will be written by writeToBuffer() method.

Returns
Quantity of bytes to be written.

◆ operator!=()

bool UDBElement::operator!= ( const UDBElement & other) const

operator !=

Parameters
otherUDBElement to be compared.
Returns
true if one of other elements is not equal to this UDBElement corresponding element, false otherwise.

◆ operator=() [1/2]

UDBElement & UDBElement::operator= ( const UDBElement & other)

operator =

Parameters
otherUDBElement to be copied.
Returns
Reference to this UDBElement object.

◆ operator=() [2/2]

UDBElement & UDBElement::operator= ( UDBElement && other)

operator =

Parameters
otherUDBElement to be moved.
Returns
Reference to this UDBElement object.

◆ operator==()

bool UDBElement::operator== ( const UDBElement & other) const

operator ==

Parameters
otherUDBElement to be compared.
Returns
true if all elements of other are equal to this UDBElement corresponding elements, false otherwise.

◆ readFromBuffer()

size_t UDBElement::readFromBuffer ( const std::vector< char > & buf,
const size_t & start_pos )

Tries to read UDBElement from buffer.

Note
This method can throw std::exception in case of errors.
Parameters
bufBuffer UDBElement should be read from.
start_posOffset of first byte to be read.
Returns
Quantity of bytes have been read.

◆ shrinkToFit()

void UDBElement::shrinkToFit ( )

Reduces memory usage by freeing unused memory in internal containers.

◆ writeToBuffer()

void UDBElement::writeToBuffer ( std::vector< char > & buf)

Writes this UDBElement to buffer buf.

Parameters
bufBuffer UDBElement should be written to.