|
Boost Users : |
Subject: Re: [Boost-users] XML Serialization: Putting Stylesheet tag insideXMLfile
From: girish hilage (girish_hilage_at_[hidden])
Date: 2010-02-20 12:55:54
Hi,
  I tried including <boost/serialization/string.hpp> file but still getting the crash.
  I have tried to resolve the problem by overloading << as follows :
  XMLArchive & operator << (XMLArchive &xa, const struct EMPLOYEE &e)
  {
      xa << BOOST_SERIALIZATION_NVP(e.id);
      xa << BOOST_SERIALIZATION_NVP(e.name);
      return xa;
  }
  and calling it like this :
  xa << e;
  But, though I am getting the expected result, it still gives me a WARNING As follows :
  test.cc: In function âint main()â:
  test.cc:94: warning: ISO C++ says that these are ambiguous, even though the worst conversion for the first is better than the worst conversion for the second:
  test.cc:72: note: candidate 1: XMLArchive& operator<<(XMLArchive&, const EMPLOYEE&)
  /usr/include/boost/archive/detail/interface_oarchive.hpp:63: note: candidate 2: Archive& boost::archive::detail::interface_oarchive<Archive>::operator<<(T&) [with T = EMPLOYEE, Archive = boost::archive::xml_oarchive]
  If I call "<<()" as :
  operator <<(xa, e);
  then it gives me no WARNING.
  Also, "ltrace -C " for the crashed program is as below :
