10 #include <libpmemobj++/slice.hpp> 
   11 #include <libpmemobj++/string_view.hpp> 
   17 #include "libpmemkv.h" 
   18 #include <libpmemobj/pool_base.h> 
   85     OK = PMEMKV_STATUS_OK,               
 
   93         PMEMKV_STATUS_CONFIG_PARSING_ERROR, 
 
   95         PMEMKV_STATUS_CONFIG_TYPE_ERROR, 
 
  100         PMEMKV_STATUS_OUT_OF_MEMORY, 
 
  103         PMEMKV_STATUS_WRONG_ENGINE_NAME, 
 
  106         PMEMKV_STATUS_TRANSACTION_SCOPE_ERROR, 
 
  111         PMEMKV_STATUS_COMPARATOR_MISMATCH, 
 
  126     static const std::string statuses[] = {
"OK",
 
  131                            "CONFIG_PARSING_ERROR",
 
  136                            "TRANSACTION_SCOPE_ERROR",
 
  138                            "COMPARATOR_MISMATCH"};
 
  140     int status_no = 
static_cast<int>(s);
 
  141     os << statuses[status_no] << 
" (" << status_no << 
")";
 
  156     const char *
what() const noexcept final
 
  158         return std::runtime_error::what();
 
  174 template <
typename T>
 
  183     result(
const T &val) noexcept(noexcept(T(std::declval<T>())));
 
  185     result(
const result &other) noexcept(noexcept(T(std::declval<T>())));
 
  186     result(
result &&other) noexcept(noexcept(T(std::declval<T>())));
 
  187     result(T &&val) noexcept(noexcept(T(std::declval<T>())));
 
  192     operator=(
const result &other) noexcept(noexcept(std::declval<T>().~T()) &&
 
  193                         noexcept(T(std::declval<T>())));
 
  195                            noexcept(T(std::declval<T>())));
 
  197     bool is_ok() const noexcept;
 
  212 template <typename T>
 
  213 result<T>::
result(const T &val) noexcept(noexcept(T(std::declval<T>())))
 
  223 template <
typename T>
 
  234 template <
typename T>
 
  239         new (&
value) T(other.value);
 
  247 template <
typename T>
 
  251         new (&
value) T(std::move(other.value));
 
  259 template <
typename T>
 
  271 template <
typename T>
 
  274                            noexcept(T(std::declval<T>())))
 
  278     else if (other.is_ok())
 
  279         new (&
value) T(other.value);
 
  293 template <
typename T>
 
  296                           noexcept(T(std::declval<T>())))
 
  299         value = std::move(other.value);
 
  300     else if (other.is_ok())
 
  301         new (&
value) T(std::move(other.value));
 
  316 template <
typename T>
 
  327 template <
typename T>
 
  342 template <
typename T>
 
  360 template <
typename T>
 
  378 template <
typename T>
 
  383         return std::move(
value);
 
  396 template <
typename T>
 
  402 template <
typename T>
 
  408 template <
typename T>
 
  414 template <
typename T>
 
  420 template <
typename T>
 
  446 #define force_create_deprecated                                                          \ 
  447     __attribute__((deprecated("use config::put_create_or_error_if_exists instead")))
 
  451     explicit config(pmemkv_config *cfg) noexcept;
 
  453     template <typename T>
 
  454     status put_data(const std::
string &key, const T *
value,
 
  455             const std::
size_t number = 1) noexcept;
 
  457     template <typename T>
 
  458     status put_object(const std::
string &key, T *
value,
 
  459               void (*deleter)(
void *)) noexcept;
 
  460     template <typename T, typename D>
 
  461     status put_object(const std::
string &key, std::unique_ptr<T, D> 
object) noexcept;
 
  462     status put_uint64(const std::
string &key, std::uint64_t 
value) noexcept;
 
  463     status put_int64(const std::
string &key, std::int64_t 
value) noexcept;
 
  464     status put_string(const std::
string &key, const std::
string &
value) noexcept;
 
  466     status put_size(std::uint64_t size) noexcept;
 
  467     status put_path(const std::
string &path) noexcept;
 
  469     status put_create_or_error_if_exists(
bool value) noexcept;
 
  471     status put_oid(PMEMoid *oid) noexcept;
 
  472     template <typename Comparator>
 
  473     status put_comparator(Comparator &&comparator);
 
  475     template <typename T>
 
  476     status get_data(const std::
string &key, T *&
value, std::
size_t &number) const
 
  478     template <typename T>
 
  479     status get_object(const std::
string &key, T *&
value) const noexcept;
 
  481     status get_uint64(const std::
string &key, std::uint64_t &
value) const noexcept;
 
  482     status get_int64(const std::
string &key, std::int64_t &
value) const noexcept;
 
  483     status get_string(const std::
string &key, std::
string &
value) const noexcept;
 
  485     pmemkv_config *release() noexcept;
 
  490     std::unique_ptr<pmemkv_config, decltype(&pmemkv_config_delete)> config_;
 
  510     tx(pmemkv_tx *tx_) noexcept;
 
  515     void abort() noexcept;
 
  518     std::unique_ptr<pmemkv_tx, decltype(&pmemkv_tx_end)> 
