diff options
author | Philipp A. Hartmann <pah@qo.cx> | 2014-04-01 17:58:29 +0400 |
---|---|---|
committer | Philipp A. Hartmann <pah@qo.cx> | 2014-06-25 20:09:16 +0400 |
commit | c9c2d06b9be04809732accecb81ed6f7658125b8 (patch) | |
tree | c7d411e69f1b66d2d04d54fb164db7a8abdb78d8 /include/rapidjson/prettywriter.h | |
parent | 0ccc51fbae6732c2867e261cebfac20f6a9206ef (diff) |
Writer: add Double(d,precision) for one-shot double output
As proposed in other patches, it is convenient to pass a user-defined
precision for the (programmatic) output of a single double value
to an OutputStream.
This patch adds an additional overload with an explicit precision
argument to the (Pretty)Writer class templates.
Diffstat (limited to 'include/rapidjson/prettywriter.h')
-rw-r--r-- | include/rapidjson/prettywriter.h | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/include/rapidjson/prettywriter.h b/include/rapidjson/prettywriter.h index 6a7b5e30..5b154ad7 100644 --- a/include/rapidjson/prettywriter.h +++ b/include/rapidjson/prettywriter.h @@ -51,6 +51,11 @@ public: PrettyWriter& Int64(int64_t i64) { PrettyPrefix(kNumberType); Base::WriteInt64(i64); return *this; }
PrettyWriter& Uint64(uint64_t u64) { PrettyPrefix(kNumberType); Base::WriteUint64(u64); return *this; }
PrettyWriter& Double(double d) { PrettyPrefix(kNumberType); Base::WriteDouble(d); return *this; }
+ //! Overridden for fluent API, see \ref Writer::Double()
+ PrettyWriter& Double(double d, int precision) {
+ int oldPrecision = Base::GetDoublePrecision();
+ return SetDoublePrecision(precision).Double(d).SetDoublePrecision(oldPrecision);
+ }
PrettyWriter& String(const Ch* str, SizeType length, bool copy = false) {
(void)copy;
|