lmi-commits
[Top][All Lists]
Advanced

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

[lmi-commits] [lmi] master 8c5be11 128/156: Use proper types for get_two


From: Greg Chicares
Subject: [lmi-commits] [lmi] master 8c5be11 128/156: Use proper types for get_two_column_header() parameters
Date: Tue, 30 Jan 2018 17:22:30 -0500 (EST)

branch: master
commit 8c5be1166f28373c121eb56070379a52041ffe9e
Author: Vadim Zeitlin <address@hidden>
Commit: Vadim Zeitlin <address@hidden>

    Use proper types for get_two_column_header() parameters
    
    Don't just pass two string parameters to this function as it was too
    easy to exchange their order accidentally, but use typed parameters
    instead.
    
    This makes the code slightly more verbose, but safer.
---
 ledger_pdf_generator_wx.cpp | 50 ++++++++++++++++++++++++++++-----------------
 1 file changed, 31 insertions(+), 19 deletions(-)

diff --git a/ledger_pdf_generator_wx.cpp b/ledger_pdf_generator_wx.cpp
index 6c9e460..a75d59d 100644
--- a/ledger_pdf_generator_wx.cpp
+++ b/ledger_pdf_generator_wx.cpp
@@ -1994,13 +1994,12 @@ class page_with_basic_tabular_report : public 
page_with_tabular_report
     // contain {{variables}} and also can be multiline but, if so, it must have
     // the same number of lines for all input arguments.
     //
-    // The suffix_xxx arguments can be used to construct the full name of the
-    // variable appropriate for the current column pair: the short one is
-    // either "Guaranteed" or "Current" while the full one also includes "Zero"
-    // for the column pairs using zero interest-rate assumption.
+    // The base and interest_rate arguments can be used to construct the full
+    // name of the variable appropriate for the current column pair, with the
+    // help of base_suffix() and ir_suffix() functions.
     virtual std::string get_two_column_header
-        (std::string const& suffix_full
-        ,std::string const& suffix_short
+        (base          guar_or_cur
+        ,interest_rate zero_or_not
         ) const = 0;
 
     enum
@@ -2108,10 +2107,9 @@ class page_with_basic_tabular_report : public 
page_with_tabular_report
                 auto y = *pos_y;
 
                 auto const header = get_two_column_header
-                    (base_suffix(guar_or_cur) + ir_suffix(zero_or_not)
-                    ,base_suffix(guar_or_cur)
-                    )
-                    ;
+                    (guar_or_cur
+                    ,zero_or_not
+                    );
                 table.output_super_header
                     (interpolate_html(header).as_html()
                     ,begin_column
@@ -2166,17 +2164,25 @@ class nasd_basic : public page_with_basic_tabular_report
     }
 
     std::string get_two_column_header
-        (std::string const& suffix_full
-        ,std::string const& suffix_short
+        (base          guar_or_cur
+        ,interest_rate zero_or_not
         ) const override
     {
         std::ostringstream oss;
         oss
-            << "{{InitAnnSepAcctGrossInt_" << suffix_full << "}} "
+            << "{{InitAnnSepAcctGrossInt_"
+            << base_suffix(guar_or_cur)
+            << ir_suffix(zero_or_not)
+            << "}} "
             << "Assumed Sep Acct\n"
             << "Gross Rate* "
-            << "({{InitAnnSepAcctNetInt_" << suffix_full << "}} net)\n"
-            << "{{InitAnnGenAcctInt_" << suffix_short << "}} GPA rate"
+            << "({{InitAnnSepAcctNetInt_"
+            << base_suffix(guar_or_cur)
+            << ir_suffix(zero_or_not)
+            << "}} net)\n"
+            << "{{InitAnnGenAcctInt_"
+            << base_suffix(guar_or_cur)
+            << "}} GPA rate"
             ;
         return oss.str();
     }
@@ -2390,15 +2396,21 @@ class reg_d_group_basic : public 
page_with_basic_tabular_report
     }
 
     std::string get_two_column_header
-        (std::string const& suffix_full
-        ,std::string const& suffix_short
+        (base          guar_or_cur
+        ,interest_rate zero_or_not
         ) const override
     {
         std::ostringstream oss;
         oss
-            << "{{InitAnnSepAcctGrossInt_" << suffix_full << "}} "
+            << "{{InitAnnSepAcctGrossInt_"
+            << base_suffix(guar_or_cur)
+            << ir_suffix(zero_or_not)
+            << "}} "
             << "Hypothetical Gross\n"
-            << "Return ({{InitAnnSepAcctNetInt_" << suffix_full << "}} net)"
+            << "Return ({{InitAnnSepAcctNetInt_"
+            << base_suffix(guar_or_cur)
+            << ir_suffix(zero_or_not)
+            << "}} net)"
             ;
         return oss.str();
     }



reply via email to

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