tx_;
 
  543     template <
bool IsConst>
 
  554     void close() noexcept;
 
  556     status count_all(std::
size_t &cnt) noexcept;
 
  562                  std::
size_t &cnt) noexcept;
 
  596     status defrag(
double start_percent = 0, 
double amount_percent = 100);
 
  600     result<read_iterator> new_read_iterator();
 
  601     result<write_iterator> new_write_iterator();
 
  603     std::
string errormsg();
 
  606     std::unique_ptr<pmemkv_db, decltype(&pmemkv_close)> db_;
 
  630 template <
bool IsConst>
 
  633                             pmemkv_write_iterator>::type;
 
  635     template <
typename T>
 
  647     status seek_to_first() noexcept;
 
  648     status seek_to_last() noexcept;
 
  650     status is_next() noexcept;
 
  657     read_range(
size_t pos = 0,
 
  658            size_t n = std::numeric_limits<
size_t>::max()) noexcept;
 
  660     template <
bool IC = IsConst>
 
  662     write_range(
size_t pos = 0,
 
  663             size_t n = std::numeric_limits<
size_t>::max()) noexcept;
 
  665     template <
bool IC = IsConst>
 
  666     typename std::enable_if<!IC, 
status>::type commit() noexcept;
 
  667     template <
bool IC = IsConst>
 
  668     typename std::enable_if<!IC>::type abort() noexcept;
 
  673         typename std::conditional<IsConst, decltype(&pmemkv_iterator_delete),
 
  674                       decltype(&pmemkv_write_iterator_delete)>::type>
 
  677     pmemkv_iterator *get_raw_it();
 
  684 template <
bool IsConst>
 
  685 template <typename T>
 
  727 template <
bool IsConst>
 
  728 template <
typename T>
 
  733 template <
bool IsConst>
 
  734 template <
typename T>
 
  741 template <
bool IsConst>
 
  742 template <
typename T>
 
  750 template <
bool IsConst>
 
  751 template <
typename T>
 
  760 template <
bool IsConst>
 
  761 template <
typename T>
 
  769 template <
bool IsConst>
 
  770 template <
typename T>
 
  779 template <
bool IsConst>
 
  780 template <
typename T>
 
  787 template <
bool IsConst>
 
  788 template <
typename T>
 
  792     return this->ao.c - other.
ao.
c;
 
  795 template <
bool IsConst>
 
  796 template <
typename T>
 
  800     return this->ao.c != other.
ao.
c;
 
  803 template <
bool IsConst>
 
  804 template <
typename T>
 
  809 template <
bool IsConst>
 
  810 template <
typename T>
 
  825     : it_(it, &pmemkv_write_iterator_delete)
 
  842 template <
bool IsConst>
 
  845     return static_cast<status>(
 
  846         pmemkv_iterator_seek(this->get_raw_it(), key.data(), key.size()));
 
  862 template <
bool IsConst>
 
  865     return static_cast<status>(
 
  866         pmemkv_iterator_seek_lower(this->get_raw_it(), key.data(), key.size()));
 
  882 template <
bool IsConst>
 
  885     return static_cast<status>(pmemkv_iterator_seek_lower_eq(this->get_raw_it(),
 
  886                                  key.data(), key.size()));
 
  902 template <
bool IsConst>
 
  905     return static_cast<status>(
 
  906         pmemkv_iterator_seek_higher(this->get_raw_it(), key.data(), key.size()));
 
  922 template <
bool IsConst>
 
  925     return static_cast<status>(pmemkv_iterator_seek_higher_eq(
 
  926         this->get_raw_it(), key.data(), key.size()));
 
  940 template <
bool IsConst>
 
  943     return static_cast<status>(pmemkv_iterator_seek_to_first(this->get_raw_it()));
 
  957 template <
bool IsConst>
 
  960     return static_cast<status>(pmemkv_iterator_seek_to_last(this->get_raw_it()));
 
  973 template <
bool IsConst>
 
  976     return static_cast<status>(pmemkv_iterator_is_next(this->get_raw_it()));
 
  992 template <
bool IsConst>
 
  995     return static_cast<status>(pmemkv_iterator_next(this->get_raw_it()));
 
 1011 template <
bool IsConst>
 
 1014     return static_cast<status>(pmemkv_iterator_prev(this->get_raw_it()));
 
 1026 template <
bool IsConst>
 
 1031     auto s = 
static_cast<status>(pmemkv_iterator_key(this->get_raw_it(), &c, &size));
 
 1055 template <
