54 if constexpr (std::is_void_v<T>) {
57 return sizeof(T) == type.
memSize;
83 auto* result =
static_cast<T*
>(
UA_new(&type));
84 if (result ==
nullptr) {
85 throw std::bad_alloc();
92 auto deleter = [&type](T* native) {
deallocate(native, type); };
93 return std::unique_ptr<T, decltype(deleter)>(
allocate<T>(type), deleter);
119 auto* result =
static_cast<T*
>(
UA_Array_new(size, &type));
120 if (result ==
nullptr) {
121 throw std::bad_alloc();
128 auto deleter = [&type, size](T* native) {
deallocateArray(native, size, type); };
129 return std::unique_ptr<T, decltype(deleter)>(
allocateArray<T>(size, type), deleter);
137 std::transform(src, src + size, dst, [&](
const T& item) {
return copy(item, type); });
139 std::copy_n(src, size, dst);
146 if (newSize == size) {
150 std::memcpy(newArray, array, std::min(size, newSize) *
sizeof(T));
151 if (newSize > size) {
152 std::memset(newArray + size, 0, newSize - size);
constexpr T copy(const T &src, const UA_DataType &type) noexcept(isPointerFree< T >)
auto allocateUniquePtr(const UA_DataType &type)
constexpr bool isPointerFree
void resizeArray(T *&array, size_t &size, size_t newSize, const UA_DataType &type)
constexpr bool isValidTypeCombination(const UA_DataType &type)
T * copyArray(const T *src, size_t size, const UA_DataType &type)
constexpr void clear(T &native, const UA_DataType &type) noexcept
T * allocate(const UA_DataType &type)
auto allocateArrayUniquePtr(size_t size, const UA_DataType &type)
constexpr bool isBorrowed(const T &) noexcept
void deallocate(T *native, const UA_DataType &type) noexcept
void deallocateArray(T *array, size_t size, const UA_DataType &type) noexcept
T * allocateArray(size_t size, const UA_DataType &type)
std::disjunction< std::is_same< T, Ts >... > IsOneOf
constexpr void throwIfBad(UA_StatusCode code)
Check the status code and throw a BadStatus exception if the status code is bad.
void UA_Array_delete(void *p, size_t size, const UA_DataType *type)
UA_StatusCode UA_copy(const void *src, void *dst, const UA_DataType *type)
_UA_BEGIN_DECLS typedef bool UA_Boolean
UA_EXTENSIONOBJECT_DECODED_NODELETE
void * UA_new(const UA_DataType *type)
void * UA_Array_new(size_t size, const UA_DataType *type)
void UA_clear(void *p, const UA_DataType *type)
void UA_delete(void *p, const UA_DataType *type)