renamed blob to blob_type_t

This commit is contained in:
2026-01-07 09:21:10 +01:00
parent 41f6c9f516
commit f30c250a20
44 changed files with 88 additions and 80 deletions
+1 -1
View File
@@ -31,7 +31,7 @@ public:
virtual void read_value(const char *id, size_t index, char *value, size_t size) = 0;
virtual void read_value(const char *id, size_t index, std::string &value) = 0;
virtual void read_value(const char *id, size_t index, std::string &value, size_t size) = 0;
virtual void read_value(const char *id, size_t index, blob &value) = 0;
virtual void read_value(const char *id, size_t index, blob_type_t &value) = 0;
virtual void read_value(const char *id, size_t index, value &value, size_t size) = 0;
};
+1 -1
View File
@@ -32,7 +32,7 @@ public:
virtual void write_value(size_t pos, const char *x, size_t size) = 0;
virtual void write_value(size_t pos, const std::string &x) = 0;
virtual void write_value(size_t pos, const std::string &x, size_t size) = 0;
virtual void write_value(size_t pos, const blob &x) = 0;
virtual void write_value(size_t pos, const blob_type_t &x) = 0;
virtual void write_value(size_t pos, const value &x, size_t size) = 0;
};
@@ -34,7 +34,7 @@ public:
void operator()(date_type_t &x) { this->convert(x); }
void operator()(time_type_t &x) { this->convert(x); }
void operator()(timestamp &x) { this->convert(x); }
void operator()(blob &x) { this->convert(x); }
void operator()(blob_type_t &x) { this->convert(x); }
private:
result<Type, conversion_error> result_{};
+13 -13
View File
@@ -158,7 +158,7 @@ result<DestType, conversion_error> to(const std::string &source, std::enable_if_
}
template < typename DestType >
result<DestType, conversion_error> to(const blob &source, std::enable_if_t<std::is_same_v<DestType, blob>>* = nullptr) {
result<DestType, conversion_error> to(const blob_type_t &source, std::enable_if_t<std::is_same_v<DestType, blob_type_t>>* = nullptr) {
return ok(source);
}
@@ -211,7 +211,7 @@ result<DestType, conversion_error> to(const SourceType &source, std::enable_if_t
}
template < typename DestType, typename SourceType >
result<DestType, conversion_error> to(const SourceType &/*source*/, std::enable_if_t<std::is_same_v<SourceType, blob> &&std::is_same_v<DestType, std::string>>* = nullptr) {
result<DestType, conversion_error> to(const SourceType &/*source*/, std::enable_if_t<std::is_same_v<SourceType, blob_type_t> &&std::is_same_v<DestType, std::string>>* = nullptr) {
return failure(conversion_error::NotConvertable);
}
@@ -224,12 +224,12 @@ result<DestType, conversion_error> to(const SourceType &source, std::enable_if_t
}
template < typename DestType, typename SourceType >
result<DestType, conversion_error> to(const SourceType &/*source*/, std::enable_if_t<std::is_arithmetic_v<DestType> && std::is_same_v<SourceType, blob>>* = nullptr) {
result<DestType, conversion_error> to(const SourceType &/*source*/, std::enable_if_t<std::is_arithmetic_v<DestType> && std::is_same_v<SourceType, blob_type_t>>* = nullptr) {
return failure(conversion_error::NotConvertable);
}
template < typename DestType, typename SourceType >
result<DestType, conversion_error> to(const SourceType &source, std::enable_if_t<std::is_integral_v<SourceType> && std::is_same_v<DestType, blob>>* = nullptr) {
result<DestType, conversion_error> to(const SourceType &source, std::enable_if_t<std::is_integral_v<SourceType> && std::is_same_v<DestType, blob_type_t>>* = nullptr) {
DestType result;
result.resize(sizeof(source));
std::memcpy(result.data(), &source, sizeof(source));
@@ -238,17 +238,17 @@ result<DestType, conversion_error> to(const SourceType &source, std::enable_if_t
}
template < typename DestType, typename SourceType >
result<DestType, conversion_error> to(const SourceType &/*source*/, std::enable_if_t<std::is_floating_point_v<SourceType> && std::is_same_v<DestType, blob>>* = nullptr) {
result<DestType, conversion_error> to(const SourceType &/*source*/, std::enable_if_t<std::is_floating_point_v<SourceType> && std::is_same_v<DestType, blob_type_t>>* = nullptr) {
return failure(conversion_error::NotConvertable);
}
template < typename DestType, typename SourceType >
result<DestType, conversion_error> to(const SourceType &/*source*/, std::enable_if_t<std::is_same_v<SourceType, std::string> && std::is_same_v<DestType, blob>>* = nullptr) {
result<DestType, conversion_error> to(const SourceType &/*source*/, std::enable_if_t<std::is_same_v<SourceType, std::string> && std::is_same_v<DestType, blob_type_t>>* = nullptr) {
return failure(conversion_error::NotConvertable);
}
template < typename DestType, typename SourceType >
result<DestType, conversion_error> to(const SourceType &/*source*/, std::enable_if_t<std::is_same_v<SourceType, const char*> && std::is_same_v<DestType, blob>>* = nullptr) {
result<DestType, conversion_error> to(const SourceType &/*source*/, std::enable_if_t<std::is_same_v<SourceType, const char*> && std::is_same_v<DestType, blob_type_t>>* = nullptr) {
return failure(conversion_error::NotConvertable);
}
@@ -353,17 +353,17 @@ result<DestType, conversion_error> to(const SourceType &/*source*/, std::enable_
}
template < typename DestType, typename SourceType >
result<DestType, conversion_error> to(const SourceType &/*source*/, std::enable_if_t<std::is_same_v<blob, DestType> && std::is_same_v<date_type_t, SourceType>>* = nullptr) {
result<DestType, conversion_error> to(const SourceType &/*source*/, std::enable_if_t<std::is_same_v<blob_type_t, DestType> && std::is_same_v<date_type_t, SourceType>>* = nullptr) {
return failure(conversion_error::NotConvertable);
}
template < typename DestType, typename SourceType >
result<DestType, conversion_error> to(const SourceType &/*source*/, std::enable_if_t<std::is_same_v<blob, DestType> && std::is_same_v<time_type_t, SourceType>>* = nullptr) {
result<DestType, conversion_error> to(const SourceType &/*source*/, std::enable_if_t<std::is_same_v<blob_type_t, DestType> && std::is_same_v<time_type_t, SourceType>>* = nullptr) {
return failure(conversion_error::NotConvertable);
}
template < typename DestType, typename SourceType >
result<DestType, conversion_error> to(const SourceType &/*source*/, std::enable_if_t<std::is_same_v<blob, DestType> && std::is_same_v<timestamp, SourceType>>* = nullptr) {
result<DestType, conversion_error> to(const SourceType &/*source*/, std::enable_if_t<std::is_same_v<blob_type_t, DestType> && std::is_same_v<timestamp, SourceType>>* = nullptr) {
return failure(conversion_error::NotConvertable);
}
@@ -413,17 +413,17 @@ result<DestType, conversion_error> to(const SourceType &/*source*/, std::enable_
}
template < typename DestType>
result<DestType, conversion_error> to(const blob &/*source*/, std::enable_if_t<std::is_same_v<date_type_t, DestType>>* = nullptr) {
result<DestType, conversion_error> to(const blob_type_t &/*source*/, std::enable_if_t<std::is_same_v<date_type_t, DestType>>* = nullptr) {
return failure(conversion_error::NotConvertable);
}
template < typename DestType>
result<DestType, conversion_error> to(const blob &/*source*/, std::enable_if_t<std::is_same_v<time_type_t, DestType>>* = nullptr) {
result<DestType, conversion_error> to(const blob_type_t &/*source*/, std::enable_if_t<std::is_same_v<time_type_t, DestType>>* = nullptr) {
return failure(conversion_error::NotConvertable);
}
template < typename DestType>
result<DestType, conversion_error> to(const blob &/*source*/, std::enable_if_t<std::is_same_v<timestamp, DestType>>* = nullptr) {
result<DestType, conversion_error> to(const blob_type_t &/*source*/, std::enable_if_t<std::is_same_v<timestamp, DestType>>* = nullptr) {
return failure(conversion_error::NotConvertable);
}
@@ -131,10 +131,10 @@ struct data_type_traits<std::string, void> {
};
template<>
struct data_type_traits<blob, void> {
struct data_type_traits<blob_type_t, void> {
static basic_type type(std::size_t /*size*/) { return basic_type::Blob; }
static void read_value(attribute_reader &reader, const char *id, size_t index, utils::blob &value, size_t /*size*/ = 0);
static void bind_value(attribute_writer &binder, size_t index, utils::blob &value, size_t /*size*/ = 0);
static void read_value(attribute_reader &reader, const char *id, size_t index, utils::blob_type_t &value, size_t /*size*/ = 0);
static void bind_value(attribute_writer &binder, size_t index, utils::blob_type_t &value, size_t /*size*/ = 0);
};
template<>
+1 -1
View File
@@ -18,7 +18,7 @@ namespace matador::utils {
* @param data Binary data to be converted
* @return Binary data as string
*/
MATADOR_UTILS_API std::string to_string(const blob &data);
MATADOR_UTILS_API std::string to_string(const blob_type_t &data);
MATADOR_UTILS_API std::string to_string(const date_type_t &data);
MATADOR_UTILS_API std::string to_string(const time_type_t &data);
+2 -2
View File
@@ -12,7 +12,7 @@ namespace matador::utils {
enum class basic_type : uint8_t;
using byte = unsigned char;
using blob = std::vector<byte>;
using blob_type_t = std::vector<byte>;
using timestamp = std::chrono::system_clock::time_point;
struct date_type_t;
@@ -25,7 +25,7 @@ using database_type = std::variant<
bool,
const char*,
std::string,
blob,
blob_type_t,
timestamp,
date_type_t,
time_type_t,
+1 -1
View File
@@ -14,7 +14,7 @@ template<typename Type>
size_t determine_size(const Type &/*val*/) { return 0; }
size_t determine_size(const std::string &val);
size_t determine_size(const char *val);
size_t determine_size(const blob &val);
size_t determine_size(const blob_type_t &val);
}