7 releases
0.0.6 | Sep 4, 2024 |
---|---|
0.0.5 | Aug 26, 2024 |
0.0.0 | Jul 16, 2024 |
#213 in Configuration
60KB
1.5K
SLoC
oml
English | 简体中文
Open Markup Language! A dynamic configuration scripting language that can embed script code in the configuration file to achieve dynamic configuration update.
Manual
rust
Install: Run cargo add oml
in the project directory
fn main() {
let oml_str = r#"
[hello]
value = 12
name = $"hello world {value + 12}"
"#;
let mut root = OmlExpr::from_str(oml_str).unwrap();
root["hello"]["value"].set_int(30);
let root = root.evalute().unwrap();
println!("{}", root["hello"]["name"].as_str()); // hello world 42
}
C++
#include <iostream>
#include <string>
#include "oml/oml.hpp"
#pragma comment(lib, "ws2_32.lib")
#pragma comment(lib, "ntdll.lib")
#pragma comment(lib, "bcrypt.lib")
#pragma comment(lib, "Userenv.lib")
#pragma comment(lib, "oml.lib")
int main() {
auto oexpr = oml::OmlExpr::from_str(R"(
[hello]
value = 12
name = $"hello world {value + 12}"
)");
if (oexpr.index() == 1) {
auto err = std::get<std::string>(oexpr);
std::cout << err << std::endl;
return 0;
}
auto expr = std::get<oml::OmlExpr>(oexpr);
expr["hello"]["value"].set_int(30);
auto ovalue = expr.evalute();
if (ovalue.index() == 1) {
auto err = std::get<std::string>(ovalue);
std::cout << err << std::endl;
return 0;
}
auto value = std::get<oml::OmlValue>(ovalue);
auto str = value["hello"]["name"].as_str();
std::cout << str << std::endl;
return 0;
}
Dependencies
~2–4MB
~73K SLoC