Commit bba388b4 authored by Milo Yip's avatar Milo Yip Committed by GitHub

Merge pull request #896 from StilesCrisis/writer-flush-api

Writer flush api
parents 465fab45 31c6c50a
...@@ -150,7 +150,7 @@ public: ...@@ -150,7 +150,7 @@ public:
(void)ret; (void)ret;
RAPIDJSON_ASSERT(ret == true); RAPIDJSON_ASSERT(ret == true);
if (Base::level_stack_.Empty()) // end of json text if (Base::level_stack_.Empty()) // end of json text
Base::os_->Flush(); Base::Flush();
return true; return true;
} }
...@@ -174,7 +174,7 @@ public: ...@@ -174,7 +174,7 @@ public:
(void)ret; (void)ret;
RAPIDJSON_ASSERT(ret == true); RAPIDJSON_ASSERT(ret == true);
if (Base::level_stack_.Empty()) // end of json text if (Base::level_stack_.Empty()) // end of json text
Base::os_->Flush(); Base::Flush();
return true; return true;
} }
......
...@@ -267,6 +267,14 @@ public: ...@@ -267,6 +267,14 @@ public:
return EndValue(WriteRawValue(json, length)); return EndValue(WriteRawValue(json, length));
} }
//! Flush the output stream.
/*!
Allows the user to flush the output stream immediately.
*/
void Flush() {
os_->Flush();
}
protected: protected:
//! Information for each nested level //! Information for each nested level
struct Level { struct Level {
...@@ -473,7 +481,7 @@ protected: ...@@ -473,7 +481,7 @@ protected:
// Flush the value if it is the top level one. // Flush the value if it is the top level one.
bool EndValue(bool ret) { bool EndValue(bool ret) {
if (RAPIDJSON_UNLIKELY(level_stack_.Empty())) // end of json text if (RAPIDJSON_UNLIKELY(level_stack_.Empty())) // end of json text
os_->Flush(); Flush();
return ret; return ret;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment