LibraryLink Utilities  3.0.1
Modern C++ wrapper over LibraryLink and WSTP
LLU::WS::GetAs< E, T > Struct Template Reference

Description

template<Encoding E, typename T>
struct LLU::WS::GetAs< E, T >

Utility structure used to enforce receiving given value via WSStream with encoding E.

Template Parameters
E- desired encoding
T- actual type of the expression

This structure is only supposed to be used as a wrapper for arguments to WSStream::operator>>

Note
It's recommended not to use WS::GetAs constructor directly, but rather utilize a helper function WS::getAs.
WSStream<WS::Encoding::Byte> mls { mlink }; // mls will receive all strings as if they were ascii-encoded by default
std::string stringWithNonAsciiChars; // we expect a string with non-ascii characters to come from WSTP
mls << WS::getAs<WS::Encoding::UTF8>(stringWithNonAsciiChars); // this will use UTF8 encoding when receiving the string

#include <EncodingTraits.hpp>

Public Member Functions

 GetAs (T &o)
 Constructor that takes a reference to value of type T and stores it. More...
 

Public Attributes

T & obj
 A reference to which later a resulting value from WSTP function will be assigned. More...
 

Constructor & Destructor Documentation

◆ GetAs()

template<Encoding E, typename T >
LLU::WS::GetAs< E, T >::GetAs ( T &  o)
inlineexplicit

Constructor that takes a reference to value of type T and stores it.

Parameters
o- reference to the object to be read from WSStream

Member Data Documentation

◆ obj

template<Encoding E, typename T >
T& LLU::WS::GetAs< E, T >::obj

A reference to which later a resulting value from WSTP function will be assigned.