Boost logo

Boost :

From: Brian McNamara (lorgon_at_[hidden])
Date: 2003-10-06 00:15:01


On Sun, Oct 05, 2003 at 07:13:58PM -0700, Craigp wrote:
> For XML serialization, container element names seem to be hardcoded to
> 'item'. Is it possible to override this? Partial specialization worked, but
> I had to make save_collection a class (I renamed it to archive_output_seq to
> mirror archive_input_seq), and, well, I used partial specialization. :-) Is
> there a better way of overriding container element names? If not, can you
> make save_collection a class, so we can partially specialize it?

If all you want to specialize is the name, then it seems to me the right
thing to do is

(1) create

   namespace boost{
   namespace serialization {
   namespace stl {
      template <class T> struct container_element_name {
         static const char* name = "item";
         // I forget if it's legal to initialize that inline or not
      };
   }}}

(2) replace the hardcoded "item" in the library with

   container_element_name<T>::name

(3) specialize this tiny little class (rather than specializing a whole
big function/class) as desired:

   template <> container_element_name< MapTiles > {
      static const char* name = "tile";
   };

Yes/no/maybe?

-- 
-Brian McNamara (lorgon_at_[hidden])

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk