Read a present std::string field as borrowed UTF-8 bytes.
333{
335 if (!field_index || !
has(field_name))
336 return std::nullopt;
337
339 if (field.type != typeid(std::string) && field.type != typeid(detail::CompositeDynamic))
340 return std::nullopt;
341
342 const auto&
rows = std::get<std::vector<uint8_t>>(*m_rows);
345 if (field.type == typeid(detail::CompositeDynamic)) {
346 DynamicCell cell;
347 std::memcpy(&cell, source, sizeof(cell));
348 if (cell.kind != text_kind)
349 return std::nullopt;
350 slice = { cell.payload, cell.length };
351 } else {
352 std::memcpy(&slice, source, sizeof(slice));
353 }
354
355 const auto&
text = std::get<std::vector<uint8_t>>(*m_text);
357 return std::nullopt;
358
359 if (
slice.length == 0)
360 return std::string_view {};
361
362 return std::string_view(
363 reinterpret_cast<const char*
>(
text.data() +
slice.offset),
364 static_cast<size_t>(
slice.length));
365}
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::vector< double > slice(std::span< const double > data, double start_ratio, double end_ratio)
Extract a contiguous slice by ratio, returning a new vector.