Hi all. 
I understood how to serialize correctly nested structures, defining serialize method inside all. 

I've a problem with an attribute of a struct. The attribute is border of OpenCV CvSeq type.

Here is my code... what can i do to solve this?


struct Element{
unsigned int id;
double area; 
double perimeter;
CvRect bounding_box; 
CvSeq* border;
...
        ...
};

namespace boost {
namespace serialization {

template<class Archive>
void serialize(Archive & ar, Element & g, const unsigned int version)
{
ar & g.id;
ar & g.area ;
ar & g.perimeter ;
        ar & g.bounding_box.width ;
ar & g.bounding_box.height ;
ar & g.bounding_box.x ;
ar & g.bounding_box.y ;
        // ar & g.border; I CAN'T DO THIS... 

}
}

The error that I obtain is: c:\boost\boost_1_42\boost\serialization\access.hpp(118) : error C2039: 'serialize' : is not a member of 'CvSeq'
        c:\opencv2.0\include\opencv\cxtypes.h(1240) : see declaration of 'CvSeq' 

For CvRect bouding:box i overcame the problem serializing the sub-elements of CvRect.


thanks for help. 

Marco.

On Mon, May 3, 2010 at 3:39 PM, Marco Meoni - Sbaush <sbaush@gmail.com> wrote:
I don't know if I understood correctly but I understood that the key function of vector serialization is split_free. I did not understand how to use this technique in the case of my example. Can you help me understand the workings of the vector serialization so as to know how to extend it to classes? What can i read to understand how to solve?

Thanks...

Marco.

On Fri, Apr 30, 2010 at 6:08 PM, Robert Ramey <ramey@rrsd.com> wrote:
Try looking inside boost/serialization/vector.hpp to see how it was done for the STL containers.
 
Robert Ramey
 
Marco Meoni - Sbaush wrote:
> Yes.
> I did an example like this to learn how to serialize in the
> "classical" way.
>
>
> My problem is that i can't define a serialize method inside
> Container, but i would serialize it anyway. How can i serialize the
> Example strut entirely? 
>
>
> Do you understand my problem?
>
>
> On Fri, Apr 30, 2010 at 3:49 AM, Robert Ramey <ramey@rrsd.com> wrote:
>
> Marco Meoni - Sbaush wrote:
>> Can someone help me?
>> Robert, where can I find what you're talking about?
>
> I don't know what you're trying to do so I'll take a guess.
>
> Does this look like what you want to do?
>
> struct Container {
>     int m_container_member;
>     ... // more members
>     template<class Archive>
>     void serialize(Archive & ar, const unsigned int version){
>         ar & m_container_member;
>         ... // more members
>     }
> };
>
> struct Example {
>     friend class boost::serialization::access; // not really
> necessary as all "struct" members are public
>     template<class Archive>
>     void serialize(Archive & ar, const unsigned int version){
>         ar & m_container;
>     }
> };
>
> int main(int argc, char * argv[]){
>     const Container c = ...
>     std::fostream os("filename");
>     boost::serialization::archive ar(os);
>     ar & c;
> }
>
> Does that help any?
>
> Robert Ramey
>
>
> _______________________________________________
> Boost-users mailing list
> Boost-users@lists.boost.org
> http://lists.boost.org/mailman/listinfo.cgi/boost-users

_______________________________________________
Boost-users mailing list
Boost-users@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users



--
Marco Meoni - Sbaush
www.marcomeoni.net



--
Marco Meoni - Sbaush
www.marcomeoni.net