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

Description

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

Wrapper over DataStoreNode structure from LibraryLink.

#include <DataNode.hpp>

Public Member Functions

 DataNode (DataStoreNode dsn)
 Create DataNode from raw DataStoreNode structure. More...
 
 DataNode (GenericDataNode gn)
 Create DataNode from raw GenericDataNode. More...
 
T & value ()
 Get node value. More...
 
const T & value () const
 Get node value. More...
 
std::string_view name () const
 Get node name. More...
 
bool hasNext () const
 Check if this node has a successor. More...
 
GenericDataNode next () const
 Get next node as GenericDataNode (because the next node may not necessarily have value of type T) More...
 
MArgumentType type () noexcept
 Get the actual type of node value. More...
 
template<std::size_t N>
decltype(auto) get ()
 Get N-th element of DataNode in a tuple-like way. More...
 

Constructor & Destructor Documentation

◆ DataNode() [1/2]

template<typename T >
LLU::DataNode< T >::DataNode ( DataStoreNode  dsn)
explicit

Create DataNode from raw DataStoreNode structure.

Parameters
dsn- raw node

◆ DataNode() [2/2]

template<typename T >
LLU::DataNode< T >::DataNode ( GenericDataNode< T >  gn)
explicit

Create DataNode from raw GenericDataNode.

Parameters
gn- generic data node

Member Function Documentation

◆ get()

template<typename T >
template<std::size_t N>
decltype(auto) LLU::DataNode< T >::get ( )
inline

Get N-th element of DataNode in a tuple-like way.

This function enables structured bindings to DataNodes.

Template Parameters
N- index (only 0 and 1 are valid)
Returns
either the node name for N == 0 or node value for N == 1

◆ hasNext()

template<typename T >
bool LLU::DataNode< T >::hasNext ( ) const
inline

Check if this node has a successor.

Returns
true iff the current node is not the last one in its DataList

◆ name()

template<typename T >
std::string_view LLU::DataNode< T >::name ( ) const
inline

Get node name.

Returns
string_view to the node name
Note
If you store the result of this function make sure it does not outlive the underlying DataStore node, otherwise make a string copy

◆ next()

template<typename T >
GenericDataNode LLU::DataNode< T >::next ( ) const
inline

Get next node as GenericDataNode (because the next node may not necessarily have value of type T)

Returns
GenericDataNode wrapper of next node, or empty if this is the last node

◆ type()

template<typename T >
MArgumentType LLU::DataNode< T >::type ( )
inlinenoexcept

Get the actual type of node value.

This is useful when working on a "generic" DataList.

Returns
Actual type of node value

◆ value() [1/2]

template<typename T >
T& LLU::DataNode< T >::value ( )
inline

Get node value.

Returns
Returns a reference to node value

◆ value() [2/2]

template<typename T >
const T& LLU::DataNode< T >::value ( ) const
inline

Get node value.

Returns
Returns a reference to node value