MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ as_composite_access

MAYAFLUX_API std::optional< CompositeAccess > as_composite_access ( const DataVariant &  ,
const DataVariant &  ,
const DataVariant &  ,
const CompositeLayout &   
)
friend

Validate and borrow packed Composite-compatible NDData.

Parameters
elementsDataVariant holding vector<uint8_t> packed elements.
textDataVariant holding vector<uint8_t> UTF-8 bytes.
blobDataVariant holding vector<uint8_t> binary bytes.
layoutFinalized layout for the packed elements.
Returns
Access view, or std::nullopt for incompatible storage or layout.
Note
This validates storage types, stride, and field extents. Individual text and binary offset bounds are checked when fields are read.

Definition at line 24 of file CompositeAccess.cpp.

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);
31 const size_t stride = layout.stride_bytes();
32 if (!element_bytes || !text_bytes || !blob_bytes || stride == 0
33 || element_bytes->size() % 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
52 return CompositeAccess(elements, text, blob, layout);
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.
Definition Composite.hpp:86
@ Runtime
General runtime operations (default fallback)
@ Kakshya
Containers[Signalsource, Stream, File], Regions, DataProcessors.