|
LibUDB 1.0
|
#include <UDBase.h>
Public Member Functions | |
| UDBase (const UDBase &other) | |
| UDBase (UDBase &&other) | |
| UDBase & | operator= (const UDBase &other) |
| UDBase & | operator= (UDBase &&other) |
| UDBase & | operator+= (const UDBase &other) |
| void | writeToBuffer (std::vector< char > &result) |
| void | readFromBuffer (const std::vector< char > &buf, const size_t &offset=0, const size_t &bytes_to_read=0) |
| void | writeToFile (const std::filesystem::path &f_path) |
| void | readFromFile (const std::filesystem::path &f_path) |
| std::vector< UDBElement > * | getRawBase () const |
| void | addElement (const UDBElement &el) |
| void | addElements (const std::vector< UDBElement > &elements) |
| virtual void | removeElement (const UDBElement &el) |
| virtual void | removeElements (std::function< bool(const UDBElement &)> predicate) |
| virtual void | replaceElement (const UDBElement &old_el, const UDBElement &new_el) |
| void | clearBase () |
| void | shrinkToFit () |
| virtual UDBase | searchElement (std::function< bool(const UDBElement &)> search_function) |
| virtual UDBase | searchElement (std::function< void(const UDBElement &, UDBase &)> search_function) |
| virtual std::vector< UDBElement > | searchElementV (std::function< bool(const UDBElement &)> search_function) |
| virtual void | sortBase (std::function< bool(const UDBElement &, const UDBElement &)> sort_function) |
| size_t | baseSize () const |
| size_t | calculateWriteSize () |
| std::vector< UDBase > | splitBase (const size_t &bytes_limit, const size_t &minimum_elements=size_t(1)) |
Static Public Member Functions | |
| static UDBase | convertToBase (const std::vector< UDBElement > &elements) |
Protected Member Functions | |
| void | readFromBufferInner (const std::vector< char > &buf, const size_t &offset, const size_t &bytes_to_read) |
| void | writeToBufferInner (std::vector< char > &result) |
Protected Attributes | |
| std::vector< UDBElement > | base |
| Internal base object. | |
| std::string | base_version = "UDB 1.0" |
| Base version string used to identify base in buffers and files. | |
The UDBase class.
This class contains methods for database managing.
| void UDBase::addElement | ( | const UDBElement & | el | ) |
Adds element to base.
| el | Element to be added. |
| void UDBase::addElements | ( | const std::vector< UDBElement > & | elements | ) |
Adds elements to base.
| elements | Vector of elements to be added. |
| size_t UDBase::baseSize | ( | ) | const |
Returns number of elements in database.
| size_t UDBase::calculateWriteSize | ( | ) |
Calculates size of buffer, wich can be return by writeToBuffer() method.
| void UDBase::clearBase | ( | ) |
Removes all elements from base.
|
static |
Converts vector of UDBElement objects to base.
| elements | Elements to be converted. |
| std::vector< UDBElement > * UDBase::getRawBase | ( | ) | const |
Returns pointer to internal base vector object.
| void UDBase::readFromBuffer | ( | const std::vector< char > & | buf, |
| const size_t & | offset = 0, | ||
| const size_t & | bytes_to_read = 0 ) |
Tries to read database from given buffer.
| buf | Buffer database should be read from. |
| offset | Position in buffer reading should be started from (default value is 0). |
| bytes_to_read | Quantity of bytes to be read. If it is 0 (default), reads whole buffer starting from offset. |
|
protected |
Internal method used in readFromBuffer() and readFromFile() methods.
| buf | Buffer base to be read from. |
| offset | Number of byte reading to be started from. |
| bytes_to_read | Number of bytes to be read. |
| void UDBase::readFromFile | ( | const std::filesystem::path & | f_path | ) |
Tries to read database from file.
| f_path | Absolute path to file database should be read from. |
|
virtual |
Removes from base all elements equal to el.
| el | Element to be removed. |
|
virtual |
Removes elements from base according to predicate function conditions.
| predicate | Function to check removing conditions. |
|
virtual |
Replaces all elements equal to old_el by new_el.
| old_el | Element to be replaced. |
| new_el | Element to be replaced by. |
|
virtual |
Returns all elements that match the conditions specified in the search_function.
| search_function | Function to check conditions. |
|
virtual |
Returns all elements added to UDBase parameter of search_function.
| search_function | Function to add elements to result; |
|
virtual |
Returns all elements that match the conditions specified in the search_function.
| search_function | Function to check conditions. |
| void UDBase::shrinkToFit | ( | ) |
Reduces memory usage by freeing unused memory in internal containers.
|
virtual |
Sorts base (quicksort algorithm).
| sort_function | Function to compare elements. |
| std::vector< UDBase > UDBase::splitBase | ( | const size_t & | bytes_limit, |
| const size_t & | minimum_elements = size_t(1) ) |
Splits base into bases of smaller size.
| bytes_limit | Maximum permitted size of smaller base. |
| minimum_elements | Minimum elements in smaller base (default value is 1). |
| void UDBase::writeToBuffer | ( | std::vector< char > & | result | ) |
Writes database to result buffer.
| result | Vector base to be written to. |
|
protected |
Internal method used in writeToBuffer() and writeToFile() methods.
| result | Vecto base to be written to. |
| void UDBase::writeToFile | ( | const std::filesystem::path & | f_path | ) |
Writes database to file.
| f_path | Absolute path to file database should be written to. |