c11n: Serialization in C

October 31, 2008 on 1:28 am | In General |

A couple years ago i mused on the idea of writing something similar to libs11n, but for C. At first i dismissed it outright, and after writing a small bit of code to see what the data structures might look like, i dismissed it again. C simply doesn’t have the expressiveness to pull it off as elegantly as C++.

Until a year or so ago, i hadn’t used C since about 13 years. Inspired by the Fossil project, however, i’ve taken a new interest in it. A few days ago, while working on pegc, i stumbled across an idea which looked like it might make a C variant of s11n possible. So i sat down and started hashing some code out, again to see what the data structures might need to look like. Low and behold, i found an approach which isn’t nearly as elegant as C++ allows for (namely due to automatic selection of types and functions via template resolution), but it would indeed seem to be possible.

As one might have suspected, i named the code “c11n”, short for “Cerialization” or “Serialization in C”.

[... one day later ...]

At about 16:00 CET/GMT+1 on October 30th, 2008, i successfully serialized and deserialized an integer value using c11n, so the general approach has proven itself to work. A few hours later it had support for all the standard PODs and a client-side custom struct type had also been demonstrated.

There is much work to be done, in particular in how to simplify integration of client-side structs. After that there’s even more work to be done to add at least one file format (like s11n, c11n’s core is ignorant of all data formats).

Since the code is basically alpha right now i haven’t bothered to put it online. Once i’ve got support for more “Cerializable” types than the basic PODs i’ll get something put into SVN so others can play with it. Barring an unforeseen catastrophe, c11n will eventually be released as part of the s11n project. (While s11n and c11n are in no way compatible with each other, c11n falls comfortably within the s11n project’s goals and ideals.)

Anyway… back to hacking…

Update: 2 Nov 2008: c11n now has a source repository:

http://fossil.wanderinghorse.net/repos/c11n/

As of about an hour ago it has support for two file formats (one adopted from libs11n and one saves and loads objects as SQL code). However, the public API for i/o isn’t yet as transparent/uniform as i’d like it. All in all, though, it’s coming along nicely.

2 Comments »

RSS feed for comments on this post. TrackBack URI

  1. Today we made big leaps in c11n:

    - It now has i/ostream handlers which can wrap both (FILE*) handles and in-memory buffers, so it’s possible to de/serialize from/to FILEs and memory.

    - i just got the first c11n file format saving node trees over the new c11n_stream API. It can’t yet load - that’ll be Saturday or Sunday. The format is compatible with s11n’s “compact” format, which means one can use s11nconvert to convert the c11n data to something s11n can use.

    Comment by admin — November 1, 2008 #

Leave a comment

XHTML: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>


HINT: the code is O Q R (without spaces!)

Powered by WordPress with Pool theme design by Borja Fernandez.
Entries and comments feeds. Valid XHTML and CSS. ^Top^