[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master d9eaa97 2/4: Revise lingo enumeration for sam
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master d9eaa97 2/4: Revise lingo enumeration for sample products |
Date: |
Sat, 14 Nov 2020 22:03:39 -0500 (EST) |
branch: master
commit d9eaa9722e9b745ae995102b2c79abdfc7d92403
Author: Gregory W. Chicares <gchicares@sbcglobal.net>
Commit: Gregory W. Chicares <gchicares@sbcglobal.net>
Revise lingo enumeration for sample products
Added a new enumerator with the explicit value zero, corresponding to an
empty string, which is important because zero is the default value for
database entities. Removed initializers for other enumerators to show
the effect of such a change: the '.database' and '.lingo' files hold a
different index, but looking up that index in the lingo map yields the
same string.
---
lingo.cpp | 3 ++-
sample.hpp | 9 +++++----
2 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/lingo.cpp b/lingo.cpp
index e78c6f6..09eea1f 100644
--- a/lingo.cpp
+++ b/lingo.cpp
@@ -64,7 +64,8 @@ void lingo::write_lingo_files()
// this map. They decay to integers in the resulting file, which
// can therefore be read without the enumerators being visible.
static std::unordered_map<superior::lingo,std::string> const
enumerative_map
- {{superior::policy_form , "UL32768-NY"}
+ {{superior::empty_string , ""}
+ ,{superior::policy_form , "UL32768-NY"}
,{superior::policy_form_KS_KY, "UL32768-X"}
};
diff --git a/sample.hpp b/sample.hpp
index ebcfdda..7ec3660 100644
--- a/sample.hpp
+++ b/sample.hpp
@@ -45,12 +45,13 @@ namespace superior
/// yes yes specifies underlying type
/// yes no implicitly converts to int
///
-/// Use nondefault initializers just to demonstrate that they work.
-/// Ultimately, enumerator zero will be reserved for an empty string.
+/// Enumerator zero is reserved for an empty string because zero is
+/// the default value for database entities.
enum lingo : int
- {policy_form = 13
- ,policy_form_KS_KY = 0
+ {empty_string = 0
+ ,policy_form
+ ,policy_form_KS_KY
};
} // namespace superior