PMEMKV  1.0.3-git1.g023abb3
This is the C++ documentation for PMEMKV.
Public Member Functions | Private Member Functions | Private Attributes | List of all members
pmem::kv::config Class Reference

Holds configuration parameters for engines. More...

#include </pmemkv/doc_update/pmemkv/src/libpmemkv.hpp>

Public Member Functions

 config () noexcept
 Default constructor with uninitialized config. More...
 
 config (pmemkv_config *cfg) noexcept
 Creates config from pointer to pmemkv_config. More...
 
 ~config ()
 Default destructor. More...
 
 config (const config &other)=delete
 
 config (config &&other) noexcept
 Move constructor. More...
 
configoperator= (const config &other)=delete
 
configoperator= (config &&other) noexcept
 Move assignment operator. More...
 
template<typename T >
status put_data (const std::string &key, const T *value, const std::size_t number=1) noexcept
 Puts binary data pointed by value, of type T, with count of elements to a config. More...
 
template<typename T >
status put_object (const std::string &key, T *value, void(*deleter)(void *)=[](T *value) { delete value;}) noexcept
 Puts object pointed by value, of type T, with given destructor to a config. More...
 
status put_uint64 (const std::string &key, std::uint64_t value) noexcept
 Puts std::uint64_t value to a config. More...
 
status put_int64 (const std::string &key, std::int64_t value) noexcept
 Puts std::int64_t value to a config. More...
 
status put_string (const std::string &key, const std::string &value) noexcept
 Puts string value to a config. More...
 
template<typename T >
status get_data (const std::string &key, T *&value, std::size_t &number) const noexcept
 Gets object from a config item with key name and copies it into T object value. More...
 
template<typename T >
status get_object (const std::string &key, T *&value) const noexcept
 Gets binary data from a config item with key name and assigns pointer to T object value. More...
 
status get_uint64 (const std::string &key, std::uint64_t &value) const noexcept
 Gets std::uint64_t value from a config item with key name. More...
 
status get_int64 (const std::string &key, std::int64_t &value) const noexcept
 Gets std::int64_t value from a config item with key name. More...
 
status get_string (const std::string &key, std::string &value) const noexcept
 Gets string value from a config item with key name. More...
 
pmemkv_config * release () noexcept
 Similarly to std::unique_ptr::release it passes the ownership of underlying pmemkv_config variable and sets it to nullptr. More...
 

Private Member Functions

int init () noexcept
 Initialization function for config. More...
 

Private Attributes

pmemkv_config * _config
 

Detailed Description

Holds configuration parameters for engines.

It stores mappings of keys (strings) to values. A value can be: uint64_t, int64_t, string, binary data, pointer to an object (with accompanying deleter function).

It also delivers methods to store and read configuration items provided by a user. Once the configuration object is set (with all required parameters),pmemkv_open it can be passed to db::open() method.

List of options which are required by pmemkv database is specific to an engine. Every engine has documented all supported config parameters (please see libpmemkv(7) for details).

Constructor & Destructor Documentation

◆ config() [1/4]

pmem::kv::config::config ( )
inlinenoexcept

Default constructor with uninitialized config.

◆ config() [2/4]

pmem::kv::config::config ( pmemkv_config *  cfg)
inlineexplicitnoexcept

Creates config from pointer to pmemkv_config.

Ownership is transferred to config class.

◆ ~config()

pmem::kv::config::~config ( )
inline

Default destructor.

Deletes config if initialized.

◆ config() [3/4]

pmem::kv::config::config ( const config other)
delete

◆ config() [4/4]

pmem::kv::config::config ( config &&  other)
inlinenoexcept

Move constructor.

Initializes config with another config. Ownership is transferred to config class.

Member Function Documentation

◆ get_data()

template<typename T >
status pmem::kv::config::get_data ( const std::string &  key,
T *&  value,
std::size_t &  count 
) const
inlinenoexcept

Gets object from a config item with key name and copies it into T object value.

