lmi-commits
[Top][All Lists]
Advanced

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

[lmi-commits] [lmi] master 06d9a8c 5/7: Pass modifiable arguments by ref


From: Greg Chicares
Subject: [lmi-commits] [lmi] master 06d9a8c 5/7: Pass modifiable arguments by reference
Date: Sun, 13 May 2018 19:45:55 -0400 (EDT)

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

    Pass modifiable arguments by reference
    
    Some member functions had 'int*' arguments; others had 'int&'. Now, all
    modifiable integer arguments are passed by reference.
---
 group_quote_pdf_gen_wx.cpp  |  6 +++---
 ledger_pdf_generator_wx.cpp | 32 ++++++++++++++++----------------
 wx_table_generator.cpp      | 36 ++++++++++++++++++------------------
 wx_table_generator.hpp      |  6 +++---
 4 files changed, 40 insertions(+), 40 deletions(-)

diff --git a/group_quote_pdf_gen_wx.cpp b/group_quote_pdf_gen_wx.cpp
index 47e621b..df87f4af 100644
--- a/group_quote_pdf_gen_wx.cpp
+++ b/group_quote_pdf_gen_wx.cpp
@@ -734,7 +734,7 @@ void group_quote_pdf_generator_wx::save(std::string const& 
output_filename)
     output_aggregate_values(pdf_writer, table_gen, &pos_y);
 
     int const y_before_header = pos_y;
-    table_gen.output_header(&pos_y);
+    table_gen.output_header(pos_y);
     int const header_height = pos_y - y_before_header;
 
     int y_after_footer = pos_y;
@@ -765,7 +765,7 @@ void group_quote_pdf_generator_wx::save(std::string const& 
output_filename)
 
     for(auto const& i : rows_)
         {
-        table_gen.output_row(&pos_y, i.output_values);
+        table_gen.output_row(pos_y, i.output_values);
 
         if(last_row_y <= pos_y)
             {
@@ -775,7 +775,7 @@ void group_quote_pdf_generator_wx::save(std::string const& 
output_filename)
             pdf_writer.dc().StartPage();
 
             pos_y = pdf_writer.get_vert_margin();
-            table_gen.output_header(&pos_y);
+            table_gen.output_header(pos_y);
             }
         }
 
diff --git a/ledger_pdf_generator_wx.cpp b/ledger_pdf_generator_wx.cpp
index 69e370f..cef9239 100644
--- a/ledger_pdf_generator_wx.cpp
+++ b/ledger_pdf_generator_wx.cpp
@@ -1390,14 +1390,14 @@ class numeric_summary_table_cell
             ("Guaranteed Values"
             ,column_guar_account_value
             ,column_separator_guar_non_guar
-            ,&y_copy
+            ,y_copy
             ,output_mode
             );
         table_gen.output_super_header
             ("Non-Guaranteed Values"
             ,column_mid_account_value
             ,column_max
-            ,&pos_y
+            ,pos_y
             ,output_mode
             );
 
@@ -1420,7 +1420,7 @@ class numeric_summary_table_cell
             ("Midpoint Values"
             ,column_mid_account_value
             ,column_separator_mid_curr
-            ,&y_copy
+            ,y_copy
             ,output_mode
             );
 
@@ -1428,7 +1428,7 @@ class numeric_summary_table_cell
             ("Current Values"
             ,column_curr_account_value
             ,column_max
-            ,&pos_y
+            ,pos_y
             ,output_mode
             );
 
@@ -1447,7 +1447,7 @@ class numeric_summary_table_cell
             ,output_mode
             );
 
-        table_gen.output_header(&pos_y, output_mode);
+        table_gen.output_header(pos_y, output_mode);
 
         pos_y += table_gen.get_separator_line_height();
         table_gen.output_horz_separator(0, column_max, pos_y, output_mode);
@@ -1517,7 +1517,7 @@ class numeric_summary_table_cell
                             ;
                         }
 
-                    table_gen.output_row(&pos_y, output_values);
+                    table_gen.output_row(pos_y, output_values);
                     break;
                 }
             }
@@ -1644,7 +1644,7 @@ class page_with_tabular_report
                         ;
                     }
 
-                table_gen.output_row(&pos_y, output_values);
+                table_gen.output_row(pos_y, output_values);
 
                 ++year;
                 if(year == year_max)
@@ -1732,7 +1732,7 @@ class page_with_tabular_report
             ,output_mode
             );
 
-        table_gen.output_header(&pos_y, output_mode);
+        table_gen.output_header(pos_y, output_mode);
 
         pos_y += table_gen.get_separator_line_height();
         auto const ncols = get_table_columns().size();
@@ -1828,14 +1828,14 @@ class ill_reg_tabular_detail_page : public 
page_with_tabular_report
             ("Guaranteed Values"
             ,column_guar_account_value
             ,column_dummy_separator
-            ,&pos_y_copy
+            ,pos_y_copy
             ,output_mode
             );
         table_gen.output_super_header
             ("Non-Guaranteed Values"
             ,column_curr_account_value
             ,column_max
-            ,&pos_y
+            ,pos_y
             ,output_mode
             );
 
@@ -2234,7 +2234,7 @@ class page_with_basic_tabular_report : public 
page_with_tabular_report
             ("Using guaranteed charges"
             ,column_guar0_cash_surr_value
             ,column_separator_guar_curr0
-            ,&pos_y
+            ,pos_y
             ,output_mode
             );
 
@@ -2243,7 +2243,7 @@ class page_with_basic_tabular_report : public 
page_with_tabular_report
             ("Using current charges"
             ,column_curr0_cash_surr_value
             ,column_max
-            ,&pos_y
+            ,pos_y
             ,output_mode
             );
 
@@ -2286,7 +2286,7 @@ class page_with_basic_tabular_report : public 
page_with_tabular_report
                     (interpolate_html(header).as_html()
                     ,begin_column
                     ,end_column
-                    ,&y
+                    ,y
                     ,output_mode
                     );
 
@@ -2687,7 +2687,7 @@ class reg_d_individual_irr_base : public 
page_with_tabular_report
             (interpolate_html(header_zero.str()).as_html()
             ,column_zero_cash_surr_value
             ,column_zero_irr_surr_value
-            ,&pos_y
+            ,pos_y
             ,output_mode
             );
 
@@ -2705,7 +2705,7 @@ class reg_d_individual_irr_base : public 
page_with_tabular_report
             (interpolate_html(header_nonzero.str()).as_html()
             ,column_nonzero_cash_surr_value
             ,column_nonzero_irr_surr_value
-            ,&pos_y
+            ,pos_y
             ,output_mode
             );
 
@@ -2854,7 +2854,7 @@ class reg_d_individual_curr : public 
page_with_tabular_report
                 ).as_html()
             ,column_curr_investment_income
             ,column_max
-            ,&pos_y
+            ,pos_y
             ,output_mode
             );
 
diff --git a/wx_table_generator.cpp b/wx_table_generator.cpp
index 4fac20b..72cb4fd 100644
--- a/wx_table_generator.cpp
+++ b/wx_table_generator.cpp
@@ -769,12 +769,12 @@ void wx_table_generator::output_horz_separator
 /// Render the headers at the given position and update it.
 
 void wx_table_generator::output_header
-    (int*                         pos_y
+    (int&                         pos_y
     ,oenum_render_or_only_measure output_mode
     )
 {
     int const anticipated_pos_y =
-          *pos_y
+          pos_y
         + draw_separators_
         + row_height() * max_header_lines_
         ;
@@ -784,7 +784,7 @@ void wx_table_generator::output_header
         case oe_render:
             break;
         case oe_only_measure:
-            *pos_y = anticipated_pos_y;
+            pos_y = anticipated_pos_y;
             return;
         }
 
@@ -822,7 +822,7 @@ void wx_table_generator::output_header
         }
 
     // And output all lines of all column headers.
-    int y_top = *pos_y;
+    int y_top = pos_y;
     int x = 0;
     for(std::size_t line = 0; line < max_header_lines_; ++line)
         {
@@ -831,18 +831,18 @@ void wx_table_generator::output_header
             ,headers_by_line.begin() + (1 + line) * num_columns
             );
         x = left_margin_;
