LibraryLink Utilities  3.0.1
Modern C++ wrapper over LibraryLink and WSTP
WSTP/Utilities.h File Reference

Header file with miscellaneous utilities used throughout the WSTP-related part of LibraryLinkUtilities. More...

Detailed Description

Header file with miscellaneous utilities used throughout the WSTP-related part of LibraryLinkUtilities.

Date
Nov 26, 2017
Author
Rafal Chojna rafal.nosp@m.c@wo.nosp@m.lfram.nosp@m..com
#include <cstring>
#include <string>
#include "wstp.h"
#include "LLU/ErrorLog/Errors.h"
#include "LLU/WSTP/EncodingTraits.hpp"
+ Include dependency graph for WSTP/Utilities.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  LLU::WSStream
 Wrapper class over WSTP with a stream-like interface. More...
 
struct  LLU::WS::Symbol
 Structure representing any symbol in Wolfram Language. More...
 
struct  LLU::WS::Function
 Structure representing any function in Wolfram Language, i.e. a head plus number of arguments. More...
 
struct  LLU::WS::Association
 Special type of a Function which corresponds to the Association expression when exchanged with the Kernel via WSStream. More...
 
struct  LLU::WS::List
 Special type of a Function which corresponds to the List expression when exchanged with the Kernel via WSStream. More...
 
struct  LLU::WS::Missing
 Special type of a Function which corresponds to the Missing expression when exchanged with the Kernel via WSStream. More...
 
struct  LLU::WS::BeginExpr
 
struct  LLU::WS::DropExpr
 
struct  LLU::WS::EndExpr
 

Namespaces

 LLU
 Main namespace of LibraryLink Utilities.
 
 LLU::WS
 Contains definitions related to WSTP functionality in LLU.
 

Enumerations

enum  LLU::WS::Direction : bool {
  Get,
  Put
}
 Helper enum for tokens that can be sent via WSTP in both directions, e.g. WS::Null. More...
 

Functions

void LLU::WS::Detail::checkError (WSLINK m, int statusOk, const std::string &errorName, const std::string &debugInfo="")
 Checks if WSTP operation was successful and throws appropriate exception otherwise. More...
 
void LLU::WS::Detail::throwLLUException (const std::string &errorName, const std::string &debugInfo="")
 Simple wrapper over ErrorManager::throwException used to break dependency cycle between WSStream and ErrorManager. More...
 
WSLINK LLU::WS::Detail::getNewLoopback (WSLINK m)
 Returns a new loopback link using WSLinkEnvironment(m) as WSENV. More...
 
int LLU::WS::Detail::countExpressionsInLoopbackLink (WSLINK &lpbckLink)
 Get the number of expressions stored in the loopback link. More...
 
template<WS::Encoding EIn, WS::Encoding EOut>
WSStream< EIn, EOut > & LLU::WS::NewPacket (WSStream< EIn, EOut > &ms)
 NewPacket is a WSStream token which tells WSTP to skip to the end of the current packet. More...
 
template<WS::Encoding EIn, WS::Encoding EOut>
WSStream< EIn, EOut > & LLU::WS::EndPacket (WSStream< EIn, EOut > &ms)
 EndPacket is a WSStream token which tells WSTP that the current expression is complete and is ready to be sent. More...
 
template<WS::Encoding EIn, WS::Encoding EOut>
WSStream< EIn, EOut > & LLU::WS::Flush (WSStream< EIn, EOut > &ms)
 Flush is a WSStream token which tells WSTP to flush out any buffers containing data waiting to be sent on link. More...
 
template<WS::Encoding EIn, WS::Encoding EOut>
WSStream< EIn, EOut > & LLU::WS::Rule (WSStream< EIn, EOut > &ms, Direction dir)
 Rule is a WSStream token corresponding to a Rule expression in the WolframLanguage. More...
 
template<WS::Encoding EIn, WS::Encoding EOut>
WSStream< EIn, EOut > & LLU::WS::Null (WSStream< EIn, EOut > &ms, Direction dir)
 Null is a WSStream token corresponding to a Null expression in the WolframLanguage. More...
 

Function Documentation

◆ checkError()

void LLU::WS::Detail::checkError ( WSLINK  m,
int  statusOk,
const std::string &  errorName,
const std::string &  debugInfo = "" 
)

Checks if WSTP operation was successful and throws appropriate exception otherwise.

Parameters
[in]m- low-level object of type WSLINK received from LibraryLink
[in]statusOk- status code return from a WSTP function
[in]errorName- what error name to put in the exception if WSTP function failed
[in]debugInfo- additional info to be attached to the exception

◆ countExpressionsInLoopbackLink()

int LLU::WS::Detail::countExpressionsInLoopbackLink ( WSLINK &  lpbckLink)

Get the number of expressions stored in the loopback link.

Parameters
lpbckLink- a reference to the loopback link, after expressions are counted this argument will be assigned a different WSLINK
Returns
a number of expression stored in the loopback link

◆ getNewLoopback()

WSLINK LLU::WS::Detail::getNewLoopback ( WSLINK  m)

Returns a new loopback link using WSLinkEnvironment(m) as WSENV.

Parameters
m- valid WSLINK
Returns
a brand new Loopback Link

◆ throwLLUException()

void LLU::WS::Detail::throwLLUException ( const std::string &  errorName,
const std::string &  debugInfo = "" 
)

Simple wrapper over ErrorManager::throwException used to break dependency cycle between WSStream and ErrorManager.

Parameters
errorName- what error name to put in the exception
debugInfo- additional info to be attached to the exception