Board index » cppbuilder » xml serialization using boost and borland c++ builder 6

xml serialization using boost and borland c++ builder 6


2006-11-14 10:02:38 PM
cppbuilder88
Hello,
I am trying to do an xml serialization using boost librabry.
Here is the source code of the example
#ifndef xml_rwarchive_h
#define xml_rwarchive_h
#include <boost/serialization/nvp.hpp>
#include <boost/serialization/utility.hpp>
#include <boost/archive/xml_oarchive.hpp>
#include <boost/archive/xml_iarchive.hpp>
#include <boost/archive/basic_xml_oarchive.hpp>
#include <boost/archive/basic_xml_iarchive.hpp>
#include <boost/archive/impl/xml_iarchive_impl.ipp>
#include <boost/archive/impl/xml_oarchive_impl.ipp>
#include <boost/archive/impl/basic_xml_oarchive.ipp>
#include <boost/archive/impl/basic_xml_iarchive.ipp>
#include <boost/archive/basic_text_oprimitive.hpp>
#include <boost/archive/basic_text_iprimitive.hpp>
#include <boost/archive/impl/basic_text_oprimitive.ipp>
#include <boost/archive/impl/basic_text_iprimitive.ipp>
#include <boost/archive/impl/basic_xml_grammar.hpp>
#include <libs/serialization/src/basic_xml_grammar.ipp>
#endif
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
#include<fstream>
#include<iostream>
class gps_position
{
private:
friend class boost::serialization::access;
template<class Archive>
void serialize(Archive& ar, const unsigned int version)
{
std::cout << "gps_position::serialize: begin" << std::endl;
ar & BOOST_SERIALIZATION_NVP(degrees);
ar & BOOST_SERIALIZATION_NVP(minutes);
ar & BOOST_SERIALIZATION_NVP(seconds);
std::cout << "gps_position::serialize: end" << std::endl;
}
int degrees;
int minutes;
float seconds;
public:
gps_position()
{
degrees = 0;
minutes = 0;
seconds = 0.0;
}
gps_position(int d, int m, float s): degrees(d), minutes(m), seconds(s){}
virtual void display() const
{
std::cout << "-----------------------" << std::endl;
std::cout << "degrees = " << degrees << std::endl;
std::cout << "minutes = " << minutes << std::endl;
std::cout << "seconds = " << seconds << std::endl;
std::cout << "-----------------------" << std::endl;
}
};
int main()
{
std::ofstream ofs("filename");
const gps_position g(35, 59, 24.567f);
g.display();
{
std::cout << "create write archive" << std::endl;
boost::archive::xml_oarchive oa(ofs);
std::cout << "write object to archive" << std::endl;
oa << BOOST_SERIALIZATION_NVP(g);
std::cout << "end of write serialization" << std::endl;
}
gps_position newg;
{
std::cout << "create read archive" << std::endl;
std::ifstream ifs("filename", std::ios::binary);
std::cout << "instantiate read archive" << std::endl;
boost::archive::xml_iarchive ia(ifs);
std::cout << "read obect from archive" << std::endl;
ia>>BOOST_SERIALIZATION_NVP(newg);
}
newg.display();
return 0;
}
when compiling with borland c++ builder 6 I get the following errors:
[C++ Error] oserializer.hpp(106): E2451 Undefined symbol 'get_instance'
[C++ Error] oserializer.hpp(108): E2251 Cannot find default constructor to
initialize base class 'basic_oserializer'
[C++ Error] iserializer.hpp(113): E2451 Undefined symbol 'get_instance'
[C++ Error] iserializer.hpp(115): E2251 Cannot find default constructor to
initialize base class 'basic_iserializer'
The errors appear when using BOOST_SERIALIZATION_NVP in the main program
Maybe I have forgotten a header file?
can you help me ?
Thank you in advance.
Best Regards.
Nicolas
 
 

Re:xml serialization using boost and borland c++ builder 6

Hello,
I am trying to do an xml serialization using boost librabry.
Here is the source code of the example
#ifndef xml_rwarchive_h
#define xml_rwarchive_h
#include <boost/serialization/nvp.hpp>
#include <boost/serialization/utility.hpp>
#include <boost/archive/xml_oarchive.hpp>
#include <boost/archive/xml_iarchive.hpp>
#include <boost/archive/basic_xml_oarchive.hpp>
#include <boost/archive/basic_xml_iarchive.hpp>
#include <boost/archive/impl/xml_iarchive_impl.ipp>
#include <boost/archive/impl/xml_oarchive_impl.ipp>
#include <boost/archive/impl/basic_xml_oarchive.ipp>
#include <boost/archive/impl/basic_xml_iarchive.ipp>
#include <boost/archive/basic_text_oprimitive.hpp>
#include <boost/archive/basic_text_iprimitive.hpp>
#include <boost/archive/impl/basic_text_oprimitive.ipp>
#include <boost/archive/impl/basic_text_iprimitive.ipp>
#include <boost/archive/impl/basic_xml_grammar.hpp>
#include <libs/serialization/src/basic_xml_grammar.ipp>
#endif
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
#include<fstream>
#include<iostream>
class gps_position
{
private:
friend class boost::serialization::access;
template<class Archive>
void serialize(Archive& ar, const unsigned int version)
{
std::cout << "gps_position::serialize: begin" << std::endl;
ar & BOOST_SERIALIZATION_NVP(degrees);
ar & BOOST_SERIALIZATION_NVP(minutes);
ar & BOOST_SERIALIZATION_NVP(seconds);
std::cout << "gps_position::serialize: end" << std::endl;
}
int degrees;
int minutes;
float seconds;
public:
gps_position()
{
degrees = 0;
minutes = 0;
seconds = 0.0;
}
gps_position(int d, int m, float s): degrees(d), minutes(m), seconds(s){}
virtual void display() const
{
std::cout << "-----------------------" << std::endl;
std::cout << "degrees = " << degrees << std::endl;
std::cout << "minutes = " << minutes << std::endl;
std::cout << "seconds = " << seconds << std::endl;
std::cout << "-----------------------" << std::endl;
}
};
int main()
{
std::ofstream ofs("filename");
const gps_position g(35, 59, 24.567f);
g.display();
{
std::cout << "create write archive" << std::endl;
boost::archive::xml_oarchive oa(ofs);
std::cout << "write object to archive" << std::endl;
oa << BOOST_SERIALIZATION_NVP(g);
std::cout << "end of write serialization" << std::endl;
}
gps_position newg;
{
std::cout << "create read archive" << std::endl;
std::ifstream ifs("filename", std::ios::binary);
std::cout << "instantiate read archive" << std::endl;
boost::archive::xml_iarchive ia(ifs);
std::cout << "read obect from archive" << std::endl;
ia>>BOOST_SERIALIZATION_NVP(newg);
}
newg.display();
return 0;
}
when compiling with borland c++ builder 6 I get the following errors:
[C++ Error] oserializer.hpp(106): E2451 Undefined symbol 'get_instance'
[C++ Error] oserializer.hpp(108): E2251 Cannot find default constructor to
initialize base class 'basic_oserializer'
[C++ Error] iserializer.hpp(113): E2451 Undefined symbol 'get_instance'
[C++ Error] iserializer.hpp(115): E2251 Cannot find default constructor to
initialize base class 'basic_iserializer'
The errors appear when using BOOST_SERIALIZATION_NVP in the main program
Maybe I have forgotten a header file?
can you help me ?
Thank you in advance.
Best Regards.
Nicolas
 

