Boost logo

Boost Users :

From: Bill Somerville (bsomerville_at_[hidden])
Date: 2008-03-03 14:37:47


Hi,
 
XML serialization needs to know the variable name for the element tag, use the following macro:
 
void serialize(Archive& ar, const unsigned int)

{

       ar & BOOST_SERIALIZATION_NVP(m_name);

}

 

macro is defined in nvp.hpp. Macro is no-op for non-XML archives. RTFM for further details and options.

--
Regards
Bill Somerville
________________________________
From: boost-users-bounces_at_[hidden] on behalf of Ambardekar, Mukund
Sent: Mon 03/03/2008 7:13 PM
To: boost-users_at_[hidden]
Subject: [Boost-users] serialization - xml
Hi,
 
I used boost serialization to write my data in binary format as in below way - 
 
std::ofstream ofs(catalogFileName.c_str(),std::ios::binary);
boost::archive::binary_oarchive oa(ofs);
//write 
oa & m_myclass; // object of CMyClass type containing some data (say name)
 
This worked correctly. Now I wanted to write into xml format. Did the below changes
 
std::ofstream ofs(catalogFileName.c_str(),std::ios::binary);
boost::archive::xml_oarchive oa(ofs);
//write 
oa & m_myclass;
 
But it is giving me below error - 
d:\tools\boost-1feb08\boost_1_34_1\boost\archive\basic_xml_oarchive.hpp(83) : error C2027: use of undefined type 'boost::STATIC_ASSERTION_FAILURE<x>'
 
Can you help me to identify the problem? 
 
FYI - I have made no changed CMyClass looks like as below. And I have made no changes in it (same one used for binary and xml)
class CMyClass
{
      public:
        Part(const std::wstring& Name);
private:
        std::wstring m_name;  
  friend class boost::serialization::access;
        template<class Archive>
        void serialize(Archive& ar, const unsigned int)
       {
       ar & m_name;
       }                      
};
 
Thanks in advance.
 
Regards,
Mukund
 
This message has been scanned by MailController - www.MailController.altohiway.com



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