7 #ifndef LLU_WSTP_GET_H_
8 #define LLU_WSTP_GET_H_
27 using ListData = std::unique_ptr<T[], ReleaseList<T>>;
33 using ArrayData = std::unique_ptr<T[], ReleaseArray<T>>;
37 using Func = std::function<int(WSLINK, T**,
int**,
char***,
int*)>;
45 return {rawResult, ReleaseArray<T> {m, dims, heads, rank}};
49 static const std::string ArrayFName;
55 using Func = std::function<int(WSLINK, T**,
int*)>;
57 static ListData<T> get(WSLINK m) {
61 return {rawResult, ReleaseList<T> {m, len}};
65 static const std::string ListFName;
71 using Func = std::function<int(WSLINK, T*)>;
73 static T get(WSLINK m) {
80 static const std::string ScalarFName;
85 typename GetArray<T>::Func GetArray<T>::ArrayF = [](WSLINK , T** ,
int** ,
char*** ,
int* ) {
86 static_assert(dependent_false_v<T>,
"Trying to use WS::GetArray<T> for unsupported type T");
91 typename GetList<T>::Func GetList<T>::ListF = [](WSLINK ) {
92 static_assert(dependent_false_v<T>,
"Trying to use WS::GetList<T> for unsupported type T");
97 typename GetScalar<T>::Func GetScalar<T>::ScalarF = [](WSLINK , T* ) {
98 static_assert(dependent_false_v<T>,
"Trying to use WS::GetScalar<T> for unsupported type T");
105 #define WS_GET_DECLARE_SPECIALIZATIONS_OF_STATIC_MEMBERS(T) \
107 GetArray<T>::Func GetArray<T>::ArrayF; \
109 const std::string GetArray<T>::ArrayFName; \
111 GetList<T>::Func GetList<T>::ListF; \
113 const std::string GetList<T>::ListFName; \
115 GetScalar<T>::Func GetScalar<T>::ScalarF; \
117 const std::string GetScalar<T>::ScalarFName;
119 WS_GET_DECLARE_SPECIALIZATIONS_OF_STATIC_MEMBERS(
unsigned char)
120 WS_GET_DECLARE_SPECIALIZATIONS_OF_STATIC_MEMBERS(
short)
121 WS_GET_DECLARE_SPECIALIZATIONS_OF_STATIC_MEMBERS(
int)
122 WS_GET_DECLARE_SPECIALIZATIONS_OF_STATIC_MEMBERS(wsint64)
123 WS_GET_DECLARE_SPECIALIZATIONS_OF_STATIC_MEMBERS(
float)
124 WS_GET_DECLARE_SPECIALIZATIONS_OF_STATIC_MEMBERS(
double)
135 GetArray<unsigned char>::Func GetArray<unsigned char>::ArrayF = WSGetInteger8Array;
138 const std::string GetArray<unsigned char>::ArrayFName =
"WSGetInteger8Array";
143 GetList<unsigned char>::Func GetList<unsigned char>::ListF = WSGetInteger8List;
146 const std::string GetList<unsigned char>::ListFName =
"WSGetInteger8List";
151 GetScalar<unsigned char>::Func GetScalar<unsigned char>::ScalarF = WSGetInteger8;
154 const std::string GetScalar<unsigned char>::ScalarFName =
"WSGetInteger8";
163 GetArray<short>::Func GetArray<short>::ArrayF = WSGetInteger16Array;
166 const std::string GetArray<short>::ArrayFName =
"WSGetInteger16Array";
171 GetList<short>::Func GetList<short>::ListF = WSGetInteger16List;
174 const std::string GetList<short>::ListFName =
"WSGetInteger16List";
179 GetScalar<short>::Func GetScalar<short>::ScalarF = WSGetInteger16;
182 const std::string GetScalar<short>::ScalarFName =
"WSGetInteger16";
191 GetArray<int>::Func GetArray<int>::ArrayF = WSGetInteger32Array;
194 const std::string GetArray<int>::ArrayFName =
"WSGetInteger32Array";
199 GetList<int>::Func GetList<int>::ListF = WSGetInteger32List;
202 const std::string GetList<int>::ListFName =
"WSGetInteger32List";
207 GetScalar<int>::Func GetScalar<int>::ScalarF = WSGetInteger32;
210 const std::string GetScalar<int>::ScalarFName =
"WSGetInteger32";
219 GetArray<wsint64>::Func GetArray<wsint64>::ArrayF = WSGetInteger64Array;
222 const std::string GetArray<wsint64>::ArrayFName =
"WSGetInteger64Array";
227 GetList<wsint64>::Func GetList<wsint64>::ListF = WSGetInteger64List;
230 const std::string GetList<wsint64>::ListFName =
"WSGetInteger64List";
235 GetScalar<wsint64>::Func GetScalar<wsint64>::ScalarF = WSGetInteger64;
238 const std::string GetScalar<wsint64>::ScalarFName =
"WSGetInteger64";
247 GetArray<float>::Func GetArray<float>::ArrayF = WSGetReal32Array;
250 const std::string GetArray<float>::ArrayFName =
"WSGetReal32Array";
255 GetList<float>::Func GetList<float>::ListF = WSGetReal32List;
258 const std::string GetList<float>::ListFName =
"WSGetReal32List";
263 GetScalar<float>::Func GetScalar<float>::ScalarF = WSGetReal32;
266 const std::string GetScalar<float>::ScalarFName =
"WSGetReal32";
275 GetArray<double>::Func GetArray<double>::ArrayF = WSGetReal64Array;
278 const std::string GetArray<double>::ArrayFName =
"WSGetReal64Array";
283 GetList<double>::Func GetList<double>::ListF = WSGetReal64List;
286 const std::string GetList<double>::ListFName =
"WSGetReal64List";
291 GetScalar<double>::Func GetScalar<double>::ScalarF = WSGetReal64;
294 const std::string GetScalar<double>::ScalarFName =
"WSGetReal64";