blob progress
This commit is contained in:
@@ -24,7 +24,12 @@ void any_type_to_string_visitor::to_string(std::string &val)
|
||||
|
||||
void any_type_to_string_visitor::to_string(utils::blob &val)
|
||||
{
|
||||
|
||||
// "This is a binary Data string" as binary data:
|
||||
// MySQL: X'5468697320697320612062616E617279204461746120737472696E67'
|
||||
// Postgres: E'\\x5468697320697320612062616E617279204461746120737472696E67'
|
||||
// MSSQL: 0x5468697320697320612062616E617279204461746120737472696E67
|
||||
// Sqlite: X'5468697320697320612062616E617279204461746120737472696E67'
|
||||
result = d.token_at(dialect::token_t::BEGIN_BINARY_DATA) + utils::to_string(val) + d.token_at(dialect::token_t::END_BINARY_DATA);
|
||||
}
|
||||
|
||||
void any_type_to_string_visitor::to_string(placeholder &/*val*/)
|
||||
@@ -292,20 +297,17 @@ query_builder &query_builder::values(const std::vector<any_type> &values)
|
||||
std::string result{"("};
|
||||
if (values.size() < 2) {
|
||||
for (auto val: values) {
|
||||
// query_.result_vars.push_back(val);
|
||||
std::visit(value_to_string_, val);
|
||||
result.append(value_to_string_.result);
|
||||
}
|
||||
} else {
|
||||
auto it = values.begin();
|
||||
auto val = *it++;
|
||||
// query_.result_vars.push_back(val);
|
||||
std::visit(value_to_string_, val);
|
||||
result.append(value_to_string_.result);
|
||||
for (; it != values.end(); ++it) {
|
||||
result.append(", ");
|
||||
val = *it;
|
||||
// query_.result_vars.push_back(val);
|
||||
std::visit(value_to_string_, val);
|
||||
result.append(value_to_string_.result);
|
||||
}
|
||||
|
||||
@@ -21,6 +21,21 @@ const std::string &to_string(const std::string &str)
|
||||
return str;
|
||||
}
|
||||
|
||||
std::string to_string(const blob &data)
|
||||
{
|
||||
static constexpr char HEXITS[] = "0123456789ABCDEF";
|
||||
|
||||
std::string str(2 * data.size(), '\0');
|
||||
auto item = str.begin();
|
||||
|
||||
for(auto c : data) {
|
||||
*item++ = HEXITS[c >> 4];
|
||||
*item++ = HEXITS[c & 0x0F];
|
||||
}
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
size_t split(const std::string &str, char delim, std::vector<std::string> &values)
|
||||
{
|
||||
std::stringstream ss(str);
|
||||
|
||||
Reference in New Issue
Block a user