lmi-commits
[Top][All Lists]
Advanced

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

[lmi-commits] [lmi] master a3b04fc 1/2: Modernize a for statement


From: Greg Chicares
Subject: [lmi-commits] [lmi] master a3b04fc 1/2: Modernize a for statement
Date: Wed, 18 Jan 2017 22:40:51 +0000 (UTC)

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

    Modernize a for statement
    
    * dbnames.xpp: improve documentation
    * database_view.cpp: modernize a for statement
    
    As the improved documentation explains, the first item is a special
    case, which may be identified in various equivalent ways:
             0 == index
       begin() == iterator
      DB_FIRST == (dereferenced iterator).Idx
---
 database_view.cpp |    6 ++----
 dbnames.xpp       |   17 ++++++++++++++++-
 2 files changed, 18 insertions(+), 5 deletions(-)

diff --git a/database_view.cpp b/database_view.cpp
index dae4292..ea5dcdf 100644
--- a/database_view.cpp
+++ b/database_view.cpp
@@ -172,15 +172,13 @@ MultiDimGrid* DatabaseView::CreateGridCtrl(wxWindow* 
parent)
 
 void DatabaseView::SetupControls()
 {
-    std::vector<db_names> const& names = GetDBNames();
     std::map<e_database_key, wxTreeItemId> name_to_id;
 
     wxTreeCtrl& tree_ctrl = tree();
 
-    for(std::size_t i = 0; i < names.size(); ++i)
+    for(auto const& name : GetDBNames())
         {
-        db_names const& name = names[i];
-        if(0 == i)
+        if(DB_FIRST == name.Idx)
             {
             LMI_ASSERT(name.Idx == name.ParentIdx);
             wxTreeItemId id = tree_ctrl.AddRoot
diff --git a/dbnames.xpp b/dbnames.xpp
index 8743334..5ce797a 100644
--- a/dbnames.xpp
+++ b/dbnames.xpp
@@ -19,8 +19,23 @@
 // email: <address@hidden>
 // snail: Chicares, 186 Belle Woods Drive, Glastonbury CT 06033, USA
 
+/// Information used by the GUI database editor.
+///
+/// The db_names::ParentIdx links permit organizing this information
+/// as a tree, corresponding to the database editor's tree control.
+/// Illustrations are concerned only with db_names::Idx values in the
+/// first column, and disregard items in the top two levels of the
+/// tree, i.e., the root (DB_FIRST) and its immediate children, whose
+/// parent is the root.
+///
+/// Physically, the first (root) item must have a parent, although
+/// logically it has none, so its parent is deemed to be itself.
+/// Similarly, it must have a long and a short name, although no end
+/// user can ever see them (because the GUI doesn't pointlessly show
+/// the root node), so they name Him Who Is Not to be Named.
+
 #define DB_NAMES \
-{DB_FIRST,DB_FIRST,"dummy","dummy",}, \
+{DB_FIRST,DB_FIRST,"Hastur","Hastur",}, \
 {DB_Topic_Underwriting,DB_FIRST,"Underwriting","Underwriting types, 
classifications, and restrictions; permissible rate classes; approved 
jurisdictions",}, \
 {DB_MinIssAge,DB_Topic_Underwriting,"MinIssAge","Minimum issue age",}, \
 {DB_MaxIssAge,DB_Topic_Underwriting,"MaxIssAge","Maximum issue age",}, \



reply via email to

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