libxode - XML, Memory, Strings... done right. In C even. Well, perhaps right is
too strong a word. Conveniently is probably the best word. Or perhaps usefully.
Whatever you call it, libxode is a C library that provides three main features:
|
XML Parsing
|
XStreams for parsing XML in a stream
Xodes a highly flexible DOM
On Demand child parsing (well, soon)
|
xode c, x = xode_from_file("magic.xml");
c = xode_get_firstchild(x);
while( c )
{
printf("%s\n" , xode_get_name(c));
c = xode_get_nextsibling(c);
}
|
|
Memory Pools
|
Organize related memory into one structure
Save mallocs and frees with heap pre-allocation
|
xode inx = xode_from_file("example.xml");
xode_pool p = xode_get_pool(x);
xode outx = xode_new_frompool(p);
xode_insert_tag(outx , "ROOTTAG" );
printf("%s\n", xode_to_str(outx));
free(p);
|
|
Spools
|
Simple handling of strings
Simple concatencation
Utilizes Pools for simple memory handling
|
xode_pool p = xode_new_pool();
xode_spool str = xode_spool_new( p );
char *myline;
xode_spooler( str, "This" , " will", " be all one", str );
xode_spooler( str, " BIG string.", str );
myline = xode_spool_tostr(str);
xode_pool_free(p); // Everything is cleaned up
|
|