Class EncodedInputStream

Synopsis

#include <include/rapidjson/encodedstream.h>

template <typename Encoding, typename InputByteStream>
class EncodedInputStream

Description

Input byte stream wrapper with a statically bound encoding.

Template Parameters

Encoding - The interpretation of encoding of the stream. Either UTF8, UTF16LE, UTF16BE, UTF32LE, UTF32BE.

InputByteStream - Type of input byte stream. For example, FileReadStream.

Methods

EncodedInputStream
Flush
Peek
Put
PutBegin
PutEnd
Take
Tell

Source

Lines 38-64 in include/rapidjson/encodedstream.h.

template <typename Encoding, typename InputByteStream>
class EncodedInputStream {
    RAPIDJSON_STATIC_ASSERT(sizeof(typename InputByteStream::Ch) == 1);
public:
    typedef typename Encoding::Ch Ch;

    EncodedInputStream(InputByteStream& is) : is_(is) { 
        current_ = Encoding::TakeBOM(is_);
    }

    Ch Peek() const { return current_; }
    Ch Take() { Ch c = current_; current_ = Encoding::Take(is_); return c; }
    size_t Tell() const { return is_.Tell(); }

    // Not implemented
    void Put(Ch) { RAPIDJSON_ASSERT(false); }
    void Flush() { RAPIDJSON_ASSERT(false); } 
    Ch* PutBegin() { RAPIDJSON_ASSERT(false); return 0; }
    size_t PutEnd(Ch*) { RAPIDJSON_ASSERT(false); return 0; }

private:
    EncodedInputStream(const EncodedInputStream&);
    EncodedInputStream& operator=(const EncodedInputStream&);

    InputByteStream& is_;
    Ch current_;
};





Add Discussion as Guest

Log in