Commit 75054c0b9404572f2c1477858fe47a61404b72f5
Committed by
Jay Berkenbilt
1 parent
5b4aba20
Add QPDFObjectHandle::newReal(double)
Showing
4 changed files
with
16 additions
and
0 deletions
include/qpdf/QPDFObjectHandle.hh
| @@ -102,6 +102,8 @@ class QPDFObjectHandle | @@ -102,6 +102,8 @@ class QPDFObjectHandle | ||
| 102 | QPDF_DLL | 102 | QPDF_DLL |
| 103 | static QPDFObjectHandle newReal(std::string const& value); | 103 | static QPDFObjectHandle newReal(std::string const& value); |
| 104 | QPDF_DLL | 104 | QPDF_DLL |
| 105 | + static QPDFObjectHandle newReal(double value); | ||
| 106 | + QPDF_DLL | ||
| 105 | static QPDFObjectHandle newName(std::string const& name); | 107 | static QPDFObjectHandle newName(std::string const& name); |
| 106 | QPDF_DLL | 108 | QPDF_DLL |
| 107 | static QPDFObjectHandle newString(std::string const& str); | 109 | static QPDFObjectHandle newString(std::string const& str); |
libqpdf/QPDFObjectHandle.cc
| @@ -604,6 +604,12 @@ QPDFObjectHandle::newReal(std::string const& value) | @@ -604,6 +604,12 @@ QPDFObjectHandle::newReal(std::string const& value) | ||
| 604 | } | 604 | } |
| 605 | 605 | ||
| 606 | QPDFObjectHandle | 606 | QPDFObjectHandle |
| 607 | +QPDFObjectHandle::newReal(double value) | ||
| 608 | +{ | ||
| 609 | + return QPDFObjectHandle(new QPDF_Real(value)); | ||
| 610 | +} | ||
| 611 | + | ||
| 612 | +QPDFObjectHandle | ||
| 607 | QPDFObjectHandle::newName(std::string const& name) | 613 | QPDFObjectHandle::newName(std::string const& name) |
| 608 | { | 614 | { |
| 609 | return QPDFObjectHandle(new QPDF_Name(name)); | 615 | return QPDFObjectHandle(new QPDF_Name(name)); |
libqpdf/QPDF_Real.cc
| 1 | #include <qpdf/QPDF_Real.hh> | 1 | #include <qpdf/QPDF_Real.hh> |
| 2 | 2 | ||
| 3 | +#include <qpdf/QUtil.hh> | ||
| 4 | + | ||
| 3 | QPDF_Real::QPDF_Real(std::string const& val) : | 5 | QPDF_Real::QPDF_Real(std::string const& val) : |
| 4 | val(val) | 6 | val(val) |
| 5 | { | 7 | { |
| 6 | } | 8 | } |
| 7 | 9 | ||
| 10 | +QPDF_Real::QPDF_Real(double value, int decimal_places) : | ||
| 11 | + val(QUtil::double_to_string(value, decimal_places)) | ||
| 12 | +{ | ||
| 13 | +} | ||
| 14 | + | ||
| 8 | QPDF_Real::~QPDF_Real() | 15 | QPDF_Real::~QPDF_Real() |
| 9 | { | 16 | { |
| 10 | } | 17 | } |
libqpdf/qpdf/QPDF_Real.hh
| @@ -7,6 +7,7 @@ class QPDF_Real: public QPDFObject | @@ -7,6 +7,7 @@ class QPDF_Real: public QPDFObject | ||
| 7 | { | 7 | { |
| 8 | public: | 8 | public: |
| 9 | QPDF_Real(std::string const& val); | 9 | QPDF_Real(std::string const& val); |
| 10 | + QPDF_Real(double value, int decimal_places = 0); | ||
| 10 | virtual ~QPDF_Real(); | 11 | virtual ~QPDF_Real(); |
| 11 | std::string unparse(); | 12 | std::string unparse(); |
| 12 | std::string getVal(); | 13 | std::string getVal(); |