bool IsConst>
 
 1061     auto s = 
static_cast<status>(
 
 1062         pmemkv_iterator_read_range(this->get_raw_it(), pos, n, &data, &size));
 
 1096     auto s = 
static_cast<status>(
 
 1097         pmemkv_write_iterator_write_range(this->it_.get(), pos, n, &data, &size));
 
 1101             return {{data, data + size}};
 
 1102         } 
catch (std::out_of_range &e) {
 
 1122     auto s = 
static_cast<status>(pmemkv_write_iterator_commit(this->it_.get()));
 
 1133     pmemkv_write_iterator_abort(this->it_.get());
 
 1145     return it_.get()->iter;
 
 1170 template <
typename T, 
typename D>
 
 1192 template <
typename Comparator>
 
 1204         return cmp.compare(key1, key2);
 
 1212         std::unique_ptr<comparator_base> ptr,
 
 1213         std::unique_ptr<pmemkv_comparator, decltype(pmemkv_comparator_delete) *>
 
 1215         : ptr(std::move(ptr)), c_cmp(std::move(c_cmp))
 
 1224     std::unique_ptr<comparator_base> 
ptr;
 
 1225     std::unique_ptr<pmemkv_comparator, decltype(pmemkv_comparator_delete) *> 
c_cmp;
 
 1234 static inline void call_up_destructor(
void *
object)
 
 1240 static inline void *call_up_get(
void *
object)
 
 1242     auto *ptr = 
static_cast<unique_ptr_wrapper_base *
>(object);
 
 1246 static inline int call_comparator_function(
const char *k1, 
size_t kb1, 
const char *k2,
 
 1247                        size_t kb2, 
void *arg)
 
 1249     auto *cmp = 
static_cast<comparator_base *
>(arg);
 
 1266 inline config::config(pmemkv_config *cfg) noexcept : config_(cfg, &pmemkv_config_delete)
 
 1278     if (this->config_.get() == 
nullptr) {
 
 1279         this->config_ = {pmemkv_config_new(), &pmemkv_config_delete};
 
 1281         if (this->config_.get() == 
nullptr)
 
 1298 template <
typename T>
 
 1300                    const std::size_t count) noexcept
 
 1305     return static_cast<status>(pmemkv_config_put_data(
 
 1306         this->config_.get(), key.data(), (
void *)value, count * 
sizeof(T)));
 
 1319 template <
typename T>
 
 1321                  void (*deleter)(
void *)) noexcept
 
 1326     return static_cast<status>(pmemkv_config_put_object(
 
 1327         this->config_.get(), key.data(), (
void *)value, deleter));
 
 1338 template <
typename T, 
typename D>
 
 1340                  std::unique_ptr<T, D> 
object) noexcept
 
 1349     } 
catch (std::bad_alloc &e) {
 
 1355     return static_cast<status>(pmemkv_config_put_object_cb(
 
 1356         this->config_.get(), key.data(), (
void *)wrapper, internal::call_up_get,
 
 1357         internal::call_up_destructor));
 
 1379 template <
typename Comparator>
 
 1383         std::is_same<decltype(std::declval<Comparator>().compare(
 
 1384                      std::declval<string_view>(),
 
 1385                      std::declval<string_view>())),
 
 1387         "Comparator should implement `int compare(pmem::kv::string_view, pmem::kv::string_view)` method");
 
 1388     static_assert(std::is_convertible<decltype(std::declval<Comparator>().name()),
 
 1389                       std::string>::value,
 
 1390               "Comparator should implement `std::string name()` method");
 
 1392     std::unique_ptr<internal::comparator_base> wrapper;
 
 1395         wrapper = std::unique_ptr<internal::comparator_base>(
 
 1397                 std::forward<Comparator>(comparator)));
 
 1398     } 
catch (std::bad_alloc &e) {
 
 1405         std::unique_ptr<pmemkv_comparator, decltype(pmemkv_comparator_delete) *>(
 
 1406             pmemkv_comparator_new(&internal::call_comparator_function,
 
 1407                           std::string(comparator.name()).c_str(),
 
 1409             &pmemkv_comparator_delete);
 
 1418     } 
catch (std::bad_alloc &e) {
 
 1424     return static_cast<status>(pmemkv_config_put_object_cb(
 
 1425         this->config_.get(), 
"comparator", (
void *)entry, internal::call_up_get,
 
 1426         internal::call_up_destructor));
 
 1442     return static_cast<status>(
 
 1443         pmemkv_config_put_uint64(this->config_.get(), key.data(), value));
 
 1459     return static_cast<status>(
 
 1460         pmemkv_config_put_int64(this->config_.get(), key.data(), value));
 
 1472                  const std::string &value) noexcept
 
 1477     return static_cast<status>(
 
 1478         pmemkv_config_put_string(this->config_.get(), key.data(), value.data()));
 
 1490     return put_uint64(
"size", size);
 
 1503     return put_string(
"path", path);
 
 1514     return put_create_or_error_if_exists(value);
 
 1529     return put_uint64(
"create_or_error_if_exists", 
static_cast<std::uint64_t
>(value));
 
 1545     return put_uint64(
"create_if_missing", 
static_cast<std::uint64_t
>(value));
 
 1562     return static_cast<status>(pmemkv_config_put_oid(this->config_.get(), oid));
 
 1575 template <
typename T>
 
 1577                    std::size_t &count) 
