Class EncodedOutputStream

Synopsis

#include <include/rapidjson/encodedstream.h>

template <typename Encoding, typename OutputByteStream>
class EncodedOutputStream

Description

Output byte stream wrapper with statically bound encoding.

Template Parameters

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

OutputByteStream - Type of input byte stream. For example, FileWriteStream.

Mentioned in

Methods

EncodedOutputStream
Flush
Peek
Put
PutBegin
PutEnd
Take
Tell

Source

Lines 99-125 in include/rapidjson/encodedstream.h.

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

    EncodedOutputStream(OutputByteStream& os, bool putBOM = true) : os_(os) { 
        if (putBOM)
            Encoding::PutBOM(os_);
    }

    void Put(Ch c) { Encoding::Put(os_, c);  }
    void Flush() { os_.Flush(); }

    // Not implemented
    Ch Peek() const { RAPIDJSON_ASSERT(false); return 0;}
    Ch Take() { RAPIDJSON_ASSERT(false); return 0;}
    size_t Tell() const { RAPIDJSON_ASSERT(false);  return 0; }
    Ch* PutBegin() { RAPIDJSON_ASSERT(false); return 0; }
    size_t PutEnd(Ch*) { RAPIDJSON_ASSERT(false); return 0; }

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

    OutputByteStream& os_;
};





Add Discussion as Guest

Log in