ostreamwrapper.h
Engine/source/persistence/rapidjson/ostreamwrapper.h
Classes:
class
Public Typedefs
BasicOStreamWrapper< std::ostream >
OStreamWrapper
BasicOStreamWrapper< std::wostream >
WOStreamWrapper
Detailed Description
Public Typedefs
typedef BasicOStreamWrapper< std::ostream > OStreamWrapper
typedef BasicOStreamWrapper< std::wostream > WOStreamWrapper
1 2// Tencent is pleased to support the open source community by making RapidJSON available. 3// 4// Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved. 5// 6// Licensed under the MIT License (the "License"); you may not use this file except 7// in compliance with the License. You may obtain a copy of the License at 8// 9// http://opensource.org/licenses/MIT 10// 11// Unless required by applicable law or agreed to in writing, software distributed 12// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 13// CONDITIONS OF ANY KIND, either express or implied. See the License for the 14// specific language governing permissions and limitations under the License. 15 16#ifndef RAPIDJSON_OSTREAMWRAPPER_H_ 17#define RAPIDJSON_OSTREAMWRAPPER_H_ 18 19#include "stream.h" 20#include <iosfwd> 21 22#ifdef __clang__ 23RAPIDJSON_DIAG_PUSH 24RAPIDJSON_DIAG_OFF(padded) 25#endif 26 27RAPIDJSON_NAMESPACE_BEGIN 28 29//! Wrapper of \c std::basic_ostream into RapidJSON's Stream concept. 30/*! 31 The classes can be wrapped including but not limited to: 32 33 - \c std::ostringstream 34 - \c std::stringstream 35 - \c std::wpstringstream 36 - \c std::wstringstream 37 - \c std::ifstream 38 - \c std::fstream 39 - \c std::wofstream 40 - \c std::wfstream 41 42 \tparam StreamType Class derived from \c std::basic_ostream. 43*/ 44 45template <typename StreamType> 46class BasicOStreamWrapper { 47public: 48 typedef typename StreamType::char_type Ch; 49 BasicOStreamWrapper(StreamType& stream) : stream_(stream) {} 50 51 void Put(Ch c) { 52 stream_.put(c); 53 } 54 55 void Flush() { 56 stream_.flush(); 57 } 58 59 // Not implemented 60 char Peek() const { RAPIDJSON_ASSERT(false); return 0; } 61 char Take() { RAPIDJSON_ASSERT(false); return 0; } 62 size_t Tell() const { RAPIDJSON_ASSERT(false); return 0; } 63 char* PutBegin() { RAPIDJSON_ASSERT(false); return 0; } 64 size_t PutEnd(char*) { RAPIDJSON_ASSERT(false); return 0; } 65 66private: 67 BasicOStreamWrapper(const BasicOStreamWrapper&); 68 BasicOStreamWrapper& operator=(const BasicOStreamWrapper&); 69 70 StreamType& stream_; 71}; 72 73typedef BasicOStreamWrapper<std::ostream> OStreamWrapper; 74typedef BasicOStreamWrapper<std::wostream> WOStreamWrapper; 75 76#ifdef __clang__ 77RAPIDJSON_DIAG_POP 78#endif 79 80RAPIDJSON_NAMESPACE_END 81 82#endif // RAPIDJSON_OSTREAMWRAPPER_H_ 83