SwatDB
Public Member Functions | Private Attributes | List of all members
Data Class Reference

#include <data.h>

Public Member Functions

 Data ()=delete
 Disable base constructor.
 
 Data (const Data &other)=delete
 Disable copy constructor.
 
Dataoperator= (const Data &other)=delete
 Disable copy assignment constructor.
 
 Data (std::uint32_t size, const char *other_data)
 Constructor with given char array and size. More...
 
 Data (std::uint32_t size, std::uint32_t capacity)
 Constructor with given size and capacity. More...
 
 Data (std::uint32_t capacity)
 Constructor with given capacity. More...
 
 ~Data ()
 Destructor. More...
 
char * getData ()
 Getter for data char array. More...
 
std::uint32_t getSize ()
 Getter for size. More...
 
void setSize (std::uint32_t new_size)
 Setter for size. More...
 
std::uint32_t getCapacity ()
 Getter for capacity. More...
 

Private Attributes

char * data
 
std::uint32_t size
 
std::uint32_t capacity
 

Detailed Description

SwatDB Data Class. Data a is class that allows storing and moving data of specified size in a more convenient way. A lot of times used as a serialized object that could be given structure by storing it as data member of another object with appropriate methods.

Constructor & Destructor Documentation

◆ Data() [1/3]

Data::Data ( std::uint32_t  size,
const char *  other_data 
)

Constructor with given char array and size.

Precondition
Valid char* and size are provided.
Postcondition
size bytes long char array is dynamically allocated and the size number of bytes are copied from the given char* pointer. size and capacity are set to the given size.

◆ Data() [2/3]

Data::Data ( std::uint32_t  size,
std::uint32_t  capacity 
)

Constructor with given size and capacity.

Precondition
None.
Postcondition
capacity bytes long char array is dynamically allocated and capacity is set to the given capacity. size is set to the given size.
Exceptions
InvalidSizeDataIf size is greater than capacity.

◆ Data() [3/3]

Data::Data ( std::uint32_t  capacity)

Constructor with given capacity.

Precondition
None.
Postcondition
capacity bytes long char array is dynamically allocated and capacity is set to the given capacity. size is set to 0.

◆ ~Data()

Data::~Data ( )

Destructor.

Precondition
Data object is valid.
Postcondition
data array is deallocated.

Member Function Documentation

◆ getCapacity()

std::uint32_t Data::getCapacity ( )

Getter for capacity.

Precondition
None.
Postcondition
capacity of the Data object is returned.
Returns
capacity of Data.

◆ getData()

char* Data::getData ( )

Getter for data char array.

Precondition
None.
Postcondition
char* to data array is returned.
Returns
char* to data array.

◆ getSize()

std::uint32_t Data::getSize ( )

Getter for size.

Precondition
None.
Postcondition
size is returned.
Returns
size of Data.

◆ setSize()

void Data::setSize ( std::uint32_t  new_size)

Setter for size.

Precondition
None.
Postcondition
size is set.
Parameters
sizeNew size to be set to.
Exceptions
InvalidSizeDataIf new_size is greater than capacity.

Member Data Documentation

◆ capacity

std::uint32_t Data::capacity
private

The actual size of dynamically allocated data array.

◆ data

char* Data::data
private

char* to dynamically allocated array that stores the data.

◆ size

std::uint32_t Data::size
private

Size in bytes up to which the data array is valid.


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