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.
--
/* jh*****@world.std.com (192.74.137.5) */ /* Joseph H. Allen */
int a[1817];main(z,p,q,r){for(p=80;q+p-80;p-=2*a[p])for(z=9;z--;)q=3&(r=time(0)
+r*57)/7,q=q?q-1?q-2?1-p%79?-1:0:p%79-77?1:0:p<1659?79:0:p>158?-79:0,q?!a[p+q*2
]?a[p+=a[p+=q]=q]=q:0:0;for(;q++-1817;)printf(q%79?"%c":"%c\n"," #"[!a[q-1]]);}