Manages the set of builtins used by an interpreter to resolve built-in calls.
More...
#include <rego.hh>
Manages the set of builtins used by an interpreter to resolve built-in calls.
This object provides all lookup for builtins. Users can add their own custom builtins using BuiltInsDef::register_builtin. Built-ins from the Rego standard library.) will be loaded as needed. Control over what parts of the standard library are available to policies is available via the BuiltInsDef::whitelist and BuiltInsDef::blacklist methods.
◆ allow_all()
Allow all built-ins to be loaded from the standard library.
- Returns
- A reference to this instance
◆ at()
Gets the built-in with the provided name.
- Parameters
-
| name | The name of the built-in to retrieve. |
- Returns
- The built-in with the specified name.
◆ blacklist() [1/2]
| BuiltInsDef & rego::BuiltInsDef::blacklist |
( |
const std::initializer_list< T > & |
forbidden | ) |
|
|
inline |
Sets a blacklist of built-in names that are forbidden from being loaded.
Built-ins whose names are in this list will be forbidden. Any previous list and behavior will be overridden.
- Parameters
-
| forbidden | the forbidden built-in names |
- Returns
- A reference to this instance
◆ blacklist() [2/2]
Sets a blacklist of built-in names that are forbidden from being loaded.
Built-ins whose names are in this list will be forbidden. Any previous list and behavior will be overridden.
- Parameters
-
| begin | iterator pointing to the beginning of a range of forbidden names |
| end | iterator pointing to the end of a range of forbidden names |
- Returns
- A reference to this instance
◆ call()
Calls the built-in with the provided name and arguments.
- Parameters
-
| name | The name of the built-in to call. |
| version | The Rego version. |
| args | The arguments to pass to the built-in. |
- Returns
- The result of the built-in call.
◆ create()
Creates the standard builtin set.
- Returns
- A shared pointer to the created BuiltInsDef.
◆ decl()
Gets the declaration node for the specified built-in.
- Parameters
-
| name | The name of the built-in. |
- Returns
- The declaration node for the built-in, or an empty node if not found.
◆ is_builtin()
Determines whether the provided name refers to a built-in.
- Parameters
-
- Returns
- True if the name refers to a built-in, otherwise false.
◆ is_deprecated()
Determines whether the provided builtin name is deprecated in the provided version.
- Parameters
-
| version | The version to check. |
| name | The name to check. |
- Returns
- True if the builtin is deprecated in the specified version, otherwise false.
◆ register_builtin()
Registers a built-in.
- Parameters
-
| built_in | The built-in to register. |
- Returns
- A reference to this instance.
◆ register_builtins()
Registers a set of built-ins.
- Parameters
-
| built_ins | The built-ins to register. |
- Returns
- A reference to this instance.
◆ register_standard_builtins()
| BuiltInsDef & rego::BuiltInsDef::register_standard_builtins |
( |
| ) |
|
This method no longer needs to be called.
- Deprecated:
- Returns
- A reference to this instance.
◆ strict_errors() [1/2]
| bool rego::BuiltInsDef::strict_errors |
( |
| ) |
const |
Whether to throw built-in errors.
- Returns
- True if built-in errors will be thrown as exceptions, false otherwise. If true, built-in errors will be thrown as exceptions. If false, built-in errors will result in Undefined nodes.
◆ strict_errors() [2/2]
Sets whether to throw built-in errors.
- Parameters
-
| strict_errors | True to throw built-in errors as exceptions, false to return Undefined nodes. |
- Returns
- A reference to this instance.
◆ whitelist() [1/2]
| BuiltInsDef & rego::BuiltInsDef::whitelist |
( |
const std::initializer_list< T > & |
allowed | ) |
|
|
inline |
Sets a whitelist of built-in names that are allowed to be loaded.
Only built-ins whose names are in this list will be allowed. Any previous list and behavior will be overridden.
- Parameters
-
| allowed | the allowed built-in names |
- Returns
- A reference to this instance
◆ whitelist() [2/2]
Sets a whitelist of built-in names that are allowed to be loaded.
Only built-ins whose names are in this list will be allowed. Any previous list and behavior will be overridden.
- Parameters
-
| begin | iterator pointing to the beginning of a range of allowed names |
| end | iterator pointing to the end of a range of allowed names |
- Returns
- A reference to this instance
The documentation for this class was generated from the following file: