Boost logo

Boost Users :

From: Frank Bergemann (FBergemann_at_[hidden])
Date: 2007-04-23 05:16:44


Hi Robert,

when i use this xml_oarchive wrapper:

                /***************************
                 *
                 * xml_oarchive wrapper
                 *
                 ***************************/
                 
                template <class Archive>
                class xml_oarchive_orga_impl :
                        public xml_oarchive_impl<Archive>
                {
#ifdef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
                        public:
#else
                            friend class detail::interface_oarchive<Archive>;
                            friend class xml_oarchive_impl<Archive>;
                            friend class save_access;
                            
                        protected:
#endif
                            xml_oarchive_orga_impl(std::ostream & os, unsigned int flags) :
                                        xml_oarchive_impl<Archive>(os, flags)
                            { };
                           
                            ~xml_oarchive_orga_impl() { } ;

                            template<class T>
                            void save_override(
                                        #ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
                                        const
                                        #endif
                                        boost::serialization::nvp<T> & t,
                                        int i
                                ){
                                MakeNVPPathConcat(t.name());
                                xml_oarchive_impl<Archive>::save_override(t, i);
                            }
                        
                };

                // do not derive from this class. If you want to extend this functionality
                // via inhertance, derived from xml_iarchive_orga_impl instead. This will
                // preserve correct static polymorphism.
                class xml_oarchive_orga :
                    public xml_oarchive_orga_impl<xml_oarchive_orga>
                {
                public:
                    xml_oarchive_orga(std::ostream & os, unsigned int flags = 0) :
                        xml_oarchive_orga_impl<xml_oarchive_orga>(os, flags)
                    {}
                    ~xml_oarchive_orga() { };
                };

... i got a compile error:

/nfs/usta/FBergemann/SCMws/OPSC_DIAXHBS_dev_R1.8_provcorba/include/boost/archive/detail/interface_oarchive.hpp: In
   member function `Archive&
   boost::archive::detail::interface_oarchive<Archive>::operator<<(T&) [with T
   = const boost::archive::version_type, Archive =
   boost::archive::xml_oarchive_orga]':
/nfs/usta/FBergemann/SCMws/OPSC_DIAXHBS_dev_R1.8_provcorba/include/boost/archive/detail/common_oarchive.hpp:34: instantiated from `void boost::archive::detail::co
mmon_oarchive<Archive>::vsave(boost::archive::version_type) [with Archive = boost::archive::xml_oarchive_orga]'
/nfs/usta/FBergemann/SCMws/OPSC_DIAXHBS_dev_R1.8_provcorba/include/boost/archive/detail/iserializer.hpp:557: instantiated from here
/nfs/usta/FBergemann/SCMws/OPSC_DIAXHBS_dev_R1.8_provcorba/include/boost/archive/detail/interface_oarchive.hpp:78: error: no
   matching function for call to `boost::archive::xml_oarchive_orga::
   save_override(const boost::archive::version_type&, int)'

Do i have to add different overloads for save_override(...) in my class - even if i do NOT want to change the ones from the base class?

\Frank

> -----Ursprüngliche Nachricht-----
> Von: "Frank Bergemann" <FBergemann_at_[hidden]>
> Gesendet: 23.04.07 08:25:14
> An: boost-users_at_[hidden]
> Betreff: Re: [Boost-users] [Serialization, XML] - how to get info "where am i?" in serialization helper (encoding is not recursive)?

>
> Hi Robert,
>
> > -----Ursprüngliche Nachricht-----
> > Von: boost-users_at_[hidden]
> > Gesendet: 23.04.07 01:37:58
> > An: boost-users_at_[hidden]
> > Betreff: Re: [Boost-users] [Serialization, XML] - how to get info "where am i?" in serialization helper (encoding is not recursive)?
>
>
> >
> > Frank Bergemann wrote:
> > > i use an external XML format for configuration of CORBA (MICO) data
> > > and managed to align that with boost::serialization
> > > (To not write my own encoder/decoder and to minimize efforts for my
> > > module, in case the customer wants more CORBA objects/methods in
> > > future. Actually i think it would be a good options to let generate
> > > the boost::serialitzation helper file directly by MICO idl compiler.)
> >
> > What is the boost::serialitzation helper file? Oh maybe its what i called a
> > wrapper
>
> i meant the serialize(...) functions.
> The ones, which are related to the CORBA data types are plain simple now, directly related to the IDL file - e.g.
>
> template<class Archive>
> void serialize(Archive & ar,
> ::EmiHLRINData::HLRINData_V4::DCsiList_s &pInstance,
> const unsigned int version)
> {
> ar & make_nvp_wrapper( "d_csi_opt", pInstance.d_csi_opt );
> ar & make_nvp_wrapper( "neg_ph_vlr", pInstance.neg_ph_vlr );
> ar & make_nvp_wrapper( "cap", pInstance.cap );
> ar & make_nvp_wrapper( "d_csi", pInstance.d_csi );
> ar & make_nvp_wrapper( "lowph", pInstance.lowph );
> ar & make_nvp_wrapper( "lowac", pInstance.lowac );
> }
>
> I saved it in a file.cc.template and let it be expanded for the Archives i use (e.g. file_xml_oarchive.cc).
> So i can pre-compile the whole stuff in a library. And only re-compile, if the IDL files change.
> ( Using templates it took ages to compile my module :-) )
>
> >
> > > OK, for this now i have to check, that the (external, non by
> > > boost::serialization generated) XML image is _actually_ compliant with
> > > C/C++ data structures - especially for dynamic sized data. That is
> > > also covered now, the checks do fine.
> >
> > How much time/effort did it take to do this?
> >
>
> Was not that much.
> I have a XML "catalogue" of CORBA commands, for each cmd referring to CORBA object, method of object & related root data objects (holding event/subscriber variables inside, to be expanded).
> Then I use boost::serialization save(xml_oarchive,...) to create a *dummy* reference object.
> I traverse this one with some XML lib. And while traversing, i lookup corresponding positions in my XML formatted configuration file (for data to fill-into the boost::serialization image) and update the value in boost::serialization XML image.
> Then i use load(xml_oarchive, ...) to create the C/C++ object, populated with my "real" data now.
> I save all the objects needed for a command in a boost::any container (for invoking a generic CORBA-object/method dispatcher).
> All this alignment stuff will be shifted to process startup phase.
> In the end it's better than writing my own XML decoder for each CORBA data object.
> It is much more generic using your boost::serialization lib :-)
>
> > > But what i didn't manage is to get the _location_ of error in the XML
> > > file - in case there is an error.
> >
> > Hmmm - location as ? point to the line/character? current name? or ?
>
> location in XML data structure (XML-path).
>
> >
> > > opsc_hlr :2204 084723:D:### invoked for <value>
> > > opsc_hlr :2204 084723:D:### c'tor
> > > opsc_hlr :2204 084723:D:### done for <value>
> > > opsc_hlr :2204 084723:D:### d'tor
> >
> > > So there is no recursion(???).
> >
> > > Is there another way to get a "where am i" information within a
> > > serialize (load/save) helper?
> >
> > make_...wrapper is not recurssive, save/load are.
> >
> > I would derive from xml_?archive and override the save(NVP(T)..) and/or
> > load(NVP...) to capture/whatever the tags as they are read/writting. Don't
> > forget to call the original save/load.
>
> Could you pls refer to short example for deriving from xml_?archive ?
>
> > Robert Ramey
> >
>
> \Frank
>

_______________________________________________________________
SMS schreiben mit WEB.DE FreeMail - einfach, schnell und
kostenguenstig. Jetzt gleich testen! http://f.web.de/?mc=021192


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