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
a96b6993
Commit
a96b6993
authored
Jul 03, 2014
by
Milo Yip
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #46 from pah/cleanup/misc
Miscellaneous cleanups
parents
80a5b909
3254a784
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
29 additions
and
49 deletions
+29
-49
.gitignore
.gitignore
+3
-0
document.h
include/rapidjson/document.h
+11
-34
en.h
include/rapidjson/error/en.h
+1
-1
reader.h
include/rapidjson/reader.h
+8
-8
rapidjsontest.cpp
test/perftest/rapidjsontest.cpp
+3
-3
readertest.cpp
test/unittest/readertest.cpp
+2
-2
valuetest.cpp
test/unittest/valuetest.cpp
+1
-1
No files found.
.gitignore
View file @
a96b6993
/bin/*
!/bin/data
!/bin/encodings
!/bin/jsonchecker
/build/*.exe
/build/gmake
/build/vs*/
...
...
include/rapidjson/document.h
View file @
a96b6993
...
...
@@ -285,12 +285,7 @@ public:
explicit
GenericValue
(
double
d
)
:
data_
(),
flags_
(
kNumberDoubleFlag
)
{
data_
.
n
.
d
=
d
;
}
//! Constructor for constant string (i.e. do not make a copy of string)
GenericValue
(
const
Ch
*
s
,
SizeType
length
)
:
data_
(),
flags_
()
{
RAPIDJSON_ASSERT
(
s
!=
NULL
);
flags_
=
kConstStringFlag
;
data_
.
s
.
str
=
s
;
data_
.
s
.
length
=
length
;
}
GenericValue
(
const
Ch
*
s
,
SizeType
length
)
:
data_
(),
flags_
()
{
SetStringRaw
(
s
,
length
);
}
//! Constructor for constant string (i.e. do not make a copy of string)
explicit
GenericValue
(
const
Ch
*
s
)
:
data_
(),
flags_
()
{
SetStringRaw
(
s
,
internal
::
StrLen
(
s
));
}
...
...
@@ -427,14 +422,8 @@ public:
A better approach is to use the now public FindMember().
*/
GenericValue
&
operator
[](
const
Ch
*
name
)
{
MemberIterator
member
=
FindMember
(
name
);
if
(
member
!=
MemberEnd
())
return
member
->
value
;
else
{
RAPIDJSON_ASSERT
(
false
);
// see above note
static
GenericValue
NullValue
;
return
NullValue
;
}
GenericValue
n
(
name
,
internal
::
StrLen
(
name
));
return
(
*
this
)[
n
];
}
const
GenericValue
&
operator
[](
const
Ch
*
name
)
const
{
return
const_cast
<
GenericValue
&>
(
*
this
)[
name
];
}
...
...
@@ -486,15 +475,8 @@ public:
\c std::map, this has been changed to MemberEnd() now.
*/
MemberIterator
FindMember
(
const
Ch
*
name
)
{
RAPIDJSON_ASSERT
(
name
);
RAPIDJSON_ASSERT
(
IsObject
());
SizeType
len
=
internal
::
StrLen
(
name
);
MemberIterator
member
=
MemberBegin
();
for
(;
member
!=
MemberEnd
();
++
member
)
if
(
member
->
name
.
data_
.
s
.
length
==
len
&&
memcmp
(
member
->
name
.
data_
.
s
.
str
,
name
,
len
*
sizeof
(
Ch
))
==
0
)
break
;
return
member
;
GenericValue
n
(
name
,
internal
::
StrLen
(
name
));
return
FindMember
(
n
);
}
ConstMemberIterator
FindMember
(
const
Ch
*
name
)
const
{
return
const_cast
<
GenericValue
&>
(
*
this
).
FindMember
(
name
);
}
...
...
@@ -565,13 +547,8 @@ public:
\note Removing member is implemented by moving the last member. So the ordering of members is changed.
*/
bool
RemoveMember
(
const
Ch
*
name
)
{
MemberIterator
m
=
FindMember
(
name
);
if
(
m
!=
MemberEnd
())
{
RemoveMember
(
m
);
return
true
;
}
else
return
false
;
GenericValue
n
(
name
,
internal
::
StrLen
(
name
));
return
RemoveMember
(
n
);
}
bool
RemoveMember
(
const
GenericValue
&
name
)
{
...
...
@@ -891,7 +868,7 @@ private:
};
// 12 bytes in 32-bit mode, 16 bytes in 64-bit mode
struct
Array
{
GenericValue
<
Encoding
,
Allocator
>
*
elements
;
GenericValue
*
elements
;
SizeType
size
;
SizeType
capacity
;
};
// 12 bytes in 32-bit mode, 16 bytes in 64-bit mode
...
...
@@ -1004,7 +981,7 @@ public:
template
<
typename
InputStream
>
GenericDocument
&
ParseStream
(
InputStream
&
is
)
{
return
ParseStream
<
0
,
Encoding
,
InputStream
>
(
is
);
return
ParseStream
<
kParseDefaultFlags
,
Encoding
,
InputStream
>
(
is
);
}
//! Parse JSON text from a mutable string.
...
...
@@ -1024,7 +1001,7 @@ public:
}
GenericDocument
&
ParseInsitu
(
Ch
*
str
)
{
return
ParseInsitu
<
0
,
Encoding
>
(
str
);
return
ParseInsitu
<
kParseDefaultFlags
,
Encoding
>
(
str
);
}
//! Parse JSON text from a read-only string.
...
...
@@ -1044,7 +1021,7 @@ public:
}
GenericDocument
&
Parse
(
const
Ch
*
str
)
{
return
Parse
<
0
>
(
str
);
return
Parse
<
kParseDefaultFlags
>
(
str
);
}
//! Whether a parse error was occured in the last parsing.
...
...
include/rapidjson/error/en.h
View file @
a96b6993
...
...
@@ -34,7 +34,7 @@ inline const RAPIDJSON_ERROR_CHARTYPE* GetParseError_En(ParseErrorCode parseErro
case
kParseErrorStringMissQuotationMark
:
return
RAPIDJSON_ERROR_STRING
(
"Missing a closing quotation mark in string."
);
case
kParseErrorStringInvalidEncoding
:
return
RAPIDJSON_ERROR_STRING
(
"Invalid encoidng in string."
);
case
kPar
es
ErrorNumberTooBig
:
return
RAPIDJSON_ERROR_STRING
(
"Number too big to be stored in double."
);
case
kPar
se
ErrorNumberTooBig
:
return
RAPIDJSON_ERROR_STRING
(
"Number too big to be stored in double."
);
case
kParseErrorNumberMissFraction
:
return
RAPIDJSON_ERROR_STRING
(
"Miss fraction part in number."
);
case
kParseErrorNumberMissExponent
:
return
RAPIDJSON_ERROR_STRING
(
"Miss exponent in number."
);
...
...
include/rapidjson/reader.h
View file @
a96b6993
...
...
@@ -71,7 +71,7 @@ enum ParseErrorCode {
kParseErrorStringMissQuotationMark
,
//!< Missing a closing quotation mark in string.
kParseErrorStringInvalidEncoding
,
//!< Invalid encoidng in string.
kPar
es
ErrorNumberTooBig
,
//!< Number too big to be stored in double.
kPar
se
ErrorNumberTooBig
,
//!< Number too big to be stored in double.
kParseErrorNumberMissFraction
,
//!< Miss fraction part in number.
kParseErrorNumberMissExponent
//!< Miss exponent in number.
};
...
...
@@ -224,7 +224,7 @@ inline const char *SkipWhitespace_SIMD(const char* p) {
x
=
_mm_or_si128
(
x
,
_mm_cmpeq_epi8
(
s
,
w1
));
x
=
_mm_or_si128
(
x
,
_mm_cmpeq_epi8
(
s
,
w2
));
x
=
_mm_or_si128
(
x
,
_mm_cmpeq_epi8
(
s
,
w3
));
unsigned
short
r
=
~
_mm_movemask_epi8
(
x
);
unsigned
short
r
=
(
unsigned
short
)
~
_mm_movemask_epi8
(
x
);
if
(
r
==
0
)
// all 16 characters are whitespace
p
+=
16
;
else
{
// some of characters may be non-whitespace
...
...
@@ -323,7 +323,7 @@ public:
template
<
typename
InputStream
,
typename
Handler
>
bool
Parse
(
InputStream
&
is
,
Handler
&
handler
)
{
return
Parse
<
0
>
(
is
,
handler
);
return
Parse
<
kParseDefaultFlags
>
(
is
,
handler
);
}
bool
HasParseError
()
const
{
return
parseErrorCode_
!=
kParseErrorNone
;
}
...
...
@@ -610,7 +610,7 @@ private:
}
}
else
RAPIDJSON_PARSE_ERROR
(
kParseErrorValueInvalid
,
i
s
.
Tell
());
RAPIDJSON_PARSE_ERROR
(
kParseErrorValueInvalid
,
s
.
Tell
());
// Parse 64bit int
uint64_t
i64
=
0
;
...
...
@@ -643,7 +643,7 @@ private:
d
=
(
double
)
i64
;
while
(
s
.
Peek
()
>=
'0'
&&
s
.
Peek
()
<=
'9'
)
{
if
(
d
>=
1E307
)
RAPIDJSON_PARSE_ERROR
(
kPar
esErrorNumberTooBig
,
i
s
.
Tell
());
RAPIDJSON_PARSE_ERROR
(
kPar
seErrorNumberTooBig
,
s
.
Tell
());
d
=
d
*
10
+
(
s
.
Take
()
-
'0'
);
}
}
...
...
@@ -662,7 +662,7 @@ private:
--
expFrac
;
}
else
RAPIDJSON_PARSE_ERROR
(
kParseErrorNumberMissFraction
,
i
s
.
Tell
());
RAPIDJSON_PARSE_ERROR
(
kParseErrorNumberMissFraction
,
s
.
Tell
());
while
(
s
.
Peek
()
>=
'0'
&&
s
.
Peek
()
<=
'9'
)
{
if
(
expFrac
>
-
16
)
{
...
...
@@ -695,11 +695,11 @@ private:
while
(
s
.
Peek
()
>=
'0'
&&
s
.
Peek
()
<=
'9'
)
{
exp
=
exp
*
10
+
(
s
.
Take
()
-
'0'
);
if
(
exp
>
308
)
RAPIDJSON_PARSE_ERROR
(
kPar
esErrorNumberTooBig
,
i
s
.
Tell
());
RAPIDJSON_PARSE_ERROR
(
kPar
seErrorNumberTooBig
,
s
.
Tell
());
}
}
else
RAPIDJSON_PARSE_ERROR
(
kParseErrorNumberMissExponent
,
i
s
.
Tell
());
RAPIDJSON_PARSE_ERROR
(
kParseErrorNumberMissExponent
,
s
.
Tell
());
if
(
expMinus
)
exp
=
-
exp
;
...
...
test/perftest/rapidjsontest.cpp
View file @
a96b6993
...
...
@@ -85,7 +85,7 @@ TEST_F(RapidJson, SIMD_SUFFIX(ReaderParse_DummyHandler_ValidateEncoding)) {
}
}
TEST_F
(
RapidJson
,
SIMD_SUFFIX
(
Do
uc
mentParseInsitu_MemoryPoolAllocator
))
{
TEST_F
(
RapidJson
,
SIMD_SUFFIX
(
Do
cu
mentParseInsitu_MemoryPoolAllocator
))
{
//const size_t userBufferSize = 128 * 1024;
//char* userBuffer = (char*)malloc(userBufferSize);
...
...
@@ -108,7 +108,7 @@ TEST_F(RapidJson, SIMD_SUFFIX(DoucmentParseInsitu_MemoryPoolAllocator)) {
//free(userBuffer);
}
TEST_F
(
RapidJson
,
SIMD_SUFFIX
(
Do
uc
mentParse_MemoryPoolAllocator
))
{
TEST_F
(
RapidJson
,
SIMD_SUFFIX
(
Do
cu
mentParse_MemoryPoolAllocator
))
{
//const size_t userBufferSize = 128 * 1024;
//char* userBuffer = (char*)malloc(userBufferSize);
...
...
@@ -130,7 +130,7 @@ TEST_F(RapidJson, SIMD_SUFFIX(DoucmentParse_MemoryPoolAllocator)) {
//free(userBuffer);
}
TEST_F
(
RapidJson
,
SIMD_SUFFIX
(
Do
uc
mentParse_CrtAllocator
))
{
TEST_F
(
RapidJson
,
SIMD_SUFFIX
(
Do
cu
mentParse_CrtAllocator
))
{
for
(
size_t
i
=
0
;
i
<
kTrialCount
;
i
++
)
{
memcpy
(
temp_
,
json_
,
length_
+
1
);
GenericDocument
<
UTF8
<>
,
CrtAllocator
>
doc
;
...
...
test/unittest/readertest.cpp
View file @
a96b6993
...
...
@@ -171,9 +171,9 @@ TEST(Reader, ParseNumber_Error) {
for
(
int
i
=
1
;
i
<
310
;
i
++
)
n1e309
[
i
]
=
'0'
;
n1e309
[
310
]
=
'\0'
;
TEST_NUMBER_ERROR
(
kPar
es
ErrorNumberTooBig
,
n1e309
);
TEST_NUMBER_ERROR
(
kPar
se
ErrorNumberTooBig
,
n1e309
);
}
TEST_NUMBER_ERROR
(
kPar
es
ErrorNumberTooBig
,
"1e309"
);
TEST_NUMBER_ERROR
(
kPar
se
ErrorNumberTooBig
,
"1e309"
);
// Miss fraction part in number.
TEST_NUMBER_ERROR
(
kParseErrorNumberMissFraction
,
"1."
);
...
...
test/unittest/valuetest.cpp
View file @
a96b6993
...
...
@@ -27,7 +27,7 @@ TEST(Value, assignment_operator) {
template
<
typename
Value
>
void
TestCopyFrom
()
{
Value
::
AllocatorType
a
;
typename
Value
::
AllocatorType
a
;
Value
v1
(
1234
);
Value
v2
(
v1
,
a
);
// deep copy constructor
EXPECT_TRUE
(
v1
.
GetType
()
==
v2
.
GetType
());
...
...
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