For encoding detection only.
| 77 | |
| 78 | // For encoding detection only. |
| 79 | const Ch* Peek4() const { |
| 80 | RAPIDJSON_ASSERT(sizeof(Ch) == 1); // Only usable for byte stream. |
| 81 | int i; |
| 82 | bool hasError = false; |
| 83 | for (i = 0; i < 4; ++i) { |
| 84 | typename StreamType::int_type c = stream_.get(); |
| 85 | if (c == StreamType::traits_type::eof()) { |
| 86 | hasError = true; |
| 87 | stream_.clear(); |
| 88 | break; |
| 89 | } |
| 90 | peekBuffer_[i] = static_cast<Ch>(c); |
| 91 | } |
| 92 | for (--i; i >= 0; --i) |
| 93 | stream_.putback(peekBuffer_[i]); |
| 94 | return !hasError ? peekBuffer_ : 0; |
| 95 | } |
| 96 | |
| 97 | private: |
| 98 | BasicIStreamWrapper(const BasicIStreamWrapper&); |