LibraryLink Utilities  3.0.1
Modern C++ wrapper over LibraryLink and WSTP
LLU::NumericArrayTypedView< T > Class Template Reference

Description

template<typename T>
class LLU::NumericArrayTypedView< T >

Simple, light-weight, non-owning wrappper over MNumericArray.

Intended for use where a temporary "upgrade" of a raw MNumericArray to a complete, strongly-typed NumericArray interface would be useful.

Template Parameters
T- type of the NumericArray data
+ Inheritance diagram for LLU::NumericArrayTypedView< T >:
+ Collaboration diagram for LLU::NumericArrayTypedView< T >:

#include <NumericArray.hpp>

Public Types

using value_type = T
 Type of elements stored. More...
 
using iterator = value_type *
 Iterator type. More...
 
using const_iterator = const value_type *
 Constant iterator type. More...
 
using reverse_iterator = std::reverse_iterator< iterator >
 Reverse iterator type. More...
 
using const_reverse_iterator = std::reverse_iterator< const_iterator >
 Constant reverse iterator type. More...
 
using reference = value_type &
 Reference type. More...
 
using const_reference = const value_type &
 Constant reference type. More...
 

Public Member Functions

 NumericArrayTypedView (const GenericNumericArray &gNA)
 Create a NumericArrayTypedView from a GenericNumericArray. More...
 
 NumericArrayTypedView (NumericArrayView nav)
 Create a NumericArrayTypedView from a NumericArrayView. More...
 
 NumericArrayTypedView (MNumericArray mna)
 Create a NumericArrayTypedView from a raw MNumericArray. More...
 
mint getRank () const override
 Get rank. More...
 
mint const * getDimensions () const override
 Get dimensions. More...
 
mint getFlattenedLength () const override
 Get length. More...
 
numericarray_data_t type () const final
 Get the data type of this array. More...
 
void * rawData () const noexcept override
 Get access to the raw data. More...
 
value_typedata () noexcept
 Get raw pointer to underlying data. More...
 
const value_typedata () const noexcept
 Get raw pointer to const underlying data. More...
 
mint size () const noexcept
 Get total number of elements in the container. More...
 
iterator begin () noexcept
 Get iterator at the beginning of underlying data. More...
 
const_iterator begin () const noexcept
 Get constant iterator at the beginning of underlying data. More...
 
const_iterator cbegin () const noexcept
 Get constant iterator at the beginning of underlying data. More...
 
iterator end () noexcept
 Get iterator after the end of underlying data. More...
 
const_iterator end () const noexcept
 Get constant iterator after the end of underlying data. More...
 
const_iterator cend () const noexcept
 Get constant iterator after the end of underlying data. More...
 
reverse_iterator rbegin () noexcept
 Get iterator at the beginning of underlying data. More...
 
const_reverse_iterator rbegin () const noexcept
 Get constant iterator at the beginning of underlying data. More...
 
const_reverse_iterator crbegin () const noexcept
 Get constant iterator at the beginning of underlying data. More...
 
reverse_iterator rend () noexcept
 Get iterator after the end of underlying data. More...
 
const_reverse_iterator rend () const noexcept
 Get constant iterator after the end of underlying data. More...
 
const_reverse_iterator crend () const noexcept
 Get constant iterator after the end of underlying data. More...
 
reference operator[] (mint index)
 Get a reference to the data element at given position. More...
 
const_reference operator[] (mint index) const
 Get a constant reference to the data element at given position. More...
 
reference front ()
 Get reference to the first element. More...
 
const_reference front () const
 Get constant reference to the first element. More...
 
reference back ()
 Get reference to the last element. More...
 
const_reference back () const
 Get constant reference to the last element. More...
 
std::vector< value_typeasVector () const
 Copy contents of the data to a std::vector of matching type. More...
 

Type aliases documentation

◆ const_iterator

template<typename T >
using LLU::IterableContainer< T >::const_iterator = const value_type*
inherited

Constant iterator type.

◆ const_reference

template<typename T >
using LLU::IterableContainer< T >::const_reference = const value_type&
inherited

Constant reference type.

◆ const_reverse_iterator

template<typename T >
using LLU::IterableContainer< T >::const_reverse_iterator = std::reverse_iterator<const_iterator>
inherited

Constant reverse iterator type.

◆ iterator

template<typename T >
using LLU::IterableContainer< T >::iterator = value_type*
inherited

Iterator type.

◆ reference

template<typename T >
using LLU::IterableContainer< T >::reference = value_type&
inherited

Reference type.

◆ reverse_iterator

template<typename T >
using LLU::IterableContainer< T >::reverse_iterator = std::reverse_iterator<iterator>
inherited

Reverse iterator type.

◆ value_type

template<typename T >
using LLU::IterableContainer< T >::value_type = T
inherited

Type of elements stored.

Constructor & Destructor Documentation

◆ NumericArrayTypedView() [1/3]

template<typename T >
LLU::NumericArrayTypedView< T >::NumericArrayTypedView ( const GenericNumericArray gNA)
inline

Create a NumericArrayTypedView from a GenericNumericArray.

Parameters
gNA- a GenericNumericArray
Exceptions
ErrorName::NumericArrayTypeError- if the actual datatype of gNA is not T

◆ NumericArrayTypedView() [2/3]

template<typename T >
LLU::NumericArrayTypedView< T >::NumericArrayTypedView ( NumericArrayView  nav)
inline

Create a NumericArrayTypedView from a NumericArrayView.

Parameters
nav- a NumericArrayView
Exceptions
ErrorName::NumericArrayTypeError- if the actual datatype of nav is not T

◆ NumericArrayTypedView() [3/3]

template<typename T >
LLU::NumericArrayTypedView< T >::NumericArrayTypedView ( MNumericArray  mna)
inline

