Boost logo

Boost Users :

Subject: Re: [Boost-users] boost serialization of std::pair
From: Stefan Strasser (strasser_at_[hidden])
Date: 2013-03-18 10:00:12


Am 18.03.2013 12:46, schrieb Andrew Smith:
> Hi,
>
> Is there any way of customizing the element names given to serialization
> of std::pair via xml_oarchive. Im think of something like
> the|||BOOST_SERIALIZATION_NVP mechanism.
>
> In particular Im looking to serialize std::map with custom elemnet names
> to replace '<first>' and '<second>'

depending on whether you want your container to always be serialized
this way, or just for your specific file type, you could derive from
xml_oarchive and implement a save_override function - see the Archive
concept documentation, or you could implement a serialize() function for
your specific container or the type holding the container.

the latter case would either look like

---
void serialize(Archive &ar,std::map<my_key,my_val> &,unsigned int)...
or
---
struct container_holder{
   //Serializable
private:
   std::map<my_key,my_val> container;
};

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