@@ -144,9 +144,9 @@ struct UTF8 {
144
144
145
145
template <typename InputStream>
146
146
static bool Decode (InputStream& is, unsigned * codepoint) {
147
- #define COPY () c = is.Take(); *codepoint = (*codepoint << 6 ) | (static_cast <unsigned char >(c) & 0x3Fu )
148
- #define TRANS (mask ) result &= ((GetRange(static_cast <unsigned char >(c)) & mask) != 0 )
149
- #define TAIL () COPY (); TRANS (0x70 )
147
+ #define RAPIDJSON_COPY () c = is.Take(); *codepoint = (*codepoint << 6 ) | (static_cast <unsigned char >(c) & 0x3Fu )
148
+ #define RAPIDJSON_TRANS (mask ) result &= ((GetRange(static_cast <unsigned char >(c)) & mask) != 0 )
149
+ #define RAPIDJSON_TAIL () RAPIDJSON_COPY (); RAPIDJSON_TRANS (0x70 )
150
150
typename InputStream::Ch c = is.Take ();
151
151
if (!(c & 0x80 )) {
152
152
*codepoint = static_cast <unsigned char >(c);
@@ -161,44 +161,44 @@ struct UTF8 {
161
161
}
162
162
bool result = true ;
163
163
switch (type) {
164
- case 2 : TAIL (); return result;
165
- case 3 : TAIL (); TAIL (); return result;
166
- case 4 : COPY (); TRANS (0x50 ); TAIL (); return result;
167
- case 5 : COPY (); TRANS (0x10 ); TAIL (); TAIL (); return result;
168
- case 6 : TAIL (); TAIL (); TAIL (); return result;
169
- case 10 : COPY (); TRANS (0x20 ); TAIL (); return result;
170
- case 11 : COPY (); TRANS (0x60 ); TAIL (); TAIL (); return result;
164
+ case 2 : RAPIDJSON_TAIL (); return result;
165
+ case 3 : RAPIDJSON_TAIL (); RAPIDJSON_TAIL (); return result;
166
+ case 4 : RAPIDJSON_COPY (); RAPIDJSON_TRANS (0x50 ); RAPIDJSON_TAIL (); return result;
167
+ case 5 : RAPIDJSON_COPY (); RAPIDJSON_TRANS (0x10 ); RAPIDJSON_TAIL (); RAPIDJSON_TAIL (); return result;
168
+ case 6 : RAPIDJSON_TAIL (); RAPIDJSON_TAIL (); RAPIDJSON_TAIL (); return result;
169
+ case 10 : RAPIDJSON_COPY (); RAPIDJSON_TRANS (0x20 ); RAPIDJSON_TAIL (); return result;
170
+ case 11 : RAPIDJSON_COPY (); RAPIDJSON_TRANS (0x60 ); RAPIDJSON_TAIL (); RAPIDJSON_TAIL (); return result;
171
171
default : return false ;
172
172
}
173
- #undef COPY
174
- #undef TRANS
175
- #undef TAIL
173
+ #undef RAPIDJSON_COPY
174
+ #undef RAPIDJSON_TRANS
175
+ #undef RAPIDJSON_TAIL
176
176
}
177
177
178
178
template <typename InputStream, typename OutputStream>
179
179
static bool Validate (InputStream& is, OutputStream& os) {
180
- #define COPY () os.Put(c = is.Take())
181
- #define TRANS (mask ) result &= ((GetRange(static_cast <unsigned char >(c)) & mask) != 0 )
182
- #define TAIL () COPY (); TRANS (0x70 )
180
+ #define RAPIDJSON_COPY () os.Put(c = is.Take())
181
+ #define RAPIDJSON_TRANS (mask ) result &= ((GetRange(static_cast <unsigned char >(c)) & mask) != 0 )
182
+ #define RAPIDJSON_TAIL () RAPIDJSON_COPY (); RAPIDJSON_TRANS (0x70 )
183
183
Ch c;
184
- COPY ();
184
+ RAPIDJSON_COPY ();
185
185
if (!(c & 0x80 ))
186
186
return true ;
187
187
188
188
bool result = true ;
189
189
switch (GetRange (static_cast <unsigned char >(c))) {
190
- case 2 : TAIL (); return result;
191
- case 3 : TAIL (); TAIL (); return result;
192
- case 4 : COPY (); TRANS (0x50 ); TAIL (); return result;
193
- case 5 : COPY (); TRANS (0x10 ); TAIL (); TAIL (); return result;
194
- case 6 : TAIL (); TAIL (); TAIL (); return result;
195
- case 10 : COPY (); TRANS (0x20 ); TAIL (); return result;
196
- case 11 : COPY (); TRANS (0x60 ); TAIL (); TAIL (); return result;
190
+ case 2 : RAPIDJSON_TAIL (); return result;
191
+ case 3 : RAPIDJSON_TAIL (); RAPIDJSON_TAIL (); return result;
192
+ case 4 : RAPIDJSON_COPY (); RAPIDJSON_TRANS (0x50 ); RAPIDJSON_TAIL (); return result;
193
+ case 5 : RAPIDJSON_COPY (); RAPIDJSON_TRANS (0x10 ); RAPIDJSON_TAIL (); RAPIDJSON_TAIL (); return result;
194
+ case 6 : RAPIDJSON_TAIL (); RAPIDJSON_TAIL (); RAPIDJSON_TAIL (); return result;
195
+ case 10 : RAPIDJSON_COPY (); RAPIDJSON_TRANS (0x20 ); RAPIDJSON_TAIL (); return result;
196
+ case 11 : RAPIDJSON_COPY (); RAPIDJSON_TRANS (0x60 ); RAPIDJSON_TAIL (); RAPIDJSON_TAIL (); return result;
197
197
default : return false ;
198
198
}
199
- #undef COPY
200
- #undef TRANS
201
- #undef TAIL
199
+ #undef RAPIDJSON_COPY
200
+ #undef RAPIDJSON_TRANS
201
+ #undef RAPIDJSON_TAIL
202
202
}
203
203
204
204
static unsigned char GetRange (unsigned char c) {
0 commit comments