47#define REGO_ERROR_BUFFER_TOO_SMALL 2
48#define REGO_ERROR_INVALID_LOG_LEVEL 3
50#define REGO_ERROR_INPUT_NULL 5
51#define REGO_ERROR_INPUT_MISSING_ARGUMENTS 6
52#define REGO_ERROR_INPUT_OBJECT_ITEM 7
55#define REGO_NODE_BINDING 1000
56#define REGO_NODE_VAR 1001
57#define REGO_NODE_TERM 1002
58#define REGO_NODE_SCALAR 1003
59#define REGO_NODE_ARRAY 1004
60#define REGO_NODE_SET 1005
61#define REGO_NODE_OBJECT 1006
62#define REGO_NODE_OBJECT_ITEM 1007
63#define REGO_NODE_INT 1008
64#define REGO_NODE_FLOAT 1009
65#define REGO_NODE_STRING 1010
66#define REGO_NODE_TRUE 1011
67#define REGO_NODE_FALSE 1012
68#define REGO_NODE_NULL 1013
69#define REGO_NODE_UNDEFINED 1014
70#define REGO_NODE_TERMS 1015
71#define REGO_NODE_BINDINGS 1016
72#define REGO_NODE_RESULTS 1017
73#define REGO_NODE_RESULT 1018
75#define REGO_NODE_ERROR 1800
76#define REGO_NODE_ERROR_MESSAGE 1801
77#define REGO_NODE_ERROR_AST 1802
78#define REGO_NODE_ERROR_CODE 1803
79#define REGO_NODE_ERROR_SEQ 1804
81#define REGO_NODE_INTERNAL 1999
84#define REGO_LOG_LEVEL_NONE 0
85#define REGO_LOG_LEVEL_ERROR 1
86#define REGO_LOG_LEVEL_OUTPUT 2
87#define REGO_LOG_LEVEL_WARN 3
88#define REGO_LOG_LEVEL_INFO 4
89#define REGO_LOG_LEVEL_DEBUG 5
90#define REGO_LOG_LEVEL_TRACE 6
91#define REGO_LOG_LEVEL_UNSUPPORTED 7
93#define REGO_BUILD_INFO \
94 (REGOCPP_VERSION " (" REGOCPP_BUILD_NAME ", " REGOCPP_BUILD_DATE \
95 ") " REGOCPP_BUILD_TOOLCHAIN " on " REGOCPP_PLATFORM)
99#if defined(REGO_SHARED) && defined(WIN32)
101#define REGO_API(x) __declspec(dllexport) x __cdecl
void regoSetStrictBuiltInErrors(regoInterpreter *rego, regoBoolean enabled)
Sets whether the built-ins should throw errors.
regoEnum regoAddEntrypoint(regoInterpreter *rego, const char *entrypoint)
Adds an entrypoint to the interpreter.
regoNode * regoOutputExpressionsAtIndex(regoOutput *output, regoSize index)
Returns a node containing a list of terms resulting from the query at the specified index.
regoEnum regoVersion(char *buffer, regoSize size)
Populate a buffer with a string representing the semantic version of the library.
regoSize regoBuildInfoSize(void)
Returns the number of bytes needed to store a 0-terminated string representing the build info.
regoEnum regoInputSet(regoInput *input, regoSize count)
Uses the top 'count' values on the stack to create a set and pushes it back onto the stack.
regoEnum regoError(regoInterpreter *rego, char *buffer, regoSize size)
Populate a buffer with the most recent error message.
regoEnum regoInputValidate(regoInput *input)
Validates the input object.
regoSize regoErrorSize(regoInterpreter *rego)
Returns the number of bytes needed to store a 0-terminated string representing the most recent error ...
regoEnum regoInputNull(regoInput *input)
Adds a null value to the input object.
regoOutput * regoBundleQuery(regoInterpreter *rego, regoBundle *bundle)
Performs a query against the specified bundle.
void regoInterpreter
Opaque interpreter type.
Definition rego_c.h:14
void regoFreeBundle(regoBundle *bundle)
Frees a Rego bundle.
regoEnum regoInputInt(regoInput *input, regoInt value)
Adds an integer value to the input object.
regoEnum regoBundleSaveBinary(regoInterpreter *rego, const char *path, regoBundle *bundle)
Saves a compiled Rego bundle to the specified binary file.
void regoInput
Opaque input type.
Definition rego_c.h:26
uint_least32_t regoSize
Size type.
Definition rego_c.h:35
regoBundle * regoBuild(regoInterpreter *rego)
Builds a compiled Rego bundle.
regoBoolean regoGetDebugEnabled(regoInterpreter *rego)
Gets the debug mode of the interpreter.
void regoFreeOutput(regoOutput *output)
Frees a Rego output.
regoSize regoVersionSize(void)
Returns the number of bytes needed to store a 0-terminated string representing version.
regoBoolean regoIsAvailableBuiltIn(regoInterpreter *rego, const char *name)
Returns whether the specified name corresponds to an available built-in in the interpreter.
void regoFree(regoInterpreter *rego)
Frees a Rego interpreter.
regoEnum regoNodeValue(regoNode *node, char *buffer, regoSize size)
Populate a buffer with the node value.
regoEnum regoNodeTypeName(regoNode *node, char *buffer, regoSize size)
Returns the name of the node type as a human-readable string.
void regoOutput
Opaque output type.
Definition rego_c.h:20
void regoSetDebugEnabled(regoInterpreter *rego, regoBoolean enabled)
Sets the debug mode of the interpreter.
regoOutput * regoQuery(regoInterpreter *rego, const char *query_expr)
Performs a query against the current base and virtual documents.
regoEnum regoSetLogLevel(regoInterpreter *rego, regoEnum level)
Sets the level of logging on the interpreter.
regoEnum regoSetDefaultLogLevel(regoEnum level)
Sets the default level of logging.
regoEnum regoAddModuleFile(regoInterpreter *rego, const char *path)
Adds a module (e.g. virtual document) from the file at the specified path.
regoSize regoNodeValueSize(regoNode *node)
Returns the number of bytes needed to store a 0-terminated string representing the text value of the ...
regoNode * regoOutputBinding(regoOutput *output, const char *name)
Returns the bound value for a given variable name at the first index.
regoSize regoNodeJSONSize(regoNode *node)
Returns the number of bytes needed to store a 0-terminated string representing the JSON representatio...
regoSize regoOutputJSONSize(regoOutput *output)
Returns the number of bytes needed to store a 0-terminated string representing the output as a human-...
regoNode * regoOutputBindingAtIndex(regoOutput *output, regoSize index, const char *name)
Returns the bound value for a given variable name.
void regoFreeInput(regoInput *input)
Frees a Rego Input object.
regoEnum regoInputFloat(regoInput *input, double value)
Adds a floating point value to the input object.
regoEnum regoInputObjectItem(regoInput *input)
Uses the top two values on the stack to create an object item and pushes it back onto the stack.
regoNode * regoBundleNode(regoBundle *bundle)
Returns a node containing the base document of the bundle.
regoEnum regoSetInputTerm(regoInterpreter *rego, const char *contents)
Sets the current input document from the specified string.
regoEnum regoNodeJSON(regoNode *node, char *buffer, regoSize size)
Populate a buffer with the JSON representation of the node.
regoType regoNodeType(regoNode *node)
Returns an enumeration value indicating the node's type.
regoBoolean regoOutputOk(regoOutput *output)
Returns whether the output is ok.
void regoNode
Opaque node type.
Definition rego_c.h:17
regoEnum regoSetInputJSONFile(regoInterpreter *rego, const char *path)
Sets the current input document from the file at the specified path.
uint_least8_t regoBoolean
Boolean type.
Definition rego_c.h:29
regoInterpreter * regoNew(void)
Allocates and initializes a new Rego interpreter.
regoEnum regoInputBoolean(regoInput *input, regoBoolean value)
Adds a boolean value to the input object.
regoBoolean regoGetStrictBuiltInErrors(regoInterpreter *rego)
Gets whether strict built-in errors are enabled.
regoInput * regoNewInput()
Allocates and initializes a new Rego Input object.
void regoSetWellFormedChecksEnabled(regoInterpreter *rego, regoBoolean enabled)
Sets whether to perform well-formedness checks after each compiler pass.
uint_least32_t regoType
Node Type type.
Definition rego_c.h:41
regoNode * regoInputNode(regoInput *input)
Returns the top of the Input stack.
regoOutput * regoBundleQueryEntrypoint(regoInterpreter *rego, regoBundle *bundle, const char *endpoint)
Performs a query against the specified bundle at the specified entrypoint.
regoEnum regoSetDebugPath(regoInterpreter *rego, const char *path)
Sets the path to the debug directory.
regoEnum regoInputString(regoInput *input, const char *value)
Adds a string value to the input object.
regoBoolean regoBundleOk(regoBundle *bundle)
Returns whether the bundle is ok.
regoNode * regoOutputExpressions(regoOutput *output)
Returns a node containing a list of terms resulting from the query at the default index.
regoBundle * regoBundleLoad(regoInterpreter *rego, const char *dir)
Loads a compiled Rego bundle from the specified directory.
regoEnum regoOutputJSON(regoOutput *output, char *buffer, regoSize size)
Populate a buffer with the output represented as a human-readable string.
regoEnum regoAddDataJSONFile(regoInterpreter *rego, const char *path)
Adds a base document from the file at the specified path.
regoEnum regoInputArray(regoInput *input, regoSize count)
Uses the top 'count' values on the stack to create an array and pushes it back onto the stack.
regoNode * regoOutputNode(regoOutput *output)
Returns the node containing the output of the query.
int_least64_t regoInt
Integer type.
Definition rego_c.h:38
regoEnum regoInputObject(regoInput *input, regoSize count)
Uses the top 'count' values on the stack to create an object and pushes it back onto the stack.
regoEnum regoAddModule(regoInterpreter *rego, const char *name, const char *contents)
Adds a module (e.g. virtual document) from the specified string.
#define REGO_API(x)
Macro for exporting functions from a shared library on other platforms.
Definition rego_c.h:105
regoBoolean regoGetWellFormedChecksEnabled(regoInterpreter *rego)
Gets whether well-formedness checks are enabled.
regoSize regoInputSize(regoInput *input)
Returns the number of items on the Input stack.
regoEnum regoGetLogLevel(regoInterpreter *rego)
Gets the level of logging on the interpreter.
regoBundle * regoBundleLoadBinary(regoInterpreter *rego, const char *path)
Loads a compiled Rego bundle from the specified binary file.
regoEnum regoBuildInfo(char *buffer, regoSize size)
Populate a buffer with a string of the form "VERSION (BUILD_NAME,BUILD_DATE) BUILD_TOOLCHAIN on PLATF...
regoEnum regoAddDataJSON(regoInterpreter *rego, const char *contents)
Adds a base document from the specified string.
regoEnum regoLogLevelFromString(const char *level)
Gets a log level constant value from a string (case-invariant).
void regoBundle
Opaque bundle type.
Definition rego_c.h:23
regoEnum regoSetQuery(regoInterpreter *rego, const char *query_expr)
Sets the query for the interpreter.
uint_least32_t regoEnum
Enum type.
Definition rego_c.h:32
regoEnum regoNodeTypeNameSize(regoNode *node)
Returns the number of bytes needed to store a 0-terminated string representing the name of the node t...
regoEnum regoSetInput(regoInterpreter *rego, regoInput *input)
Sets the current input document from the specified Input object.
regoEnum regoBundleSave(regoInterpreter *rego, const char *dir, regoBundle *bundle)
Saves a compiled Rego bundle to the specified directory.
regoSize regoOutputSize(regoOutput *output)
Returns the number of results in the output.
regoSize regoNodeSize(regoNode *node)
Returns the number of children of the node.
regoNode * regoNodeGet(regoNode *node, regoSize index)
Returns the child node at the specified index.