From 07f40bd25442f25c0af948ae1b0dac7fdff1688c Mon Sep 17 00:00:00 2001 From: Jay Berkenbilt Date: Fri, 12 Feb 2021 03:44:12 -0500 Subject: QUtil::double_to_string: trim trailing zeroes with option to disable --- include/qpdf/QPDFObjectHandle.hh | 5 +++++ include/qpdf/QUtil.hh | 9 ++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/qpdf/QPDFObjectHandle.hh b/include/qpdf/QPDFObjectHandle.hh index 4c986af7..41646b79 100644 --- a/include/qpdf/QPDFObjectHandle.hh +++ b/include/qpdf/QPDFObjectHandle.hh @@ -476,6 +476,11 @@ class QPDFObjectHandle static QPDFObjectHandle newReal(std::string const& value); QPDF_DLL static QPDFObjectHandle newReal(double value, int decimal_places = 0); + // ABI: combine with other newReal by adding trim_trailing_zeroes + // above as an optional parameter with a default of true. + QPDF_DLL + static QPDFObjectHandle newReal(double value, int decimal_places, + bool trim_trailing_zeroes); QPDF_DLL static QPDFObjectHandle newName(std::string const& name); QPDF_DLL diff --git a/include/qpdf/QUtil.hh b/include/qpdf/QUtil.hh index 5b1f8aae..769c5fd7 100644 --- a/include/qpdf/QUtil.hh +++ b/include/qpdf/QUtil.hh @@ -47,9 +47,16 @@ namespace QUtil QPDF_DLL std::string int_to_string_base(long long, int base, int length = 0); QPDF_DLL - std::string uint_to_string_base(unsigned long long, int base, int length = 0); + std::string uint_to_string_base(unsigned long long, int base, + int length = 0); QPDF_DLL std::string double_to_string(double, int decimal_places = 0); + // ABI: combine with other double_to_string by adding + // trim_trailing_zeroes above as an optional parameter with a + // default of true. + QPDF_DLL + std::string double_to_string(double, int decimal_places, + bool trim_trailing_zeroes); // These string to number methods throw std::runtime_error on // underflow/overflow. -- cgit v1.2.3-54-g00ecf