renamed blob to blob_type_t
This commit is contained in:
@@ -45,7 +45,7 @@ public:
|
||||
void write_value(size_t pos, const char* x, size_t size) override;
|
||||
void write_value(size_t pos, const std::string& x) override;
|
||||
void write_value(size_t pos, const std::string& x, size_t size) override;
|
||||
void write_value(size_t pos, const utils::blob& x) override;
|
||||
void write_value(size_t pos, const utils::blob_type_t& x) override;
|
||||
void write_value(size_t pos, const utils::value& x, size_t size) override;
|
||||
|
||||
private:
|
||||
|
||||
@@ -34,7 +34,7 @@ struct basic_type_to_string_visitor
|
||||
void operator()(const utils::date_type_t &x) { result = writer->to_string(x); }
|
||||
void operator()(const utils::time_type_t &x) { result = writer->to_string(x); }
|
||||
void operator()(const utils::timestamp &x) { result = writer->to_string(x); }
|
||||
void operator()(const utils::blob &x) { result = writer->to_string(x); }
|
||||
void operator()(const utils::blob_type_t &x) { result = writer->to_string(x); }
|
||||
|
||||
attribute_string_writer *writer{};
|
||||
sql::query_context &query;
|
||||
|
||||
@@ -78,7 +78,7 @@ public:
|
||||
void write_value(size_t pos, const char *x, size_t size) override;
|
||||
void write_value(size_t pos, const std::string &x) override;
|
||||
void write_value(size_t pos, const std::string &x, size_t size) override;
|
||||
void write_value(size_t pos, const utils::blob &x) override;
|
||||
void write_value(size_t pos, const utils::blob_type_t &x) override;
|
||||
void write_value(size_t pos, const utils::value &x, size_t size) override;
|
||||
|
||||
private:
|
||||
|
||||
@@ -37,7 +37,7 @@ public:
|
||||
using sql_func_to_string_map = std::unordered_map<sql_function_t, std::string>;
|
||||
|
||||
using next_placeholder_func = std::function<std::string(size_t)>;
|
||||
using to_escaped_string_func = std::function<std::string(const utils::blob &)>;
|
||||
using to_escaped_string_func = std::function<std::string(const utils::blob_type_t &)>;
|
||||
|
||||
public:
|
||||
[[nodiscard]] const std::string& token_at(dialect_token token) const;
|
||||
@@ -115,7 +115,7 @@ public:
|
||||
*/
|
||||
[[nodiscard]] std::string next_placeholder(const std::vector<std::string> &bind_vars) const;
|
||||
|
||||
[[nodiscard]] std::string to_escaped_string(const utils::blob &value, const connection_impl *conn = nullptr) const;
|
||||
[[nodiscard]] std::string to_escaped_string(const utils::blob_type_t &value, const connection_impl *conn = nullptr) const;
|
||||
|
||||
/**
|
||||
* Returns the default schema name.
|
||||
@@ -183,7 +183,7 @@ private:
|
||||
friend class dialect_builder;
|
||||
|
||||
next_placeholder_func placeholder_func_ = [](size_t) { return "?"; };
|
||||
to_escaped_string_func to_escaped_string_func_ = [](const utils::blob &val) { return utils::to_string(val); };
|
||||
to_escaped_string_func to_escaped_string_func_ = [](const utils::blob_type_t &val) { return utils::to_string(val); };
|
||||
|
||||
escape_identifier_t identifier_escape_type_ = escape_identifier_t::ESCAPE_BOTH_SAME;
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
#include "matador/utils/version.hpp"
|
||||
|
||||
namespace matador::utils {
|
||||
using blob = std::vector<unsigned char>;
|
||||
using blob_type_t = std::vector<unsigned char>;
|
||||
}
|
||||
|
||||
namespace matador::sql {
|
||||
@@ -43,7 +43,7 @@ public:
|
||||
|
||||
[[nodiscard]] const class dialect &dialect() const;
|
||||
|
||||
[[nodiscard]] virtual std::string to_escaped_string(const utils::blob &value) const = 0;
|
||||
[[nodiscard]] virtual std::string to_escaped_string(const utils::blob_type_t &value) const = 0;
|
||||
[[nodiscard]] const connection_info &info() const;
|
||||
|
||||
protected:
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
|
||||
@@ -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_{};
|
||||
|
||||
@@ -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<>
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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);
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user