Skip to content

CospecGames/wsf

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WereShift Format

A D binary serialization format made for the game "Wereshift". It can be used elsewhere as a small binary format.

Parsing file

Tag data = Tag.parseFile("file.wsf");
writeln(data["foo"]);
writeln(data.seq[0]);

Building file

Tag myData = Tag.emptyCompound();
myData["foo"] = "bar";
myData.seq ~= new Tag("baz");

// Note: this will overwrite the contents of the file
myData.buildFile("file.wsf");

Serialize struct

struct MyData {
    int x;
    string y;
}

// Works for: Structs, classes and pointers to structs
Tag tag = serializeWSF(MyData(42, "Meaning of Life"));
writeln(tag.toString());

Deserialize

struct MyData {
    int x;
    string y;
}

// Works for: Structs, classes and pointers to structs
MyData data = deserializeWSF!MyData(Tag.parseFile("importantData.wsf"));

ignore & optional

The ignore UDA will cause the serializer and deserializer to ignore a field.

The optional UDA will cause the deserializer to skip a field if no data was found for it.

Notes

TODO

  • Memory based streams
  • C interface(?)

About

A D binary serialization format

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages