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
b8b7dfed
Commit
b8b7dfed
authored
Jan 30, 2016
by
Milo Yip
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix partial specialization issue
parent
ed12665f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
28 deletions
+31
-28
schema.h
include/rapidjson/schema.h
+31
-28
No files found.
include/rapidjson/schema.h
View file @
b8b7dfed
...
...
@@ -1249,6 +1249,36 @@ private:
bool
exclusiveMaximum_
;
};
template
<
typename
Stack
,
typename
Ch
>
struct
TokenHelper
{
RAPIDJSON_FORCEINLINE
static
void
AppendIndexToken
(
Stack
&
documentStack
,
SizeType
index
)
{
*
documentStack
.
template
Push
<
Ch
>
()
=
'/'
;
char
buffer
[
21
];
size_t
length
=
static_cast
<
size_t
>
((
sizeof
(
SizeType
)
==
4
?
u32toa
(
index
,
buffer
)
:
u64toa
(
index
,
buffer
))
-
buffer
);
for
(
size_t
i
=
0
;
i
<
length
;
i
++
)
*
documentStack
.
template
Push
<
Ch
>
()
=
buffer
[
i
];
}
};
// Partial specialized version for char to prevent buffer copying.
template
<
typename
Stack
>
struct
TokenHelper
<
Stack
,
char
>
{
RAPIDJSON_FORCEINLINE
static
void
AppendIndexToken
(
Stack
&
documentStack
,
SizeType
index
)
{
if
(
sizeof
(
SizeType
)
==
4
)
{
char
*
buffer
=
documentStack
.
template
Push
<
char
>
(
1
+
10
);
// '/' + uint
*
buffer
++
=
'/'
;
const
char
*
end
=
internal
::
u32toa
(
index
,
buffer
);
documentStack
.
template
Pop
<
char
>
(
static_cast
<
size_t
>
(
10
-
(
end
-
buffer
)));
}
else
{
char
*
buffer
=
documentStack
.
template
Push
<
char
>
(
1
+
20
);
// '/' + uint64
*
buffer
++
=
'/'
;
const
char
*
end
=
internal
::
u64toa
(
index
,
buffer
);
documentStack
.
template
Pop
<
char
>
(
static_cast
<
size_t
>
(
20
-
(
end
-
buffer
)));
}
}
};
}
// namespace internal
///////////////////////////////////////////////////////////////////////////////
...
...
@@ -1709,7 +1739,7 @@ private:
PushSchema
(
root_
);
else
{
if
(
CurrentContext
().
inArray
)
AppendToken
<
Ch
>
(
CurrentContext
().
arrayElementIndex
);
internal
::
TokenHelper
<
internal
::
Stack
<
StateAllocator
>
,
Ch
>::
AppendIndexToken
(
documentStack_
,
CurrentContext
().
arrayElementIndex
);
if
(
!
CurrentSchema
().
BeginValue
(
CurrentContext
()))
return
false
;
...
...
@@ -1789,33 +1819,6 @@ private:
}
}
template
<
typename
Ch
>
void
AppendToken
(
SizeType
index
)
{
*
documentStack_
.
template
Push
<
Ch
>
()
=
'/'
;
char
buffer
[
21
];
size_t
length
=
static_cast
<
size_t
>
((
sizeof
(
SizeType
)
==
4
?
internal
::
u32toa
(
index
,
buffer
)
:
internal
::
u64toa
(
index
,
buffer
))
-
buffer
);
for
(
size_t
i
=
0
;
i
<
length
;
i
++
)
*
documentStack_
.
template
Push
<
Ch
>
()
=
buffer
[
i
];
}
// Specialized version for char to prevent buffer copying.
template
<>
void
AppendToken
<
char
>
(
SizeType
index
)
{
if
(
sizeof
(
SizeType
)
==
4
)
{
char
*
buffer
=
documentStack_
.
template
Push
<
Ch
>
(
1
+
10
);
// '/' + uint
*
buffer
++
=
'/'
;
const
char
*
end
=
internal
::
u32toa
(
index
,
buffer
);
documentStack_
.
template
Pop
<
Ch
>
(
static_cast
<
size_t
>
(
10
-
(
end
-
buffer
)));
}
else
{
char
*
buffer
=
documentStack_
.
template
Push
<
Ch
>
(
1
+
20
);
// '/' + uint64
*
buffer
++
=
'/'
;
const
char
*
end
=
internal
::
u64toa
(
index
,
buffer
);
documentStack_
.
template
Pop
<
Ch
>
(
static_cast
<
size_t
>
(
20
-
(
end
-
buffer
)));
}
}
RAPIDJSON_FORCEINLINE
void
PushSchema
(
const
SchemaType
&
schema
)
{
new
(
schemaStack_
.
template
Push
<
Context
>
())
Context
(
*
this
,
&
schema
);
}
RAPIDJSON_FORCEINLINE
void
PopSchema
()
{
...
...
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