![]() |
rego-cpp 1.4.0
A C++ implementation of the Rego language and runtime
|
This directory contains examples of how to use the library from the different languages we support (other than C++. For C++ examples see the tests or tools directories).
At the moment we support C, C++, Rust, Python, and dotnet. The C API has been designed to make it straightforward to wrap for other languages. To see some examples, look at the wrappers directory.
You can begin by looking at example.cc to see some sample usage of the API. custom_builtin.cc shows how to add your own custom builtins (only supported in C++ at this point in time).
From there, the best way to get a more in-depth understanding of the C++ API is to look at the rego tool.
There are two C examples. The first, example.c exercises the C API, showing all the various ways it can be used. The second C example is a command line tool that takes one or more Rego data, module, and input files and evaluates a query against them.
To build it on Linux:
and on Windows:
The resulting executable can be called from within the dist directory:
The Python example is a demonstration program that shows how to use all the features of the wrapper, including queries, input/data, and bundles.
There is also a command line tool that takes zero or more Rego data, module, and input files and evaluates a query against them.
The Rust example is a demonstration program that shows how to use all the features of the wrapper, including queries, input/data, and bundles.
The dotnet example does not provide a full command-line tool, but it does show how use all the features of the wrapper: