Validate and borrow packed Composite-compatible NDData.
27{
28 const auto*
element_bytes = std::get_if<std::vector<uint8_t>>(&elements);
29 const auto* text_bytes = std::get_if<std::vector<uint8_t>>(&text);
30 const auto* blob_bytes = std::get_if<std::vector<uint8_t>>(&blob);
32 if (!
element_bytes || !text_bytes || !blob_bytes || stride == 0
35 "as_composite_access: invalid storage or element stride");
36 return std::nullopt;
37 }
38
39 for (
const auto& field :
layout.fields()) {
40 if (field.offset_bytes > stride || field.size_bytes > stride - field.offset_bytes
41 || ((field.type == typeid(std::string)
42 || field.type == typeid(std::vector<uint8_t>))
43 && field.size_bytes != 2 * sizeof(uint64_t))
44 || (field.type == typeid(detail::CompositeDynamic)
45 && field.size_bytes != 3 * sizeof(uint64_t))) {
47 "as_composite_access: invalid layout for field '{}'", field.name);
48 return std::nullopt;
49 }
50 }
51
53}
#define MF_WARN(comp, ctx,...)
CompositeAccess(const DataVariant &elements, const DataVariant &text, const DataVariant &blob, const CompositeLayout &layout) noexcept
std::span< const uint8_t > element_bytes() const noexcept
Borrow all packed element bytes without conversion.
const CompositeLayout & layout() const noexcept
Layout used to interpret packed elements.
size_t stride_bytes() const noexcept
Bytes per packed element after finalization.
@ Runtime
General runtime operations (default fallback)
@ Kakshya
Containers[Signalsource, Stream, File], Regions, DataProcessors.