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:
authorMilo Yip <miloyip@gmail.com>2014-08-09 17:37:02 +0400
committerMilo Yip <miloyip@gmail.com>2014-08-09 17:37:02 +0400
commit1900b7bacea0d3329cd3ecc7aba4262b4bea8307 (patch)
tree9267ebd471e1eea7f4c1621a855bfd8aa7a70ebc /include
parent0d915644a4cf03ef14ecffe54e6b8cb506fd40e9 (diff)
Remove double precision settings API in Writer
Diffstat (limited to 'include')
-rw-r--r--include/rapidjson/prettywriter.h12
-rw-r--r--include/rapidjson/writer.h48
2 files changed, 2 insertions, 58 deletions
diff --git a/include/rapidjson/prettywriter.h b/include/rapidjson/prettywriter.h
index 02b9420b..d3514684 100644
--- a/include/rapidjson/prettywriter.h
+++ b/include/rapidjson/prettywriter.h
@@ -31,9 +31,6 @@ 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.
@@ -119,15 +116,6 @@ public:
//! Simpler but slower overload.
bool String(const Ch* str) { return String(str, internal::StrLen(str)); }
- //! Overridden for fluent API, see \ref Writer::Double()
- bool Double(double d, int precision) {
- int oldPrecision = Base::GetDoublePrecision();
- SetDoublePrecision(precision);
- bool ret = Double(d);
- SetDoublePrecision(oldPrecision);
- return ret;
- }
-
//@}
protected:
void PrettyPrefix(Type type) {
diff --git a/include/rapidjson/writer.h b/include/rapidjson/writer.h
index af9fea36..9d25b276 100644
--- a/include/rapidjson/writer.h
+++ b/include/rapidjson/writer.h
@@ -43,12 +43,10 @@ public:
\param levelDepth Initial capacity of stack.
*/
Writer(OutputStream& os, Allocator* allocator = 0, size_t levelDepth = kDefaultLevelDepth) :
- os_(&os), level_stack_(allocator, levelDepth * sizeof(Level)),
- doublePrecision_(kDefaultDoublePrecision), hasRoot_(false) {}
+ os_(&os), level_stack_(allocator, levelDepth * sizeof(Level)), hasRoot_(false) {}
Writer(Allocator* allocator = 0, size_t levelDepth = kDefaultLevelDepth) :
- os_(0), level_stack_(allocator, levelDepth * sizeof(Level)),
- doublePrecision_(kDefaultDoublePrecision), hasRoot_(false) {}
+ os_(0), level_stack_(allocator, levelDepth * sizeof(Level)), hasRoot_(false) {}
//! Reset the writer with a new stream.
/*!
@@ -70,7 +68,6 @@ public:
*/
void Reset(OutputStream& os) {
os_ = &os;
- doublePrecision_ = kDefaultDoublePrecision;
hasRoot_ = false;
level_stack_.Clear();
}
@@ -83,21 +80,6 @@ public:
return hasRoot_ && level_stack_.Empty();
}
- //! Set the number of significant digits for \c double values
- /*! When writing a \c double value to the \c OutputStream, the number
- of significant digits is limited to 6 by default.
- \param p maximum number of significant digits (default: 6)
- \return The Writer itself for fluent API.
- */
- Writer& SetDoublePrecision(int p = kDefaultDoublePrecision) {
- if (p < 0) p = kDefaultDoublePrecision; // negative precision is ignored
- doublePrecision_ = p;
- return *this;
- }
-
- //! \see SetDoublePrecision()
- int GetDoublePrecision() const { return doublePrecision_; }
-
/*!@name Implementation of Handler
\see Handler
*/
@@ -112,12 +94,6 @@ public:
//! Writes the given \c double value to the stream
/*!
- The number of significant digits (the precision) to be written
- can be set by \ref SetDoublePrecision() for the Writer:
- \code
- Writer<...> writer(...);
- writer.SetDoublePrecision(12).Double(M_PI);
- \endcode
\param d The value to be written.
\return Whether it is succeed.
*/
@@ -167,23 +143,6 @@ public:
/*! @name Convenience extensions */
//@{
- //! Writes the given \c double value to the stream (explicit precision)
- /*!
- The currently set double precision is ignored in favor of the explicitly
- given precision for this value.
- \see Double(), SetDoublePrecision(), GetDoublePrecision()
- \param d The value to be written
- \param precision The number of significant digits for this value
- \return Whether it is succeeded.
- */
- bool Double(double d, int precision) {
- int oldPrecision = GetDoublePrecision();
- SetDoublePrecision(precision);
- bool ret = Double(d);
- SetDoublePrecision(oldPrecision);
- return ret;
- }
-
//! Simpler but slower overload.
bool String(const Ch* str) { return String(str, internal::StrLen(str)); }
@@ -350,11 +309,8 @@ protected:
OutputStream* os_;
internal::Stack<Allocator> level_stack_;
- int doublePrecision_;
bool hasRoot_;
- static const int kDefaultDoublePrecision = 6;
-
private:
// Prohibit copy constructor & assignment operator.
Writer(const Writer&);