modeling language for xml

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,999
Messages
2,570,244
Members
46,838
Latest member
KandiceChi

Latest Threads

Top