MantisBase v0.3.4
Loading...
Searching...
No Matches
expr_evaluator.h
Go to the documentation of this file.
1
6#ifndef EXPR_EVALUATOR_H
7#define EXPR_EVALUATOR_H
8
9#include <string>
10#include <nlohmann/json.hpp>
11#include <dukglue/dukglue.h>
12
13#include "../utils/utils.h"
14
15namespace mb
16{
17 using TokenMap = std::unordered_map<std::string, nlohmann::json>;
18
19 class DukCtx {
20 public:
21 DukCtx();
22
23 ~DukCtx();
24
25 [[nodiscard]] duk_context* get() const;
26
27 private:
28 duk_context* m_ctx;
29 };
30
34 struct Expr
35 {
43 static bool eval(const std::string& expr, const std::unordered_map<std::string, nlohmann::json>& vars = {});
44 };
45} // mb
46
47#endif //EXPR_EVALUATOR_H
Definition expr_evaluator.h:19
duk_context * get() const
Definition expr_evaluator.cpp:17
DukCtx()
Definition expr_evaluator.cpp:7
~DukCtx()
Definition expr_evaluator.cpp:12
router.h
Definition auth.h:15
std::unordered_map< std::string, nlohmann::json > TokenMap
Definition expr_evaluator.h:17
Struct instance for handling evaluation of database access rules.
Definition expr_evaluator.h:35
static bool eval(const std::string &expr, const std::unordered_map< std::string, nlohmann::json > &vars={})
Evaluates a given expression in a context of the given TokenMap variables.
Definition expr_evaluator.cpp:19