15 #ifndef RAPIDJSON_FILEWRITESTREAM_H_
16 #define RAPIDJSON_FILEWRITESTREAM_H_
21 RAPIDJSON_NAMESPACE_BEGIN
31 FileWriteStream(std::FILE* fp,
char* buffer,
size_t bufferSize) : fp_(fp), buffer_(buffer), bufferEnd_(buffer + bufferSize), current_(buffer_) {
36 if (current_ >= bufferEnd_)
42 void PutN(
char c,
size_t n) {
43 size_t avail =
static_cast<size_t>(bufferEnd_ - current_);
45 std::memset(current_, c, avail);
49 avail =
static_cast<size_t>(bufferEnd_ - current_);
53 std::memset(current_, c, n);
59 if (current_ != buffer_) {
60 fwrite(buffer_, 1, static_cast<size_t>(current_ - buffer_), fp_);
74 FileWriteStream(
const FileWriteStream&);
75 FileWriteStream& operator=(
const FileWriteStream&);
89 RAPIDJSON_NAMESPACE_END
91 #endif // RAPIDJSON_FILESTREAM_H_
Wrapper of C file stream for input using fread().
Definition: filewritestream.h:27
char Ch
Character type. Only support char.
Definition: filewritestream.h:29
common definitions and configuration
#define RAPIDJSON_ASSERT(x)
Assertion.
Definition: rapidjson.h:344
void PutN(Stream &stream, Ch c, size_t n)
Put N copies of a character to a stream.
Definition: rapidjson.h:559