Write UTF-8 bytes to a std::string field.
187{
189 const std::type_index expected = declared
190 &&
m_layout.
fields()[*declared].type ==
typeid(detail::CompositeDynamic)
191 ? typeid(detail::CompositeDynamic) : typeid(std::string);
193 if (!field_index)
194 return false;
195
197 auto& text = std::get<std::vector<uint8_t>>(
m_text);
198 if (
value.size() > text.max_size() - text.size()) {
200 "CompositeArray: text value for field '{}' exceeds addressable size", field_name);
201 return false;
202 }
203
204 const std::string value_copy(
value);
205 const TextSlice
slice {
206 .offset = static_cast<uint64_t>(text.size()),
207 .length = static_cast<uint64_t>(value_copy.size())
208 };
209 text.insert(text.end(), value_copy.begin(), value_copy.end());
210
211 auto&
rows = std::get<std::vector<uint8_t>>(
m_rows);
213 if (field.type == typeid(detail::CompositeDynamic)) {
214 const DynamicCell cell { text_kind,
slice.offset,
slice.length };
215 std::memcpy(destination, &cell, sizeof(cell));
216 } else {
217 std::memcpy(destination, &
slice,
sizeof(
slice));
218 }
219
221 return true;
222}
#define MF_WARN(comp, ctx,...)
void set_present(size_t index, size_t field_index, bool present) noexcept
std::optional< CompositeSlice > slice(size_t start, size_t count) const
Borrow consecutive elements without copying.
std::optional< size_t > validate_write(size_t index, std::string_view field_name, std::type_index type) const
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.
@ Runtime
General runtime operations (default fallback)
@ Kakshya
Containers[Signalsource, Stream, File], Regions, DataProcessors.