15 #ifndef RAPIDJSON_FILEWRITESTREAM_H_ 16 #define RAPIDJSON_FILEWRITESTREAM_H_ 23 RAPIDJSON_DIAG_OFF(unreachable-code)
36 FileWriteStream(std::FILE* fp,
char*
buffer,
size_t bufferSize) : fp_(fp), buffer_(buffer), bufferEnd_(buffer + bufferSize), current_(buffer_) {
41 if (current_ >= bufferEnd_)
47 void PutN(
char c,
size_t n) {
48 size_t avail =
static_cast<size_t>(bufferEnd_ - current_);
50 std::memset(current_, c, avail);
54 avail =
static_cast<size_t>(bufferEnd_ - current_);
58 std::memset(current_, c, n);
64 if (current_ != buffer_) {
65 size_t result = std::fwrite(buffer_, 1, static_cast<size_t>(current_ - buffer_), fp_);
66 if (result < static_cast<size_t>(current_ - buffer_)) {
104 #endif // RAPIDJSON_FILESTREAM_H_ char Ch
Character type. Only support char.
Definition: filewritestream.h:34
#define RAPIDJSON_NAMESPACE_BEGIN
provide custom rapidjson namespace (opening expression)
Definition: rapidjson.h:121
A contiguous memory buffer with an optional growing ability.
Definition: core.h:778
#define RAPIDJSON_NAMESPACE_END
provide custom rapidjson namespace (closing expression)
Definition: rapidjson.h:124
Wrapper of C file stream for output using fwrite().
Definition: filewritestream.h:32
#define RAPIDJSON_ASSERT(x)
Assertion.
Definition: rapidjson.h:437