lmi-commits
[Top][All Lists]
Advanced

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

[lmi-commits] [lmi] master fd235d8 3/4: Prefer if...else if...else for c


From: Greg Chicares
Subject: [lmi-commits] [lmi] master fd235d8 3/4: Prefer if...else if...else for clarity
Date: Wed, 8 Aug 2018 12:20:10 -0400 (EDT)

branch: master
commit fd235d87ad362d0074ec7622827f0ab006b4fe0b
Author: Gregory W. Chicares <address@hidden>
Commit: Gregory W. Chicares <address@hidden>

    Prefer if...else if...else for clarity
    
    See:
      https://lists.nongnu.org/archive/html/lmi/2018-08/msg00002.html
---
 ledger_pdf_generator_wx.cpp | 58 +++++++++++++++++++++++----------------------
 1 file changed, 30 insertions(+), 28 deletions(-)

diff --git a/ledger_pdf_generator_wx.cpp b/ledger_pdf_generator_wx.cpp
index d4069ba..77c23af 100644
--- a/ledger_pdf_generator_wx.cpp
+++ b/ledger_pdf_generator_wx.cpp
@@ -1477,26 +1477,25 @@ class numeric_summary_table_cell
                             : oe_shown
                             ;
 
-                        std::string const variable_name = 
columns[j].variable_name;
-
-                        // Special hack for the dummy columns whose value is 
always
-                        // empty as it's used only as separator.
-                        std::string output_value = variable_name.empty()
-                            ? std::string{}
-                            : interpolate_html.evaluate(variable_name, year - 
1)
-                            ;
-
-                        // The illustration reg calls for values at certain
-                        // durations, and then at one summary age, so change
-                        // beginning of last row from a duration to an age.
-                        if(j == column_policy_year)
+                        std::string output_value;
+                        if(is_last_row && column_policy_year == j)
+                            {
+                            // Other rows are for given durations, but the
+                            // last row is for a given age (typically 70).
+                            std::ostringstream oss;
+                            oss << "Age " << age_last;
+                            output_value = oss.str();
+                            }
+                        else if(columns[j].variable_name.empty())
+                            {
+                            ; // Separator column: use empty string.
+                            }
+                        else
                             {
-                            if(is_last_row)
-                                {
-                                std::ostringstream oss;
-                                oss << "Age " << age_last;
-                                output_value = oss.str();
-                                }
+                            output_value = interpolate_html.evaluate
+                                (columns[j].variable_name
+                                ,year - 1
+                                );
                             }
 
                         if(oe_shown == columns[j].visibility)
@@ -1625,15 +1624,18 @@ class page_with_tabular_report
                         : oe_shown
                         ;
 
-                    std::string const variable_name = columns[j].variable_name;
-
-                    // Special hack for the dummy columns used in some reports,
-                    // whose value is always empty as it's used only as
-                    // separator.
-                    std::string output_value = variable_name.empty()
-                        ? std::string{}
-                        : interpolate_html.evaluate(variable_name, year)
-                        ;
+                    std::string output_value;
+                    if(columns[j].variable_name.empty())
+                        {
+                        ; // Separator column: use empty string.
+                        }
+                    else
+                        {
+                        output_value = interpolate_html.evaluate
+                            (columns[j].variable_name
+                            ,year
+                            );
+                        }
 
                     if(oe_shown == columns[j].visibility)
                         {



reply via email to

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