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

#include <driver.h>

Inheritance diagram for spicy::rt::Driver:
SpicyDriver SpicyDriver SpicyDump

Public Member Functions

hilti::rt::Result< hilti::rt::NothinglistParsers (std::ostream &out)
 
hilti::rt::Result< const spicy::rt::Parser * > lookupParser (const std::string &name="")
 
hilti::rt::Result< spicy::rt::ParsedUnitprocessInput (const spicy::rt::Parser &parser, std::istream &in, int increment=0)
 
hilti::rt::Result< hilti::rt::NothingprocessPreBatchedInput (std::istream &in)
 
void debug (const std::string &msg)
 

Detailed Description

Runtime driver to retrieve and feed Spicy parsers.

The HILTI/Spicy runtime environments must be managed externally, and must have been initialized already before using any of the driver's functionality.

Member Function Documentation

◆ debug()

void Driver::debug ( const std::string &  msg)
inline

Records a debug message to the spicy-driver runtime debug stream.

◆ listParsers()

Result< Nothing > Driver::listParsers ( std::ostream &  out)

Prints a human-readable list of all available parsers, retrieved from the Spicy runtime system.

Parameters
outstream to print the summary to
Returns
an error if the list cannot be retrieved

◆ lookupParser()

Result< const spicy::rt::Parser * > Driver::lookupParser ( const std::string &  name = "")

Retrieves a parser by its name.

Parameters
namename of the parser to be retrieved, either as shown in the output of listParsers(); or, alternatively, as a string rendering of a port or MIME type as defined by a unit's properties. If no name is given and there's only one parser available, that one is taken automatically.
Returns
the parser, or an error if it could not be retrieved

◆ processInput()

Result< spicy::rt::ParsedUnit > Driver::processInput ( const spicy::rt::Parser parser,
std::istream &  in,
int  increment = 0 
)

Feeds a parser with an input stream of data.

Parameters
parserparser to instantiate and feed
instream to read input data from; will read until EOF is encountered
incrementif non-zero, will feed the data in small chunks at a time; this is mainly for testing parsers; incremental parsing
Returns
error if the input couldn't be fed to the parser (excluding parse errors)
Exceptions
HILTIor Spocy runtime error if the parser into trouble

◆ processPreBatchedInput()

Result< hilti::rt::Nothing > Driver::processPreBatchedInput ( std::istream &  in)

Processes a batch of input data given in Spicy's custom batch format. See the documentation of spicy-driver for a reference of the batch format.

Parameters
inan open stream to read the batch from
Returns
appropriate error if there was a problem processing the batch

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