const noexcept
 
 1579     if (this->config_.get() == 
nullptr)
 
 1583     auto s = 
static_cast<status>(pmemkv_config_get_data(
 
 1584         this->config_.get(), key.data(), (
const void **)&value, &size));
 
 1589     count = size / 
sizeof(T);
 
 1603 template <
typename T>
 
 1606     if (this->config_.get() == 
nullptr)
 
 1609     auto s = 
static_cast<status>(pmemkv_config_get_object(
 
 1610         this->config_.get(), key.data(), (
void **)&value));
 
 1626     if (this->config_.get() == 
nullptr)
 
 1629     return static_cast<status>(
 
 1630         pmemkv_config_get_uint64(this->config_.get(), key.data(), &value));
 
 1644     if (this->config_.get() == 
nullptr)
 
 1647     return static_cast<status>(
 
 1648         pmemkv_config_get_int64(this->config_.get(), key.data(), &value));
 
 1662     if (this->config_.get() == 
nullptr)
 
 1667     auto s = 
static_cast<status>(
 
 1668         pmemkv_config_get_string(this->config_.get(), key.data(), &data));
 
 1686     return this->config_.release();
 
 1692 inline tx::tx(pmemkv_tx *tx_) noexcept : tx_(tx_, &pmemkv_tx_end)
 
 1707     return static_cast<status>(pmemkv_tx_remove(tx_.get(), key.data(), key.size()));
 
 1721     return static_cast<status>(pmemkv_tx_put(tx_.get(), key.data(), key.size(),
 
 1722                          value.data(), value.size()));
 
 1734     return static_cast<status>(pmemkv_tx_commit(tx_.get()));
 
 1743     pmemkv_tx_abort(tx_.get());
 
 1752 static inline int call_get_kv_function(
const char *key, 
size_t keybytes,
 
 1753                        const char *value, 
size_t valuebytes, 
void *arg)
 
 1755     return (*
reinterpret_cast<std::function<get_kv_function> *
>(arg))(
 
 1759 static inline void call_get_v_function(
const char *value, 
size_t valuebytes, 
void *arg)
 
 1761     (*
reinterpret_cast<std::function<get_v_function> *
>(arg))(
 
 1765 static inline void call_get_copy(
const char *v, 
size_t vb, 
void *arg)
 
 1767     auto c = 
reinterpret_cast<std::string *
>(arg);
 
 1791         static_cast<status>(pmemkv_open(engine_name.c_str(), cfg.release(), &
db));
 
 1793         this->db_.reset(
db);
 
 1802     this->db_.reset(
nullptr);
 
 1814     return static_cast<status>(pmemkv_count_all(this->db_.get(), &cnt));
 
 1829     return static_cast<status>(
 
 1830         pmemkv_count_above(this->db_.get(), key.data(), key.size(), &cnt));
 
 1845     return static_cast<status>(
 
 1846         pmemkv_count_equal_above(this->db_.get(), key.data(), key.size(), &cnt));
 
 1861     return static_cast<status>(
 
 1862         pmemkv_count_equal_below(this->db_.get(), key.data(), key.size(), &cnt));
 
 1877     return static_cast<status>(
 
 1878         pmemkv_count_below(this->db_.get(), key.data(), key.size(), &cnt));
 
 1893                 std::size_t &cnt) noexcept
 
 1895     return static_cast<status>(pmemkv_count_between(this->db_.get(), key1.data(),
 
 1896                             key1.size(), key2.data(),
 
 1897                             key2.size(), &cnt));
 
 1914     return static_cast<status>(pmemkv_get_all(this->db_.get(), callback, arg));
 
 1929     return static_cast<status>(
 
 1930         pmemkv_get_all(this->db_.get(), call_get_kv_function, &f));
 
 1952     return static_cast<status>(
 
 1953         pmemkv_get_above(this->db_.get(), key.data(), key.size(), callback, arg));
 
 1972     return static_cast<status>(pmemkv_get_above(
 
 1973         this->db_.get(), key.data(), key.size(), call_get_kv_function, &f));
 
 1996     return static_cast<status>(pmemkv_get_equal_above(this->db_.get(), key.data(),
 
 1997                               key.size(), callback, arg));
 
 2016                   std::function<get_kv_function> f) noexcept
 
 2018     return static_cast<status>(pmemkv_get_equal_above(
 
 2019         this->db_.get(), key.data(), key.size(), call_get_kv_function, &f));
 
 2042     return static_cast<status>(pmemkv_get_equal_below(this->db_.get(), key.data(),
 
 2043                               key.size(), callback, arg));
 
 2062                   std::function<get_kv_function> f) noexcept
 
 2064     return static_cast<status>(pmemkv_get_equal_below(
 
 2065         this->db_.get(), key.data(), key.size(), call_get_kv_function, &f));
 
 2087     return static_cast<status>(
 
 2088         pmemkv_get_below(this->db_.get(), key.data(), key.size(), callback, arg));
 
 2107     return static_cast<status>(pmemkv_get_below(
 
 2108         this->db_.get(), key.data(), key.size(), call_get_kv_function, &f));
 
 2131     return static_cast<status>(pmemkv_get_between(this->db_.get(), key1.data(),
 
 2132                               key1.size(), key2.data(),
 
 2133                               key2.size(), callback, arg));
 
 2151                   std::function<get_kv_function> f) noexcept
 
 2153     return static_cast<status>(
 
 2154         pmemkv_get_between(this->db_.get(), key1.data(), key1.size(), key2.data(),
 
 2155                    key2.size(), call_get_kv_function, &f));
 
 2169     return static_cast<status>(
 
 2170         pmemkv_exists(this->db_.get(), key.data(), key.size()));
 
 2190     return static_cast<status>(
 
 2191         pmemkv_get(this->db_.get(), key.data(), key.size(), callback, arg));
 
 2207     return static_cast<status>(pmemkv_get(this->db_.get(), key.data(), key.size(),
 
 2208                           call_get_v_function, &f));
 
 2223     return static_cast<status>(pmemkv_get(this->db_.get(), key.data(), key.size(),
 
 2224                           call_get_copy, value));
 
 2238     return static_cast<status>(pmemkv_put(this->db_.get(), key.data(), key.size(),
 
 2239                           value.data(), value.size()));
 
 2252     return static_cast<status>(
 
 2253         pmemkv_remove(this->db_.get(), key.data(), key.size()));
 
 2267     return static_cast<status>(
 
 2268         pmemkv_defrag(this->db_.get(), start_percent, amount_percent));
 
 2278     pmemkv_write_iterator *tmp;
 
 2279     auto ret = 
