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

Writer flush api
This commit is contained in:
Milo Yip 2017-03-16 10:36:25 +08:00 committed by GitHub
commit bba388b4fa
2 changed files with 11 additions and 3 deletions

View File

@ -150,7 +150,7 @@ public:
(void)ret;
RAPIDJSON_ASSERT(ret == true);
if (Base::level_stack_.Empty()) // end of json text
Base::os_->Flush();
Base::Flush();
return true;
}
@ -174,7 +174,7 @@ public:
(void)ret;
RAPIDJSON_ASSERT(ret == true);
if (Base::level_stack_.Empty()) // end of json text
Base::os_->Flush();
Base::Flush();
return true;
}

View File

@ -267,6 +267,14 @@ public:
return EndValue(WriteRawValue(json, length));
}
//! Flush the output stream.
/*!
Allows the user to flush the output stream immediately.
*/
void Flush() {
os_->Flush();
}
protected:
//! Information for each nested level
struct Level {
@ -473,7 +481,7 @@ protected:
// Flush the value if it is the top level one.
bool EndValue(bool ret) {
if (RAPIDJSON_UNLIKELY(level_stack_.Empty())) // end of json text
os_->Flush();
Flush();
return ret;
}