Boost logo

Boost Users :

From: Davi de Castro Reis (davicastro_at_[hidden])
Date: 2005-03-24 11:32:41


Uh, thanks for the help, Remi and Stefan.

I could actually implement what I wanted using your tips. So, in my
library, I can serialize any class given a "description" of it.
Something like this:

class A
{
        int m1;
        char *m2;
}

typedef make_traits<A,
        int,
        CString
>

//A is now serializable. The CString class
//is a modifier to treat the second field
//as a c string
A x
A y
stream << pack(x)
stream >> unpack(y)

//Now x is equal to y

class B
{
        unsigned int m1;
        A *m2;
}
typedef make_traits<B,
        unsigned int,
        NewPtr<A>
>

//B is now serializable. The NewPtr modifier
//says that the m2 should be treated as a C++ class
//pointer

This is rather cool and impressive. Using your tips I could go further,
so it was not needed anymore to specify the members in the correct
order, nor all of them.

But in the end I found it quite ugly. So I decided to go through a
another way, easier for the user and with a cleaner syntax, but not so
"hardcore". But your ideas are great, and probably have a good use. So,
thanks for the help.

[]s
Davi de Castro Reis


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net