ID:1689355
 
What is ZML?

ZML is a markup language and universal object type for DM. It offers both simplicity of an easy-to-read file format and meshes it with a database-like object, which can contain directories.

In ZML, objects are abstracted. You don't need to create any datums for use with this.

ZML can be downloaded here.

Using ZML is very simple. Everything is driven by functions that are defined on the global scope, so they are readily accessible at any time.

Creating a ZML object uses ZML_Create(), which takes an optional string as a file to parse. Be sure to exclude the ".zml" extension as it is automatically included.
var/d = ZML_Create()


Adding to the object is also very simple.
ZML_Set(d, "somevar", 10)


Now, the object contains a variable named "somevar" at its root. But, what if we wanted to have the object contain a subset of variables?
ZML_Set(d, "subset/x1", 1)
ZML_Set(d, "subset/x2", 2)
ZML_Set(d, "subset/x3", 3)


Using the "/" character, we're telling the ZML object to create the variables x1, x2, and x3 in the "subset" directory. This directory is an associative list held at the object's root.

These directories can also hold other directories.
ZML_Set(d, "dir1/dir2/dir3/x4", 4)


If we wanted to see what is being held in the object (in ZML notation), we would call ZML_ToString(). An optional string can be added to start from a certain directory, but we want to see everything from the root so far.
ZML_ToString(d, "")


This yields:
somevar = 10;
subset {
x1 = 1;
x2 = 2;
x3 = 3;
}
dir1 {
dir2 {
dir3 {
x4 = 4;
}
}
}


Now, if we wanted to save this object to a file, we can call ZML_Save() which will output the exact text above to a file of your choosing. This text can later be loaded using ZML_Load() to re-create the object at a later time.
ZML_Save(d, "SomeFile")


A note, however. When saving to a ZML file, all data is converted to text. Be sure to make necessary conversion calls like text2num() to turn numbers into their actual form. That's all for now!
Tangentially related, but what is the licensing on ZML? The hub doesn't mention one and no LICENSE file exists in the source for it.
I've included the GNU GPL 2.0 license into the library. I guess licenses for libraries are a thing and I forgot about that. Shows how often I make them.
very neat.