Write binary bytes to a fixed or dynamic BLOB field.
266{
268 const std::type_index expected = declared
269 &&
m_layout.
fields()[*declared].type ==
typeid(detail::CompositeDynamic)
270 ? typeid(detail::CompositeDynamic) : typeid(std::vector<uint8_t>);
272 if (!field_index)
273 return false;
274
275 auto& blob = std::get<std::vector<uint8_t>>(
m_blob);
276 if (
value.size() > blob.max_size() - blob.size())
277 return false;
278 const std::vector<uint8_t> value_copy(
value.begin(),
value.end());
279 const TextSlice
slice {
static_cast<uint64_t
>(blob.size()),
static_cast<uint64_t
>(value_copy.size()) };
280 blob.insert(blob.end(), value_copy.begin(), value_copy.end());
281
283 auto&
rows = std::get<std::vector<uint8_t>>(
m_rows);
285 if (field.type == typeid(detail::CompositeDynamic)) {
286 const DynamicCell cell { blob_kind,
slice.offset,
slice.length };
287 std::memcpy(destination, &cell, sizeof(cell));
288 } else {
289 std::memcpy(destination, &
slice,
sizeof(
slice));
290 }
292 return true;
293}
void set_present(size_t index, size_t field_index, bool present) noexcept
std::optional< CompositeSlice > slice(size_t start, size_t count) const
Borrow consecutive elements without copying.
std::optional< size_t > validate_write(size_t index, std::string_view field_name, std::type_index type) const
size_t stride_bytes() const noexcept
Bytes per packed element after finalization.
const std::vector< CompositeField > & fields() const noexcept
Declared fields in element order, with finalized byte offsets.
std::optional< size_t > find_field(std::string_view name) const noexcept
Find a field index by name, or std::nullopt if absent.