lmi
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lmi] change file formats to XML


From: Vaclav Slavik
Subject: Re: [lmi] change file formats to XML
Date: Wed, 17 Mar 2010 14:49:14 +0100

Hi,

On Tue, 2010-03-16 at 20:35 +0000, Greg Chicares wrote:
>   struct xml_sequence_io
>   {
>   ...
>     static void to_xml(xml::element& e, T const& t)
>     {
> -       LMI_ASSERT(e.elements("item").empty());
> +       e.erase(e.begin(), e.end());
>   ...
>     static void to_xml(xml::element& e, T const& t)
>     {
> +       t.clear();
> -       LMI_ASSERT(t.empty());

I would do this and the same thing in xml_io<T>::to_xml() too.

>   ...
>   template<typename T>
> - void set_element(xml::element& parent, std::string const& name, T
> const& t)
> + void add_element(xml::element& parent, std::string const& name, T
> const& t)
>   ...
>   void get_element(xml::element const& parent, std::string const&
> name, T& t) 

This is probably better, too. Alternatively, set_element() should check
if find(name) finds something (i.e. the name is already used) and either
assert in that case or replace the old value. I don't have a preference
either way and it shouldn't really matter with the way this code is
currently used.

Vaclav





reply via email to

[Prev in Thread] Current Thread [Next in Thread]