Parameters
[in]keyThe string representing config item's name.
[out]valueThe pointer to data.
[out]countThe count of elements stored under reference.
Returns
pmem::kv::status

◆ get_int64()

status pmem::kv::config::get_int64 ( const std::string &  key,
std::int64_t &  value 
) const
inlinenoexcept

Gets std::int64_t value from a config item with key name.

Parameters
[in]keyThe string representing config item's name.
[out]valueThe std::int64_t value.
Returns
pmem::kv::status

◆ get_object()

template<typename T >
status pmem::kv::config::get_object ( const std::string &  key,
T *&  value 
) const
inlinenoexcept

Gets binary data from a config item with key name and assigns pointer to T object value.

Parameters
[in]keyThe string representing config item's name.
[out]valueThe pointer to object.
Returns
pmem::kv::status

◆ get_string()

status pmem::kv::config::get_string ( const std::string &  key,
std::string &  value 
) const
inlinenoexcept

Gets string value from a config item with key name.

Parameters
[in]keyThe string representing config item's name.
[out]valueThe string value.
Returns
pmem::kv::status

◆ get_uint64()

status pmem::kv::config::get_uint64 ( const std::string &  key,
std::uint64_t &  value 
) const
inlinenoexcept

Gets std::uint64_t value from a config item with key name.

Parameters
[in]keyThe string representing config item's name.
[out]valueThe std::uint64_t value.
Returns
pmem::kv::status

◆ init()

int pmem::kv::config::init ( )
inlineprivatenoexcept

Initialization function for config.

It's lazy initialized and called within all put functions.

Returns
int initialization result; 0 on success

◆ operator=() [1/2]

config & pmem::kv::config::operator= ( config &&  other)
inlinenoexcept

Move assignment operator.

Deletes previous config and replaces it with another config. Ownership is transferred to config class.

◆ operator=() [2/2]

config& pmem::kv::config::operator= ( const config other)
delete

◆ put_data()

template<typename T >
status pmem::kv::config::put_data ( const std::string &  key,
const T *  value,
const std::size_t  count = 1 
)
inlinenoexcept

Puts binary data pointed by value, of type T, with count of elements to a config.

Count parameter is useful for putting arrays of data.

Parameters
[in]keyThe string representing config item's name.
[in]valueThe pointer to data.
[in]countThe count of elements stored under reference.
Returns
pmem::kv::status

◆ put_int64()

status pmem::kv::config::put_int64 ( const std::string &  key,
std::int64_t  value 
)
inlinenoexcept

Puts std::int64_t value to a config.

Parameters
[in]keyThe string representing config item's name.
[in]valueThe std::int64_t value.
Returns
pmem::kv::status

◆ put_object()

template<typename T >
status pmem::kv::config::put_object ( const std::string &  key,
T *  value,
void(*)(void *)  deleter = [](T *value) { delete value; } 
)
inlinenoexcept

Puts object pointed by value, of type T, with given destructor to a config.

Parameters
[in]keyThe string representing config item's name.
[in]valueThe pointer to object.
[in]deleterThe object's destructor function.
Returns
pmem::kv::status

◆ put_string()

status pmem::kv::config::put_string ( const std::string &  key,
const std::string &  value 
)
inlinenoexcept

Puts string value to a config.

Parameters
[in]keyThe string representing config item's name.
[in]valueThe string value.
Returns
pmem::kv::status

◆ put_uint64()

status pmem::kv::config::put_uint64 ( const std::string &  key,
std::uint64_t  value 
)
inlinenoexcept

Puts std::uint64_t value to a config.

Parameters
[in]keyThe string representing config item's name.
[in]valueThe std::uint64_t value.
Returns
pmem::kv::status

◆ release()

pmemkv_config * pmem::kv::config::release ( )
inlinenoexcept

Similarly to std::unique_ptr::release it passes the ownership of underlying pmemkv_config variable and sets it to nullptr.

Returns
handle to pmemkv_config

Member Data Documentation

◆ _config

pmemkv_config* pmem::kv::config::_config
private

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