LibraryLink Utilities  3.0.1
Modern C++ wrapper over LibraryLink and WSTP
TypedMArgument.h File Reference

Detailed Description

Author
Rafal Chojna rafal.nosp@m.c@wo.nosp@m.lfram.nosp@m..com
Date
April 28, 2020
#include <complex>
#include <string_view>
#include <variant>
#include "LLU/Containers/Generic/Image.hpp"
#include "LLU/Containers/Generic/NumericArray.hpp"
#include "LLU/Containers/Generic/SparseArray.hpp"
#include "LLU/Containers/Generic/Tensor.hpp"
#include "LLU/MArgument.h"
#include "LLU/Utilities.hpp"
+ Include dependency graph for TypedMArgument.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

 LLU
 Main namespace of LibraryLink Utilities.
 
 LLU::Argument
 Namespace for functionality related to arguments passed from LibraryLink to library functions and their types.
 
 LLU::Argument::Typed
 Namespace defining C++ types corresponding to primitive LibraryLink argument types.
 

Type aliases

using LLU::Argument::Typed::Boolean = bool
 Boolean type, corresponds to True or False in the Wolfram Language. More...
 
using LLU::Argument::Typed::Integer = mint
 Machine integer type. More...
 
using LLU::Argument::Typed::Real = double
 Double precision floating point type. More...
 
using LLU::Argument::Typed::Complex = std::complex< double >
 Complex number type, bitwise-compatible with mcomplex defined in WolframLibrary.h. More...
 
using LLU::Argument::Typed::Tensor = MContainer< MArgumentType::Tensor >
 Tensor stands for a GenericTensor - type agnostic wrapper over MTensor. More...
 
using LLU::Argument::Typed::SparseArray = MContainer< MArgumentType::SparseArray >
 SparseArray stands for a GenericSparseArray - type agnostic wrapper over MSparseArray. More...
 
using LLU::Argument::Typed::NumericArray = MContainer< MArgumentType::NumericArray >
 NumericArray stands for a GenericNumericArray - type agnostic wrapper over MNumericArray. More...
 
using LLU::Argument::Typed::Image = MContainer< MArgumentType::Image >
 Image stands for a GenericImage - type agnostic wrapper over MImage. More...
 
using LLU::Argument::Typed::UTF8String = std::string_view
 String values from LibraryLink (char*) are wrapped in std::string_view. More...
 
using LLU::Argument::Typed::DataStore = MContainer< MArgumentType::DataStore >
 DataStore stands for a GenericDataList - type agnostic wrapper over DataStore. More...
 
using LLU::Argument::TypedArgument = std::variant< std::monostate, Typed::Boolean, Typed::Integer, Typed::Real, Typed::Complex, Typed::Tensor, Typed::SparseArray, Typed::NumericArray, Typed::Image, Typed::UTF8String, Typed::DataStore >
 C++ wrapper over LibraryLink's MArgument, which is a plain union. More...
 
using LLU::Argument::Typed::Any = TypedArgument
 Any is a union of all supported types. Typed::Any can be used as a template parameter for DataList to get a heterogeneous DataList. More...
 
template<MArgumentType T>
using LLU::Argument::WrapperType = std::conditional_t< T==MArgumentType::MArgument, TypedArgument, std::variant_alternative_t< static_cast< size_t >(T), TypedArgument > >
 Get wrapper type corresponding to primitive LibraryLink argument type T. More...
 

Functions

TypedArgument LLU::Argument::fromMArgument (MArgument m, MArgumentType t)
 Get a TypeArgument from plain MArgument and an enum describing the active union member. More...
 
void LLU::Argument::toMArgument (const TypedArgument &tma, MArgument &res)
 Assign current value of given TypedArgument to given MArgument. More...
 
template<MArgumentType T>
WrapperType< T > LLU::Argument::toWrapperType (const CType< T > &value)
 Convert a value of one of the LibraryLink argument type to its wrapper. More...
 
template<MArgumentType T>
CType< T > LLU::Argument::toPrimitiveType (const WrapperType< T > &value)
 Convert value of one of the wrapper types (see LLU::Argument::Typed namespace) to the corresponding LibraryLink type. More...
 

Variables

template<typename T >
constexpr MArgumentType LLU::Argument::WrapperIndex = static_cast<MArgumentType>(variant_index<TypedArgument, T>())
 Index of a wrapper type in the TypedArgument variant or std::variant_size_v<TypedArgument> otherwise. More...
 
template<typename T >
constexpr bool LLU::Argument::WrapperQ = std::is_same_v<T, TypedArgument> || (variant_index<TypedArgument, T>() < std::variant_size_v<TypedArgument>)
 Type trait to determine if given type is a "wrapper type" (i.e. More...