Skip to content

Swarthe/ode

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 

Repository files navigation

Ordered Data Exchange

A hierarchical data management and serialisation library written in ANSI C, with a focus on simplicity, security and efficiency.

Installation

git clone https://github.com/Swarthe/ode

Include the header files src/*.h where they are needed, and compile the source files src/*.c together with your project.

You may optionally modify src/ode_alloc.h to use your preferred allocator.

Usage

Error checking is omitted for the sake of brevity.

Root object initialisation

ode_t *data;

We can create an empty object

data = ode_create("root", -1);

Or read its contents from serialised data.

data = ode_deserial(buffer, buffer_size);

Storage & manipulation of data

Adding subordinate objects:

ode_add(data, "test1", -1);
ode_add(ode_get1(data, "test1", -1), "test2", 5);

Storing and modifying data:

ode_t *sub;

sub = ode_add(data, "emptyobj", -1);
ode_mod(sub, ODE_VALUE, "testval", -1);
ode_mod(sub, ODE_NAME, "objwithval", -1);

Removing data:

sub = ode_get(data, "test1", "test2", (char *) NULL);
ode_zero(sub, &bzero);      /* Optional */
ode_del(sub);

Data usage

We can obtain data directly

puts(ode_getstr(data, ODE_NAME));
fwrite(ode_getstr(data, ODE_NAME), 1, ode_getlen(data, ODE_NAME), stdout);

Or by iterating through subordinates.

ode_t *o;

for (o = ode_iter(data, NULL); o; o = ode_iter(data, o))
    puts(ode_getstr(o, ODE_NAME));

Finalisation

Serialising data for future use:

char *buffer;
size_t buffer_size;

buffer = ode_serial(data, &buffer_size);

Freeing all data:

ode_del(data);

License

This library is free software and subject to the MIT license. See LICENSE.txt for more information.

About

Data management and serialisation library

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages