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)
28 RAPIDJSON_NAMESPACE_BEGIN
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';
93 RAPIDJSON_NAMESPACE_END
99 #endif // RAPIDJSON_FILESTREAM_H_