oml

Crates.iooml
lib.rsoml
version0.0.6
sourcesrc
created_at2024-07-16 14:37:30.994828
updated_at2024-09-04 16:14:29.254709
descriptionOpen Markup Language!
homepagehttps://github.com/fawdlstty/oml
repositoryhttps://github.com/fawdlstty/oml
max_upload_size
id1305122
size83,579
Fawdlstty (fawdlstty)

documentation

README

oml

version status

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;
}
Commit count: 0

cargo fmt