Boost logo

Boost :

From: Yitzhak Sapir (yitzhaks_at_[hidden])
Date: 2002-12-18 04:05:28

I think it is possible to implement a reflection framework using the
preprocessor library. In much the same way that one of the links
previously mentioned
( ), a
description system could be made. The difference is that unlike the
example definition of the above link:

class A {
    int i;
    char* pc;
    double d;
    long larr[10];
    A** ppa;
    A* pa;
                          RTTI_PTR(pc, RTTI_FLD_PUBLIC),
                          RTTI_FIELD(d, RTTI_FLD_PUBLIC),
                          RTTI_ARRAY(larr, RTTI_FLD_PROTECTED),
                          RTTI_PTR_TO_PTR(ppa, RTTI_FLD_PROTECTED),
                          RTTI_PTR(pa, RTTI_FLD_PROTECTED)));

We would have something more like the following:

           (RTTI_(int, i, RTTI_FLD_PUBLIC), \
            RTTI_(char*, pc, RTTI_FLD_PUBLIC), \
            RTTI_(double, d, RTTI_FLD_PUBLIC), \
            RTTI_ARRAY(long, 10, larr, RTTI_FLD_PROTECTED), \
            RTTI_(A**, ppa, RTTI_FLD_PROTECTED), \
            RTTI_(A*, pa, RTTI_FLD_PROTECTED)));

class A
    int x; // some member variable which is not described

This has the advantage that you don't to respecify everything twice, and
yet, most of the serialization functions could be generated automatically

Boost list run by bdawes at, gregod at, cpdaniel at, john at