Debian Codegraph @

LspCpp/third_party/rapidjson/test/unittest/fwdtest.cpp

raw
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 #include "unittest.h"
16
17 // Using forward declared types here.
18
19 #include "rapidjson/fwd.h"
20
21 #ifdef __GNUC__
22 RAPIDJSON_DIAG_PUSH
23 RAPIDJSON_DIAG_OFF(effc++)
24 #endif
25
26 using namespace rapidjson;
27
28 struct Foo {
29 Foo();
30 ~Foo();
31
32 // encodings.h
33 UTF8<char>* utf8;
34 UTF16<wchar_t>* utf16;
35 UTF16BE<wchar_t>* utf16be;
36 UTF16LE<wchar_t>* utf16le;
37 UTF32<unsigned>* utf32;
38 UTF32BE<unsigned>* utf32be;
39 UTF32LE<unsigned>* utf32le;
40 ASCII<char>* ascii;
41 AutoUTF<unsigned>* autoutf;
42 Transcoder<UTF8<char>, UTF8<char> >* transcoder;
43
44 // allocators.h
45 CrtAllocator* crtallocator;
46 MemoryPoolAllocator<CrtAllocator>* memorypoolallocator;
47
48 // stream.h
49 StringStream* stringstream;
50 InsituStringStream* insitustringstream;
51
52 // stringbuffer.h
53 StringBuffer* stringbuffer;
54
55 // // filereadstream.h
56 // FileReadStream* filereadstream;
57
58 // // filewritestream.h
59 // FileWriteStream* filewritestream;
60
61 // memorybuffer.h
62 MemoryBuffer* memorybuffer;
63
64 // memorystream.h
65 MemoryStream* memorystream;
66
67 // reader.h
68 BaseReaderHandler<UTF8<char>, void>* basereaderhandler;
69 Reader* reader;
70
71 // writer.h
72 Writer<StringBuffer, UTF8<char>, UTF8<char>, CrtAllocator, 0>* writer;
73
74 // prettywriter.h
75 PrettyWriter<StringBuffer, UTF8<char>, UTF8<char>, CrtAllocator, 0>* prettywriter;
76
77 // document.h
78 Value* value;
79 Document* document;
80
81 // pointer.h
82 Pointer* pointer;
83
84 // schema.h
85 SchemaDocument* schemadocument;
86 SchemaValidator* schemavalidator;
87
88 // char buffer[16];
89 };
90
91 // Using type definitions here.
92
93 #include "rapidjson/stringbuffer.h"
94 #include "rapidjson/filereadstream.h"
95 #include "rapidjson/filewritestream.h"
96 #include "rapidjson/memorybuffer.h"
97 #include "rapidjson/memorystream.h"
98 #include "rapidjson/document.h" // -> reader.h
99 #include "rapidjson/writer.h"
100 #include "rapidjson/prettywriter.h"
101 #include "rapidjson/schema.h" // -> pointer.h
102
103 typedef Transcoder<UTF8<>, UTF8<> > TranscoderUtf8ToUtf8;
104 typedef BaseReaderHandler<UTF8<>, void> BaseReaderHandlerUtf8Void;
105
106 Foo::Foo() :
107 // encodings.h
108 utf8(RAPIDJSON_NEW(UTF8<>)),
109 utf16(RAPIDJSON_NEW(UTF16<>)),
110 utf16be(RAPIDJSON_NEW(UTF16BE<>)),
111 utf16le(RAPIDJSON_NEW(UTF16LE<>)),
112 utf32(RAPIDJSON_NEW(UTF32<>)),
113 utf32be(RAPIDJSON_NEW(UTF32BE<>)),
114 utf32le(RAPIDJSON_NEW(UTF32LE<>)),
115 ascii(RAPIDJSON_NEW(ASCII<>)),
116 autoutf(RAPIDJSON_NEW(AutoUTF<unsigned>)),
117 transcoder(RAPIDJSON_NEW(TranscoderUtf8ToUtf8)),
118
119 // allocators.h
120 crtallocator(RAPIDJSON_NEW(CrtAllocator)),
121 memorypoolallocator(RAPIDJSON_NEW(MemoryPoolAllocator<>)),
122
123 // stream.h
124 stringstream(RAPIDJSON_NEW(StringStream)(NULL)),
125 insitustringstream(RAPIDJSON_NEW(InsituStringStream)(NULL)),
126
127 // stringbuffer.h
128 stringbuffer(RAPIDJSON_NEW(StringBuffer)),
129
130 // // filereadstream.h
131 // filereadstream(RAPIDJSON_NEW(FileReadStream)(stdout, buffer, sizeof(buffer))),
132
133 // // filewritestream.h
134 // filewritestream(RAPIDJSON_NEW(FileWriteStream)(stdout, buffer, sizeof(buffer))),
135
136 // memorybuffer.h
137 memorybuffer(RAPIDJSON_NEW(MemoryBuffer)),
138
139 // memorystream.h
140 memorystream(RAPIDJSON_NEW(MemoryStream)(NULL, 0)),
141
142 // reader.h
143 basereaderhandler(RAPIDJSON_NEW(BaseReaderHandlerUtf8Void)),
144 reader(RAPIDJSON_NEW(Reader)),
145
146 // writer.h
147 writer(RAPIDJSON_NEW(Writer<StringBuffer>)),
148
149 // prettywriter.h
150 prettywriter(RAPIDJSON_NEW(PrettyWriter<StringBuffer>)),
151
152 // document.h
153 value(RAPIDJSON_NEW(Value)),
154 document(RAPIDJSON_NEW(Document)),
155
156 // pointer.h
157 pointer(RAPIDJSON_NEW(Pointer)),
158
159 // schema.h
160 schemadocument(RAPIDJSON_NEW(SchemaDocument)(*document)),
161 schemavalidator(RAPIDJSON_NEW(SchemaValidator)(*schemadocument))
162 {
163
164 }
165
166 Foo::~Foo() {
167 // encodings.h
168 RAPIDJSON_DELETE(utf8);
169 RAPIDJSON_DELETE(utf16);
170 RAPIDJSON_DELETE(utf16be);
171 RAPIDJSON_DELETE(utf16le);
172 RAPIDJSON_DELETE(utf32);
173 RAPIDJSON_DELETE(utf32be);
174 RAPIDJSON_DELETE(utf32le);
175 RAPIDJSON_DELETE(ascii);
176 RAPIDJSON_DELETE(autoutf);
177 RAPIDJSON_DELETE(transcoder);
178
179 // allocators.h
180 RAPIDJSON_DELETE(crtallocator);
181 RAPIDJSON_DELETE(memorypoolallocator);
182
183 // stream.h
184 RAPIDJSON_DELETE(stringstream);
185 RAPIDJSON_DELETE(insitustringstream);
186
187 // stringbuffer.h
188 RAPIDJSON_DELETE(stringbuffer);
189
190 // // filereadstream.h
191 // RAPIDJSON_DELETE(filereadstream);
192
193 // // filewritestream.h
194 // RAPIDJSON_DELETE(filewritestream);
195
196 // memorybuffer.h
197 RAPIDJSON_DELETE(memorybuffer);
198
199 // memorystream.h
200 RAPIDJSON_DELETE(memorystream);
201
202 // reader.h
203 RAPIDJSON_DELETE(basereaderhandler);
204 RAPIDJSON_DELETE(reader);
205
206 // writer.h
207 RAPIDJSON_DELETE(writer);
208
209 // prettywriter.h
210 RAPIDJSON_DELETE(prettywriter);
211
212 // document.h
213 RAPIDJSON_DELETE(value);
214 RAPIDJSON_DELETE(document);
215
216 // pointer.h
217 RAPIDJSON_DELETE(pointer);
218
219 // schema.h
220 RAPIDJSON_DELETE(schemadocument);
221 RAPIDJSON_DELETE(schemavalidator);
222 }
223
224 TEST(Fwd, Fwd) {
225 Foo f;
226 }
227
228 #ifdef __GNUC__
229 RAPIDJSON_DIAG_POP
230 #endif