rego-cpp 0.4.5
A C++ implementation of the Rego language and runtime
Loading...
Searching...
No Matches
rego_c.h
Go to the documentation of this file.
1// Copyright (c) Microsoft Corporation.
2// Licensed under the MIT License.
3
6#ifndef _REGO_C_H_
7#define _REGO_C_H_
8
9#include "version.h"
10
11typedef void regoInterpreter;
12typedef void regoNode;
13typedef void regoOutput;
14typedef unsigned int regoEnum;
15typedef unsigned char regoBoolean;
16typedef unsigned int regoSize;
17
18// error codes
19#define REGO_OK 0
20#define REGO_ERROR 1
21#define REGO_ERROR_BUFFER_TOO_SMALL 2
22#define REGO_ERROR_INVALID_LOG_LEVEL 3
23#define REGO_ERROR_MANUAL_TZDATA_NOT_SUPPORTED 4
24
25// term node types
26#define REGO_NODE_BINDING 1000
27#define REGO_NODE_VAR 1001
28#define REGO_NODE_TERM 1002
29#define REGO_NODE_SCALAR 1003
30#define REGO_NODE_ARRAY 1004
31#define REGO_NODE_SET 1005
32#define REGO_NODE_OBJECT 1006
33#define REGO_NODE_OBJECT_ITEM 1007
34#define REGO_NODE_INT 1008
35#define REGO_NODE_FLOAT 1009
36#define REGO_NODE_STRING 1010
37#define REGO_NODE_TRUE 1011
38#define REGO_NODE_FALSE 1012
39#define REGO_NODE_NULL 1013
40#define REGO_NODE_UNDEFINED 1014
41#define REGO_NODE_TERMS 1015
42#define REGO_NODE_BINDINGS 1016
43#define REGO_NODE_RESULTS 1017
44#define REGO_NODE_RESULT 1018
45
46#define REGO_NODE_ERROR 1800
47#define REGO_NODE_ERROR_MESSAGE 1801
48#define REGO_NODE_ERROR_AST 1802
49#define REGO_NODE_ERROR_CODE 1803
50#define REGO_NODE_ERROR_SEQ 1804
51
52#define REGO_NODE_INTERNAL 1999
53
54// log levels
55#define REGO_LOG_LEVEL_NONE 0
56#define REGO_LOG_LEVEL_ERROR 1
57#define REGO_LOG_LEVEL_OUTPUT 2
58#define REGO_LOG_LEVEL_WARN 3
59#define REGO_LOG_LEVEL_INFO 4
60#define REGO_LOG_LEVEL_DEBUG 5
61#define REGO_LOG_LEVEL_TRACE 6
62
63#ifdef __cplusplus
64extern "C"
65{
66#endif
68 // ----- Interpreter functions ------ //
70
83 regoEnum regoSetLogLevel(regoEnum level);
84
95 regoEnum regoSetLogLevelFromString(const char* level);
96
110 regoEnum regoSetTZDataPath(const char* path);
111
119 regoInterpreter* regoNew(void);
120
128 regoInterpreter* regoNewV1(void);
129
137 void regoFree(regoInterpreter* rego);
138
150 regoEnum regoAddModuleFile(regoInterpreter* rego, const char* path);
151
164 regoInterpreter* rego, const char* name, const char* contents);
165
179 regoEnum regoAddDataJSONFile(regoInterpreter* rego, const char* path);
180
194 regoEnum regoAddDataJSON(regoInterpreter* rego, const char* contents);
195
209 regoEnum regoSetInputJSONFile(regoInterpreter* rego, const char* path);
210
227 regoEnum regoSetInputJSON(regoInterpreter* rego, const char* contents);
228
242 regoEnum regoSetInputTerm(regoInterpreter* rego, const char* contents);
243
256 void regoSetDebugEnabled(regoInterpreter* rego, regoBoolean enabled);
257
264 regoBoolean regoGetDebugEnabled(regoInterpreter* rego);
265
280 regoEnum regoSetDebugPath(regoInterpreter* rego, const char* path);
281
293 regoInterpreter* rego, regoBoolean enabled);
294
301 regoBoolean regoGetWellFormedChecksEnabled(regoInterpreter* rego);
302
314 regoOutput* regoQuery(regoInterpreter* rego, const char* query_expr);
315
326 void regoSetStrictBuiltInErrors(regoInterpreter* rego, regoBoolean enabled);
327
334 regoBoolean regoGetStrictBuiltInErrors(regoInterpreter* rego);
335
345 const char* regoGetError(regoInterpreter* rego);
346
348 // -------- Output functions -------- //
350
361 regoBoolean regoOutputOk(regoOutput* output);
362
369 regoSize regoOutputSize(regoOutput* output);
370
379 regoNode* regoOutputExpressionsAtIndex(regoOutput* output, regoSize index);
380
388 regoNode* regoOutputExpressions(regoOutput* output);
389
399 regoNode* regoOutputNode(regoOutput* output);
400
412 regoOutput* output, regoSize index, const char* name);
413
423 regoNode* regoOutputBinding(regoOutput* output, const char* name);
424
431 const char* regoOutputString(regoOutput* output);
432
440 void regoFreeOutput(regoOutput* output);
441
443 // --------- Node functions --------- //
445
446 // clang-format off
447
480 regoEnum regoNodeType(regoNode* node);
481
482 // clang-format on
483
493 const char* regoNodeTypeName(regoNode* node);
494
505 regoSize regoNodeValueSize(regoNode* node);
506
518 regoEnum regoNodeValue(regoNode* node, char* buffer, regoSize size);
519
526 regoSize regoNodeSize(regoNode* node);
527
535 regoNode* regoNodeGet(regoNode* node, regoSize index);
536
547 regoSize regoNodeJSONSize(regoNode* node);
548
560 regoEnum regoNodeJSON(regoNode* node, char* buffer, regoSize size);
561
562#ifdef __cplusplus
563}
564#endif
565
566#endif
Definition rego.hh:17
void regoSetStrictBuiltInErrors(regoInterpreter *rego, regoBoolean enabled)
regoNode * regoOutputExpressionsAtIndex(regoOutput *output, regoSize index)
const char * regoOutputString(regoOutput *output)
regoBoolean regoGetDebugEnabled(regoInterpreter *rego)
void regoFreeOutput(regoOutput *output)
void regoFree(regoInterpreter *rego)
regoEnum regoNodeValue(regoNode *node, char *buffer, regoSize size)
void regoSetDebugEnabled(regoInterpreter *rego, regoBoolean enabled)
regoEnum regoSetLogLevelFromString(const char *level)
regoOutput * regoQuery(regoInterpreter *rego, const char *query_expr)
regoEnum regoAddModuleFile(regoInterpreter *rego, const char *path)
regoSize regoNodeValueSize(regoNode *node)
regoNode * regoOutputBinding(regoOutput *output, const char *name)
regoSize regoNodeJSONSize(regoNode *node)
regoNode * regoOutputBindingAtIndex(regoOutput *output, regoSize index, const char *name)
regoEnum regoSetInputTerm(regoInterpreter *rego, const char *contents)
const char * regoNodeTypeName(regoNode *node)
regoEnum regoNodeJSON(regoNode *node, char *buffer, regoSize size)
regoBoolean regoOutputOk(regoOutput *output)
regoEnum regoSetInputJSON(regoInterpreter *rego, const char *contents)
regoEnum regoSetInputJSONFile(regoInterpreter *rego, const char *path)
regoInterpreter * regoNew(void)
const char * regoGetError(regoInterpreter *rego)
regoBoolean regoGetStrictBuiltInErrors(regoInterpreter *rego)
void regoSetWellFormedChecksEnabled(regoInterpreter *rego, regoBoolean enabled)
regoEnum regoSetDebugPath(regoInterpreter *rego, const char *path)
regoEnum regoNodeType(regoNode *node)
regoNode * regoOutputExpressions(regoOutput *output)
regoEnum regoSetTZDataPath(const char *path)
regoEnum regoAddDataJSONFile(regoInterpreter *rego, const char *path)
regoNode * regoOutputNode(regoOutput *output)
regoEnum regoAddModule(regoInterpreter *rego, const char *name, const char *contents)
regoBoolean regoGetWellFormedChecksEnabled(regoInterpreter *rego)
regoInterpreter * regoNewV1(void)
regoEnum regoAddDataJSON(regoInterpreter *rego, const char *contents)
regoEnum regoSetLogLevel(regoEnum level)
regoSize regoOutputSize(regoOutput *output)
regoSize regoNodeSize(regoNode *node)
regoNode * regoNodeGet(regoNode *node, regoSize index)