lmi
[Top][All Lists]
Advanced

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

[lmi] Why 'continue' here?


From: Greg Chicares
Subject: [lmi] Why 'continue' here?
Date: Tue, 7 Aug 2018 20:56:04 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1

Vadim--This is not urgent, because I believe I've figured it out
below. When you have time...can you remember the reason for this
'continue' in numeric_summary_table_cell::render_or_measure()
on the original 'vz-no-xslfo' branch?

$git blame -MCw -L'^/output_values.j. = oss.str..;/',+2 -- 
ledger_pdf_generator_wx.cpp 
000000000 (Not Committed Yet   2018-08-07 13:28:34 +0000 1494)                  
               output_values[j] = oss.str();
a78b402a8 (Gregory W. Chicares 2018-01-27 07:08:11 +0000 1495)                  
               continue;

$git show a78b402a8
commit a78b402a87d2954de9bc8bf98ecf0ccbe75cb294
Author: Gregory W. Chicares <address@hidden>
Date:   2018-01-27T07:08:11+00:00

    Import remaining new files verbatim from vz-no-xslfo
...
diff --git a/ledger_pdf_generator_wx.cpp b/ledger_pdf_generator_wx.cpp
new file mode 100644
index 00000000..ae6d649c
--- /dev/null
+++ b/ledger_pdf_generator_wx.cpp
@@ -0,0 +1,2940 @@
...
+                case e_output_normal:
+                    for(std::size_t col = 0; col < columns.size(); ++col)
+                        {
+                        std::string const variable_name = 
columns[col].variable_name;
+
+                        // According to regulations, we need to replace the
+                        // policy year in the last row with the age.
+                        if(col == column_policy_year)
+                            {
+                            if(is_last_row)
+                                {
+                                std::ostringstream oss;
+                                oss << "Age " << age_last;
+                                values[col] = oss.str();
+ [WHY 'continue' HERE?]         continue;
+                                }
+                            }
+
+                        // Special hack for the dummy columns whose value is 
always
+                        // empty as it's used only as separator.
+                        values[col] = variable_name.empty()
+                            ? std::string{}
+                            : interpolate_html.evaluate(variable_name, year - 
1)
+                            ;
+                        }
+
+                    table.output_row(&pos_y, values.data());
+                    break;

AFAICT, it serves only to skip the
    interpolate_html.evaluate(variable_name, year - 1)
statement when both of these conditions
    (col == column_policy_year) && (is_last_row)
are true.

Executing that statement:
    interpolate_html.evaluate(variable_name, year - 1)
would be legal--it wouldn't crash, and it's executed successfully
for this variable_name ("PolicyYear") for every row except the
final one.

However, the final row is for a particular age (typically age 70),
which requires special formatting:

   Duration  Policy values...
   --------  ----------------
      10       ...
      20       ...
   Age 70      ...    <-- last row: age instead of duration

and I'm guessing that therefore the intention of the code:

  for(all columns)
      {
      if(special_condition)
          {
          output = special_age_70_string;
          continue;
          }
      output = normal_output;
      }

is simply this:

  for(all columns)
      {
      output = normal_output;
      if(special_condition)
          output = special_age_70_string;
      }

I'll rewrite it that way, because at the bottom of that for-loop
I want to add some code that should be executed on every pass.



reply via email to

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