Hello all,
I'm new to the serialization library and new to Boost in general and
as many newbies do, have some problems using them. I'm trying to
serialize an object in my program but the compiler keeps on reporting
errors about the types. Specifically, it trips on the
BOOST_STATIC_ASSERT(check_tracking<T>::value); in oserializer.hpp in
include/archive/detail.
The exact compiler message is:
C:/Boost/include/boost-1_33/boost/archive/detail/oserializer.hpp: In
function `void boost::archive::save(Archive&, T&) [with Archive =
boost::archive::text_oarchive, T = std::vector]':
C:/Boost/include/boost-1_33/boost/archive/basic_text_oarchive.hpp:78:
instantiated from `void
boost::archive::basic_text_oarchive<Archive>::save_override(T&, int)
[with T = std::vector, Archive =
boost::archive::text_oarchive]'
C:/Boost/include/boost-1_33/boost/archive/detail/interface_oarchive.hpp:85:
instantiated from `Archive&
boost::archive::detail::interface_oarchive<Archive>::operator<<(T&)
[with T = std::vector, Archive =
boost::archive::text_oarchive]'
sconbuild.cpp:557: instantiated from here
C:/Boost/include/boost-1_33/boost/archive/detail/oserializer.hpp:566:
error: incomplete type `boost::STATIC_ASSERTION_FAILURE< false>' used
in nested name specifier
C:/Boost/include/boost-1_33/boost/archive/detail/oserializer.hpp:566:
error: size of array has non-integral type `<type error>'
Basically, I'm trying to serialize a std::vector<Builder>. Builder is
a class that employs selective serialization, it only serializes
certain members depending on what type this Builder is. I use a
switch-case statement for that:
switch(type)
{
case 0:
ar & program;
break;
case 1:
ar & object;
break;
case 2:
ar & java;
break;
case 3:
ar & comment;
break;
case 4:
ar & print;
break;
case 5:
ar & variable;
break;
case 6:
ar & library;
break;
case 7:
ar & sharedLibrary;
break;
case 8:
ar & node;
break;
case 9:
ar & import;
break;
case 10:
ar & code;
break;
case 11:
ar & sourceSignatures;
break;
case 12:
ar & targetSignatures;
break;
case 13:
ar & setOption;
break;
case 14:
ar & ignore;
break;
case 15:
ar & depend;
break;
case 16:
ar & environmentVariable;
break;
}
These members I am serializing are shared pointers of class types, and
each of these class types has a serialize member function that
serializes primitive/standard library data types, i.e.:
template<class Archive> void serialize(Archive & ar, const unsigned int version)
{
ar & indent; //std::string
ar & target; // std::string
ar & file; //std::string
}
That said, ALL of my serializations in these subtypes, i.e. ar &
environmentVariable all
serialize booleans and std::string.
Here is a summary of what I am doing:
1. serialize a vector of Builder objects
2. Builder objects have their shared_ptr selectively serialized
3. The types used to instantiate shared_ptr in my program all
serialize booleans and/or std::string
I read up on modifying object tracking to track_never but it still doesn't work.
Is there something I am doing wrong here?
Thank you
Benjamin Lau (Windows XP SP2, MinGW with no STLPort)
P/s If there is insufficient information, or it is not clear, my most
sincere apologies, because the last time I posted whole code on a
mailing list, the mailing list program rejected my post. I'll try and
get a program that can replicate this behaviour, but so far nothing
seems to replicate this behaviour. Thanks you.