MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
MayaFlux::Kakshya::CompositeArray Class Reference

Owns a sequence of values that share a CompositeLayout. More...

#include <Composite.hpp>

+ Collaboration diagram for MayaFlux::Kakshya::CompositeArray:

Public Member Functions

std::optional< CompositeAccess > access () const
 Validate and borrow the packed NDData stores and layout.
 
size_t append ()
 Append one zero-initialized element with no fields present.
 
std::optional< Composite > at (size_t index) const noexcept
 Borrow an element by index.
 
const DataVariant & blob_data () const noexcept
 Borrow the binary byte store used by BLOB fields.
 
bool clear (size_t index, std::string_view field_name)
 Mark a field absent without removing its stored bytes.
 
 CompositeArray (CompositeLayout layout)
 Finalize a layout and construct an empty array.
 
const DataVariant & element_data () const noexcept
 Borrow the full packed-element DataVariant without conversion.
 
bool empty () const noexcept
 Whether this array contains no elements.
 
const CompositeLayout & layout () const noexcept
 Finalized layout shared by all elements.
 
template<typename T >
requires ArithmeticData<T>
bool set (size_t index, std::string_view field_name, T value)
 Write an arithmetic field of an existing element.
 
bool set_blob (size_t index, std::string_view field_name, std::span< const uint8_t > value)
 Write binary bytes to a fixed or dynamic BLOB field.
 
bool set_null (size_t index, std::string_view field_name)
 Write a present NULL to a dynamic field.
 
bool set_text (size_t index, std::string_view field_name, std::string_view value)
 Write UTF-8 bytes to a std::string field.
 
size_t size () const noexcept
 Number of packed elements.
 
std::optional< CompositeSlice > slice (const Region &region) const
 Borrow an inclusive, one-dimensional Region of elements.
 
std::optional< CompositeSlice > slice (size_t start, size_t count) const
 Borrow consecutive elements without copying.
 
const DataVariant & text_data () const noexcept
 Borrow the UTF-8 byte DataVariant used by text fields.
 
template<typename T >
requires (ArithmeticData<T> && DataVariantElement<T>)
std::optional< CompositeProjection > to_nddata (std::string_view field_name) const
 Materialize one exact-type numeric field as homogeneous NDData.
 

Private Member Functions

bool is_present (size_t index, size_t field_index) const noexcept
 
bool set_integer (size_t index, std::string_view field_name, int64_t value)
 
void set_present (size_t index, size_t field_index, bool present) noexcept
 
bool set_real (size_t index, std::string_view field_name, double value)
 
std::optional< size_t > validate_dynamic_write (size_t index, std::string_view field_name) const
 
std::optional< size_t > validate_write (size_t index, std::string_view field_name, std::type_index type) const
 

Private Attributes

DataVariant m_blob { std::vector<uint8_t> {} }
 
CompositeLayout m_layout
 
DataVariant m_rows { std::vector<uint8_t> {} }
 
DataVariant m_text { std::vector<uint8_t> {} }
 

Friends

class Composite
 
class CompositeInsertion
 

Detailed Description

Owns a sequence of values that share a CompositeLayout.

Owns three uint8_t DataVariants: fixed-stride packed elements, variable- length UTF-8 text, and binary bytes. The layout carries field names, types, offsets, and stride; the presence bitmap distinguishes absent fields from zero or empty values.

Usage:

layout.add_field<std::string>("name");
layout.add_field<double>("score");
CompositeArray items(std::move(layout));
auto index = items.append();
items.set_text(index, "name", "Ada");
items.set(index, "score", 0.95);
auto item = items.at(index);
uint32_t index
Definition VKDevice.cpp:122
const CompositeLayout & layout() const noexcept
Finalized layout shared by all elements.
Owns a sequence of values that share a CompositeLayout.
bool add_field(std::string name)
Declare a named arithmetic, text, or binary field.
Definition Composite.hpp:65
Shared field description and byte layout for a CompositeArray.
Definition Composite.hpp:52
Note
Views returned by at(), access(), and slice() borrow this array's stores and layout. Keep the array alive and at the same address while using them. Include CompositeAccess.hpp for slice and projection APIs.

Definition at line 209 of file Composite.hpp.


The documentation for this class was generated from the following files: