inkcpp
Loading...
Searching...
No Matches
HInkRunner Class Reference

A handle for an ink runner. More...

#include <inkcpp.h>

Public Types

typedef InkValue(* InkExternalFunction) (int argc, const InkValue argv[])
 Callback for a Ink external function which returns void.
 
typedef void(* InkExternalFunctionVoid) (int argc, const InkValue argv[])
 Callback for a Ink external function wihich returns a value.
 

Public Member Functions

void ink_runner_delete (HInkRunner *self)
 Deconstructs the Runner and all frees assoziated resources.
 
HInkSnapshotink_runner_create_snapshot (const HInkRunner *self)
 Creates a snapshot, for later reloading.
 
int ink_runner_can_continue (const HInkRunner *self)
 Can the runner continue?
 
const char * ink_runner_get_line (HInkRunner *self)
 Continue execution until the next newline, then allocate a c-style string with the output.
 
int ink_runner_num_tags (const HInkRunner *self)
 Returns the number of tags on the current line.
 
const char * ink_runner_tag (const HInkRunner *self, int index)
 Access a tag by index.
 
int ink_runner_num_knot_tags (const HInkRunner *self)
 Get Number of knot/stitch tags.
 
ink_hash_t ink_runner_current_knot (const HInkRunner *self)
 Get hash of current knot/stitch name.
 
bool ink_runner_move_to (HInkRunner *self, ink_hash_t path)
 Moves the runner to the specified path.
 
const char * ink_runner_knot_tag (const HInkRunner *self, int index)
 
int ink_runner_num_global_tags (const HInkRunner *self)
 Get Number of global tags.
 
const char * ink_runner_global_tag (const HInkRunner *self, int index)
 
int ink_runner_num_choices (const HInkRunner *self)
 Returns the number of choices currently available.
 
const HInkChoiceink_runner_get_choice (const HInkRunner *self, int index)
 Gets a choice.
 
void ink_runner_choose (HInkRunner *self, int index)
 Make a choice.
 
void ink_runner_bind_void (HInkRunner *self, const char *function_name, InkExternalFunctionVoid callback, int lookaheadSafe)
 Binds a external function which is called form the runtime, with no return value.
 
void ink_runner_bind (HInkRunner *self, const char *function_name, InkExternalFunction callback, int lookaheadSafe)
 Binds a external function which is called from the runtime, with a return vallue.
 

Detailed Description

A handle for an ink runner.

An independent runner which can execute ink script from a story independent of other runners. Think of the ink story object like an executable file and the runners as 'threads' (not to be confused with ink threads, which are a language feature). Runners track their own instruction pointer, choice list, temporary variables, callstack, etc. They can either be started with their own globals store, or can share one with other runner instances.

See also
globals
story

Member Typedef Documentation

◆ InkExternalFunction

typedef InkValue(* InkExternalFunction) (int argc, const InkValue argv[])

Callback for a Ink external function which returns void.

Parameters
argcnumber of arguments
argvarray containing the arguments

◆ InkExternalFunctionVoid

typedef void(* InkExternalFunctionVoid) (int argc, const InkValue argv[])

Callback for a Ink external function wihich returns a value.

Parameters
argcnumber of arguments
argvarray contaning the arguments
Returns
value to be furthe process by the ink runtime

Member Function Documentation

◆ ink_runner_bind()

void ink_runner_bind ( HInkRunner * self,
const char * function_name,
InkExternalFunction callback,
int lookaheadSafe )

Binds a external function which is called from the runtime, with a return vallue.

See also
ink_runner_bind_void()
Parameters
self
function_namename of external function declared inside ink script
callback
lookaheadSafeif false stop glue lookahead if encounter this function this prevents double execution of external functions but can lead to missing glues

◆ ink_runner_bind_void()

void ink_runner_bind_void ( HInkRunner * self,
const char * function_name,
InkExternalFunctionVoid callback,
int lookaheadSafe )

Binds a external function which is called form the runtime, with no return value.

See also
ink_runner_bind()
Parameters
self
function_namedeclared in ink script
callback
lookaheadSafeif false stop glue lookahead if encounter this function this prevents double execution of external functions but can lead to missing glues

◆ ink_runner_can_continue()

int ink_runner_can_continue ( const HInkRunner * self)

Can the runner continue?

Checks if the runner can continue execution. If it can't, we are either at a choice or are out of content.

See also
continue
has_choices
Returns
Can continue be called

◆ ink_runner_choose()

void ink_runner_choose ( HInkRunner * self,
int index )

Make a choice.

Takes the choice at the given index and moves the instruction pointer to that branch.

Parameters
indexindex of the choice to make
self

◆ ink_runner_create_snapshot()

HInkSnapshot * ink_runner_create_snapshot ( const HInkRunner * self)

Creates a snapshot, for later reloading.

Attention
All runners assoziated with the same globals will create the same snapshot HInkSnapshot

◆ ink_runner_current_knot()

ink_hash_t ink_runner_current_knot ( const HInkRunner * self)

Get hash of current knot/stitch name.

Returns
hash of current knot/stitch name
See also
ink::hash_string()
Parameters
self

◆ ink_runner_get_choice()

const HInkChoice * ink_runner_get_choice ( const HInkRunner * self,
int index )

Gets a choice.

Returns the choice object at a given index

See also
num_choices
Parameters
indexindex of the choice to access
Returns
choice object with info on the choice
Parameters
self

◆ ink_runner_get_line()

const char * ink_runner_get_line ( HInkRunner * self)

Continue execution until the next newline, then allocate a c-style string with the output.

This allocated string is managed by the runtime and will be deleted at the next choose() or getline()

Returns
allocated c-style string with the output of a single line of execution

◆ ink_runner_global_tag()

const char * ink_runner_global_tag ( const HInkRunner * self,
int index )

Parameters
self

◆ ink_runner_knot_tag()

const char * ink_runner_knot_tag ( const HInkRunner * self,
int index )

Parameters
self

◆ ink_runner_move_to()

bool ink_runner_move_to ( HInkRunner * self,
ink_hash_t path )

Moves the runner to the specified path.

Clears any execution context and moves the runner to the content at the specified path.

Parameters
pathpath to search and move execution to
Returns
If the path was found
Parameters
self
See also
ink_hash_string()

◆ ink_runner_num_choices()

int ink_runner_num_choices ( const HInkRunner * self)

Returns the number of choices currently available.

Returns
number of choices
Parameters
self

◆ ink_runner_num_global_tags()

int ink_runner_num_global_tags ( const HInkRunner * self)

Get Number of global tags.

@info global tags are also assoziated to the first line in the knot/stitch

See also
has_global_tags get_global_tags num_knot_tags num_tags
Returns
the number of tags at the top of the document.
Parameters
self

◆ ink_runner_num_knot_tags()

int ink_runner_num_knot_tags ( const HInkRunner * self)

Get Number of knot/stitch tags.

@info knot/stitch tags are also assoziated to the first line in the knot/stitch

Returns
number of tags at the top of a knot/stitch
See also
has_knot_tags get_knot_tag num_global_tags num_tags
Parameters
self

◆ ink_runner_num_tags()

int ink_runner_num_tags ( const HInkRunner * self)

Returns the number of tags on the current line.

Excludes global tags.

See also
get_tag has_tags num_global_tags num_knot_tags

◆ ink_runner_tag()

const char * ink_runner_tag ( const HInkRunner * self,
int index )

Access a tag by index.

Note that this method only allows the retrieval of tags attached to the current line. For tags at the top of the script, use get_global_tag()

Parameters
indextag id to fetch [0;num_tags())
Returns
pointer to the tag string memory or nullptr if the index is invalid
See also
has_tags num_tags get_global_tag get_knot_tag
Parameters
self

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