nk 1.0.0
C++ Numerical Computing Runtime
Loading...
Searching...
No Matches
struct.hpp
Go to the documentation of this file.
1
3// toolboxes/builtin/include/nk/builtin/language/structures/struct.hpp
4#pragma once
5
6#include <memory_resource>
7#include <nk/value/fn_handle.hpp>
8#include <nk/value/span.hpp>
9#include <nk/value/value.hpp>
10
11namespace nk {
12
15
16class Engine;
17}
18
19namespace nk::runtime {
20
21void registerStructuresRuntime(Engine &engine);
22void registerStructfunCallbackBuiltin(Engine &engine);
23
33Value structure(std::pmr::memory_resource *mr = nullptr);
34
47 std::pmr::memory_resource *mr = nullptr);
48
55Value fieldnames(const Value &s, std::pmr::memory_resource *mr = nullptr);
56
66Value isfield(const Value &s, const Value &name,
67 std::pmr::memory_resource *mr = nullptr);
68
78Value rmfield(const Value &s, const Value &name,
79 std::pmr::memory_resource *mr = nullptr);
80
98Value structfun(FnHandle fn, const Value &s, bool uniformOutput,
99 std::pmr::memory_resource *mr = nullptr);
100
107Value getfield(const Value &s, const Value &name, std::pmr::memory_resource *mr = nullptr);
108
116Value setfield(const Value &s, const Value &name, const Value &value, std::pmr::memory_resource *mr = nullptr);
117
123Value orderfields(const Value &s, std::pmr::memory_resource *mr = nullptr);
124
130Value struct2cell(const Value &s, std::pmr::memory_resource *mr = nullptr);
131
132
134} // namespace nk::runtime
135
Core MATLAB-compatible multidimensional array and scalar value type.
Definition value.hpp:61
Value fieldnames(const Value &s, std::pmr::memory_resource *mr=nullptr)
Field names of a struct (fn = fieldnames(s)).
Value structure(std::pmr::memory_resource *mr=nullptr)
Empty struct scalar (s = struct()).
Value getfield(const Value &s, const Value &name, std::pmr::memory_resource *mr=nullptr)
Gets the value of specified field in structure (v = getfield(s, 'field')).
Value setfield(const Value &s, const Value &name, const Value &value, std::pmr::memory_resource *mr=nullptr)
Sets the value of specified field in structure (s = setfield(s, 'field', val)).
Value orderfields(const Value &s, std::pmr::memory_resource *mr=nullptr)
Orders fields of structure array alphabetically (s = orderfields(s)).
Value rmfield(const Value &s, const Value &name, std::pmr::memory_resource *mr=nullptr)
Remove a field from a struct (s2 = rmfield(s, name)).
Value struct2cell(const Value &s, std::pmr::memory_resource *mr=nullptr)
Converts structure array to cell array of field values (c = struct2cell(s)).
Value isfield(const Value &s, const Value &name, std::pmr::memory_resource *mr=nullptr)
Test for field existence (tf = isfield(s, name)).
Value structfun(FnHandle fn, const Value &s, bool uniformOutput, std::pmr::memory_resource *mr=nullptr)
Apply a function handle to every field of a struct (y = structfun(fn, s, uniformOutput)).