rego-cpp 0.4.5
A C++ implementation of the Rego language and runtime
|
#include <rego.hh>
Public Member Functions | |
UnwrapOpt (std::size_t index) | |
bool | exclude_got () const |
UnwrapOpt & | exclude_got (bool exclude_got) |
bool | specify_number () const |
UnwrapOpt & | specify_number (bool specify_number) |
const std::string & | code () const |
UnwrapOpt & | code (const std::string &value) |
const std::string & | pre () const |
UnwrapOpt & | pre (const std::string &value) |
const std::string & | message () const |
UnwrapOpt & | message (const std::string &value) |
const std::string & | func () const |
UnwrapOpt & | func (const std::string &value) |
const std::vector< Token > & | types () const |
UnwrapOpt & | types (const std::vector< Token > &value) |
const Token & | type () const |
UnwrapOpt & | type (const Token &value) |
Node | unwrap (const Nodes &args) const |
This struct provides options for unwrapping an argument and producing an error message.
The act of unwrapping a node is the process of testing whether a node or one of its direct descendents is of one or more types. So, for example, the following nodes:
Would all be successfully unwrapped as (int 5)
if the type JSONInt was specified. However, if Float was specified, the result would be an error node.
rego::UnwrapOpt::UnwrapOpt | ( | std::size_t | index | ) |
Construct an UnwrapOpt.
index | The index of the argument to unwrap. |
const std::string & rego::UnwrapOpt::code | ( | ) | const |
The error code for the error message.
Default value if omitted is EvalTypeError.
bool rego::UnwrapOpt::exclude_got | ( | ) | const |
Whether the statement indicating what was received instead of the expect type should be excluded.
const std::string & rego::UnwrapOpt::func | ( | ) | const |
The name of the function.
If provide, will be a prefix on the message as "<func-name>:"
const std::string & rego::UnwrapOpt::message | ( | ) | const |
The full error message.
If this is set, no message will be generated and instead this will be returned verbatim.
const std::string & rego::UnwrapOpt::pre | ( | ) | const |
The error preamble.
If omitted, a default preamble will be constructed from the operation metadata in the form "operand <i> must be <t>".
bool rego::UnwrapOpt::specify_number | ( | ) | const |
Whether to specify in the error message which kind of number was received (i.e. integer or floating point)
const Token & rego::UnwrapOpt::type | ( | ) | const |
The singular type to match against.
const std::vector< Token > & rego::UnwrapOpt::types | ( | ) | const |
The types to match against.
The operand must be one of the provided types or else an error node will be return.
Node rego::UnwrapOpt::unwrap | ( | const Nodes & | args | ) | const |
Unwraps an argument from the provided vector of nodes.
args | The vector of nodes to unwrap from. |