static_cast<status>(pmemkv_write_iterator_new(
db_.get(), &tmp));
 
 2293     pmemkv_iterator *tmp;
 
 2294     auto ret = 
static_cast<status>(pmemkv_iterator_new(
db_.get(), &tmp));
 
 2310     return std::string(pmemkv_errormsg());
 
 2318 static inline std::string 
errormsg()
 
 2320     return std::string(pmemkv_errormsg());
 
 2331     auto s = 
static_cast<status>(pmemkv_tx_begin(
db_.get(), &tx_));
 
Defines a type of object to be thrown by result::get_value() when result doesn't contain value.
Definition: libpmemkv.hpp:150
 
const char * what() const noexcept final
Definition: libpmemkv.hpp:156
 
bad_result_access(const char *what_arg)
Definition: libpmemkv.hpp:152
 
Holds configuration parameters for engines.
Definition: libpmemkv.hpp:445
 
status put_create_or_error_if_exists(bool value) noexcept
Puts create_or_error_if_exists parameter to a config.
Definition: libpmemkv.hpp:1527
 
status put_force_create(bool value) noexcept force_create_deprecated
It's an alias for config::put_create_or_error_if_exists, kept for compatibility.
Definition: libpmemkv.hpp:1512
 
status put_uint64(const std::string &key, std::uint64_t value) noexcept
Puts std::uint64_t value to a config.
Definition: libpmemkv.hpp:1437
 
status put_size(std::uint64_t size) noexcept
Puts size to a config, it's required when creating new database pool.
Definition: libpmemkv.hpp:1488
 
config() noexcept
Default constructor with uninitialized config.
Definition: libpmemkv.hpp:1258
 
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.
Definition: libpmemkv.hpp:1604
 
status put_create_if_missing(bool value) noexcept
Puts create_if_missing parameter to a config.
Definition: libpmemkv.hpp:1543
 
status put_string(const std::string &key, const std::string &value) noexcept
Puts string value to a config.
Definition: libpmemkv.hpp:1471
 
int init() noexcept
Initialization function for config.
Definition: libpmemkv.hpp:1276
 
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.
Definition: libpmemkv.hpp:1641
 
status get_string(const std::string &key, std::string &value) const noexcept
Gets string value from a config item with key name.
Definition: libpmemkv.hpp:1659
 
