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, xrpl::uint256>;
97 using ByteVectorType = std::vector<xrpl::uint256>;
100 std::is_same_v<DecayedType, xrpl::uint256> || std::is_same_v<DecayedType, xrpl::uint192>
102 auto const rc = bindBytes(value.data(), value.size());
103 throwErrorIfNeeded(rc,
"Bind xrpl::base_uint");
104 }
else if constexpr (std::is_same_v<DecayedType, xrpl::AccountID>) {
105 auto const rc = bindBytes(value.data(), value.size());
106 throwErrorIfNeeded(rc,
"Bind xrpl::AccountID");
107 }
else if constexpr (std::is_same_v<DecayedType, UCharVectorType>) {
108 auto const rc = bindBytes(value.data(), value.size());
109 throwErrorIfNeeded(rc,
"Bind vector<unsigned char>");
110 }
else if constexpr (std::is_convertible_v<DecayedType, std::string>) {
113 bindBytes(
reinterpret_cast<unsigned char const*
>(value.data()), value.size());
114 throwErrorIfNeeded(rc,
"Bind string (as bytes)");
115 }
else if constexpr (std::is_convertible_v<DecayedType, Text>) {
117 cass_statement_bind_string_n(*
this, idx, value.text.c_str(), value.text.size());
118 throwErrorIfNeeded(rc,
"Bind string (as TEXT)");
119 }
else if constexpr (
120 std::is_same_v<DecayedType, UintTupleType> ||
121 std::is_same_v<DecayedType, UintByteTupleType>
123 auto const rc = cass_statement_bind_tuple(*
this, idx,
Tuple{std::forward<Type>(value)});
124 throwErrorIfNeeded(rc,
"Bind tuple<uint32, uint32> or <uint32_t, xrpl::uint256>");
125 }
else if constexpr (std::is_same_v<DecayedType, ByteVectorType>) {
127 cass_statement_bind_collection(*
this, idx,
Collection{std::forward<Type>(value)});
128 throwErrorIfNeeded(rc,
"Bind collection");
129 }
else if constexpr (std::is_same_v<DecayedType, bool>) {
130 auto const rc = cass_statement_bind_bool(*
this, idx, value ? cass_true : cass_false);
131 throwErrorIfNeeded(rc,
"Bind bool");
132 }
else if constexpr (std::is_same_v<DecayedType, Limit>) {
133 auto const rc = cass_statement_bind_int32(*
this, idx, value.limit);
134 throwErrorIfNeeded(rc,
"Bind limit (int32)");
135 }
else if constexpr (std::is_convertible_v<DecayedType, boost::uuids::uuid>) {
136 auto const uuidStr = boost::uuids::to_string(value);
138 auto rc = cass_uuid_from_string(uuidStr.c_str(), &cassUuid);
139 throwErrorIfNeeded(rc,
"CassUuid from string");
140 rc = cass_statement_bind_uuid(*
this, idx, cassUuid);
141 throwErrorIfNeeded(rc,
"Bind boost::uuid");
143 }
else if constexpr (std::is_convertible_v<DecayedType, int64_t>) {
144 auto const rc = cass_statement_bind_int64(*
this, idx, value);
145 throwErrorIfNeeded(rc,
"Bind int64");