lmi-commits
[Top][All Lists]
Advanced

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

[lmi-commits] [lmi] master 784ccff 1/4: Prefer 'n_'- prefix for "number


From: Greg Chicares
Subject: [lmi-commits] [lmi] master 784ccff 1/4: Prefer 'n_'- prefix for "number of"
Date: Wed, 23 May 2018 12:25:26 -0400 (EDT)

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

    Prefer 'n_'- prefix for "number of"
    
    Generally changed '\<num_' prefixes to the shorter 'n_' that is already
    widely used throughout lmi.
    
    In 'input_sequence_entry.cpp', changed this:
        int const num_intervals = intervals.size();
    which meant "number of intervals", but not this:
        int num_i = duration_num_field(i).GetValue();
    which means "numerical duration value in the ith field".
    
    Did not change 'rate_table*.cpp', which is a standalone utility suite
    independent of the production system with its own self-consistent style.
---
 group_quote_pdf_gen_wx.cpp |  4 ++--
 input_sequence_entry.cpp   |  4 ++--
 main_wx_test.cpp           |  4 ++--
 miscellany.cpp             | 10 +++++-----
 wx_table_generator.cpp     | 40 ++++++++++++++++++++--------------------
 wx_test_paste_census.cpp   |  8 ++++----
 6 files changed, 35 insertions(+), 35 deletions(-)

