J
Joseph H Allen
I've discovered that the C preprocessor is powerful enough to create a cheap
object modeling language for XML (or any structured data format). Check
out http://world.std.com/~jhallen/sdu.html The library is not very
complete, but I wanted to get something out there.
A schema looks like this:
STRUCT(root,
STRING(title)
INTEGER(size)
LIST(items,item)
)
STRUCT(item,
STRING(name)
INTEGER(price)
)
This gets fed into two sets of C preprocessor macros. One drives the XML
parser. The other converts the schema into C structures, so that after
parsing you end up with a tree of these data structures:
struct root
{
/* Standard header (base class) */
struct root *next; /* Next in list */
struct meta *_meta; /* Definition of this for parser/printer */
/* User members */
char *title;
int size;
struct item *items;
};
struct item
{
struct root *next;
struct meta *_meta;
char *name;
int price;
};
It's nice because the modeling language names appear as first class member
names in C.
object modeling language for XML (or any structured data format). Check
out http://world.std.com/~jhallen/sdu.html The library is not very
complete, but I wanted to get something out there.
A schema looks like this:
STRUCT(root,
STRING(title)
INTEGER(size)
LIST(items,item)
)
STRUCT(item,
STRING(name)
INTEGER(price)
)
This gets fed into two sets of C preprocessor macros. One drives the XML
parser. The other converts the schema into C structures, so that after
parsing you end up with a tree of these data structures:
struct root
{
/* Standard header (base class) */
struct root *next; /* Next in list */
struct meta *_meta; /* Definition of this for parser/printer */
/* User members */
char *title;
int size;
struct item *items;
};
struct item
{
struct root *next;
struct meta *_meta;
char *name;
int price;
};
It's nice because the modeling language names appear as first class member
names in C.