15 #ifndef RAPIDJSON_FILEREADSTREAM_H_
16 #define RAPIDJSON_FILEREADSTREAM_H_
21 RAPIDJSON_NAMESPACE_BEGIN
37 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) {
43 Ch Peek()
const {
return *current_; }
44 Ch Take() { Ch c = *current_; Read();
return c; }
45 size_t Tell()
const {
return count_ +
static_cast<size_t>(current_ - buffer_); }
54 const Ch* Peek4()
const {
55 return (current_ + 4 <= bufferLast_) ? current_ : 0;
60 if (current_ < bufferLast_)
64 readCount_ = fread(buffer_, 1, bufferSize_, fp_);
65 bufferLast_ = buffer_ + readCount_ - 1;
68 if (readCount_ < bufferSize_) {
69 buffer_[readCount_] =
'\0';
86 RAPIDJSON_NAMESPACE_END
88 #endif // RAPIDJSON_FILESTREAM_H_
FileReadStream(std::FILE *fp, char *buffer, size_t bufferSize)
Constructor.
Definition: filereadstream.h:37
File byte stream for input using fread().
Definition: filereadstream.h:27
char Ch
Character type (byte).
Definition: filereadstream.h:29
common definitions and configuration
#define RAPIDJSON_ASSERT(x)
Assertion.
Definition: rapidjson.h:344