[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master 08559c3 121/156: Factor out base_suffix() and
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master 08559c3 121/156: Factor out base_suffix() and ir_suffix() functions |
Date: |
Tue, 30 Jan 2018 17:22:27 -0500 (EST) |
branch: master
commit 08559c3a245971b37f160b037ac615a9b2531909
Author: Vadim Zeitlin <address@hidden>
Commit: Vadim Zeitlin <address@hidden>
Factor out base_suffix() and ir_suffix() functions
No real changes, just make these functions, and the enums they are used
with, available for reuse in other code and not only from the basic
illustration table page.
---
ledger_pdf_generator_wx.cpp | 72 +++++++++++++++++++++++----------------------
1 file changed, 37 insertions(+), 35 deletions(-)
diff --git a/ledger_pdf_generator_wx.cpp b/ledger_pdf_generator_wx.cpp
index bc98f9b..f2d2d15 100644
--- a/ledger_pdf_generator_wx.cpp
+++ b/ledger_pdf_generator_wx.cpp
@@ -77,6 +77,39 @@ bool starts_with(std::string const& s, char const* prefix)
return s.compare(0, strlen(prefix), prefix) == 0;
}
+// Helper enums identifying the possible {Guaranteed,Current}{Zero,}
+// combinations.
+enum class base
+ {guaranteed
+ ,current
+ };
+
+enum class interest_rate
+ {zero
+ ,non_zero
+ };
+
+// And functions to retrieve their string representation.
+std::string base_suffix(base guar_or_cur)
+{
+ switch(guar_or_cur)
+ {
+ case base::guaranteed: return "Guaranteed";
+ case base::current: return "Current" ;
+ }
+ throw "Unreachable--unknown base value";
+}
+
+std::string ir_suffix(interest_rate zero_or_not)
+{
+ switch(zero_or_not)
+ {
+ case interest_rate::zero: return "Zero";
+ case interest_rate::non_zero: return "" ;
+ }
+ throw "Unreachable--unknown interest_rate value";
+}
+
// Helper class grouping functions for dealing with interpolating strings
// containing variable references.
class html_interpolator
@@ -2035,16 +2068,6 @@ class page_with_basic_tabular_report : public
page_with_tabular_report
// Output the second super header row which is composed of three
// physical lines.
- enum class base
- {guaranteed
- ,current
- };
-
- enum class interest_rate
- {zero
- ,non_zero
- };
-
// This function outputs all lines of a single header, corresponding to
// the "Guaranteed" or "Current", "Zero" or not, column and returns the
// vertical position below the header.
@@ -2059,31 +2082,10 @@ class page_with_basic_tabular_report : public
page_with_tabular_report
auto y = *pos_y;
- std::string const suffix_short = [=]()
- {
- switch(guar_or_cur)
- {
- case base::guaranteed: return "Guaranteed";
- case base::current: return "Current" ;
- }
- throw "Unreachable--unknown base value";
- }()
- ;
-
- std::string const suffix_full = suffix_short + [=]()
- {
- switch(zero_or_not)
- {
- case interest_rate::zero: return "Zero";
- case interest_rate::non_zero: return "" ;
- }
- throw "Unreachable--unknown interest_rate value";
- }()
- ;
-
-
- auto const header =
- get_two_column_header(suffix_full, suffix_short)
+ auto const header = get_two_column_header
+ (base_suffix(guar_or_cur) + ir_suffix(zero_or_not)
+ ,base_suffix(guar_or_cur)
+ )
;
table.output_super_header
(interpolate_html(header).as_html()
- [lmi-commits] [lmi] master 4250de9 104/156: Add first variant of NASD supplemental page, (continued)
- [lmi-commits] [lmi] master 4250de9 104/156: Add first variant of NASD supplemental page, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 7a1e1e8 025/156: Include the missing <cstring> header, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 8bfb896 109/156: Add NASD illustration first explanatory notes page, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master ea20a31 095/156: Make pdf_illustration dtor virtual, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 61fae89 091/156: Reimplement the contract numbers fragment as an external template, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 0c55621 085/156: Replace trivial PDF page classes with single standard_page one, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master ea2564b 099/156: Split the NASD header template in the upper and lower parts, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master c1bf4a8 032/156: Adjust position of the right hand side of the header manually, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 89b4674 120/156: Add automatic support for multiline super-headers, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 0f885a2 116/156: Define CorpNameAbbrev60 and Insured1Abbrev30 in common code, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 08559c3 121/156: Factor out base_suffix() and ir_suffix() functions,
Greg Chicares <=
- [lmi-commits] [lmi] master 36c84ce 123/156: Add another individual private placement illustration page, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 0ecc8ec 036/156: Add support for partials to our ad hoc Mustache parser, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 6f09722 107/156: Add missing words to the narrative summary continuation page, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 6510601 150/156: Rename a mute variable to avoid gcc -Wshadow warning, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 048ae05 093/156: Start NASD PDF illustration class implementation, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 5ea5c86 101/156: Simplify and correct current PDF DC font handling, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master ec490eb 153/156: Revise and extend some comments in PDF generation code, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 38cab5e 096/156: Make footer template depend on illustration kind, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master d1204c2 111/156: Factor out common parts of render_or_measure_fixed_page_part(), Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master e388f6e 037/156: Add beginning of numeric summary page using an external template, Greg Chicares, 2018/01/30