lmi-commits
[Top][All Lists]
Advanced

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

[lmi-commits] [4990] Optionally override missing-version error message


From: Greg Chicares
Subject: [lmi-commits] [4990] Optionally override missing-version error message
Date: Mon, 14 Jun 2010 11:45:11 +0000

Revision: 4990
          http://svn.sv.gnu.org/viewvc/?view=rev&root=lmi&revision=4990
Author:   chicares
Date:     2010-06-14 11:45:11 +0000 (Mon, 14 Jun 2010)
Log Message:
-----------
Optionally override missing-version error message

Modified Paths:
--------------
    lmi/trunk/xml_serializable.hpp
    lmi/trunk/xml_serializable.tpp

Modified: lmi/trunk/xml_serializable.hpp
===================================================================
--- lmi/trunk/xml_serializable.hpp      2010-06-14 11:29:46 UTC (rev 4989)
+++ lmi/trunk/xml_serializable.hpp      2010-06-14 11:45:11 UTC (rev 4990)
@@ -73,6 +73,7 @@
         ) const;
 
     // Backward compatibility.
+    virtual void handle_missing_version_attribute() const;
     virtual bool is_detritus(std::string const&) const;
     virtual void redintegrate_ex_ante
         (int                file_version

Modified: lmi/trunk/xml_serializable.tpp
===================================================================
--- lmi/trunk/xml_serializable.tpp      2010-06-14 11:29:46 UTC (rev 4989)
+++ lmi/trunk/xml_serializable.tpp      2010-06-14 11:45:11 UTC (rev 4990)
@@ -104,12 +104,8 @@
     std::string file_version_string;
     if(!xml_lmi::get_attr(x, "version", file_version_string))
         {
-        fatal_error()
-            << "XML tag <"
-            << xml_root_name()
-            << "> lacks required version attribute."
-            << LMI_FLUSH
-            ;
+        handle_missing_version_attribute();
+        file_version_string = "0";
         }
     int file_version = value_cast<int>(file_version_string);
 
@@ -276,6 +272,25 @@
     parent.push_back(xml::element(name.c_str(), t()[name].str().c_str()));
 }
 
+/// React to absence of required 'version' attribute.
+///
+/// This default implementation throws an informative exception.
+///
+/// A derived class may override this with a do-nothing implementation
+/// if it is necessary to extend backward compatibility to historical
+/// xml files that originally had no such attribute.
+
+template<typename T>
+void xml_serializable<T>::handle_missing_version_attribute() const
+{
+    fatal_error()
+        << "XML tag <"
+        << xml_root_name()
+        << "> lacks required version attribute."
+        << LMI_FLUSH
+        ;
+}
+
 /// Ascertain whether an element-tag is obsolete.
 ///
 /// Tags that were present in older versions and later removed are




reply via email to

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