Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/miloyip/rapidjson.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilipp A. Hartmann <pah@qo.cx>2014-02-28 16:57:13 +0400
committerPhilipp A. Hartmann <pah@qo.cx>2014-06-25 20:09:16 +0400
commit0ccc51fbae6732c2867e261cebfac20f6a9206ef (patch)
tree930ab7ef35cf025a0fc7a8cc2bd47befd53feab1 /include/rapidjson/prettywriter.h
parent60b8c11909986fac47e10e00a895d25d0cb2f1b7 (diff)
Writer: add SetDoublePrecision to control number of significant digits
Writing a double to an OutputStream current prints at most 6 significant digits (according to the C standard). The function SetDoublePrecision(), added to the Writer classes can be used to fluently set the precision, i.e. the number of significant digits to use for writing the double: Writer<...> writer(...); d.Accept(writer.SetDoublePrecision(12));
Diffstat (limited to 'include/rapidjson/prettywriter.h')
-rw-r--r--include/rapidjson/prettywriter.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/include/rapidjson/prettywriter.h b/include/rapidjson/prettywriter.h
index b917d77b..6a7b5e30 100644
--- a/include/rapidjson/prettywriter.h
+++ b/include/rapidjson/prettywriter.h
@@ -26,6 +26,9 @@ public:
PrettyWriter(OutputStream& os, Allocator* allocator = 0, size_t levelDepth = Base::kDefaultLevelDepth) :
Base(os, allocator, levelDepth), indentChar_(' '), indentCharCount_(4) {}
+ //! Overridden for fluent API, see \ref Writer::SetDoublePrecision()
+ PrettyWriter& SetDoublePrecision(int p) { Base::SetDoublePrecision(p); return *this; }
+
//! Set custom indentation.
/*! \param indentChar Character for indentation. Must be whitespace character (' ', '\\t', '\\n', '\\r').
\param indentCharCount Number of indent characters for each indentation level.