bzar
A Commando
QMLON on github
I started working on a sprite sheet description file format a couple of days back for a project I'm working on. It got a bit out of hand and now I've created a generic object (or struct or anything) tree initializer system that relies heavily on the new C++ standard, C++11. I'm pretty excited about it since it seems to work so well, but I'm sure there are some problems I haven't thought of or improvements that could be done.
This is why I decided to request for comments here. Keep in mind when suggesting that
A short description on how QMLON (stands for QML object notation, since the description files are written in QML-inspired notation) works:
First you create a QMLON-file, which describes the entities you want to initialize. QMLON is kinda like JSON, but has explicitly defined types for objects. For an example of a QMLON file, see spritesheet.qmlon in the (currently only) QMLON spritesheet test.
Second you create initializers for your types, that can set properties and add children to your target data structures. An initializer is a collection of function objects (in most cases created as lambda functions) that are executed based on the QMLON file. Property initializer functions usually are either simple setters that transform the qmlon::Value to a primitive type and set it to the target object, like setting the property "x" here, or compound initializers, like setting property "position" here, that initialize non-trivial structures and generally resemble child object initializer functions, like adding a sprite to a sprite sheet here.
Third you parse your QMLON description from a file or a string using qmlon::readValue. This creates a tree of qmlon::Values and qmlon::Objects that will be used in the initialization.
Fourth you tell qmlon to make you a tree.
And then you're done. Most work goes to writing the initializers, but in my opinion, it's pretty minimal work given the task.
So... comments?
I started working on a sprite sheet description file format a couple of days back for a project I'm working on. It got a bit out of hand and now I've created a generic object (or struct or anything) tree initializer system that relies heavily on the new C++ standard, C++11. I'm pretty excited about it since it seems to work so well, but I'm sure there are some problems I haven't thought of or improvements that could be done.
This is why I decided to request for comments here. Keep in mind when suggesting that
- for implementation reasons this is and will be for C++11 (not C, not C++03)
- generic use is critical
- qmlon should not impose any requirements for the initialized content other than being able to set initialized properties after construction (if someone has a good idea on how to add generic support for constructor-based initialization I'm all ears)
A short description on how QMLON (stands for QML object notation, since the description files are written in QML-inspired notation) works:
First you create a QMLON-file, which describes the entities you want to initialize. QMLON is kinda like JSON, but has explicitly defined types for objects. For an example of a QMLON file, see spritesheet.qmlon in the (currently only) QMLON spritesheet test.
Second you create initializers for your types, that can set properties and add children to your target data structures. An initializer is a collection of function objects (in most cases created as lambda functions) that are executed based on the QMLON file. Property initializer functions usually are either simple setters that transform the qmlon::Value to a primitive type and set it to the target object, like setting the property "x" here, or compound initializers, like setting property "position" here, that initialize non-trivial structures and generally resemble child object initializer functions, like adding a sprite to a sprite sheet here.
Third you parse your QMLON description from a file or a string using qmlon::readValue. This creates a tree of qmlon::Values and qmlon::Objects that will be used in the initialization.
Fourth you tell qmlon to make you a tree.
And then you're done. Most work goes to writing the initializers, but in my opinion, it's pretty minimal work given the task.
So... comments?
Last edited by a moderator: