summaryrefslogtreecommitdiff
path: root/modules/codec
diff options
context:
space:
mode:
Diffstat (limited to 'modules/codec')
-rw-r--r--modules/codec/c++/data_raw.hpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/modules/codec/c++/data_raw.hpp b/modules/codec/c++/data_raw.hpp
index 2da49b4..3447f42 100644
--- a/modules/codec/c++/data_raw.hpp
+++ b/modules/codec/c++/data_raw.hpp
@@ -483,6 +483,25 @@ class data<schema::Array<T,Dim>, encode::NativeRaw> {
static_assert(sizeof...(Dims)==Dim, "Argument size must be equal to the Dimension");
}
+ template<std::integral... Dims>
+ constexpr error_or<void> adopt(typename raw_native_array_type_helper<T>::Type* adoptee, Dims... adoptee_size){
+ if(value_ != nullptr){
+ return make_error<err::invalid_state>("Can't adopt into existing state");
+ }
+ dims_ = {adoptee_size...};
+ value_size_ = get_full_size();
+ value_ = adoptee;
+
+ return make_void();
+ }
+
+ constexpr error_or<typename raw_native_array_type_helper<T>::Type*> extract(){
+ auto old_val = value_;
+ value_ = nullptr;
+ value_size_ = 0u;
+ return old_val;
+ }
+
constexpr data<schema::Ref<T>, encode::NativeRaw> at(const std::array<uint64_t, Dim>& ind){
return {value_[this->get_flat_index(ind)]};
}