lmi-commits
[Top][All Lists]
Advanced

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

[lmi-commits] [4832] Replace overloaded mc_str() with a template (thanks


From: Greg Chicares
Subject: [lmi-commits] [4832] Replace overloaded mc_str() with a template (thanks to VS)
Date: Mon, 05 Apr 2010 23:45:22 +0000

Revision: 4832
          http://svn.sv.gnu.org/viewvc/?view=rev&root=lmi&revision=4832
Author:   chicares
Date:     2010-04-05 23:45:21 +0000 (Mon, 05 Apr 2010)
Log Message:
-----------
Replace overloaded mc_str() with a template (thanks to VS)

Modified Paths:
--------------
    lmi/trunk/ChangeLog
    lmi/trunk/group_values.cpp
    lmi/trunk/ihs_basicval.cpp
    lmi/trunk/ledger_invariant.cpp
    lmi/trunk/ledger_variant.cpp
    lmi/trunk/mc_enum_types_aux.cpp
    lmi/trunk/mc_enum_types_aux.hpp

Modified: lmi/trunk/ChangeLog
===================================================================
--- lmi/trunk/ChangeLog 2010-04-05 19:40:52 UTC (rev 4831)
+++ lmi/trunk/ChangeLog 2010-04-05 23:45:21 UTC (rev 4832)
@@ -24792,3 +24792,15 @@
   ihs_basicval.cpp
 Round DCV COI rates; print them with 'idiosyncrasy_dcvq'.
 
+20100405T2345Z <address@hidden> [761]
+
+  group_values.cpp
+  ihs_avdebug.cpp
+  ihs_basicval.cpp
+  ledger.cpp
+  ledger_invariant.cpp
+  ledger_variant.cpp
+  mc_enum_types_aux.cpp
+  mc_enum_types_aux.hpp
+Replace overloaded mc_str() with a template (thanks to VS).
+

Modified: lmi/trunk/group_values.cpp
===================================================================
--- lmi/trunk/group_values.cpp  2010-04-05 19:40:52 UTC (rev 4831)
+++ lmi/trunk/group_values.cpp  2010-04-05 23:45:21 UTC (rev 4832)
@@ -33,19 +33,19 @@
 #include "assert_lmi.hpp"
 #include "emit_ledger.hpp"
 #include "fenv_guard.hpp"
-#include "illustrator.hpp" // assert_consistency()
+#include "illustrator.hpp"       // assert_consistency()
 #include "input.hpp"
 #include "ledger.hpp"
 #include "ledgervalues.hpp"
 #include "materially_equal.hpp"
-#include "mc_enum_types_aux.hpp"
+#include "mc_enum_types_aux.hpp" // mc_str()
 #include "path_utility.hpp"
 #include "progress_meter.hpp"
 #include "timer.hpp"
 #include "value_cast.hpp"
 
-#include <algorithm> // std::max()
-#include <iterator>  // std::back_inserter()
+#include <algorithm>             // std::max()
+#include <iterator>              // std::back_inserter()
 #include <string>
 
 namespace

Modified: lmi/trunk/ihs_basicval.cpp
===================================================================
--- lmi/trunk/ihs_basicval.cpp  2010-04-05 19:40:52 UTC (rev 4831)
+++ lmi/trunk/ihs_basicval.cpp  2010-04-05 23:45:21 UTC (rev 4832)
@@ -48,7 +48,8 @@
 #include "interest_rates.hpp"
 #include "loads.hpp"
 #include "math_functors.hpp"
-#include "miscellany.hpp" // ios_out_trunc_binary()
+#include "mc_enum_types_aux.hpp" // mc_str()
+#include "miscellany.hpp"        // ios_out_trunc_binary()
 #include "mortality_rates.hpp"
 #include "outlay.hpp"
 #include "product_data.hpp"
@@ -57,8 +58,8 @@
 #include "value_cast.hpp"
 
 #include <algorithm>
-#include <cmath>          // std::pow()
-#include <cstring>        // std::strlen(), std::strncmp()
+#include <cmath>                 // std::pow()
+#include <cstring>               // std::strlen(), std::strncmp()
 #include <fstream>
 #include <functional>
 #include <limits>
@@ -446,14 +447,6 @@
     return z;
 }
 
-// To be moved soon.
-
-template<typename T>
-std::string mce_string(T t)
-{
-    return mc_enum<T>(t).str();
-}
-
 /// Initialize 7702 object.
 ///
 /// This function is called unconditionally, even for CVAT cases that
