15 #ifndef RAPIDJSON_FILEREADSTREAM_H_ 16 #define RAPIDJSON_FILEREADSTREAM_H_ 23 RAPIDJSON_DIAG_OFF(padded)
24 RAPIDJSON_DIAG_OFF(unreachable-code)
25 RAPIDJSON_DIAG_OFF(missing-noreturn)
44 FileReadStream(std::FILE* fp,
char*
buffer,
size_t bufferSize) : fp_(fp), buffer_(buffer), bufferSize_(bufferSize), bufferLast_(0), current_(buffer_), readCount_(0), count_(0), eof_(false) {
50 Ch Peek()
const {
return *current_; }
51 Ch Take() { Ch c = *current_; Read();
return c; }
52 size_t Tell()
const {
return count_ +
static_cast<size_t>(current_ - buffer_); }
61 const Ch* Peek4()
const {
62 return (current_ + 4 - !eof_ <= bufferLast_) ? current_ : 0;
67 if (current_ < bufferLast_)
71 readCount_ = std::fread(buffer_, 1, bufferSize_, fp_);
72 bufferLast_ = buffer_ + readCount_ - 1;
75 if (readCount_ < bufferSize_) {
76 buffer_[readCount_] =
'\0';
99 #endif // RAPIDJSON_FILESTREAM_H_ #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
char Ch
Character type (byte).
Definition: filereadstream.h:36
File byte stream for input using fread().
Definition: filereadstream.h:34
#define RAPIDJSON_NAMESPACE_END
provide custom rapidjson namespace (closing expression)
Definition: rapidjson.h:124
FileReadStream(std::FILE *fp, char *buffer, size_t bufferSize)
Constructor.
Definition: filereadstream.h:44
#define RAPIDJSON_ASSERT(x)
Assertion.
Definition: rapidjson.h:437