serialization and object tracking question...

I am having trouble wrapping my head around object tracking for serialization. I see how to change the default behavior: BOOST_CLASS_TRACKING(my_class, boost::serialization::track_never) ...but based on the error below how do I determine what kind of object tracking is needed? oserializer.hpp:566: error: invalid application of 'sizeof' to incomplete type 'boost::STATIC_ASSERTION_FAILURE<false>' inline void save(Archive & ar, T &t){ // if your program traps here, it indicates taht your doing one of the following: // a) serializing an object of a type marked "track_never" through a pointer. // b) saving an non-const object of a type not markd "track_never) // Either of these conditions may be an indicator of an error usage of the // serialization library and should be double checked. See documentation on // object tracking. BOOST_STATIC_ASSERT(check_tracking<T>::value); The following is the class to be serialized: class client_i { private: friend class boost::serialization::access; template<class Archive> void serialize(Archive & ar, const unsigned int version) { ar & m_client; } clients m_client; public: client_i() {}; client_i(clients c) : m_client(c) {}; ~client_i() {}; }; clients is a mysql++ specialized sql structure that is created via one of the mysql++ macros, i.e. sql_create_N(). Any help understanding this would be greatly appreciated. Thanks, Graham

I think the issue is that the structure clients used in class client_i as m_client doesn't have any information on how do serialize itself. I don't have control over the clients structure, as it is created for me by the mysql++ macro. It is a simple structure with public access to its internals which are primitives. Just use the non-intrusive serialization method? Or is there a more convenient method? Thanks, Graham On 10/7/07, Graham Reitz <graham.cpp@gmail.com> wrote:
I am having trouble wrapping my head around object tracking for serialization.
I see how to change the default behavior: BOOST_CLASS_TRACKING(my_class, boost::serialization::track_never)
...but based on the error below how do I determine what kind of object tracking is needed?
oserializer.hpp:566: error: invalid application of 'sizeof' to incomplete type 'boost::STATIC_ASSERTION_FAILURE<false>'
inline void save(Archive & ar, T &t){ // if your program traps here, it indicates taht your doing one of the following: // a) serializing an object of a type marked "track_never" through a pointer. // b) saving an non-const object of a type not markd "track_never) // Either of these conditions may be an indicator of an error usage of the // serialization library and should be double checked. See documentation on // object tracking. BOOST_STATIC_ASSERT(check_tracking<T>::value);
The following is the class to be serialized:
class client_i { private: friend class boost::serialization::access;
template<class Archive> void serialize(Archive & ar, const unsigned int version) { ar & m_client; }
clients m_client; public:
client_i() {}; client_i(clients c) : m_client(c) {}; ~client_i() {}; };
clients is a mysql++ specialized sql structure that is created via one of the mysql++ macros, i.e. sql_create_N().
Any help understanding this would be greatly appreciated.
Thanks,
Graham

Ok I am confused (again) I changed it to the non-intrusive mode: namespace boost { namespace serialization { template<class Archive> void serialize(Archive & ar, clients & c, const unsigned int version) { ar & c.client_first_name; // all std::string ar & c.client_middle_initial; ar & c.client_last_name; ar & c.client_street_address; } } // namespace serialization } // namespace boost With: BOOST_CLASS_TRACKING(clients, boost::serialization::track_never) I receive this error: boost/serialization/access.hpp:109: error: 'struct clients' has no member named 'serialize' Without: //BOOST_CLASS_TRACKING(clients, boost::serialization::track_never) I receive this error: boost/archive/detail/oserializer.hpp:566: error: invalid application of 'sizeof' to incomplete type 'boost::STATIC_ASSERTION_FAILURE<false>' Which is what I started with. What am I missing? Thanks for any help, Graham On 10/7/07, Graham Reitz <graham.cpp@gmail.com> wrote:
I think the issue is that the structure clients used in class client_i as m_client doesn't have any information on how do serialize itself.
I don't have control over the clients structure, as it is created for me by the mysql++ macro. It is a simple structure with public access to its internals which are primitives.
Just use the non-intrusive serialization method? Or is there a more convenient method?
Thanks, Graham
On 10/7/07, Graham Reitz <graham.cpp@gmail.com> wrote:
I am having trouble wrapping my head around object tracking for serialization.
I see how to change the default behavior: BOOST_CLASS_TRACKING(my_class, boost::serialization::track_never)
...but based on the error below how do I determine what kind of object tracking is needed?
oserializer.hpp:566: error: invalid application of 'sizeof' to incomplete type 'boost::STATIC_ASSERTION_FAILURE<false>'
inline void save(Archive & ar, T &t){ // if your program traps here, it indicates taht your doing one of the following: // a) serializing an object of a type marked "track_never" through a pointer. // b) saving an non-const object of a type not markd "track_never) // Either of these conditions may be an indicator of an error usage of the // serialization library and should be double checked. See documentation on // object tracking. BOOST_STATIC_ASSERT(check_tracking<T>::value);
The following is the class to be serialized:
class client_i { private: friend class boost::serialization::access;
template<class Archive> void serialize(Archive & ar, const unsigned int version) { ar & m_client; }
clients m_client; public:
client_i() {}; client_i(clients c) : m_client(c) {}; ~client_i() {}; };
clients is a mysql++ specialized sql structure that is created via one of the mysql++ macros, i.e. sql_create_N().
Any help understanding this would be greatly appreciated.
Thanks,
Graham

I think the best option for you will be to: a) use default tracking - that is don't use BOOST_CLASS_TRACKING b) read the "rationale" section of the documentation which addresses the trap at line 566. Robert Ramey

ok thanks...it seems I simply need to make the object to be serialized a const object, correct? graham On 10/8/07, Robert Ramey <ramey@rrsd.com> wrote:
I think the best option for you will be to:
a) use default tracking - that is don't use BOOST_CLASS_TRACKING b) read the "rationale" section of the documentation which addresses the trap at line 566.
Robert Ramey
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
participants (2)
-
Graham Reitz
-
Robert Ramey