Borrow a dynamic value; an absent field returns std::nullopt.
397{
399 if (!field_index || !
has(field_name)
400 ||
m_layout->
fields()[*field_index].type !=
typeid(detail::CompositeDynamic))
401 return std::nullopt;
402
403 const auto&
rows = std::get<std::vector<uint8_t>>(*m_rows);
404 DynamicCell cell;
407 if (cell.kind == null_kind)
409 if (cell.kind == integer_kind) {
410 int64_t result;
411 std::memcpy(&result, &cell.payload, sizeof(result));
413 }
414 if (cell.kind == real_kind) {
415 double result;
416 std::memcpy(&result, &cell.payload, sizeof(result));
418 }
419 if (cell.kind == text_kind) {
420 if (
auto result =
text(field_name))
422 }
423 if (cell.kind == blob_kind) {
424 if (
auto result =
blob(field_name))
426 }
427 return std::nullopt;
428}
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.
std::optional< std::string_view > text(std::string_view field_name) const noexcept
Read a present std::string field as borrowed UTF-8 bytes.
const CompositeLayout * m_layout
bool has(std::string_view field_name) const noexcept
Whether a named field exists and is present in this element.
std::optional< std::span< const uint8_t > > blob(std::string_view field_name) const noexcept
Borrow the bytes of a fixed or dynamic BLOB field.
std::variant< std::monostate, int64_t, double, std::string_view, std::span< const uint8_t > > CompositeValue
Borrowed value of a present dynamic field; monostate represents NULL.