Re:xml serialization using boost and borland c++ builder 6

Hello,
I am trying to do an xml serialization using boost librabry.
Here is the source code of the example
#ifndef xml_rwarchive_h
#define xml_rwarchive_h
#include <boost/serialization/nvp.hpp>
#include <boost/serialization/utility.hpp>
#include <boost/archive/xml_oarchive.hpp>
#include <boost/archive/xml_iarchive.hpp>
#include <boost/archive/basic_xml_oarchive.hpp>
#include <boost/archive/basic_xml_iarchive.hpp>
#include <boost/archive/impl/xml_iarchive_impl.ipp>
#include <boost/archive/impl/xml_oarchive_impl.ipp>
#include <boost/archive/impl/basic_xml_oarchive.ipp>
#include <boost/archive/impl/basic_xml_iarchive.ipp>
#include <boost/archive/basic_text_oprimitive.hpp>
#include <boost/archive/basic_text_iprimitive.hpp>
#include <boost/archive/impl/basic_text_oprimitive.ipp>
#include <boost/archive/impl/basic_text_iprimitive.ipp>
#include <boost/archive/impl/basic_xml_grammar.hpp>
#include <libs/serialization/src/basic_xml_grammar.ipp>
#endif
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
#include<fstream>
#include<iostream>
class gps_position
{
private:
friend class boost::serialization::access;
template<class Archive>
void serialize(Archive& ar, const unsigned int version)
{
std::cout << "gps_position::serialize: begin" << std::endl;
ar & BOOST_SERIALIZATION_NVP(degrees);
ar & BOOST_SERIALIZATION_NVP(minutes);
ar & BOOST_SERIALIZATION_NVP(seconds);
std::cout << "gps_position::serialize: end" << std::endl;
}
int degrees;
int minutes;
float seconds;
public:
gps_position()
{
degrees = 0;
minutes = 0;
seconds = 0.0;
}
gps_position(int d, int m, float s): degrees(d), minutes(m), seconds(s){}
virtual void display() const
{
std::cout << "-----------------------" << std::endl;
std::cout << "degrees = " << degrees << std::endl;
std::cout << "minutes = " << minutes << std::endl;
std::cout << "seconds = " << seconds << std::endl;
std::cout << "-----------------------" << std::endl;
}
};
int main()
{
std::ofstream ofs("filename");
const gps_position g(35, 59, 24.567f);
g.display();
{
std::cout << "create write archive" << std::endl;
boost::archive::xml_oarchive oa(ofs);
std::cout << "write object to archive" << std::endl;
oa << BOOST_SERIALIZATION_NVP(g);
std::cout << "end of write serialization" << std::endl;
}
gps_position newg;
{
std::cout << "create read archive" << std::endl;
std::ifstream ifs("filename", std::ios::binary);
std::cout << "instantiate read archive" << std::endl;
boost::archive::xml_iarchive ia(ifs);
std::cout << "read obect from archive" << std::endl;
ia>>BOOST_SERIALIZATION_NVP(newg);
}
newg.display();
return 0;
}
when compiling with borland c++ builder 6 I get the following errors:
[C++ Error] oserializer.hpp(106): E2451 Undefined symbol 'get_instance'
[C++ Error] oserializer.hpp(108): E2251 Cannot find default constructor to
initialize base class 'basic_oserializer'
[C++ Error] iserializer.hpp(113): E2451 Undefined symbol 'get_instance'
[C++ Error] iserializer.hpp(115): E2251 Cannot find default constructor to
initialize base class 'basic_iserializer'
The errors appear when using BOOST_SERIALIZATION_NVP in the main program
Maybe I have forgotten a header file?
can you help me ?
Thank you in advance.
Best Regards.
Nicolas
 

{smallsort}

Re:xml serialization using boost and borland c++ builder 6

Please direct your browser at info.borland.com/newsgroups/ and
read the newsgroup guidelines. One of them asks us not to post the
same question to different newsgroups, but to pick the most
appropriate one and just post there. Thanks!