mirror of
https://github.com/isar/libmdbx.git
synced 2025-04-04 16:12:58 +08:00
mdbx++: добавление is_xyz()
для key_mode
и value_mode
.
This commit is contained in:
parent
55142d8d6f
commit
355090f02e
62
mdbx.h++
62
mdbx.h++
@ -3119,6 +3119,26 @@ enum class key_mode {
|
|||||||
///< \note Not yet implemented and PRs are welcome.
|
///< \note Not yet implemented and PRs are welcome.
|
||||||
};
|
};
|
||||||
|
|
||||||
|
MDBX_CXX01_CONSTEXPR_ENUM bool is_usual(key_mode mode) noexcept {
|
||||||
|
return (MDBX_db_flags_t(mode) & (MDBX_REVERSEKEY | MDBX_INTEGERKEY)) == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
MDBX_CXX01_CONSTEXPR_ENUM bool is_ordinal(key_mode mode) noexcept {
|
||||||
|
return (MDBX_db_flags_t(mode) & MDBX_INTEGERKEY) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
MDBX_CXX01_CONSTEXPR_ENUM bool is_samelength(key_mode mode) noexcept {
|
||||||
|
return (MDBX_db_flags_t(mode) & MDBX_INTEGERKEY) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
MDBX_CXX01_CONSTEXPR_ENUM bool is_reverse(key_mode mode) noexcept {
|
||||||
|
return (MDBX_db_flags_t(mode) & MDBX_REVERSEKEY) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
MDBX_CXX01_CONSTEXPR_ENUM bool is_msgpack(key_mode mode) noexcept {
|
||||||
|
return mode == key_mode::msgpack;
|
||||||
|
}
|
||||||
|
|
||||||
/// \brief Kind of the values and sorted multi-values with corresponding
|
/// \brief Kind of the values and sorted multi-values with corresponding
|
||||||
/// comparison.
|
/// comparison.
|
||||||
enum class value_mode {
|
enum class value_mode {
|
||||||
@ -3171,6 +3191,15 @@ enum class value_mode {
|
|||||||
///< end of the keys to the beginning. In terms of keys,
|
///< end of the keys to the beginning. In terms of keys,
|
||||||
///< they are not unique, i.e. has duplicates which are
|
///< they are not unique, i.e. has duplicates which are
|
||||||
///< sorted by associated data values.
|
///< sorted by associated data values.
|
||||||
|
#else
|
||||||
|
multi_reverse = uint32_t(MDBX_DUPSORT) | uint32_t(MDBX_REVERSEDUP),
|
||||||
|
multi_samelength = uint32_t(MDBX_DUPSORT) | uint32_t(MDBX_DUPFIXED),
|
||||||
|
multi_ordinal = uint32_t(MDBX_DUPSORT) | uint32_t(MDBX_DUPFIXED) |
|
||||||
|
uint32_t(MDBX_INTEGERDUP),
|
||||||
|
multi_reverse_samelength = uint32_t(MDBX_DUPSORT) |
|
||||||
|
uint32_t(MDBX_REVERSEDUP) |
|
||||||
|
uint32_t(MDBX_DUPFIXED),
|
||||||
|
#endif
|
||||||
msgpack = -1 ///< A more than one data value could be associated with each
|
msgpack = -1 ///< A more than one data value could be associated with each
|
||||||
///< key. Values are in [MessagePack](https://msgpack.org/)
|
///< key. Values are in [MessagePack](https://msgpack.org/)
|
||||||
///< format with appropriate comparison. Internally each key is
|
///< format with appropriate comparison. Internally each key is
|
||||||
@ -3178,16 +3207,33 @@ enum class value_mode {
|
|||||||
///< In terms of keys, they are not unique, i.e. has duplicates
|
///< In terms of keys, they are not unique, i.e. has duplicates
|
||||||
///< which are sorted by associated data values.
|
///< which are sorted by associated data values.
|
||||||
///< \note Not yet implemented and PRs are welcome.
|
///< \note Not yet implemented and PRs are welcome.
|
||||||
#else
|
|
||||||
multi_reverse = uint32_t(MDBX_DUPSORT) | uint32_t(MDBX_REVERSEDUP),
|
|
||||||
multi_samelength = uint32_t(MDBX_DUPSORT) | uint32_t(MDBX_DUPFIXED),
|
|
||||||
multi_ordinal = uint32_t(MDBX_DUPSORT) | uint32_t(MDBX_DUPFIXED) |
|
|
||||||
uint32_t(MDBX_INTEGERDUP),
|
|
||||||
multi_reverse_samelength = uint32_t(MDBX_DUPSORT) |
|
|
||||||
uint32_t(MDBX_REVERSEDUP) | uint32_t(MDBX_DUPFIXED)
|
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
MDBX_CXX01_CONSTEXPR_ENUM bool is_usual(value_mode mode) noexcept {
|
||||||
|
return (MDBX_db_flags_t(mode) & (MDBX_DUPSORT | MDBX_INTEGERDUP |
|
||||||
|
MDBX_DUPFIXED | MDBX_REVERSEDUP)) == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
MDBX_CXX01_CONSTEXPR_ENUM bool is_multi(value_mode mode) noexcept {
|
||||||
|
return (MDBX_db_flags_t(mode) & MDBX_DUPSORT) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
MDBX_CXX01_CONSTEXPR_ENUM bool is_ordinal(value_mode mode) noexcept {
|
||||||
|
return (MDBX_db_flags_t(mode) & MDBX_INTEGERDUP) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
MDBX_CXX01_CONSTEXPR_ENUM bool is_samelength(value_mode mode) noexcept {
|
||||||
|
return (MDBX_db_flags_t(mode) & MDBX_DUPFIXED) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
MDBX_CXX01_CONSTEXPR_ENUM bool is_reverse(value_mode mode) noexcept {
|
||||||
|
return (MDBX_db_flags_t(mode) & MDBX_REVERSEDUP) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
MDBX_CXX01_CONSTEXPR_ENUM bool is_msgpack(value_mode mode) noexcept {
|
||||||
|
return mode == value_mode::msgpack;
|
||||||
|
}
|
||||||
|
|
||||||
/// \brief A handle for an individual database (key-value spaces) in the
|
/// \brief A handle for an individual database (key-value spaces) in the
|
||||||
/// environment.
|
/// environment.
|
||||||
/// \see txn::open_map() \see txn::create_map()
|
/// \see txn::open_map() \see txn::create_map()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user