XVF
XVF (eXtensible Visitation Framework) is a C++ template-based framework for developing visitors and generic visitation methods. In XVF, a generic, introspection visitor is messaged with type, naming and layout information about the visited objects. The visitor uses the introspective messages in any useful manner and controls the recursion during visitation. The visitor's introspection methods are virtual, such that any visitor can be used in any visitation traversal. The set of introspection methods in the visitor closely follows a decomposition of the data types in C++: structures (classes), pointers, arrays and primitive datums (char, int, double).

Visitor classes
Visitors are sub-classes of XVFVisitor. XVFVisitor has methods for keeping track of what object is being visited, what members are being visited. Each intrinsic type (e.g. char, int, double) has a visitation method specialized for it in the visitor class.
Visitors are messaged with information about the visitee during visitation traversal.

Visitee type objects
The XVFType class provides type object information about types (e.g. type name and size), allocation methods, and assignment.
XVFType::type("Foo") returns the type object for the Foo class.
XVFType objects are constructed dynamically by class templates. There are five XVFType templates: intrinsic types (i.e. char, int, unsigned long), abstract classes crea(i.e. non-instantiable classes), concrete classes (i.e. instantiable classes), pointers, and arrays.
The XVFTypeIntrinsic<T> template creates XVFType classes for intrinsic types. The templates XVFTypeClass<T> and XVFTypeAbstract<T> create type objects for instantiable and abstract classes, respectively. Type objects for intrinsic types are created "by hand" in XVF. Pointer and array type objects are constructed by XVFTypePtr<T> and XVFTypeArray<T>, respectively. XVFType templates are never instatiated by the user of XVF, but are created automatically by the instatiation of xvf_type(T*) template functions based on pointers to type T.
Each type object implements a virtual visit(void *data, XVFVisitor *V) method that is specialized by the type object template to call xvf_visit((T *) data, V);

Visitor/Visitee Interface
Visitee classes are not sub-classes of a special "Visitee" class. They are "glued" to the XVF library by static type polymorphic functions:
XVFType *xvf_type(T *x)
returns the XVFType object for type T.
T *xvf_alloc(T *dummy)
allocates an object of type T.
void xvf_dealloc(T *x)
deallocates an object of type T.
void xvf_visit(T *x, XVFVisitor *V, int opts)
recursively visit an object of type T with visitor V.
Note: XVF does not dispatch using const &T because then void could not be handled in a unified manner and because datums are visited by address.

Visitation Methods
Any type T that implements a xvf_type(T *x) and xvf_visit(T *x, XVFVisitor *V, int opts) (the opts argument is explained later) functions can be visited by any XVFVisitor object.
XVF supplies macros for constructing a class' visitation method, visitation and type object accessor functions.
For example:

// Declare xvf_type(Foo *)
XVF_CLASS_BEGIN(Foo);

class Foo {
  double x, y;
  int i3[3];
public:
  Foo() { ... }
  Foo(double x, double y) { ... }

  // xvf_type() support
  XVF_CLASS_METHODS(XVF_);

  // xvf_visit() support
  XVF_CLASS_VISIT_BEGIN_INLINE(Foo)
  {
     XVF_MEMB(x);
     XVF_MEMB(y);
     XVF_MEMB(i3);
  }
  XVF_CLASS_VISIT_END()
};

// Define xvf_visit(Foo *)
XVF_CLASS_END(Foo);

// Define xvf_type(Foo *)
XVF_CLASS_INSTANCE(Foo);

Visitor Messages
The visitor is messaged with information about the visited object during traversal. The visitor can dynamically control recursion for any visitation member. The XVF_MEMB() macro above expands into messages to the visitor.
For example: any visitor V visiting Foo F will be have the following methods called on it:

xvf_visit(&F, V);

is equivalent to:

V->this_begin(xvf_type(&F), &F, opts);
 if ( V->memb(xvf_type(&F.x), "x", &F.x, opts) ) {
   V->memb_begin(xvf_type(&F.x), "x", &F.x, opts);
    xvf_visit(&F.x, V, opts);
   V->memb_end(xvf_type(&F.x), "x", &F.x, opts);
 }
 if ( V->memb(xvf_type(&F.y), "y", &F.y, opts) ) {
   V->memb_begin(xvf_type(&F.y), "y", &F.y, opts);
    xvf_visit(&F.y, V, opts);
   V->memb_end(xvf_type(&F.y), "y" &F.y, opts);
 }
 if ( V->memb(xvf_type(&F.i3), "i3", &F.y, opts) ) {
   V->memb_begin(xvf_type(&F.i3), "i3", &F.y, opts);
     V->arry_begin(xvf_type(&F.i3),
                   xvf_type(&F.i3[0]),
                   &F.i3, 3, opts);
       V->elem_begin(0, opts);
         xvf_visit(&F.i3[0], V, opts);
       V->elem_end(0, opts);
       V->elem_begin(1, opts);
         xvf_visit(&F.i3[1], V, opts);
       V->elem_end(1, opts);
       V->elem_begin(2, opts);
         xvf_visit(&F.i3[2], V, opts);
       V->elem_end(3, opts);
     V->arry_end(xvf_type(&F.i3),
                 xvf_type(&F.i3[0]),
                 &F.i3, 3, opts);
   V->memb_end(xvf_type(&F.i3), "i3" &F.y, opts);
 }
V->this_end();