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
6ee69155
Commit
6ee69155
authored
Apr 11, 2015
by
miloyip
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move GenericPointer::kInvalidIndex to rapidjson::kPointerInvalidIndex
It is needed to prevent linking error for gcc/clang
parent
bd435f76
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
10 deletions
+10
-10
pointer.h
include/rapidjson/pointer.h
+7
-7
pointertest.cpp
test/unittest/pointertest.cpp
+3
-3
No files found.
include/rapidjson/pointer.h
View file @
6ee69155
...
...
@@ -19,6 +19,8 @@
RAPIDJSON_NAMESPACE_BEGIN
static
const
SizeType
kPointerInvalidIndex
=
~
SizeType
(
0
);
template
<
typename
ValueType
,
typename
Allocator
=
CrtAllocator
>
class
GenericPointer
{
public
:
...
...
@@ -28,11 +30,9 @@ public:
struct
Token
{
const
Ch
*
name
;
SizeType
length
;
SizeType
index
;
//!< A valid index if not equal to kInvalidIndex.
SizeType
index
;
//!< A valid index if not equal to k
Pointer
InvalidIndex.
};
static
const
SizeType
kInvalidIndex
=
-
1
;
GenericPointer
()
:
allocator_
(),
ownAllocator_
(),
...
...
@@ -150,7 +150,7 @@ public:
bool
exist
=
true
;
for
(
Token
*
t
=
tokens_
;
t
!=
tokens_
+
tokenCount_
;
++
t
)
{
if
(
v
->
GetType
()
!=
kObjectType
&&
v
->
GetType
()
!=
kArrayType
)
{
if
(
t
->
index
==
kInvalidIndex
)
if
(
t
->
index
==
k
Pointer
InvalidIndex
)
v
->
SetObject
();
else
v
->
SetArray
();
...
...
@@ -170,7 +170,7 @@ public:
}
break
;
case
kArrayType
:
if
(
t
->
index
==
kInvalidIndex
)
if
(
t
->
index
==
k
Pointer
InvalidIndex
)
v
->
SetArray
();
// Change to Array
if
(
t
->
index
>=
v
->
Size
())
{
v
->
Reserve
(
t
->
index
+
1
,
allocator
);
...
...
@@ -207,7 +207,7 @@ public:
}
break
;
case
kArrayType
:
if
(
t
->
index
==
kInvalidIndex
||
t
->
index
>=
v
->
Size
())
if
(
t
->
index
==
k
Pointer
InvalidIndex
||
t
->
index
>=
v
->
Size
())
return
0
;
v
=
&
((
*
v
)[
t
->
index
]);
break
;
...
...
@@ -307,7 +307,7 @@ private:
}
}
token
.
index
=
isNumber
?
n
:
kInvalidIndex
;
token
.
index
=
isNumber
?
n
:
k
Pointer
InvalidIndex
;
}
RAPIDJSON_ASSERT
(
name
<=
nameBuffer_
+
length
);
// Should not overflow buffer
...
...
test/unittest/pointertest.cpp
View file @
6ee69155
...
...
@@ -128,7 +128,7 @@ TEST(Pointer, Parse) {
EXPECT_TRUE
(
p
.
IsValid
());
EXPECT_EQ
(
1u
,
p
.
GetTokenCount
());
EXPECT_STREQ
(
"01"
,
p
.
GetTokens
()[
0
].
name
);
EXPECT_EQ
(
Pointer
::
k
InvalidIndex
,
p
.
GetTokens
()[
0
].
index
);
EXPECT_EQ
(
kPointer
InvalidIndex
,
p
.
GetTokens
()[
0
].
index
);
}
if
(
sizeof
(
SizeType
)
==
4
)
{
...
...
@@ -137,7 +137,7 @@ TEST(Pointer, Parse) {
EXPECT_TRUE
(
p
.
IsValid
());
EXPECT_EQ
(
1u
,
p
.
GetTokenCount
());
EXPECT_STREQ
(
"4294967296"
,
p
.
GetTokens
()[
0
].
name
);
EXPECT_EQ
(
Pointer
::
k
InvalidIndex
,
p
.
GetTokens
()[
0
].
index
);
EXPECT_EQ
(
kPointer
InvalidIndex
,
p
.
GetTokens
()[
0
].
index
);
}
}
...
...
@@ -167,7 +167,7 @@ TEST(Pointer, Stringify) {
}
// Construct a Pointer with static tokens, no dynamic allocation involved.
#define NAME(s) { s, sizeof(s) / sizeof(s[0]) - 1,
Pointer::k
InvalidIndex }
#define NAME(s) { s, sizeof(s) / sizeof(s[0]) - 1,
kPointer
InvalidIndex }
#define INDEX(i) { #i, sizeof(#i) - 1, i }
static
const
Pointer
::
Token
kTokens
[]
=
{
NAME
(
"foo"
),
INDEX
(
0
)
};
// equivalent to "/foo/0"
...
...
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