diff --git a/group_quote_pdf_gen_wx.cpp b/group_quote_pdf_gen_wx.cpp
index a7c1045..93a06e5 100644
--- a/group_quote_pdf_gen_wx.cpp
+++ b/group_quote_pdf_gen_wx.cpp
@@ -1082,7 +1082,7 @@ void group_quote_pdf_generator_wx::output_aggregate_values
 
     for(int col = e_first_totalled_column; col < e_col_max; ++col)
         {
-        int const num_dec =
+        int const n_dec =
             ((e_col_basic_face_amount           == col) ? 0
             :(e_col_basic_premium               == col) ? 2
             :(e_col_supplemental_face_amount    == col) ? 0
@@ -1091,7 +1091,7 @@ void group_quote_pdf_generator_wx::output_aggregate_values
             :(e_col_total_premium               == col) ? 2
             :throw std::logic_error("Invalid column type.")
             );
-        std::pair<int,oenum_format_style> const f(num_dec, oe_format_normal);
+        std::pair<int,oenum_format_style> const f(n_dec, oe_format_normal);
 
         table_gen.output_highlighted_cell
             (col
diff --git a/input_sequence_entry.cpp b/input_sequence_entry.cpp
index 0f6e2e9..496f385 100644
--- a/input_sequence_entry.cpp
+++ b/input_sequence_entry.cpp
@@ -427,9 +427,9 @@ void InputSequenceEditor::sequence(InputSequence const& s)
         }
 
     std::vector<ValueInterval> const& intervals = s.intervals();
-    int const num_intervals = intervals.size();
+    int const n_intervals = intervals.size();
 
-    for(int i = 0; i < num_intervals; ++i)
+    for(int i = 0; i < n_intervals; ++i)
         {
         ValueInterval const& data = intervals[i];
 
diff --git a/main_wx_test.cpp b/main_wx_test.cpp
index 4f735f9..1da9e77 100644
--- a/main_wx_test.cpp
+++ b/main_wx_test.cpp
@@ -587,8 +587,8 @@ wxWindow* wx_test_focus_controller_child(MvcController& 
dialog, char const* name
             {
             // We found the notebook, now we can use it to make the page
             // containing the target window current.
-            size_t const num_pages = book->GetPageCount();
-            for(size_t n = 0; n < num_pages; n++)
+            size_t const n_pages = book->GetPageCount();
+            for(size_t n = 0; n < n_pages; n++)
                 {
                 if(book->GetPage(n) == maybe_page)
                     {
diff --git a/miscellany.cpp b/miscellany.cpp
index 9513cff..1978fb1 100644
--- a/miscellany.cpp
+++ b/miscellany.cpp
@@ -314,20 +314,20 @@ int page_count
     int const used_per_page = groups_per_page * rows_per_group;
 
     // Finally determine how many pages are needed to show all the rows.
-    int num_pages = (total_rows + used_per_page - 1) / used_per_page;
+    int n_pages = (total_rows + used_per_page - 1) / used_per_page;
 
     // The last page may not be needed if all the rows on it can fit into the
     // remaining space, too small for a full group, but perhaps sufficient for
     // these rows, in the last by one page.
-    if(1 < num_pages)
+    if(1 < n_pages)
         {
-        auto const rows_on_last_page = total_rows - (num_pages - 1) * 
used_per_page;
+        auto const rows_on_last_page = total_rows - (n_pages - 1) * 
used_per_page;
         auto const free_rows = rows_per_page - groups_per_page * 
(rows_per_group + 1);
         if(rows_on_last_page <= free_rows)
             {
-            num_pages--;
+            n_pages--;
             }
         }
 
-    return num_pages;
+    return n_pages;
 }
diff --git a/wx_table_generator.cpp b/wx_table_generator.cpp
index 0882b8d..857053d 100644
--- a/wx_table_generator.cpp
+++ b/wx_table_generator.cpp
@@ -352,7 +352,7 @@ wxRect wx_table_generator::text_rect(std::size_t column, 
int y)
 void wx_table_generator::compute_column_widths()
 {
     // Number of non-hidden columns.
-    int num_columns = 0;
+    int n_columns = 0;
 
     // Number of non-hidden elastic columns.
     //
@@ -363,7 +363,7 @@ void wx_table_generator::compute_column_widths()
     // has been allocated to each column, any excess width left over
     // is to be distributed among such elastic columns only:
     // i.e., they (and only they) are to be "expanded".
-    int num_expand = 0;
+    int n_expand = 0;
 
     // Total width of all non-hidden inelastic columns.
     // The width of each inelastic column reflects:
@@ -385,11 +385,11 @@ void wx_table_generator::compute_column_widths()
             continue;
             }
 
-        num_columns++;
+        n_columns++;
 
         if(i.is_elastic())
             {
-            num_expand++;
+            n_expand++;
             }
         else
             {
@@ -411,13 +411,13 @@ void wx_table_generator::compute_column_widths()
         // columns, so the column-fitting problem is overconstrained.
         // Therefore, don't even try reducing margins if there are any
         // elastic columns.
-        if(!num_expand)
+        if(!n_expand)
             {
 // Also calculate the number of pixels by which it overflows for each column
             // We need to round up in division here to be sure that all columns
             // fit into the available width.
             auto const overflow_per_column =
-                (overflow + num_columns - 1) / num_columns;
+                (overflow + n_columns - 1) / n_columns;
 // Now determine whether reducing the margins will make the table fit.
 // If that works, then do it; else don't do it, and print a warning.
 //
@@ -446,7 +446,7 @@ void wx_table_generator::compute_column_widths()
 // condition to something like:
 //    overflow_per_column <= column_margin_ - 4 // two pixels on each side
 //    overflow_per_column <= column_margin_ - 2 // one pixel on each side
-                auto underflow = overflow_per_column * num_columns - overflow;
+                auto underflow = overflow_per_column * n_columns - overflow;
 
                 for(auto& i : all_columns_)
                     {
@@ -496,12 +496,12 @@ void wx_table_generator::compute_column_widths()
 
         // PDF !! Before release, consider showing less information here.
         warning()
-            << "Not enough space for all " << num_columns << " columns."
+            << "Not enough space for all " << n_columns << " columns."
             << "\nPrintable width is " << total_width_ << " points."
-            << "\nData alone require " << total_inelastic_width - 2 * 
column_margin() * num_columns
+            << "\nData alone require " << total_inelastic_width - 2 * 
column_margin() * n_columns
             << " points without any margins for legibility."
             << "\nColumn margins of " << column_margin() << " points on both 
sides"
-            << " would take up " << 2 * column_margin() * num_columns << " 
additional points."
+            << " would take up " << 2 * column_margin() * n_columns << " 
additional points."
             << "\nFor reference:"
             << "\n'M' is " << dc_.GetTextExtent("M").x << " points wide."
             << "\n'N' is " << dc_.GetTextExtent("N").x << " points wide."
@@ -532,10 +532,10 @@ void wx_table_generator::compute_column_widths()
     // pixel available for elastic columns and they would all
     // in effect be dropped; again, in the problem domain, that would
     // actually be preferable to failing to produce any output.
-    if(num_expand)
+    if(n_expand)
         {
         int const per_expand
-            = (total_width_ - total_inelastic_width + num_expand - 1) / 
num_expand;
+            = (total_width_ - total_inelastic_width + n_expand - 1) / n_expand;
 
         for(auto& i : all_columns_)
             {
@@ -568,8 +568,8 @@ void wx_table_generator::do_output_single_row
         do_output_vert_separator(pos_x, y_top, pos_y);
         }
 
-    std::size_t const num_columns = all_columns().size();
-    for(std::size_t col = 0; col < num_columns; ++col)
+    std::size_t const n_columns = all_columns().size();
+    for(std::size_t col = 0; col < n_columns; ++col)
         {
         column_info const& ci = all_columns().at(col);
         if(ci.is_hidden())
@@ -734,9 +734,9 @@ void wx_table_generator::output_headers
     // Split headers in single lines and fill up the entire columns*lines 2D
     // matrix, using empty strings for the headers with less than the maximal
     // number of lines.
-    std::size_t const num_columns = all_columns().size();
-    std::vector<std::string> headers_by_line(max_header_lines_ * num_columns);
-    for(std::size_t col = 0; col < num_columns; ++col)
+    std::size_t const n_columns = all_columns().size();
+    std::vector<std::string> headers_by_line(max_header_lines_ * n_columns);
+    for(std::size_t col = 0; col < n_columns; ++col)
         {
         column_info const& ci = all_columns().at(col);
         if(ci.is_hidden())
@@ -752,7 +752,7 @@ void wx_table_generator::output_headers
         for(std::size_t line = 0; line < lines.size(); ++line)
             {
             headers_by_line.at
-                ((first_line + line) * num_columns + col
+                ((first_line + line) * n_columns + col
                 ) = lines.at(line);
             }
         }
@@ -763,8 +763,8 @@ void wx_table_generator::output_headers
     for(std::size_t line = 0; line < max_header_lines_; ++line)
         {
         std::vector<std::string> const nth_line
-            (headers_by_line.begin() +      line  * num_columns
-            ,headers_by_line.begin() + (1 + line) * num_columns
+            (headers_by_line.begin() +      line  * n_columns
+            ,headers_by_line.begin() + (1 + line) * n_columns
             );
         x = left_margin_;
         do_output_single_row(x, pos_y, nth_line);
diff --git a/wx_test_paste_census.cpp b/wx_test_paste_census.cpp
index 04005ff..17238f7 100644
--- a/wx_test_paste_census.cpp
+++ b/wx_test_paste_census.cpp
@@ -124,8 +124,8 @@ void check_list_columns
 {
     std::set<std::string> remaining(expected.begin(), expected.end());
 
-    unsigned int const num_columns = dvc->GetColumnCount();
-    for(unsigned int n = 0; n < num_columns; ++n)
+    unsigned int const n_columns = dvc->GetColumnCount();
+    for(unsigned int n = 0; n < n_columns; ++n)
         {
         std::string const title = dvc->GetColumn(n)->GetTitle().ToStdString();
         LMI_ASSERT_WITH_MSG
@@ -152,8 +152,8 @@ unsigned int find_model_column_by_title
     ,std::string const& title
     )
 {
-    unsigned int const num_columns = dvc->GetColumnCount();
-    for(unsigned int n = 0; n < num_columns; ++n)
+    unsigned int const n_columns = dvc->GetColumnCount();
+    for(unsigned int n = 0; n < n_columns; ++n)
         {
         wxDataViewColumn const* column = dvc->GetColumn(n);
         if(column->GetTitle().ToStdString() == title)



reply via email to

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