ostreamwrapper.h Source File

ostreamwrapper.h Source File#

Composable Kernel: ostreamwrapper.h Source File
ostreamwrapper.h
Go to the documentation of this file.
1// Tencent is pleased to support the open source community by making RapidJSON available.
2//
3// Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip.
4//
5// Licensed under the MIT License (the "License"); you may not use this file except
6// in compliance with the License. You may obtain a copy of the License at
7//
8// http://opensource.org/licenses/MIT
9//
10// Unless required by applicable law or agreed to in writing, software distributed
11// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
12// CONDITIONS OF ANY KIND, either express or implied. See the License for the
13// specific language governing permissions and limitations under the License.
14
15#ifndef RAPIDJSON_OSTREAMWRAPPER_H_
16#define RAPIDJSON_OSTREAMWRAPPER_H_
17
18#include "stream.h"
19#include <iosfwd>
20
21#ifdef __clang__
22RAPIDJSON_DIAG_PUSH
23RAPIDJSON_DIAG_OFF(padded)
24#endif
25
27
29
43
44template <typename StreamType>
46{
47 public:
48 typedef typename StreamType::char_type Ch;
49 BasicOStreamWrapper(StreamType& stream) : stream_(stream) {}
50
51 void Put(Ch c) { stream_.put(c); }
52
53 void Flush() { stream_.flush(); }
54
55 // Not implemented
56 char Peek() const
57 {
58 RAPIDJSON_ASSERT(false);
59 return 0;
60 }
61 char Take()
62 {
63 RAPIDJSON_ASSERT(false);
64 return 0;
65 }
66 size_t Tell() const
67 {
68 RAPIDJSON_ASSERT(false);
69 return 0;
70 }
71 char* PutBegin()
72 {
73 RAPIDJSON_ASSERT(false);
74 return 0;
75 }
76 size_t PutEnd(char*)
77 {
78 RAPIDJSON_ASSERT(false);
79 return 0;
80 }
81
82 private:
85
86 StreamType& stream_;
87};
88
91
92#ifdef __clang__
93RAPIDJSON_DIAG_POP
94#endif
95
97
98#endif // RAPIDJSON_OSTREAMWRAPPER_H_
Wrapper of std::basic_ostream into RapidJSON's Stream concept.
Definition ostreamwrapper.h:46
BasicOStreamWrapper(StreamType &stream)
Definition ostreamwrapper.h:49
void Flush()
Definition ostreamwrapper.h:53
size_t PutEnd(char *)
Definition ostreamwrapper.h:76
char Take()
Definition ostreamwrapper.h:61
size_t Tell() const
Definition ostreamwrapper.h:66
char Peek() const
Definition ostreamwrapper.h:56
char * PutBegin()
Definition ostreamwrapper.h:71
void Put(Ch c)
Definition ostreamwrapper.h:51
StreamType::char_type Ch
Definition ostreamwrapper.h:48
#define RAPIDJSON_ASSERT(x)
Assertion.
Definition rapidjson.h:451
#define RAPIDJSON_NAMESPACE_BEGIN
provide custom rapidjson namespace (opening expression)
Definition rapidjson.h:121
#define RAPIDJSON_NAMESPACE_END
provide custom rapidjson namespace (closing expression)
Definition rapidjson.h:124
BasicOStreamWrapper< std::wostream > WOStreamWrapper
Definition ostreamwrapper.h:90
BasicOStreamWrapper< std::ostream > OStreamWrapper
Definition ostreamwrapper.h:89