56 explicit Statement(std::string_view query, Args&&... args)
57 :
ManagedObject{cass_statement_new_n(query.
data(), query.size(), sizeof...(args)), kDELETER}
59 cass_statement_set_consistency(*
this, CASS_CONSISTENCY_QUORUM);
60 cass_statement_set_is_idempotent(*
this, cass_true);
61 bind<Args...>(std::forward<Args>(args)...);
91 bindAt(std::size_t
const idx, Type&& value)
const
94 auto throwErrorIfNeeded = [idx](CassError rc, std::string_view label) {
96 throw std::logic_error(fmt::format(
"[{}] at idx {}: {}", label, idx, cass_error_desc(rc)));
99 auto bindBytes = [
this, idx](
auto const*
data,
size_t size) {
100 return cass_statement_bind_bytes(*
this, idx,
static_cast<cass_byte_t const*
>(
data), size);
103 using DecayedType = std::decay_t<Type>;
104 using UCharVectorType = std::vector<unsigned char>;
105 using UintTupleType = std::tuple<uint32_t, uint32_t>;
106 using UintByteTupleType = std::tuple<uint32_t, ripple::uint256>;
107 using ByteVectorType = std::vector<ripple::uint256>;
109 if constexpr (std::is_same_v<DecayedType, ripple::uint256> || std::is_same_v<DecayedType, ripple::uint192>) {
110 auto const rc = bindBytes(value.data(), value.size());
111 throwErrorIfNeeded(rc,
"Bind ripple::base_uint");
112 }
else if constexpr (std::is_same_v<DecayedType, ripple::AccountID>) {
113 auto const rc = bindBytes(value.data(), value.size());
114 throwErrorIfNeeded(rc,
"Bind ripple::AccountID");
115 }
else if constexpr (std::is_same_v<DecayedType, UCharVectorType>) {
116 auto const rc = bindBytes(value.data(), value.size());
117 throwErrorIfNeeded(rc,
"Bind vector<unsigned char>");
118 }
else if constexpr (std::is_convertible_v<DecayedType, std::string>) {
120 auto const rc = bindBytes(
reinterpret_cast<unsigned char const*
>(value.data()), value.size());
121 throwErrorIfNeeded(rc,
"Bind string (as bytes)");
122 }
else if constexpr (std::is_convertible_v<DecayedType, Text>) {
123 auto const rc = cass_statement_bind_string_n(*
this, idx, value.text.c_str(), value.text.size());
124 throwErrorIfNeeded(rc,
"Bind string (as TEXT)");
125 }
else if constexpr (std::is_same_v<DecayedType, UintTupleType> ||
126 std::is_same_v<DecayedType, UintByteTupleType>) {
127 auto const rc = cass_statement_bind_tuple(*
this, idx,
Tuple{std::forward<Type>(value)});
128 throwErrorIfNeeded(rc,
"Bind tuple<uint32, uint32> or <uint32_t, ripple::uint256>");
129 }
else if constexpr (std::is_same_v<DecayedType, ByteVectorType>) {
130 auto const rc = cass_statement_bind_collection(*
this, idx,
Collection{std::forward<Type>(value)});
131 throwErrorIfNeeded(rc,
"Bind collection");
132 }
else if constexpr (std::is_same_v<DecayedType, bool>) {
133 auto const rc = cass_statement_bind_bool(*
this, idx, value ? cass_true : cass_false);
134 throwErrorIfNeeded(rc,
"Bind bool");
135 }
else if constexpr (std::is_same_v<DecayedType, Limit>) {
136 auto const rc = cass_statement_bind_int32(*
this, idx, value.limit);
137 throwErrorIfNeeded(rc,
"Bind limit (int32)");
140 else if constexpr (std::is_convertible_v<DecayedType, int64_t>) {
141 auto const rc = cass_statement_bind_int64(*
this, idx, value);
142 throwErrorIfNeeded(rc,
"Bind int64");