status put_comparator(Comparator &&comparator)
Puts comparator object to a config.
Definition: libpmemkv.hpp:1380
 
pmemkv_config * release() noexcept
Similarly to std::unique_ptr::release it passes the ownership of underlying pmemkv_config variable an...
Definition: libpmemkv.hpp:1684
 
status put_oid(PMEMoid *oid) noexcept
Puts PMEMoid object to a config.
Definition: libpmemkv.hpp:1557
 
status put_object(const std::string &key, T *value, void(*deleter)(void *)) noexcept
Puts object pointed by value, of type T, with given destructor to a config.
Definition: libpmemkv.hpp:1320
 
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.
Definition: libpmemkv.hpp:1576
 
status put_path(const std::string &path) noexcept
Puts path (of a database pool) to a config, to open or create.
Definition: libpmemkv.hpp:1501
 
status put_int64(const std::string &key, std::int64_t value) noexcept
Puts std::int64_t value to a config.
Definition: libpmemkv.hpp:1454
 
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.
Definition: libpmemkv.hpp:1623
 
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.
Definition: libpmemkv.hpp:1299
 
OutputIterator provides iteration through elements without a possibility of reading them....
Definition: libpmemkv.hpp:686
 
std::output_iterator_tag iterator_category
Definition: libpmemkv.hpp:694
 
assign_only ao
Definition: libpmemkv.hpp:724
 
void pointer
Definition: libpmemkv.hpp:691
 
void value_type
Definition: libpmemkv.hpp:693
 
std::ptrdiff_t difference_type
Definition: libpmemkv.hpp:692
 
Iterator provides methods to iterate over records in db.
Definition: libpmemkv.hpp:631
 
pmemkv_iterator * get_raw_it()
 
typename std::conditional< IsConst, pmemkv_iterator, pmemkv_write_iterator >::type iterator_type
Definition: libpmemkv.hpp:633
 
result< string_view > key() noexcept
Returns record's key (pmem::kv::string_view), in pmem::kv::result<pmem::kv::string_view>.
Definition: libpmemkv.hpp:1027
 
status prev() noexcept
Changes iterator position to the previous record.
Definition: libpmemkv.hpp:1012
 
std::enable_if<!IC, result< pmem::obj::slice< OutputIterator< char > > > >::type write_range(size_t pos=0, size_t n=std::numeric_limits< size_t >::max()) noexcept
 
status is_next() noexcept
Checks if there is a next record available.
Definition: libpmemkv.hpp:974
 
iterator(iterator_type *it)
 
status seek_higher_eq(string_view key) noexcept
Changes iterator position to the record with key equal or higher than given key.
Definition: libpmemkv.hpp:923
 
std::enable_if<!IC, status >::type commit() noexcept
 
status next() noexcept
Changes iterator position to the next record.
Definition: libpmemkv.hpp:993
 
status seek_to_last() noexcept
Changes iterator position to the last record.
Definition: libpmemkv.hpp:958
 
status seek_lower(string_view key) noexcept
Changes iterator position to the record with key lower than given key.
Definition: libpmemkv.hpp:863
 
std::unique_ptr< iterator_type, typename std::conditional< IsConst, decltype(&pmemkv_iterator_delete), decltype(&pmemkv_write_iterator_delete)>::type > it_
Definition: libpmemkv.hpp:675
 
result< string_view > read_range(size_t pos=0, size_t n=std::numeric_limits< size_t >::max()) noexcept
Returns value's range (pmem::kv::string_view) to read, in pmem::kv::result.
Definition: libpmemkv.hpp:1056
 
status seek_to_first() noexcept
Changes iterator position to the first record.
Definition: libpmemkv.hpp:941
 
status seek_lower_eq(string_view key) noexcept
Changes iterator position to the record with key equal or lower than given key.
Definition: libpmemkv.hpp:883
 
status seek_higher(string_view key) noexcept
Changes iterator position to the record with key higher than given key.
Definition: libpmemkv.hpp:903
 
std::enable_if<!IC >::type abort() noexcept
 
status seek(string_view key) noexcept
Changes iterator position to the record with given key.
Definition: libpmemkv.hpp:843
 
Main pmemkv class, it provides functions to operate on data in database.
Definition: libpmemkv.hpp:542
 
result< read_iterator > new_read_iterator()
Returns new read iterator in pmem::kv::result.
Definition: libpmemkv.hpp:2291
 
status count_all(std::size_t &cnt) noexcept
It returns number of currently stored elements in pmem::kv::db.
Definition: libpmemkv.hpp:1812
 
status exists(string_view key) noexcept
Checks existence of record with given key.
Definition: libpmemkv.hpp:2167
 
status defrag(double start_percent=0, double amount_percent=100)
Defragments approximately 'amount_percent' percent of elements in the database starting from 'start_p...
Definition: libpmemkv.hpp:2265
 