Create a NumericArrayTypedView from a raw MNumericArray.

Parameters
mna- a raw MNumericArray
Exceptions
ErrorName::NumericArrayTypeError- if the actual datatype of mna is not T

Member Function Documentation

◆ asVector()

template<typename T >
std::vector<value_type> LLU::IterableContainer< T >::asVector ( ) const
inlineinherited

Copy contents of the data to a std::vector of matching type.

Returns
std::vector with the copy of the data

◆ back() [1/2]

template<typename T >
reference LLU::IterableContainer< T >::back ( )
inlineinherited

Get reference to the last element.

Note
For empty container the behavior is undefined.

◆ back() [2/2]

template<typename T >
const_reference LLU::IterableContainer< T >::back ( ) const
inlineinherited

Get constant reference to the last element.

Note
For empty container the behavior is undefined.

◆ begin() [1/2]

template<typename T >
const_iterator LLU::IterableContainer< T >::begin ( ) const
inlinenoexceptinherited

Get constant iterator at the beginning of underlying data.

◆ begin() [2/2]

template<typename T >
iterator LLU::IterableContainer< T >::begin ( )
inlinenoexceptinherited

Get iterator at the beginning of underlying data.

◆ cbegin()

template<typename T >
const_iterator LLU::IterableContainer< T >::cbegin ( ) const
inlinenoexceptinherited

Get constant iterator at the beginning of underlying data.

◆ cend()

template<typename T >
const_iterator LLU::IterableContainer< T >::cend ( ) const
inlinenoexceptinherited

Get constant iterator after the end of underlying data.

◆ crbegin()

template<typename T >
const_reverse_iterator LLU::IterableContainer< T >::crbegin ( ) const
inlinenoexceptinherited

Get constant iterator at the beginning of underlying data.

◆ crend()

template<typename T >
const_reverse_iterator LLU::IterableContainer< T >::crend ( ) const
inlinenoexceptinherited

Get constant iterator after the end of underlying data.

◆ data() [1/2]

template<typename T >
const value_type* LLU::IterableContainer< T >::data ( ) const
inlinenoexceptinherited

Get raw pointer to const underlying data.

◆ data() [2/2]

template<typename T >
value_type* LLU::IterableContainer< T >::data ( )
inlinenoexceptinherited

Get raw pointer to underlying data.

◆ end() [1/2]

template<typename T >
const_iterator LLU::IterableContainer< T >::end ( ) const
inlinenoexceptinherited

Get constant iterator after the end of underlying data.

◆ end() [2/2]

template<typename T >
iterator LLU::IterableContainer< T >::end ( )
inlinenoexceptinherited

Get iterator after the end of underlying data.

◆ front() [1/2]

template<typename T >
reference LLU::IterableContainer< T >::front ( )
inlineinherited

Get reference to the first element.

Note
For empty container the behavior is undefined.

◆ front() [2/2]

template<typename T >
const_reference LLU::IterableContainer< T >::front ( ) const
inlineinherited

Get constant reference to the first element.

Note
For empty container the behavior is undefined.

◆ getDimensions()

mint const* LLU::NumericArrayView::getDimensions ( ) const
inlineoverridevirtualinherited

Get dimensions.

Returns
raw pointer to dimensions of the array
See also
http://reference.wolfram.com/language/LibraryLink/ref/callback/MNumericArray_getDimensions.html

Implements LLU::NumericArrayInterface.

◆ getFlattenedLength()

mint LLU::NumericArrayView::getFlattenedLength ( ) const
inlineoverridevirtualinherited

◆ getRank()

mint LLU::NumericArrayView::getRank ( ) const
inlineoverridevirtualinherited

◆ operator[]() [1/2]

template<typename T >
reference LLU::IterableContainer< T >::operator[] ( mint  index)
inlineinherited

Get a reference to the data element at given position.

Parameters
[in]index- position of desired data element

◆ operator[]() [2/2]

template<typename T >
const_reference LLU::IterableContainer< T >::operator[] ( mint  index) const
inlineinherited

Get a constant reference to the data element at given position.

Parameters
[in]index- position of desired data element

◆ rawData()

void* LLU::NumericArrayView::rawData ( ) const
inlineoverridevirtualnoexceptinherited

Get access to the raw data.

Use with caution.

Returns
pointer to the raw data
See also
http://reference.wolfram.com/language/LibraryLink/ref/callback/MNumericArray_getData.html

Implements LLU::NumericArrayInterface.

◆ rbegin() [1/2]

template<typename T >
const_reverse_iterator LLU::IterableContainer< T >::rbegin ( ) const
inlinenoexceptinherited

Get constant iterator at the beginning of underlying data.

◆ rbegin() [2/2]

template<typename T >
reverse_iterator LLU::IterableContainer< T >::rbegin ( )
inlinenoexceptinherited

Get iterator at the beginning of underlying data.

◆ rend() [1/2]

template<typename T >
const_reverse_iterator LLU::IterableContainer< T >::rend ( ) const
inlinenoexceptinherited

Get constant iterator after the end of underlying data.

◆ rend() [2/2]

template<typename T >
reverse_iterator LLU::IterableContainer< T >::rend ( )
inlinenoexceptinherited

Get iterator after the end of underlying data.

◆ size()

template<typename T >
mint LLU::IterableContainer< T >::size ( ) const
inlinenoexceptinherited

Get total number of elements in the container.

◆ type()

numericarray_data_t LLU::NumericArrayView::type ( ) const
inlinefinalvirtualinherited

Get the data type of this array.

Returns
type of elements (see definition of numericarray_data_t)
See also
http://reference.wolfram.com/language/LibraryLink/ref/callback/MNumericArray_getDataType.html

Implements LLU::NumericArrayInterface.