I have been experimenting with the boost serialization library. It seems to do what I need. I am using Boost_1_33_1 and Microsoft’s VC8 compiler. When I create a simple little program, I’m getting a lot of compiler warnings even at the /w3 level. Could compiler switches or installation configuration be the problem?
#include "stdafx.h"
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include
#include
typedef std::vectorstd::wstring VCT_WSTR;
struct Foo {
VCT_WSTR vws;
private:
// Take care of serializing the class
friend class boost::serialization::access;
template< class Archive > void serialize( Archive &ar, unsigned int ver );
};
BOOST_CLASS_VERSION ( Foo, 1 )
template< class Archive >
void Foo::serialize( Archive &ar, unsigned int /* ver */ )
{
ar & vws;
}
// text archive
void Test1( const Foo &foo )
{
unsigned int flags = boost::archive::no_header |
boost::archive::no_codecvt |
boost::archive::no_xml_tag_checking;
std::wstringstream wos;
boost::archive::text_woarchive oa(wos,flags);
oa & foo;
std::wcout << L"Foo is " << wos.str() << L"\n";
wos.str(L""); // reset the output stream
oa & foo;
std::wcout << L"Foo is " << wos.str() << L"\n";
}
int _tmain(int argc, _TCHAR* argv[])
{
argc; argv;
// Set up some recognizable values
Foo foo;
for( size_t i=0; i < 5; ++i )
foo.vws.push_back( L"Big String for vws" );
Test1( foo );
return 0;
}
Compiler options are:
/O2 /I "D:\Boost_1_33_1" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_SCL_SECURE_NO_DEPRECATE" /D "_UNICODE" /D "UNICODE" /FD /EHsc /MD /Yu"stdafx.h" /Fp"Release\Test.pch" /Fo"Release\\" /Fd"Release\vc80.pdb" /W4 /nologo /c /Wp64 /Zi /TP /errorReport:prompt
Sample of Warnings (at /w4)
------ Build started: Project: Test, Configuration: Release Win32 ------
Compiling...
Test.cpp
D:\Boost_1_33_1\boost/io/ios_state.hpp(52) : warning C4512: 'boost::io::ios_flags_saver' : assignment operator could not be generated
D:\Boost_1_33_1\boost/io/ios_state.hpp(32) : see declaration of 'boost::io::ios_flags_saver'
D:\Boost_1_33_1\boost/io/ios_state.hpp(75) : warning C4512: 'boost::io::ios_precision_saver' : assignment operator could not be generated
D:\Boost_1_33_1\boost/io/ios_state.hpp(55) : see declaration of 'boost::io::ios_precision_saver'
D:\Boost_1_33_1\boost/io/ios_state.hpp(98) : warning C4512: 'boost::io::ios_width_saver' : assignment operator could not be generated
D:\Boost_1_33_1\boost/io/ios_state.hpp(78) : see declaration of 'boost::io::ios_width_saver'
D:\Boost_1_33_1\boost/io/ios_state.hpp(275) : warning C4512: 'boost::io::ios_iword_saver' : assignment operator could not be generated
D:\Boost_1_33_1\boost/io/ios_state.hpp(253) : see declaration of 'boost::io::ios_iword_saver'
D:\Boost_1_33_1\boost/io/ios_state.hpp(300) : warning C4512: 'boost::io::ios_pword_saver' : assignment operator could not be generated
D:\Boost_1_33_1\boost/io/ios_state.hpp(278) : see declaration of 'boost::io::ios_pword_saver'
D:\Boost_1_33_1\boost/io/ios_state.hpp(330) : warning C4512: 'boost::io::ios_base_all_saver' : assignment operator could not be generated
D:\Boost_1_33_1\boost/io/ios_state.hpp(306) : see declaration of 'boost::io::ios_base_all_saver'
D:\Boost_1_33_1\boost/io/ios_state.hpp(406) : warning C4512: 'boost::io::ios_all_word_saver' : assignment operator could not be generated
D:\Boost_1_33_1\boost/io/ios_state.hpp(382) : see declaration of 'boost::io::ios_all_word_saver'
D:\Boost_1_33_1\boost/serialization/void_cast.hpp(127) : warning C4512: 'boost::serialization::void_cast_detail::void_caster' : assignment operator could not be generated
D:\Boost_1_33_1\boost/serialization/void_cast.hpp(91) : see declaration of 'boost::serialization::void_cast_detail::void_caster'
D:\Boost_1_33_1\boost/io/ios_state.hpp(246) : warning C4512: 'boost::io::basic_ios_locale_saver<Ch>' : assignment operator could not be generated
with
[
Ch=wchar_t
]
D:\Boost_1_33_1\boost/archive/basic_text_oprimitive.hpp(75) : see reference to class template instantiation 'boost::io::basic_ios_locale_saver<Ch>' being compiled
with
[
Ch=wchar_t
]
D:\Boost_1_33_1\boost/archive/text_woarchive.hpp(45) : see reference to class template instantiation 'boost::archive::basic_text_oprimitive<OStream>' being compiled
with
[
OStream=std::wostream
]
D:\Boost_1_33_1\boost/archive/text_woarchive.hpp(99) : see reference to class template instantiation 'boost::archive::text_woarchive_impl<Archive>' being compiled
D:\Boost_1_33_1\boost/archive/detail/oserializer.hpp(118) : warning C4100: 'flags' : unreferenced formal parameter
D:\Boost_1_33_1\boost/archive/detail/oserializer.hpp(118) : while compiling class template member function 'bool boost::archive::detail::oserializer::tracking(const unsigned int) const'
with
[
Archive=boost::archive::text_woarchive,
T=Foo
]
D:\Boost_1_33_1\boost/archive/detail/oserializer.hpp(264) : see reference to class template instantiation 'boost::archive::detail::oserializer' being compiled
with
[
Archive=boost::archive::text_woarchive,
T=Foo
]
D:\Boost_1_33_1\boost/archive/detail/oserializer.hpp(263) : while compiling class template member function 'void boost::archive::detail::save_non_pointer_type::save_standard::invoke(Archive &,const Foo &)'
with
[
Archive=boost::archive::text_woarchive,
T=Foo
]
D:\Boost_1_33_1\boost/archive/detail/oserializer.hpp(322) : see reference to class template instantiation 'boost::archive::detail::save_non_pointer_type::save_standard' being compiled
with
[
Archive=boost::archive::text_woarchive,
T=Foo
]
D:\Boost_1_33_1\boost/archive/detail/oserializer.hpp(310) : while compiling class template member function 'void boost::archive::detail::save_non_pointer_type::invoke(Archive &,const Foo &)'
with
[
Archive=boost::archive::text_woarchive,
T=Foo
]
D:\Boost_1_33_1\boost/archive/detail/oserializer.hpp(536) : see reference to class template instantiation 'boost::archive::detail::save_non_pointer_type' being compiled
with
[
Archive=boost::archive::text_woarchive,
T=Foo
]
D:\Boost_1_33_1\boost/archive/basic_text_oarchive.hpp(78) : see reference to function template instantiation 'void boost::archive::save(Archive &,const T &)' being compiled
with
[
Archive=boost::archive::text_woarchive,
T=const Foo
]
D:\Boost_1_33_1\boost/archive/detail/interface_oarchive.hpp(78) : see reference to function template instantiation 'void boost::archive::basic_text_oarchive<Archive>::save_override<T>(T &,int)' being compiled
with
[
Archive=boost::archive::text_woarchive,
T=const Foo
]
D:\Boost_1_33_1\boost/archive/detail/interface_oarchive.hpp(86) : see reference to function template instantiation 'Archive &boost::archive::detail::interface_oarchive<Archive>::operator <<<T>(T &)' being compiled
with
[
Archive=boost::archive::text_woarchive,
T=const Foo
]
.\Test.cpp(60) : see reference to function template instantiation 'Archive &boost::archive::detail::interface_oarchive<Archive>::operator &<const Foo>(T &)' being compiled
with
[
Archive=boost::archive::text_woarchive,
T=const Foo
]