added assignment from value, conversion to database_type and appropriate tests

This commit is contained in:
2026-04-05 12:48:13 +02:00
parent 9e4660c4ee
commit 1806e2670c
7 changed files with 170 additions and 5 deletions
+1
View File
@@ -42,6 +42,7 @@ public:
[[nodiscard]] utils::constraints type() const;
[[nodiscard]] size_t size() const;
[[nodiscard]] int index() const;
[[nodiscard]] utils::value value() const;
template<class Type>
std::optional<Type> as() const {
+1
View File
@@ -9,6 +9,7 @@ namespace matador::utils {
enum class utils_error {
InvalidVersionString,
IdentifierTypeMismatch
};
class utils_category_impl final : public std::error_category
+7 -4
View File
@@ -16,6 +16,7 @@
#include <variant>
namespace matador::utils {
class value;
class identifier_serializer {
public:
virtual ~identifier_serializer() = default;
@@ -94,7 +95,6 @@ public:
>;
identifier();
template<typename Type, std::enable_if_t<is_identifier_supported_v<Type>, int> = 0>
explicit identifier(Type &&id)
: value_(std::forward<Type>(id)) {
@@ -117,17 +117,20 @@ public:
}
identifier& operator=(const std::string &value);
identifier& operator=(const char *value);
template<typename Type, std::enable_if_t<is_identifier_supported_v<Type> && std::is_same_v<std::decay_t<Type>, bool>, int> = 0>
identifier &operator=(Type &&value) {
identifier& operator=(Type &&value) {
value_ = std::forward<Type>(value);
return *this;
}
~identifier() = default;
result<void, error> assign(const value &val);
static result<identifier, error> from_value(const value &val);
[[nodiscard]] database_type to_database_type() const;
bool operator==(const identifier &x) const;
bool operator!=(const identifier &x) const;
bool operator<(const identifier &x) const;