-        do_output_single_row(x, *pos_y, nth_line);
+        do_output_single_row(x, pos_y, nth_line);
         }
 
     // Finally draw the separators above and (a double one) below them.
     if(draw_separators_)
         {
-        do_output_horz_separator(left_margin_, x,  y_top);
-        do_output_horz_separator(left_margin_, x, *pos_y); *pos_y += 1;
-        do_output_horz_separator(left_margin_, x, *pos_y);
+        do_output_horz_separator(left_margin_, x, y_top);
+        do_output_horz_separator(left_margin_, x, pos_y); ++pos_y;
+        do_output_horz_separator(left_margin_, x, pos_y);
         }
 
-    LMI_ASSERT(anticipated_pos_y == *pos_y);
+    LMI_ASSERT(anticipated_pos_y == pos_y);
 }
 
 /// Render a super-header, i.e. a header spanning over several columns. The
@@ -853,19 +853,19 @@ void wx_table_generator::output_super_header
         (std::string const&           header
         ,std::size_t                  begin_column
         ,std::size_t                  end_column
-        ,int*                         pos_y
+        ,int&                         pos_y
         ,oenum_render_or_only_measure output_mode
         )
 {
     std::vector<std::string> const lines(split_into_lines(header));
-    int const anticipated_pos_y = *pos_y + row_height() * lines.size();
+    int const anticipated_pos_y = pos_y + row_height() * lines.size();
 
     switch(output_mode)
         {
         case oe_render:
             break;
         case oe_only_measure:
-            *pos_y = anticipated_pos_y;
+            pos_y = anticipated_pos_y;
             return;
         }
 
@@ -873,7 +873,7 @@ void wx_table_generator::output_super_header
     // but we can reuse the existing text_rect() if we just increase its width
     // by the width of all the extra (i.e. not counting the starting one)
     // columns in this span.
-    auto rect = text_rect(begin_column, *pos_y);
+    auto rect = text_rect(begin_column, pos_y);
     rect.width += do_get_cell_x(end_column) - do_get_cell_x(begin_column + 1);
 
     for(auto const& line : lines)
@@ -881,10 +881,10 @@ void wx_table_generator::output_super_header
         dc_.DrawLabel(line, rect, wxALIGN_CENTER_HORIZONTAL);
 
         rect.y += row_height_;
-        *pos_y += row_height_;
+        pos_y  += row_height_;
         }
 
-    LMI_ASSERT(anticipated_pos_y == *pos_y);
+    LMI_ASSERT(anticipated_pos_y == pos_y);
 }
 
 /// Render a row with the given values at the given position and update it.
@@ -892,16 +892,16 @@ void wx_table_generator::output_super_header
 /// same number of them as the number of columns.
 
 void wx_table_generator::output_row
-    (int*                           pos_y
+    (int&                           pos_y
     ,std::vector<std::string> const values
     )
 {
     int x = left_margin_;
-    do_output_single_row(x, *pos_y, values);
+    do_output_single_row(x, pos_y, values);
 
     if(draw_separators_)
         {
-        do_output_horz_separator(left_margin_, x, *pos_y);
+        do_output_horz_separator(left_margin_, x, pos_y);
         }
 }
 
diff --git a/wx_table_generator.hpp b/wx_table_generator.hpp
index a670065..dd35ed8 100644
--- a/wx_table_generator.hpp
+++ b/wx_table_generator.hpp
@@ -68,7 +68,7 @@ class wx_table_generator
     ~wx_table_generator();
 
     void output_header
-        (int*                         pos_y
+        (int&                         pos_y
         ,oenum_render_or_only_measure output_mode = oe_render
         );
 
@@ -76,11 +76,11 @@ class wx_table_generator
         (std::string const&           header
         ,std::size_t                  begin_column
         ,std::size_t                  end_column
-        ,int*                         pos_y
+        ,int&                         pos_y
         ,oenum_render_or_only_measure output_mode = oe_render
         );
 
-    void output_row(int* pos_y, std::vector<std::string> const values);
+    void output_row(int& pos_y, std::vector<std::string> const values);
 
     void output_highlighted_cell
         (std::size_t        column



reply via email to

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