@@ -494,9 +487,9 @@
         oss
             << yare_input_.ProductName
             << '_'
-            << mce_string(yare_input_.Gender)
+            << mc_str(yare_input_.Gender)
             << '_'
-            << mce_string(yare_input_.Smoking)
+            << mc_str(yare_input_.Smoking)
             << ".dcvq"
             << configurable_settings::instance().spreadsheet_file_extension()
             ;

Modified: lmi/trunk/ledger_invariant.cpp
===================================================================
--- lmi/trunk/ledger_invariant.cpp      2010-04-05 19:40:52 UTC (rev 4831)
+++ lmi/trunk/ledger_invariant.cpp      2010-04-05 23:45:21 UTC (rev 4832)
@@ -43,6 +43,7 @@
 #include "ledger_variant.hpp" // TODO ?? For IRRs--prolly don't blong here.
 #include "loads.hpp"
 #include "mc_enum_aux.hpp" // mc_e_vector_to_string_vector()
+#include "mc_enum_types_aux.hpp" // mc_str()
 #include "miscellany.hpp"
 #include "outlay.hpp"
 #include "product_data.hpp"

Modified: lmi/trunk/ledger_variant.cpp
===================================================================
--- lmi/trunk/ledger_variant.cpp        2010-04-05 19:40:52 UTC (rev 4831)
+++ lmi/trunk/ledger_variant.cpp        2010-04-05 23:45:21 UTC (rev 4832)
@@ -33,7 +33,7 @@
 #include "database.hpp" // Used only for initial loan rate.
 #include "dbnames.hpp"  // Used only for initial loan rate.
 #include "interest_rates.hpp"
-#include "mc_enum_types_aux.hpp"
+#include "mc_enum_types_aux.hpp" // mc_str()
 #include "outlay.hpp"
 
 #include <algorithm>

Modified: lmi/trunk/mc_enum_types_aux.cpp
===================================================================
--- lmi/trunk/mc_enum_types_aux.cpp     2010-04-05 19:40:52 UTC (rev 4831)
+++ lmi/trunk/mc_enum_types_aux.cpp     2010-04-05 23:45:21 UTC (rev 4832)
@@ -99,25 +99,18 @@
     return false;
 }
 
-std::string mc_str(mcenum_dbopt z)
+template<typename T>
+std::string mc_str(T t)
 {
-    return mce_dbopt(z).str();
+    return mc_enum<T>(t).str();
 }
 
-std::string mc_str(mcenum_run_basis z)
-{
-    return mce_run_basis(z).str();
-}
-  #include "alert.hpp"
-std::string mc_str(mcenum_state z)
-{
-//    return mce_state(z).str();
+template std::string mc_str(mcenum_dbopt    );
+template std::string mc_str(mcenum_gender   );
+template std::string mc_str(mcenum_run_basis);
+template std::string mc_str(mcenum_smoking  );
+template std::string mc_str(mcenum_state    );
 
-try{
-    return mce_state(z).str();
-} catch(...) {fatal_error() << z << " !" << LMI_FLUSH; throw 0;}
-}
-
 mcenum_state mc_state_from_string(std::string const& s)
 {
     return mce_state(s).value();

Modified: lmi/trunk/mc_enum_types_aux.hpp
===================================================================
--- lmi/trunk/mc_enum_types_aux.hpp     2010-04-05 19:40:52 UTC (rev 4831)
+++ lmi/trunk/mc_enum_types_aux.hpp     2010-04-05 23:45:21 UTC (rev 4832)
@@ -59,14 +59,13 @@
 
 /// Transform a plain enumerator to its string equivalent.
 ///
-/// This is rarely useful, but it's beneficial where it's used--see:
+/// This message:
 ///   http://lists.nongnu.org/archive/html/lmi/2008-08/msg00022.html
-/// Of course, a more general facility could easily be created.
-/// Perhaps these should be written as a template anyway.
+/// explains why this template is explicitly instantiated in the
+/// accompanying TU, and not defined here.
 
-std::string mc_str(mcenum_dbopt);
-std::string mc_str(mcenum_run_basis);
-std::string mc_str(mcenum_state);
+template<typename T>
+std::string mc_str(T);
 
 mcenum_state mc_state_from_string(std::string const&);
 





reply via email to

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