oml 0.0.7
dotnet add package oml --version 0.0.7
NuGet\Install-Package oml -Version 0.0.7
<PackageReference Include="oml" Version="0.0.7" />
paket add oml --version 0.0.7
#r "nuget: oml, 0.0.7"
// Install oml as a Cake Addin #addin nuget:?package=oml&version=0.0.7 // Install oml as a Cake Tool #tool nuget:?package=oml&version=0.0.7
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 {value + 12}"
"#;
let mut eroot = OmlExpr::from_str(oml_str).unwrap();
eroot["hello"]["value"].set_int(30);
let root = eroot.evalute().unwrap();
println!("{}", root["hello"]["name"].as_str()); // hello 42
}
C++
Download and compile static libraries (or dynamic libraries)
git clone git@github.com:fawdlstty/oml.git
cd oml
cargo build --release --lib # debug: cargo build --lib
The static library (or dynamic library) is generated in the target/release
directory. Copy it to the C++ project and reference it
#include <iostream>
#include <string>
#include "oml/oml.hpp"
#ifdef _MSC_VER
#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")
#endif
int main() {
auto oexpr = oml::OmlExpr::from_str(R"(
[hello]
value = 12
name = $"hello {value + 12}"
)");
if (oeroot.index() == 1) {
std::cout << std::get<std::string>(oeroot) << std::endl;
return 0;
}
auto eroot = std::get<oml::OmlExpr>(oeroot);
eroot["hello"]["value"].set_int(30);
auto oroot = eroot.evalute();
if (oroot.index() == 1) {
std::cout << std::get<std::string>(oroot) << std::endl;
return 0;
}
auto root = std::get<oml::OmlValue>(oroot);
std::cout << root["hello"]["name"].as_str() << std::endl; // hello 42
return 0;
}
C#
Run command:
dotnet add package oml
Example:
using System;
namespace test {
public class Program {
public static void Main () {
string src = """
[hello]
value = 12
name = $"hello {value + 12}"
""";
var oeroot = oml.OmlExpr.from_str (src);
if (oeroot.IsOk(out oml.OmlExpr eroot)) {
eroot ["hello"] ["value"].set_int (30);
var oroot = eroot.evalute ();
if (oroot.IsOk (out oml.OmlValue root)) {
Console.WriteLine (root ["hello"] ["name"].as_str()); // hello 42
} else if (oroot.IsErr (out string err)) {
Console.WriteLine (err);
}
} else if (oeroot.IsErr (out string err)) {
Console.WriteLine (err);
}
Console.ReadKey ();
}
}
}
Other features
The value is available when the conditions are met:
[hello]
value = 12
@if value == 12
name = $"hello {value}"
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net8.0
- RustyOptions (>= 0.10.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.