35 #include <warehouse_ros_sqlite/warehouse_ros_sqlite_export.h>
46 void operator()(sqlite3_stmt* stmt)
const;
57 template <
typename =
void>
61 template <
char escaped_char,
char... other_chars>
64 if (c == escaped_char)
65 s.push_back(escaped_char);
69 template <
char... escaped_chars>
70 std::string
escape(
const std::string& s)
73 ans.reserve(4 *
sizeof...(escaped_chars) +
s.size());
74 for (
const auto c :
s)
100 return "`" + detail::escape<'`'>(
s) +
"`";
108 return schema::detail::escape<'\''>(c);
112 return TABLE_NAME_PREFIX + detail::escape<'@'>(db_name) +
"@" + detail::escape<'@'>(collection_name);
115 const std::string& collection_name)
118 detail::escape<'@', '"'>(collection_name) +
"\"";
127 inline WAREHOUSE_ROS_SQLITE_EXPORT std::array<unsigned char, 16>
parse_md5_hexstring(
const std::string& md5)
129 if (md5.size() != 32)
131 throw std::invalid_argument(
"md5.size() must equal 32");
133 std::array<unsigned char, 16> binary_md5;
135 for (
auto& c : binary_md5)
138 const auto substr = md5.substr(md5_idx, 2);
139 const auto t = std::strtoul(substr.c_str(), &end, 16);
140 if (substr.c_str() + 2 != end)
141 throw std::invalid_argument(
"md5 is not hex string");
142 c =
static_cast<unsigned char>(t);