8#include <userver/utils/strong_typedef.hpp>
10#include <userver/storages/clickhouse/io/type_traits.hpp>
11#include <userver/storages/clickhouse/io/typedefs.hpp>
13USERVER_NAMESPACE_BEGIN
17std::string Escape(uint8_t);
18std::string Escape(uint16_t);
19std::string Escape(uint32_t);
20std::string Escape(uint64_t);
21std::string Escape(int8_t);
22std::string Escape(int16_t);
23std::string Escape(int32_t);
24std::string Escape(int64_t);
26std::string Escape(
const char* source);
27std::string Escape(
const std::string& source);
28std::string Escape(std::string_view source);
30std::string Escape(std::chrono::system_clock::time_point source);
31std::string Escape(DateTime64Milli source);
32std::string Escape(DateTime64Micro source);
33std::string Escape(DateTime64Nano source);
35template <
typename Container>
36std::string Escape(
const Container& source) {
37 static_assert(traits::kIsRange<Container>,
38 "There's no escape implementation for the type.");
41 if constexpr (traits::kIsSizeable<Container>) {
43 constexpr size_t kResultReserveMultiplier = 5;
44 result.reserve(source.size() * kResultReserveMultiplier);
46 result.push_back(
'[');
48 bool is_first_item =
true;
49 for (
const auto& item : source) {
51 result.push_back(
',');
53 result += impl::Escape(item);
54 is_first_item =
false;
56 result.push_back(
']');