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
95b346c3
Commit
95b346c3
authored
Oct 31, 2016
by
Milo Yip
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor GenericValue deep-clone constructor
parent
d57944fc
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
5 deletions
+22
-5
document.h
include/rapidjson/document.h
+22
-5
No files found.
include/rapidjson/document.h
View file @
95b346c3
...
...
@@ -2419,11 +2419,28 @@ inline
GenericValue
<
Encoding
,
Allocator
>::
GenericValue
(
const
GenericValue
<
Encoding
,
SourceAllocator
>&
rhs
,
Allocator
&
allocator
)
{
switch
(
rhs
.
GetType
())
{
case
kObjectType
:
case
kArrayType
:
{
// perform deep copy via SAX Handler
GenericDocument
<
Encoding
,
Allocator
>
d
(
&
allocator
);
rhs
.
Accept
(
d
);
RawAssign
(
*
d
.
stack_
.
template
Pop
<
GenericValue
>
(
1
));
case
kObjectType
:
{
SizeType
count
=
rhs
.
data_
.
o
.
size
;
Member
*
lm
=
reinterpret_cast
<
Member
*>
(
allocator
.
Malloc
(
count
*
sizeof
(
Member
)));
const
typename
GenericValue
<
Encoding
,
SourceAllocator
>::
Member
*
rm
=
rhs
.
GetMembersPointer
();
for
(
SizeType
i
=
0
;
i
<
count
;
i
++
)
{
new
(
&
lm
[
i
].
name
)
GenericValue
(
rm
[
i
].
name
,
allocator
);
new
(
&
lm
[
i
].
value
)
GenericValue
(
rm
[
i
].
value
,
allocator
);
}
data_
.
f
.
flags
=
kObjectFlag
;
data_
.
o
.
size
=
data_
.
o
.
capacity
=
count
;
SetMembersPointer
(
lm
);
}
break
;
case
kArrayType
:
{
SizeType
count
=
rhs
.
data_
.
a
.
size
;
GenericValue
*
le
=
reinterpret_cast
<
GenericValue
*>
(
allocator
.
Malloc
(
count
*
sizeof
(
GenericValue
)));
const
GenericValue
<
Encoding
,
SourceAllocator
>*
re
=
rhs
.
GetElementsPointer
();
for
(
SizeType
i
=
0
;
i
<
count
;
i
++
)
new
(
&
le
[
i
])
GenericValue
(
re
[
i
],
allocator
);
data_
.
f
.
flags
=
kArrayFlag
;
data_
.
a
.
size
=
data_
.
a
.
capacity
=
count
;
SetElementsPointer
(
le
);
}
break
;
case
kStringType
:
...
...
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