__libc_start_main(0x804a554, 1, 0xbf973d44, 0x804beb0, 0x804bea0 <unfinished ...>
std::ios_base::Init::Init()(0x804f554, 0x8967bc, 0, 0xb7f52438, 1)Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â = 9
__cxa_atexit(0x804a2b8, 0x804f554, 0x804bf68, 0xb7f52438, 1)Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â = 0
__cxa_guard_acquire(0x804f558, 0x804f258, 0, 0x48bff4, 0x804beb0)Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â = 1
__cxa_guard_acquire(0x804f560, 0x8049d93, 0x23b1f0, 0xb7f532f0, 0xb7f53a8c)Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â = 1
boost::serialization::detail::extended_type_info_typeid_0::extended_type_info_typeid_0()(0x804f590, 0xbf973b74, 1, 1, 0) = 0xb6bf88
boost::serialization::detail::extended_type_info_typeid_0::type_register(std::type_info const&)(0x804f590, 0x804c7f4, 1, 1, 0) = 0x99d0008
__cxa_guard_release(0x804f560, 0x8049d93, 0x23b1f0, 0xb7f532f0, 0xb7f53a8c)Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â = 0x804f560
__cxa_atexit(0x804b20c, 0x804f590, 0x804bf68, 0xb7f532f0, 0xb7f53a8c)Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â = 0
boost::archive::detail::basic_oserializer::basic_oserializer(boost::serialization::extended_type_info const&)(0x804f584, 0x804f590, 0x804f38c, 0, 0x23b1f0) = 0x804f584
__cxa_guard_release(0x804f558, 0x804f258, 0, 0x48bff4, 0x804beb0)Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â = 0x804f558
__cxa_atexit(0x804ae62, 0x804f584, 0x804bf68, 0x48bff4, 0x804beb0)Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â = 0
std::basic_ofstream<char, std::char_traits<char> >::basic_ofstream(char const*, std::_Ios_Openmode)(0xbf973b1c, 0x804c0af, 48, 0x896818, 0xb7f52428) = 0xbf973ba8
boost::archive::xml_oarchive_impl<boost::archive::xml_oarchive>::xml_oarchive_impl(std::ostream&, unsigned int)(0xbf973c30, 0xbf973b1c, 0, 0x48bff4, 0) = 0
std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string()(0xbf973c64, 0xbf973b1c, 0, 0x48bff4, 0) = 0xbf973c64
std::string::operator=(char const*)(0xbf973c64, 0x804c0bd, 48, 0x896818, 0xb7f52428)Â Â Â Â Â Â Â Â Â Â Â Â = 0xbf973c64
boost::archive::basic_xml_oarchive<boost::archive::xml_oarchive>::save_start(char const*)(0xbf973c30, 0x804c0c8, 0xff636d6e, 0xbf973c60, 0x804c0bd) = 0xbf973c30
boost::archive::detail::basic_oarchive::save_object(void const*, boost::archive::detail::basic_oserializer const&)(0xbf973c30, 0xbf973c60, 0x804f584, 0x1010101, 0x1010101 <unfinished ...>
boost::archive::basic_xml_oarchive<boost::archive::xml_oarchive>::save_override(boost::archive::class_id_optional_type const&, int)(0xbf973c30, 0xbf973a0c, 0, 0, 0xaffd10) = 0xbf973b1c
boost::archive::basic_xml_oarchive<boost::archive::xml_oarchive>::save_override(boost::archive::tracking_type const&, int)(0xbf973c30, 0xbf973a1f, 0, 0, 0xaffd10) = 0xbf973b1c
boost::archive::basic_xml_oarchive<boost::archive::xml_oarchive>::save_override(boost::archive::version_type const&, int)(0xbf973c30, 0xbf973a10, 0, 0, 0xaffd10) = 0xbf973b1c
__dynamic_cast(0xbf973c30, 0x804f4f0, 0x804c9ec, 0, 0xafd170)Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â = 0
__cxa_bad_cast(0xbf973c30, 0x804f4f0, 0x804c9ec, 0, 0xafd170 <unfinished ...>
__gxx_personality_v0(1, 1, 0x432b2b00, 0x474e5543, 0x99d2480)Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â = 8
__gxx_personality_v0(1, 1, 0x432b2b00, 0x474e5543, 0x99d2480)Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â = 8
__gxx_personality_v0(1, 1, 0x432b2b00, 0x474e5543, 0x99d2480)Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â = 8
__gxx_personality_v0(1, 1, 0x432b2b00, 0x474e5543, 0x99d2480)Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â = 8
__gxx_personality_v0(1, 1, 0x432b2b00, 0x474e5543, 0x99d2480)Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â = 8
__gxx_personality_v0(1, 1, 0x432b2b00, 0x474e5543, 0x99d2480)Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â = 8
__gxx_personality_v0(1, 1, 0x432b2b00, 0x474e5543, 0x99d2480)Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â = 8
__gxx_personality_v0(1, 1, 0x432b2b00, 0x474e5543, 0x99d2480)Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â = 8
__gxx_personality_v0(1, 1, 0x432b2b00, 0x474e5543, 0x99d2480)Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â = 8
__gxx_personality_v0(1, 1, 0x432b2b00, 0x474e5543, 0x99d2480)Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â = 8
__gxx_personality_v0(1, 1, 0x432b2b00, 0x474e5543, 0x99d2480)Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â = 8
__gxx_personality_v0(1, 1, 0x432b2b00, 0x474e5543, 0x99d2480)Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â = 8
__gxx_personality_v0(1, 1, 0x432b2b00, 0x474e5543, 0x99d2480)Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â = 8
__gxx_personality_v0(1, 1, 0x432b2b00, 0x474e5543, 0x99d2480)Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â = 8
__gxx_personality_v0(1, 1, 0x432b2b00, 0x474e5543, 0x99d2480)Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â = 8
terminate called after throwing an instance of 'std::bad_cast'
__gxx_personality_v0(1, 1, 0x432b2b00, 0x474e5543, 0x99d2480)Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â = 8
__gxx_personality_v0(1, 1, 0x432b2b00, 0x474e5543, 0x99d2480)Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â = 6
__gxx_personality_v0(1, 2, 0x432b2b00, 0x474e5543, 0x99d2480)Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â = 8
__gxx_personality_v0(1, 6, 0x432b2b00, 0x474e5543, 0x99d2480)Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â = 7
 what(): std::bad_cast
--- SIGABRT (Aborted) ---
+++ killed by SIGABRT +++
  So, does anyone know about any solution on,
  * either, how to remove the WARNING
  * or, how to avoid the crash?
Â
  I am using boost-1.37.0-6.fc11.i586 on FC11.
Regards,
Girish
--- On Fri, 2/19/10, Robert Ramey <ramey_at_[hidden]> wrote:
From: Robert Ramey <ramey_at_[hidden]>
Subject: Re: [Boost-users] XML Serialization: Putting Stylesheet tag insideXMLfile
To: boost-users_at_[hidden]
Date: Friday, February 19, 2010, 4:34 PM
girish hilage wrote:
> Hi,
>
>Â Â I am able to insert the stylesheet tag from inside a constructor
> of my new derived class.
>Â Â Please find below the whole program.
>
>Â Â But, I am still getting an error :
>Â Â terminate called after throwing an instance of 'std::bad_cast'
>Â Â Â what():Â std::bad_cast
>Â Â Aborted (core dumped)
>
>Â Â on the statement :
>Â Â xa << BOOST_SERIALIZATION_NVP(e);
>Â Â in the code below.
>
>Â Â The statements :
>Â Â xa.putTag ("TESTING_XMLCLASS");
>Â Â xa << BOOST_SERIALIZATION_NVP(tmp);
>Â Â oa << BOOST_SERIALIZATION_NVP(e);
>Â Â work as expected.
>
>Â Â Can you please let me know what could be the reason for this?
>
I can't. The only thing that looks missing to me is:
#include <boost/serialization/string.hpp>
Robert Ramey
_______________________________________________
Boost-users mailing list
Boost-users_at_[hidden]
http://lists.boost.org/mailman/listinfo.cgi/boost-users
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