[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [4991] Extend backward compatibility to encompass the 2008
From: |
Greg Chicares |
Subject: |
[lmi-commits] [4991] Extend backward compatibility to encompass the 20080218T1743Z change |
Date: |
Mon, 14 Jun 2010 12:59:39 +0000 |
Revision: 4991
http://svn.sv.gnu.org/viewvc/?view=rev&root=lmi&revision=4991
Author: chicares
Date: 2010-06-14 12:59:38 +0000 (Mon, 14 Jun 2010)
Log Message:
-----------
Extend backward compatibility to encompass the 20080218T1743Z change
Modified Paths:
--------------
lmi/trunk/ChangeLog
lmi/trunk/configurable_settings.cpp
lmi/trunk/configurable_settings.hpp
lmi/trunk/configurable_settings_test.cpp
Modified: lmi/trunk/ChangeLog
===================================================================
--- lmi/trunk/ChangeLog 2010-06-14 11:45:11 UTC (rev 4990)
+++ lmi/trunk/ChangeLog 2010-06-14 12:59:38 UTC (rev 4991)
@@ -26050,3 +26050,29 @@
configurable_settings.hpp
Refactor, deriving configurable_settings from xml_serializable.
+20100612T2157Z <address@hidden> [701]
+
+ configurable_settings.cpp
+ configurable_settings_test.cpp
+Fix defect introduced 20061110T1628Z by warning at startup if settings
+cannot be saved.
+
+20100614T1129Z <address@hidden> [701]
+
+ xml_serializable.tpp
+Refactor to improve concinnity. The redintegrate_ex* implementations
+were equivalent; now they're identical.
+
+20100614T1145Z <address@hidden> [701]
+
+ xml_serializable.hpp
+ xml_serializable.tpp
+Optionally override missing-version error message.
+
+20100614T1259Z <address@hidden> [701]
+
+ configurable_settings.cpp
+ configurable_settings.hpp
+ configurable_settings_test.cpp
+Extend backward compatibility to encompass the 20080218T1743Z change.
+
Modified: lmi/trunk/configurable_settings.cpp
===================================================================
--- lmi/trunk/configurable_settings.cpp 2010-06-14 11:45:11 UTC (rev 4990)
+++ lmi/trunk/configurable_settings.cpp 2010-06-14 12:59:38 UTC (rev 4991)
@@ -44,6 +44,7 @@
#include <algorithm> // std::copy()
#include <iterator>
#include <sstream>
+#include <stdexcept>
template class xml_serializable<configurable_settings>;
@@ -215,11 +216,12 @@
/// Backward-compatibility serial number of this class's xml version.
///
-/// version 0: 20100612T0139Z
+/// version 0: [prior to the lmi epoch]
+/// version 1: 20100612T0139Z
int configurable_settings::class_version() const
{
- return 0;
+ return 1;
}
std::string const& configurable_settings::xml_root_name() const
@@ -228,6 +230,10 @@
return s;
}
+void configurable_settings::handle_missing_version_attribute() const
+{
+}
+
/// Entities that were present in older versions and then removed
/// are recognized and ignored. If they're resurrected in a later
/// version, then they aren't ignored.
@@ -246,6 +252,50 @@
return contains(v, s);
}
+void configurable_settings::redintegrate_ex_ante
+ (int file_version
+ ,std::string const& name
+ ,std::string & value
+ ) const
+{
+ if(class_version() == file_version)
+ {
+ return;
+ }
+
+ if(0 == file_version)
+ {
+ // Skin names differed prior to the 20080218T1743Z change,
+ // which predated the 'version' attribute.
+ if("skin_filename" == name && contains(value, "xml_notebook"))
+ {
+ value =
+ "xml_notebook.xrc" == value ? "skin.xrc"
+ : "xml_notebook_coli_boli.xrc" == value ?
"skin_coli_boli.xrc"
+ : "xml_notebook_group_carveout.xrc" == value ?
"skin_group_carveout.xrc"
+ : "xml_notebook_private_placement.xrc" == value ?
"skin_reg_d.xrc"
+ : "xml_notebook_single_premium.xrc" == value ?
"skin_single_premium.xrc"
+ : "xml_notebook_variable_annuity.xrc" == value ?
"skin_variable_annuity.xrc"
+ : throw std::runtime_error(value + ": unexpected skin
filename.")
+ ;
+ }
+ }
+}
+
+void configurable_settings::redintegrate_ex_post
+ (int file_version
+ ,std::map<std::string, std::string> const& // detritus_map
+ ,std::list<std::string> const& // residuary_names
+ )
+{
+ if(class_version() == file_version)
+ {
+ return;
+ }
+
+ // Nothing to do for now.
+}
+
// TODO ?? CALCULATION_SUMMARY Address the validation issue:
/// A whitespace-delimited list of columns to be shown on the
Modified: lmi/trunk/configurable_settings.hpp
===================================================================
--- lmi/trunk/configurable_settings.hpp 2010-06-14 11:45:11 UTC (rev 4990)
+++ lmi/trunk/configurable_settings.hpp 2010-06-14 12:59:38 UTC (rev 4991)
@@ -84,7 +84,18 @@
virtual std::string const& xml_root_name() const;
// xml_serializable overrides.
+ virtual void handle_missing_version_attribute() const;
virtual bool is_detritus(std::string const&) const;
+ virtual void redintegrate_ex_ante
+ (int file_version
+ ,std::string const& name
+ ,std::string & value
+ ) const;
+ virtual void redintegrate_ex_post
+ (int file_version
+ ,std::map<std::string, std::string> const& detritus_map
+ ,std::list<std::string> const& residuary_names
+ );
std::string calculation_summary_columns_;
std::string cgi_bin_log_filename_;
Modified: lmi/trunk/configurable_settings_test.cpp
===================================================================
--- lmi/trunk/configurable_settings_test.cpp 2010-06-14 11:45:11 UTC (rev
4990)
+++ lmi/trunk/configurable_settings_test.cpp 2010-06-14 12:59:38 UTC (rev
4991)
@@ -28,9 +28,13 @@
#include "configurable_settings.hpp"
+#include "miscellany.hpp" // ios_out_trunc_binary()
#include "path_utility.hpp" // initialize_filesystem()
#include "test_tools.hpp"
+#include <boost/filesystem/fstream.hpp>
+#include <boost/filesystem/path.hpp>
+
class configurable_settings_test
{
public:
@@ -38,11 +42,13 @@
{
test_normal_usage();
test_writability();
+ test_backward_compatibility();
}
private:
static void test_normal_usage();
static void test_writability();
+ static void test_backward_compatibility();
};
/// Test for gross failure upon instantiation.
@@ -63,6 +69,30 @@
c.xml_serializable<configurable_settings>::save(filename);
}
+/// Test each aspect of backward compatibility:
+/// - missing 'version' attribute
+/// - missing elements
+/// - a withdrawn element
+/// - an obsolete skin name
+
+void configurable_settings_test::test_backward_compatibility()
+{
+ fs::path const filename("eraseme");
+ fs::ofstream ofs(filename, ios_out_trunc_binary());
+ ofs
+ << "<?xml version=\"1.0\"?>\n"
+ << "<configurable_settings>\n"
+ << "<xml_schema_filename>[withdrawn]</xml_schema_filename>\n"
+ <<
"<skin_filename>xml_notebook_private_placement.xrc</skin_filename>\n"
+ << "</configurable_settings>\n"
+ ;
+ ofs.close();
+
+ configurable_settings& c = configurable_settings::instance();
+ c.xml_serializable<configurable_settings>::load(filename);
+ BOOST_TEST_EQUAL("skin_reg_d.xrc", c.skin_filename());
+}
+
int test_main(int, char*[])
{
// Absolute paths require "native" name-checking policy for msw.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [lmi-commits] [4991] Extend backward compatibility to encompass the 20080218T1743Z change,
Greg Chicares <=