 |
LibraryLink Utilities
3.0.1
Modern C++ wrapper over LibraryLink and WSTP
|
Go to the documentation of this file.
6 #ifndef LLU_CONTAINERS_GENERIC_DATASTORE_HPP
7 #define LLU_CONTAINERS_GENERIC_DATASTORE_HPP
26 using EnableIfArgumentType = std::enable_if_t<Argument::PrimitiveQ<remove_cv_ref<T>> || Argument::WrapperQ<remove_cv_ref<T>>,
int>;
28 template<MArgumentType T>
29 using EnableIfUnambiguousWrapperType = std::enable_if_t<!Argument::PrimitiveQ<Argument::WrapperType<T>>,
int>;
83 DataStoreNode
back()
const {
115 template<
typename T, EnableIfArgumentType<T> = 0>
116 void push_back(T nodeValue);
126 template<
typename T, EnableIfArgumentType<T> = 0>
127 void push_back(std::string_view name, T nodeValue);
134 template<MArgumentType Type, EnableIfUnambiguousWrapperType<Type> = 0>
145 template<MArgumentType Type, EnableIfUnambiguousWrapperType<Type> = 0>
155 template<MArgumentType Type>
166 template<MArgumentType Type>
186 Container cloneImpl()
const override {
194 mint shareCountImpl() const noexcept
override {
202 void passImpl(MArgument& res)
const noexcept
override {
204 MArgument_setDataStore(res, this->getContainer());
208 template<
typename T, GenericDataList::EnableIfArgumentType<T>>
210 static_assert(!std::is_same_v<T, MTensor>,
"Do not use push_back templated on the argument type with MTensor or MNumericArray.");
211 if constexpr (Argument::PrimitiveQ<T>) {
214 }
else if constexpr (Argument::WrapperQ<T>) {
220 template<
typename T, GenericDataList::EnableIfArgumentType<T>>
222 static_assert(!std::is_same_v<T, MTensor>,
"Do not use push_back templated on the argument type with MTensor or MNumericArray.");
223 if constexpr (Argument::PrimitiveQ<T>) {
226 }
else if constexpr (Argument::WrapperQ<T>) {
235 auto* ptr = std::get_if<T>(std::addressof(v));
239 return std::move(*ptr);
243 #endif // LLU_CONTAINERS_GENERIC_DATASTORE_HPP
Template of the base class for all generic containers.
Definition: Base.hpp:35
const_iterator cend() const
Proxy iterator past the last element of the DataStore.
Definition: Generic/DataStore.hpp:104
void push_back(Argument::CType< Type > nodeValue)
Add new nameless node at the end of the underlying DataStore.
Definition: Generic/DataStore.hpp:156
const std::string DLInvalidNodeType
DataStoreNode passed to Node wrapper carries data of invalid type.
std::conditional_t< T==MArgumentType::MArgument, MArgument, std::variant_alternative_t< static_cast< size_t >(T), PrimitiveAny > > CType
Type alias that binds given MArgumentType (enumerated value) to the corresponding type of MArgument.
Definition: MArgument.h:53
MContainer specialization for DataStore, provides basic list interface for the underlying raw DataSto...
Definition: Generic/DataStore.hpp:23
Main namespace of LibraryLink Utilities.
Definition: Queue.h:13
MContainer is an abstract class template for generic containers. Only specializations shall be used.
Definition: Base.hpp:245
void push_back(T nodeValue)
Add new nameless node at the end of the underlying DataStore.
Definition: Generic/DataStore.hpp:209
MContainer()
Default constructor, creates empty DataStore owned by the Library.
Definition: Generic/DataStore.hpp:44
Proxy input iterator over DataStoreNodes, when dereferenced yields GenericDataNode proxy objects.
Definition: Iterators/DataStore.hpp:75
TypedArgument Any
Any is a union of all supported types. Typed::Any can be used as a template parameter for DataList to...
Definition: TypedMArgument.h:70
T as() const
Get node value if it is of type T, otherwise throw an exception.
Definition: Generic/DataStore.hpp:233
@ Library
The library (LLU) is responsible for managing the container's memory. Used for Manual passing and con...
static void addDataStoreNode(DataStore ds, std::string_view name, value_type val)
Add val to the DataStore ds inside a node named name This is a static method because there is no MArg...
iterator end() const
Proxy iterator past the last element of the DataStore.
Definition: Generic/DataStore.hpp:94
MContainer< MArgumentType::DataStore > DataStore
DataStore stands for a GenericDataList - type agnostic wrapper over DataStore.
Definition: TypedMArgument.h:62
std::conditional_t< T==MArgumentType::MArgument, TypedArgument, std::variant_alternative_t< static_cast< size_t >(T), TypedArgument > > WrapperType
Get wrapper type corresponding to primitive LibraryLink argument type T.
Definition: TypedMArgument.h:92
mint length() const
Get the length of the DataStore.
Definition: Generic/DataStore.hpp:67
DataStoreNode back() const
Get the last node of the DataStore.
Definition: Generic/DataStore.hpp:83
MContainer clone() const
Clone this MContainer, performs a deep copy of the underlying DataStore.
Definition: Generic/DataStore.hpp:59
static void throwException(const std::string &errorName, T &&... args)
Throw exception with given name.
Definition: ErrorManager.h:199
Definitions of MContainerBase and MContainer class templates.
void push_back(std::string_view name, Argument::WrapperType< Type > nodeValue)
Add new named node at the end of the underlying DataStore.
Definition: Generic/DataStore.hpp:146
void push_back(std::string_view name, Argument::CType< Type > nodeValue)
Add new named node at the end of the underlying DataStore.
Definition: Generic/DataStore.hpp:167
MArgumentType
Strongly type enum with possible types of data stored in MArgument.
Definition: MArgument.h:22
const_iterator cbegin() const
Proxy iterator to the first element of the DataStore.
Definition: Generic/DataStore.hpp:99
iterator begin() const
Proxy iterator to the first element of the DataStore.
Definition: Generic/DataStore.hpp:88
DataStoreNode front() const
Get the first node of the DataStore.
Definition: Generic/DataStore.hpp:75
static const st_WolframIOLibrary_Functions * DataStoreAPI()
Get a pointer to structure with function pointers to DataStore API.
Definition: LibraryData.cpp:45
Template class and utilities to work with MArgument in type-safe manner.
Argument::TypedArgument value() const
Get value of the node as the variant type.
Definition: DataStore.cpp:26
Ownership
An enum listing possible owners of a LibraryLink container.
Definition: Base.hpp:22
void push_back(Argument::WrapperType< Type > nodeValue)
Add new nameless node at the end of the underlying DataStore.
Definition: Generic/DataStore.hpp:135
This structure offers a static copy of WolframLibData accessible throughout the whole life of the DLL...
Definition: LibraryData.h:48