Boost logo

Boost :

From: Craigp (craigp_at_[hidden])
Date: 2003-10-06 03:22:20


Robert, as per my last post, would you mind adding something like the
following to allow for overriding XML container element names?

template <class T> struct container_element_name
{
  static const char* name;
};

//default name
template <class T>
const char* container_element_name<T>::name = "item";

Replace "item" with container_element_name<Container>::name in
collections_load_imp.hpp and collections_save_imp.hpp (and
[load,save]_array_type in [i,o]serializer.hpp)?

Thanks!
--craig

"Brian McNamara" <lorgon_at_[hidden]> wrote in message
news:<20031006051501.GB13144_at_[hidden]>...
> 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])
> _______________________________________________
> Unsubscribe & other changes:
http://lists.boost.org/mailman/listinfo.cgi/boost
>


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