[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master 1ab47c0 063/156: Fix definition of integer-va
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master 1ab47c0 063/156: Fix definition of integer-valued variable in PDF illustrations |
Date: |
Tue, 30 Jan 2018 17:22:12 -0500 (EST) |
branch: master
commit 1ab47c08f08919ef93b4d8e7244f13fd13ff18b3
Author: Vadim Zeitlin <address@hidden>
Commit: Vadim Zeitlin <address@hidden>
Fix definition of integer-valued variable in PDF illustrations
Add add_variable() overload for integers and use it instead of wrongly
passing double-valued variables to the existing overload taking bool.
Explicitly delete the overload for double as it can't be used here
because formatting information, required for any floating point value,
is only available at ledger_evaluator level.
---
ledger_pdf_generator_wx.cpp | 21 +++++++++++++++++----
1 file changed, 17 insertions(+), 4 deletions(-)
diff --git a/ledger_pdf_generator_wx.cpp b/ledger_pdf_generator_wx.cpp
index b64d02a..9130b88 100644
--- a/ledger_pdf_generator_wx.cpp
+++ b/ledger_pdf_generator_wx.cpp
@@ -26,6 +26,7 @@
#include "alert.hpp"
#include "assert_lmi.hpp"
#include "authenticity.hpp"
+#include "bourn_cast.hpp"
#include "calendar_date.hpp"
#include "force_linking.hpp"
#include "html.hpp"
@@ -139,11 +140,23 @@ class html_interpolator
add_variable(name, text::from(value));
}
+ void add_variable(std::string const& name, int value)
+ {
+ std::ostringstream oss;
+ oss << value;
+ add_variable(name, oss.str());
+ }
+
void add_variable(std::string const& name, bool value)
{
add_variable(name, std::string(value ? "1" : "0"));
}
+ // Detect, at compile-time, mistaken attempts to add floating point
+ // variables: all those are only available from ledger_evaluator as they
+ // must be formatted correctly.
+ void add_variable(std::string const& name, double value) = delete;
+
// Test a boolean variable: the value must be "0" or "1", which is mapped
// to false or true respectively. Anything else results in an exception.
bool test_variable(std::string const& name) const
@@ -2050,7 +2063,7 @@ class pdf_illustration_regular : public pdf_illustration
add_variable
("MecYearPlus1"
- ,invar.MecYear + 1
+ ,bourn_cast<int>(invar.MecYear) + 1
);
// Variable representing the premium payment frequency with the
@@ -2138,7 +2151,7 @@ class pdf_illustration_regular : public pdf_illustration
add_variable
("LapseYear_Guaranteed_Plus1"
- ,lapse_year_guaruanteed + 1
+ ,bourn_cast<int>(lapse_year_guaruanteed) + 1
);
add_variable
@@ -2148,7 +2161,7 @@ class pdf_illustration_regular : public pdf_illustration
add_variable
("LapseYear_Midpoint_Plus1"
- ,lapse_year_midpoint + 1
+ ,bourn_cast<int>(lapse_year_midpoint) + 1
);
add_variable
@@ -2158,7 +2171,7 @@ class pdf_illustration_regular : public pdf_illustration
add_variable
("LapseYear_Current_Plus1"
- ,lapse_year_current + 1
+ ,bourn_cast<int>(lapse_year_current) + 1
);
// Add all the pages.
- [lmi-commits] [lmi] master 2e4850c 023/156: Implement the rest of "Narrative Summary" page body text, (continued)
- [lmi-commits] [lmi] master 2e4850c 023/156: Implement the rest of "Narrative Summary" page body text, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master c341dbb 108/156: Factor out compliance_tracking template from the footer one, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 76881d8 019/156: Refactor: extra add_body_paragraph() helper, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 08127f1 028/156: Add symbolic constant for the "valign" HTML attribute, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 0d6c7f0 062/156: Get rid of separate wxDC parameter in the code, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master bbada54 084/156: Add image to the columns headings page too, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 3cf5a1c 056/156: Add wx_table_generator::output_super_header(), Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 95e616e 105/156: Add wx_table_generator::columns_count() accessor, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 3f1d437 088/156: Add add_abbreviated_variable() helper, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 118a249 097/156: Add "Column Definitions and Key Terms" page to NASD illustrations, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 1ab47c0 063/156: Fix definition of integer-valued variable in PDF illustrations,
Greg Chicares <=
- [lmi-commits] [lmi] master bb21f4d 077/156: Fix header for composite illustrations, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master d2b2cae 038/156: Change column_headings page to use external template, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 2bb1c91 041/156: Remove unnecessary outer html and body tags, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 1afd45c 040/156: Avoid spurious coding style violation, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 9695e9e 112/156: Create InitAnnLoanDueRate vector in addition to the scalar, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 5f6dc89 131/156: Use string objects for illustration_table_column fields, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master fb01571 035/156: Pass what is being expanded to interpolation function, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master fc6d8b7 034/156: Implement the "Columns Headings" page, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 46788b8 119/156: Start implementing individual private placement illustration kind, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 1287474 114/156: Start private group placement illustration class implementation, Greg Chicares, 2018/01/30