Class BasicOStreamWrapper

Synopsis

#include <include/rapidjson/ostreamwrapper.h>

template <typename StreamType>
class BasicOStreamWrapper

Description

Wrapper of std::basic_ostream into RapidJSON's Stream concept.

The classes can be wrapped including but not limited to:

  • std::ostringstream
  • std::stringstream
  • std::wpstringstream
  • std::wstringstream
  • std::ifstream
  • std::fstream
  • std::wofstream
  • std::wfstream
Template Parameters

StreamType - Class derived from std::basic_ostream.

Methods

BasicOStreamWrapper
Flush
Peek
Put
PutBegin
PutEnd
Take
Tell

Source

Lines 44-70 in include/rapidjson/ostreamwrapper.h.

template <typename StreamType>
class BasicOStreamWrapper {
public:
    typedef typename StreamType::char_type Ch;
    BasicOStreamWrapper(StreamType& stream) : stream_(stream) {}

    void Put(Ch c) {
        stream_.put(c);
    }

    void Flush() {
        stream_.flush();
    }

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

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

    StreamType& stream_;
};





Add Discussion as Guest

Log in