#deserialize #parser #gamedev #source-file #file-tree

nightly clauser

Library for parsing and deserializing Clausewitz files

1 unstable release

0.1.0 Jun 25, 2024

#2089 in Parser implementations

MIT license

81KB
2K SLoC

clauser

crates.io badge docs.rs badge

clauser is a library for working with configuration, script, and data files from the Clausewitz engine used by Paradox Interactive for their grand strategy games.

It currently implements a Tokenizer, a low-level Reader, a serde-based Deserializer, and an copying Value deserializer for situations where serde won't work. For more information, read the documentation.

Examples

Using serde:

use serde::Deserialize;

#[derive(Deserialize)]
struct TestObject {
  a: i32,
  b: String,
  c: Date
}

let obj = clauser::de::from_str::<TestObject>(
  "a = 1 b = test c = 1940.1.1"
);
assert!(obj.a == 1);
assert!(obj.b == "test");
assert!(obj.c == Date::new(1940, 1, 1, 0));

lib.rs:

clauser

clauser is a library for working with configuration, script, and data files from the Clausewitz engine used by Paradox Interactive for their grand strategy games.

It contains a number of components:

  • Deserializer is a [serde] deserializer that can deserialize Clausewitz files into Rust data structures.
  • Value allows deserializing a Clausewitz file into a tree of values, for situations where the schema of the data isn't known beforehand.
  • Tokenizer turns a Clausewitz file into a series of tokens.
  • Reader is a wrapper around Tokenizer that enables low-level parsing operations on a Clausewitz source file.

Dependencies

~1.3–2.2MB
~34K SLoC