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
db0a03a4
Commit
db0a03a4
authored
Nov 30, 2015
by
Milo Yip
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix #483 by using the correct value type
parent
8ec389f1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
3 deletions
+38
-3
pointer.h
include/rapidjson/pointer.h
+3
-3
pointertest.cpp
test/unittest/pointertest.cpp
+35
-0
No files found.
include/rapidjson/pointer.h
View file @
db0a03a4
...
...
@@ -390,7 +390,7 @@ public:
bool
exist
=
true
;
for
(
const
Token
*
t
=
tokens_
;
t
!=
tokens_
+
tokenCount_
;
++
t
)
{
if
(
v
->
IsArray
()
&&
t
->
name
[
0
]
==
'-'
&&
t
->
length
==
1
)
{
v
->
PushBack
(
Value
().
Move
(),
allocator
);
v
->
PushBack
(
Value
Type
().
Move
(),
allocator
);
v
=
&
((
*
v
)[
v
->
Size
()
-
1
]);
exist
=
false
;
}
...
...
@@ -408,7 +408,7 @@ public:
if
(
t
->
index
>=
v
->
Size
())
{
v
->
Reserve
(
t
->
index
+
1
,
allocator
);
while
(
t
->
index
>=
v
->
Size
())
v
->
PushBack
(
Value
().
Move
(),
allocator
);
v
->
PushBack
(
Value
Type
().
Move
(),
allocator
);
exist
=
false
;
}
v
=
&
((
*
v
)[
t
->
index
]);
...
...
@@ -416,7 +416,7 @@ public:
else
{
typename
ValueType
::
MemberIterator
m
=
v
->
FindMember
(
GenericStringRef
<
Ch
>
(
t
->
name
,
t
->
length
));
if
(
m
==
v
->
MemberEnd
())
{
v
->
AddMember
(
Value
(
t
->
name
,
t
->
length
,
allocator
).
Move
(),
Valu
e
().
Move
(),
allocator
);
v
->
AddMember
(
Value
Type
(
t
->
name
,
t
->
length
,
allocator
).
Move
(),
ValueTyp
e
().
Move
(),
allocator
);
v
=
&
(
--
v
->
MemberEnd
())
->
value
;
// Assumes AddMember() appends at the end
exist
=
false
;
}
...
...
test/unittest/pointertest.cpp
View file @
db0a03a4
...
...
@@ -1456,3 +1456,38 @@ TEST(Pointer, Ambiguity) {
EXPECT_EQ
(
456
,
Pointer
(
"/0/1"
).
Get
(
d
)
->
GetInt
());
}
}
// https://github.com/miloyip/rapidjson/issues/483
namespace
myjson
{
class
MyAllocator
{
public
:
static
const
bool
kNeedFree
=
true
;
void
*
Malloc
(
size_t
_size
)
{
return
malloc
(
_size
);
}
void
*
Realloc
(
void
*
_org_p
,
size_t
_org_size
,
size_t
_new_size
)
{
(
void
)
_org_size
;
return
realloc
(
_org_p
,
_new_size
);
}
static
void
Free
(
void
*
_p
)
{
return
free
(
_p
);
}
};
typedef
rapidjson
::
GenericDocument
<
rapidjson
::
UTF8
<>
,
rapidjson
::
MemoryPoolAllocator
<
MyAllocator
>
,
MyAllocator
>
Document
;
typedef
rapidjson
::
GenericPointer
<
::
myjson
::
Document
::
ValueType
,
MyAllocator
>
Pointer
;
typedef
::
myjson
::
Document
::
ValueType
Value
;
}
TEST
(
Pointer
,
Issue483
)
{
std
::
string
mystr
,
path
;
myjson
::
Document
document
;
myjson
::
Value
value
(
rapidjson
::
kStringType
);
value
.
SetString
(
mystr
.
c_str
(),
mystr
.
length
(),
document
.
GetAllocator
());
myjson
::
Pointer
(
path
.
c_str
()).
Set
(
document
,
value
,
document
.
GetAllocator
());
}
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