Our first offering on GitHub: object-model-serializer

posted in A Keyboard and the Truth for project 96 Mill
Published June 08, 2015
Advertisement
Greetings All,

Part of our summer project plans are to get some older projects onto GitHub with free permissive licenses for both private and commercial works (Currently we are using MIT license).

Our first offering is something I've wanted to see become a common library for a long time.

Serialization of object models in C++

...that is an easier route to save game files for complex game states;

without having to understand the nitty gritty of object model serialization techniques.

https://github.com/edigames/object-model-serializer

First off, there are better known, more complete (at least as of this writing), and far more complex implementations out there.


But a key element for us was to adhere to a few guiding principles:

  • It should be tiny (2 files)
  • It should be non-intrusive, procedural style no base class inheritance requirements
  • It should internally handle references and cycles ("saving pointers")
  • It should be 'soft serialization' ability to add/remove and out-of-order members without 'version blocks'
  • It should come with a complex use case example (see simple_rpg folder)
  • It should use standard streams, for file and in-memory serialization.
  • It should be a lightweight binary format (soft serialization is 'easy' in something like json/xml)
  • It should not use external pre-processor, or code generation techniques (gross.)

Some future goals...

  • It should be endian/architechture agnostic (this should be relatively simple)
  • Higher level interfaces should be optional to reduce syntax and mundane routines

It is still a work in progress, but I have overcome a sticking point which made me question feasibility (without excessive overhead), such that I now feel it is ready for folks to have a look and even begin using.

I ask everyone willing to have a look, comment, rant, contibute etc.

Problems, specifically in usage will be addressed as quickly as possible.
Previous Entry Update 6/3/15
Next Entry Update 6/16
10 likes 2 comments

Comments

Bacterius

I'd suggest using msgpack as a lightweight binary format back-end for your serialization code instead of rolling your own, benefits is it already handles endianness correctly, is basically the same as your approach (type marker followed by data) but also has size optimizations for e.g. small ints, small strings, and so on, supports arrays (both indexed and associative), and has efficient, lightweight and battle-tested implementations (I'm quite fond of https://github.com/camgunz/cmp). I'm sure there is a suitably C++ized implementation available as well..

I would imagine a streaming encoder/decoder is all you need for soft serialization, don't want to impose a strict object model on the user, rather let him define his own... perhaps more advanced features might want to dig into the serialized stream for e.g. lazy initialization, but I don't know how useful that really is.

June 09, 2015 09:48 AM
EDI

@Bacterius

Thanks for your feedback!

I looked at the msgpack implementation, it seemed like a nice way to get endianess; will definetly look more into using it!

One thing I'm not so sure of is the ideal of a 'streaming encoder/decoder' being enough for soft serialization.

A few of the big issues that oms solves are maintaining references and cycles, which is pretty complex to do; most people I encounter have no idea how.

And the ability to add/remove and out-of-order members of objects; which requires a lot of binary jump/offset magic.

Users define their own object models, they just use oms to save them.

June 09, 2015 02:03 PM
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Profile
Author
Advertisement
Advertisement