95 bindAt(std::size_t
const idx, Type&& value)
const
98 auto throwErrorIfNeeded = [idx](CassError rc, std::string_view label) {
100 throw std::logic_error(
101 fmt::format(
"[{}] at idx {}: {}", label, idx, cass_error_desc(rc))
105 auto bindBytes = [
this, idx](
auto const*
data,
size_t size) {
106 return cass_statement_bind_bytes(
107 *
this, idx,
static_cast<cass_byte_t const*
>(
data), size
111 using DecayedType = std::decay_t<Type>;
112 using UCharVectorType = std::vector<unsigned char>;
113 using UintTupleType = std::tuple<uint32_t, uint32_t>;
114 using UintByteTupleType = std::tuple<uint32_t, ripple::uint256>;
115 using ByteVectorType = std::vector<ripple::uint256>;
117 if constexpr (std::is_same_v<DecayedType, ripple::uint256> ||
118 std::is_same_v<DecayedType, ripple::uint192>) {
119 auto const rc = bindBytes(value.data(), value.size());
120 throwErrorIfNeeded(rc,
"Bind ripple::base_uint");
121 }
else if constexpr (std::is_same_v<DecayedType, ripple::AccountID>) {
122 auto const rc = bindBytes(value.data(), value.size());
123 throwErrorIfNeeded(rc,
"Bind ripple::AccountID");
124 }
else if constexpr (std::is_same_v<DecayedType, UCharVectorType>) {
125 auto const rc = bindBytes(value.data(), value.size());
126 throwErrorIfNeeded(rc,
"Bind vector<unsigned char>");
127 }
else if constexpr (std::is_convertible_v<DecayedType, std::string>) {
130 bindBytes(
reinterpret_cast<unsigned char const*
>(value.data()), value.size());
131 throwErrorIfNeeded(rc,
"Bind string (as bytes)");
132 }
else if constexpr (std::is_convertible_v<DecayedType, Text>) {
134 cass_statement_bind_string_n(*
this, idx, value.text.c_str(), value.text.size());
135 throwErrorIfNeeded(rc,
"Bind string (as TEXT)");
136 }
else if constexpr (std::is_same_v<DecayedType, UintTupleType> ||
137 std::is_same_v<DecayedType, UintByteTupleType>) {
138 auto const rc = cass_statement_bind_tuple(*
this, idx,
Tuple{std::forward<Type>(value)});
139 throwErrorIfNeeded(rc,
"Bind tuple<uint32, uint32> or <uint32_t, ripple::uint256>");
140 }
else if constexpr (std::is_same_v<DecayedType, ByteVectorType>) {
142 cass_statement_bind_collection(*
this, idx,
Collection{std::forward<Type>(value)});
143 throwErrorIfNeeded(rc,
"Bind collection");
144 }
else if constexpr (std::is_same_v<DecayedType, bool>) {
145 auto const rc = cass_statement_bind_bool(*
this, idx, value ? cass_true : cass_false);
146 throwErrorIfNeeded(rc,
"Bind bool");
147 }
else if constexpr (std::is_same_v<DecayedType, Limit>) {
148 auto const rc = cass_statement_bind_int32(*
this, idx, value.limit);
149 throwErrorIfNeeded(rc,
"Bind limit (int32)");
150 }
else if constexpr (std::is_convertible_v<DecayedType, boost::uuids::uuid>) {
151 auto const uuidStr = boost::uuids::to_string(value);
153 auto rc = cass_uuid_from_string(uuidStr.c_str(), &cassUuid);
154 throwErrorIfNeeded(rc,
"CassUuid from string");
155 rc = cass_statement_bind_uuid(*
this, idx, cassUuid);
156 throwErrorIfNeeded(rc,
"Bind boost::uuid");
158 }
else if constexpr (std::is_convertible_v<DecayedType, int64_t>) {
159 auto const rc = cass_statement_bind_int64(*
this, idx, value);
160 throwErrorIfNeeded(rc,
"Bind int64");