Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
R
rapidjson
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
rapidjson
Commits
4595cc48
Commit
4595cc48
authored
Jul 02, 2018
by
Romain Moret
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename a few internal preprocessor macros to avoid potential naming conflicts
parent
7e68aa0a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
27 deletions
+27
-27
encodings.h
include/rapidjson/encodings.h
+27
-27
No files found.
include/rapidjson/encodings.h
View file @
4595cc48
...
...
@@ -144,9 +144,9 @@ struct UTF8 {
template
<
typename
InputStream
>
static
bool
Decode
(
InputStream
&
is
,
unsigned
*
codepoint
)
{
#define COPY() c = is.Take(); *codepoint = (*codepoint << 6) | (static_cast<unsigned char>(c) & 0x3Fu)
#define TRANS(mask) result &= ((GetRange(static_cast<unsigned char>(c)) & mask) != 0)
#define
TAIL() COPY();
TRANS(0x70)
#define
RAPIDJSON_
COPY() c = is.Take(); *codepoint = (*codepoint << 6) | (static_cast<unsigned char>(c) & 0x3Fu)
#define
RAPIDJSON_
TRANS(mask) result &= ((GetRange(static_cast<unsigned char>(c)) & mask) != 0)
#define
RAPIDJSON_TAIL() RAPIDJSON_COPY(); RAPIDJSON_
TRANS(0x70)
typename
InputStream
::
Ch
c
=
is
.
Take
();
if
(
!
(
c
&
0x80
))
{
*
codepoint
=
static_cast
<
unsigned
char
>
(
c
);
...
...
@@ -161,44 +161,44 @@ struct UTF8 {
}
bool
result
=
true
;
switch
(
type
)
{
case
2
:
TAIL
();
return
result
;
case
3
:
TAIL
();
TAIL
();
return
result
;
case
4
:
COPY
();
TRANS
(
0x50
);
TAIL
();
return
result
;
case
5
:
COPY
();
TRANS
(
0x10
);
TAIL
();
TAIL
();
return
result
;
case
6
:
TAIL
();
TAIL
();
TAIL
();
return
result
;
case
10
:
COPY
();
TRANS
(
0x20
);
TAIL
();
return
result
;
case
11
:
COPY
();
TRANS
(
0x60
);
TAIL
();
TAIL
();
return
result
;
case
2
:
RAPIDJSON_
TAIL
();
return
result
;
case
3
:
RAPIDJSON_TAIL
();
RAPIDJSON_
TAIL
();
return
result
;
case
4
:
RAPIDJSON_COPY
();
RAPIDJSON_TRANS
(
0x50
);
RAPIDJSON_
TAIL
();
return
result
;
case
5
:
RAPIDJSON_COPY
();
RAPIDJSON_TRANS
(
0x10
);
RAPIDJSON_TAIL
();
RAPIDJSON_
TAIL
();
return
result
;
case
6
:
RAPIDJSON_TAIL
();
RAPIDJSON_TAIL
();
RAPIDJSON_
TAIL
();
return
result
;
case
10
:
RAPIDJSON_COPY
();
RAPIDJSON_TRANS
(
0x20
);
RAPIDJSON_
TAIL
();
return
result
;
case
11
:
RAPIDJSON_COPY
();
RAPIDJSON_TRANS
(
0x60
);
RAPIDJSON_TAIL
();
RAPIDJSON_
TAIL
();
return
result
;
default
:
return
false
;
}
#undef COPY
#undef TRANS
#undef TAIL
#undef
RAPIDJSON_
COPY
#undef
RAPIDJSON_
TRANS
#undef
RAPIDJSON_
TAIL
}
template
<
typename
InputStream
,
typename
OutputStream
>
static
bool
Validate
(
InputStream
&
is
,
OutputStream
&
os
)
{
#define COPY() os.Put(c = is.Take())
#define TRANS(mask) result &= ((GetRange(static_cast<unsigned char>(c)) & mask) != 0)
#define
TAIL() COPY();
TRANS(0x70)
#define
RAPIDJSON_
COPY() os.Put(c = is.Take())
#define
RAPIDJSON_
TRANS(mask) result &= ((GetRange(static_cast<unsigned char>(c)) & mask) != 0)
#define
RAPIDJSON_TAIL() RAPIDJSON_COPY(); RAPIDJSON_
TRANS(0x70)
Ch
c
;
COPY
();
RAPIDJSON_
COPY
();
if
(
!
(
c
&
0x80
))
return
true
;
bool
result
=
true
;
switch
(
GetRange
(
static_cast
<
unsigned
char
>
(
c
)))
{
case
2
:
TAIL
();
return
result
;
case
3
:
TAIL
();
TAIL
();
return
result
;
case
4
:
COPY
();
TRANS
(
0x50
);
TAIL
();
return
result
;
case
5
:
COPY
();
TRANS
(
0x10
);
TAIL
();
TAIL
();
return
result
;
case
6
:
TAIL
();
TAIL
();
TAIL
();
return
result
;
case
10
:
COPY
();
TRANS
(
0x20
);
TAIL
();
return
result
;
case
11
:
COPY
();
TRANS
(
0x60
);
TAIL
();
TAIL
();
return
result
;
case
2
:
RAPIDJSON_
TAIL
();
return
result
;
case
3
:
RAPIDJSON_TAIL
();
RAPIDJSON_
TAIL
();
return
result
;
case
4
:
RAPIDJSON_COPY
();
RAPIDJSON_TRANS
(
0x50
);
RAPIDJSON_
TAIL
();
return
result
;
case
5
:
RAPIDJSON_COPY
();
RAPIDJSON_TRANS
(
0x10
);
RAPIDJSON_TAIL
();
RAPIDJSON_
TAIL
();
return
result
;
case
6
:
RAPIDJSON_TAIL
();
RAPIDJSON_TAIL
();
RAPIDJSON_
TAIL
();
return
result
;
case
10
:
RAPIDJSON_COPY
();
RAPIDJSON_TRANS
(
0x20
);
RAPIDJSON_
TAIL
();
return
result
;
case
11
:
RAPIDJSON_COPY
();
RAPIDJSON_TRANS
(
0x60
);
RAPIDJSON_TAIL
();
RAPIDJSON_
TAIL
();
return
result
;
default
:
return
false
;
}
#undef COPY
#undef TRANS
#undef TAIL
#undef
RAPIDJSON_
COPY
#undef
RAPIDJSON_
TRANS
#undef
RAPIDJSON_
TAIL
}
static
unsigned
char
GetRange
(
unsigned
char
c
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment