-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
36 lines (27 loc) · 1.32 KB
/
main.cpp
File metadata and controls
36 lines (27 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include <iostream>
#include "SreRuleEngine.h"
int main() {
SreRuleEngine engine;
// 设置上下文变量
SreContext ctx;
ctx["a"] = "你好";
ctx["b"] = "hello, world, xxxx";
// 示例表达式:使用内置函数 contains 和 containsAny
std::string expr = "(contains(#{a}, '好') or contains(#{a}, 'yyy') ) and containsAny(#{b}, 'xxx', '22')";
bool result = engine.evaluate(expr, ctx);
std::cout << "Expression result: " << std::boolalpha << result << std::endl;
expr = "(contains(#{a}, 'xxx')) and containsAny(#{b}, 'xxx', '22')";
result = engine.evaluate(expr, ctx);
std::cout << "Expression result: " << std::boolalpha << result << std::endl;
expr = "(not contains(#{a}, 'xxx')) and containsAny(#{b}, 'xxxx', '22')";
result = engine.evaluate(expr, ctx);
std::cout << "Expression result: " << std::boolalpha << result << std::endl;
expr = "(contains(#{a}, 'contains')) and containsAny(#{b}, 'xxxx', '22')";
result = engine.evaluate(expr, ctx);
std::cout << "Expression result: " << std::boolalpha << result << std::endl;
return 0;
}
// TIP See CLion help at <a
// href="https://www.jetbrains.com/help/clion/">jetbrains.com/help/clion/</a>.
// Also, you can try interactive lessons for CLion by selecting
// 'Help | Learn IDE Features' from the main menu.