Spicy
Public Member Functions | List of all members
spicy::rt::UnitContext Class Reference

#include <unit-context.h>

Public Member Functions

template<typename T >
 UnitContext (hilti::rt::StrongReference< T > obj, const hilti::rt::TypeInfo *ti)
 
template<typename Context >
hilti::rt::StrongReference< Context > as (const hilti::rt::TypeInfo *ti) const
 
 UnitContext (const UnitContext &)=default
 
 UnitContext (UnitContext &&)=default
 
UnitContextoperator= (const UnitContext &)=default
 
UnitContextoperator= (UnitContext &&)=default
 

Detailed Description

Exception thrown on attempts to use a context not matching what the unit expects. Type-erased wrapper around an instance of a parsing unit's context type.

This stores a reference to the instance, along with shallow copy semantics. That means that units using copies of a particular instance of this class will all share the same context.

Constructor & Destructor Documentation

◆ UnitContext()

template<typename T >
spicy::rt::UnitContext::UnitContext ( hilti::rt::StrongReference< T >  obj,
const hilti::rt::TypeInfo ti 
)
inline
Template Parameters
Ttype of the a unit's context.
Parameters
objreference to a concrete context's instance
titype information matching obj

Member Function Documentation

◆ as()

template<typename Context >
hilti::rt::StrongReference<Context> spicy::rt::UnitContext::as ( const hilti::rt::TypeInfo ti) const
inline

Returns the stored context instance, typed correctly.

Template Parameters
Contexttype of the context stored.
Parameters
objti type information matching Context

The documentation for this class was generated from the following files: