76 bindAt(std::size_t
const idx, Type&& value)
const
79 auto throwErrorIfNeeded = [idx](CassError rc, std::string_view label) {
81 throw std::logic_error(
82 fmt::format(
"[{}] at idx {}: {}", label, idx, cass_error_desc(rc))
87 auto bindBytes = [
this, idx](
auto const*
data,
size_t size) {
88 return cass_statement_bind_bytes(
89 *
this, idx,
static_cast<cass_byte_t const*
>(
data), size
93 using DecayedType = std::decay_t<Type>;
94 using UCharVectorType = std::vector<unsigned char>;
95 using UintTupleType = std::tuple<uint32_t, uint32_t>;
96 using UintByteTupleType = std::tuple<uint32_t, ripple::uint256>;
97 using ByteVectorType = std::vector<ripple::uint256>;
100 std::is_same_v<DecayedType, ripple::uint256> ||
101 std::is_same_v<DecayedType, ripple::uint192>
103 auto const rc = bindBytes(value.data(), value.size());
104 throwErrorIfNeeded(rc,
"Bind ripple::base_uint");
105 }
else if constexpr (std::is_same_v<DecayedType, ripple::AccountID>) {
106 auto const rc = bindBytes(value.data(), value.size());
107 throwErrorIfNeeded(rc,
"Bind ripple::AccountID");
108 }
else if constexpr (std::is_same_v<DecayedType, UCharVectorType>) {
109 auto const rc = bindBytes(value.data(), value.size());
110 throwErrorIfNeeded(rc,
"Bind vector<unsigned char>");
111 }
else if constexpr (std::is_convertible_v<DecayedType, std::string>) {
114 bindBytes(
reinterpret_cast<unsigned char const*
>(value.data()), value.size());
115 throwErrorIfNeeded(rc,
"Bind string (as bytes)");
116 }
else if constexpr (std::is_convertible_v<DecayedType, Text>) {
118 cass_statement_bind_string_n(*
this, idx, value.text.c_str(), value.text.size());
119 throwErrorIfNeeded(rc,
"Bind string (as TEXT)");
120 }
else if constexpr (
121 std::is_same_v<DecayedType, UintTupleType> ||
122 std::is_same_v<DecayedType, UintByteTupleType>
124 auto const rc = cass_statement_bind_tuple(*
this, idx,
Tuple{std::forward<Type>(value)});
125 throwErrorIfNeeded(rc,
"Bind tuple<uint32, uint32> or <uint32_t, ripple::uint256>");
126 }
else if constexpr (std::is_same_v<DecayedType, ByteVectorType>) {
128 cass_statement_bind_collection(*
this, idx,
Collection{std::forward<Type>(value)});
129 throwErrorIfNeeded(rc,
"Bind collection");
130 }
else if constexpr (std::is_same_v<DecayedType, bool>) {
131 auto const rc = cass_statement_bind_bool(*
this, idx, value ? cass_true : cass_false);
132 throwErrorIfNeeded(rc,
"Bind bool");
133 }
else if constexpr (std::is_same_v<DecayedType, Limit>) {
134 auto const rc = cass_statement_bind_int32(*
this, idx, value.limit);
135 throwErrorIfNeeded(rc,
"Bind limit (int32)");
136 }
else if constexpr (std::is_convertible_v<DecayedType, boost::uuids::uuid>) {
137 auto const uuidStr = boost::uuids::to_string(value);
139 auto rc = cass_uuid_from_string(uuidStr.c_str(), &cassUuid);
140 throwErrorIfNeeded(rc,
"CassUuid from string");
141 rc = cass_statement_bind_uuid(*
this, idx, cassUuid);
142 throwErrorIfNeeded(rc,
"Bind boost::uuid");
144 }
else if constexpr (std::is_convertible_v<DecayedType, int64_t>) {
145 auto const rc = cass_statement_bind_int64(*
this, idx, value);
146 throwErrorIfNeeded(rc,
"Bind int64");