status open(const std::string &engine_name, config &&cfg=config{}) noexcept
Opens the pmemkv database with specified config.
Definition: libpmemkv.hpp:1787
 
status remove(string_view key) noexcept
Removes from database record with given key.
Definition: libpmemkv.hpp:2250
 
status put(string_view key, string_view value) noexcept
Inserts a key-value pair into pmemkv database.
Definition: libpmemkv.hpp:2236
 
status count_above(string_view key, std::size_t &cnt) noexcept
It returns number of currently stored elements in pmem::kv::db, whose keys are greater than the given...
Definition: libpmemkv.hpp:1827
 
status get_equal_above(string_view key, get_kv_callback *callback, void *arg) noexcept
Executes (C-like) callback function for every record stored in pmem::kv::db, whose keys are greater t...
Definition: libpmemkv.hpp:1993
 
db() noexcept
Default constructor with uninitialized database.
Definition: libpmemkv.hpp:1775
 
status get_all(get_kv_callback *callback, void *arg) noexcept
Executes (C-like) callback function for every record stored in pmem::kv::db.
Definition: libpmemkv.hpp:1912
 
result< tx > tx_begin() noexcept
Starts a pmemkv transaction.
Definition: libpmemkv.hpp:2328
 
status count_between(string_view key1, string_view key2, std::size_t &cnt) noexcept
It returns number of currently stored elements in pmem::kv::db, whose keys are greater than the key1 ...
Definition: libpmemkv.hpp:1892
 
std::string errormsg()
Returns a human readable string describing the last error.
Definition: libpmemkv.hpp:2308
 
status count_below(string_view key, std::size_t &cnt) noexcept
It returns number of currently stored elements in pmem::kv::db, whose keys are less than the given ke...
Definition: libpmemkv.hpp:1875
 
status get_equal_below(string_view key, get_kv_callback *callback, void *arg) noexcept
Executes (C-like) callback function for every record stored in pmem::kv::db, whose keys are lower tha...
Definition: libpmemkv.hpp:2039
 
status get_between(string_view key1, string_view key2, get_kv_callback *callback, void *arg) noexcept
Executes (C-like) callback function for every record stored in pmem::kv::db, whose keys are greater t...
Definition: libpmemkv.hpp:2128
 
void close() noexcept
Closes pmemkv database.
Definition: libpmemkv.hpp:1800
 
result< write_iterator > new_write_iterator()
Returns new write iterator in pmem::kv::result.
Definition: libpmemkv.hpp:2276
 
status get_above(string_view key, get_kv_callback *callback, void *arg) noexcept
Executes (C-like) callback function for every record stored in pmem::kv::db, whose keys are greater t...
Definition: libpmemkv.hpp:1949
 
std::unique_ptr< pmemkv_db, decltype(&pmemkv_close)> db_
Definition: libpmemkv.hpp:606
 
status get_below(string_view key, get_kv_callback *callback, void *arg) noexcept
Executes (C-like) callback function for every record stored in pmem::kv::db, whose keys are lower tha...
Definition: libpmemkv.hpp:2084
 
status count_equal_above(string_view key, std::size_t &cnt) noexcept
It returns number of currently stored elements in pmem::kv::db, whose keys are greater than or equal ...
Definition: libpmemkv.hpp:1843
 
status count_equal_below(string_view key, std::size_t &cnt) noexcept
It returns number of currently stored elements in pmem::kv::db, whose keys are lower than or equal to...
Definition: libpmemkv.hpp:1859
 
status get(string_view key, get_v_callback *callback, void *arg) noexcept
Executes (C-like) callback function for record with given key.
Definition: libpmemkv.hpp:2188
 
Definition: libpmemkv.hpp:1184
 
virtual ~comparator_base()
Definition: libpmemkv.hpp:1186
 
virtual int compare(string_view key1, string_view key2)=0
 
Stores result of an operation. It always contains status and optionally can contain value.
Definition: libpmemkv.hpp:175
 
bool is_ok() const noexcept
Checks if the result contains value (status == status::OK).
Definition: libpmemkv.hpp:328
 
result(const T &val) noexcept(noexcept(T(std::declval< T >())))
Creates result with value (status is automatically initialized to status::OK).
Definition: libpmemkv.hpp:213
 
const T & get_value() const &
Returns const reference to value from the result.
Definition: libpmemkv.hpp:343
 
status s
Definition: libpmemkv.hpp:180
 
T value
Definition: libpmemkv.hpp:177
 
status get_status() const noexcept
Returns status from the result.
Definition: libpmemkv.hpp:397
 
result & operator=(const result &other) noexcept(noexcept(std::declval< T >().~T()) &&noexcept(T(std::declval< T >())))
Default copy assignment operator.
Definition: libpmemkv.hpp:273
 
~result()
Explicit destructor.
Definition: libpmemkv.hpp:260
 
Pmemkv transaction handle.
Definition: libpmemkv.hpp:508
 
void abort() noexcept
Aborts the transaction.
Definition: libpmemkv.hpp:1741
 
tx(pmemkv_tx *tx_) noexcept
Constructs C++ tx object from a C pmemkv_tx pointer.
Definition: libpmemkv.hpp:1692
 
status put(string_view key, string_view value) noexcept
Inserts a key-value pair into pmemkv database.
Definition: libpmemkv.hpp:1719
 
status commit() noexcept
Commits the transaction.
Definition: libpmemkv.hpp:1732
 
status remove(string_view key) noexcept
Removes from database record with given key.
Definition: libpmemkv.hpp:1705
 
std::unique_ptr< pmemkv_tx, decltype(&pmemkv_tx_end)> tx_
Definition: libpmemkv.hpp:518
 
#define force_create_deprecated
Definition: libpmemkv.hpp:446
 
pmemkv_get_v_callback get_v_callback
Value-only callback, C-style.
Definition: libpmemkv.hpp:71
 
void get_v_function(string_view value)
The C++ idiomatic function type to use for callback using only the value.
Definition: libpmemkv.hpp:62
 
bool operator==(const result< T > &lhs, const status &rhs)
Definition: libpmemkv.hpp:403
 
status
Status returned by most of pmemkv functions.
Definition: libpmemkv.hpp:84
 
@ DEFRAG_ERROR
the defragmentation process failed (possibly in the middle of a run)
 
@ STOPPED_BY_CB
iteration was stopped by user's callback
 
@ CONFIG_TYPE_ERROR
config item has different type than expected
 
@ WRONG_ENGINE_NAME
engine name does not match any available engine
 
@ NOT_SUPPORTED
function is not implemented by current engine
 
@ TRANSACTION_SCOPE_ERROR
an error with the scope of the libpmemobj transaction
 
@ COMPARATOR_MISMATCH
db was created with a different comparator
 
@ NOT_FOUND
record (or config item) not found
 
@ UNKNOWN_ERROR
unknown error
 
@ CONFIG_PARSING_ERROR
parsing data to config failed
 
@ OUT_OF_MEMORY
operation failed because there is not enough memory (or space on the device)
 
@ INVALID_ARGUMENT
argument to function has wrong value
 
pmemkv_get_kv_callback get_kv_callback
Key-value pair callback, C-style.
Definition: libpmemkv.hpp:67
 
obj::string_view string_view
Partial string_view implementation, defined in pmem::obj namespace in libpmemobj-cpp library (see: ht...
Definition: libpmemkv.hpp:47
 
bool operator!=(const result< T > &lhs, const status &rhs)
Definition: libpmemkv.hpp:415
 
std::ostream & operator<<(std::ostream &os, const status &s)
Provides string representation of a status, along with its number as specified by enum.
Definition: libpmemkv.hpp:124
 
int get_kv_function(string_view key, string_view value)
The C++ idiomatic function type to use for callback using key-value pair.
Definition: libpmemkv.hpp:55
 
bool operator!=(const status &lhs, const result< T > &rhs)
Definition: libpmemkv.hpp:421
 
Persistent memory namespace.
 
Definition: libpmemkv.hpp:713
 
T * c
Definition: libpmemkv.hpp:721
 
Definition: libpmemkv.hpp:1210
 
std::unique_ptr< comparator_base > ptr
Definition: libpmemkv.hpp:1224
 
void * get() override
Definition: libpmemkv.hpp:1219
 
comparator_config_entry(std::unique_ptr< comparator_base > ptr, std::unique_ptr< pmemkv_comparator, decltype(pmemkv_comparator_delete) * > c_cmp)
Definition: libpmemkv.hpp:1211
 
std::unique_ptr< pmemkv_comparator, decltype(pmemkv_comparator_delete) * > c_cmp
Definition: libpmemkv.hpp:1225
 
Definition: libpmemkv.hpp:1193
 
int compare(string_view key1, string_view key2) override
Definition: libpmemkv.hpp:1202
 
comparator_wrapper(Comparator &&cmp)
Definition: libpmemkv.hpp:1198
 
comparator_wrapper(const Comparator &cmp)
Definition: libpmemkv.hpp:1194
 
Comparator cmp
Definition: libpmemkv.hpp:1207
 
Definition: libpmemkv.hpp:1162
 
virtual ~unique_ptr_wrapper_base()
Definition: libpmemkv.hpp:1163
 
Definition: libpmemkv.hpp:1171
 
unique_ptr_wrapper(std::unique_ptr< T, D > ptr)
Definition: libpmemkv.hpp:1172
 
void * get() override
Definition: libpmemkv.hpp:1176
 
std::unique_ptr< T, D > ptr
Definition: libpmemkv.hpp:1181