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
5b593bba
Commit
5b593bba
authored
Mar 14, 2017
by
John Stiles
Committed by
GitHub
Mar 14, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2 from miloyip/master
Merge back
parents
33a9f585
266870df
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
20 deletions
+17
-20
writer.h
include/rapidjson/writer.h
+4
-20
writertest.cpp
test/unittest/writertest.cpp
+13
-0
No files found.
include/rapidjson/writer.h
View file @
5b593bba
...
...
@@ -199,8 +199,7 @@ public:
return
EndValue
(
WriteString
(
str
,
length
));
}
template
<
typename
T
>
RAPIDJSON_ENABLEIF_RETURN
((
internal
::
IsSame
<
Ch
,
T
>
),
(
bool
))
String
(
const
T
*
str
,
SizeType
length
,
bool
copy
=
false
)
{
bool
String
(
const
Ch
*
str
,
SizeType
length
,
bool
copy
=
false
)
{
RAPIDJSON_ASSERT
(
str
!=
0
);
(
void
)
copy
;
Prefix
(
kStringType
);
...
...
@@ -219,8 +218,7 @@ public:
return
WriteStartObject
();
}
template
<
typename
T
>
RAPIDJSON_ENABLEIF_RETURN
((
internal
::
IsSame
<
Ch
,
T
>
),
(
bool
))
Key
(
const
T
*
str
,
SizeType
length
,
bool
copy
=
false
)
{
return
String
(
str
,
length
,
copy
);
}
bool
Key
(
const
Ch
*
str
,
SizeType
length
,
bool
copy
=
false
)
{
return
String
(
str
,
length
,
copy
);
}
bool
EndObject
(
SizeType
memberCount
=
0
)
{
(
void
)
memberCount
;
...
...
@@ -250,23 +248,9 @@ public:
//@{
//! Simpler but slower overload.
template
<
typename
T
>
RAPIDJSON_ENABLEIF_RETURN
((
internal
::
IsSame
<
Ch
,
T
>
),
(
bool
))
String
(
const
T
*
const
&
str
)
{
return
String
(
str
,
internal
::
StrLen
(
str
));
}
template
<
typename
T
>
RAPIDJSON_ENABLEIF_RETURN
((
internal
::
IsSame
<
Ch
,
T
>
),
(
bool
))
Key
(
const
T
*
const
&
str
)
{
return
Key
(
str
,
internal
::
StrLen
(
str
));
}
bool
String
(
const
Ch
*
const
&
str
)
{
return
String
(
str
,
internal
::
StrLen
(
str
));
}
bool
Key
(
const
Ch
*
const
&
str
)
{
return
Key
(
str
,
internal
::
StrLen
(
str
));
}
//! The compiler can give us the length of quoted strings for free.
template
<
typename
T
,
size_t
N
>
RAPIDJSON_ENABLEIF_RETURN
((
internal
::
IsSame
<
Ch
,
T
>
),
(
bool
))
String
(
const
T
(
&
str
)[
N
])
{
RAPIDJSON_ASSERT
(
str
[
N
-
1
]
==
'\0'
);
// you must pass in a null-terminated string (quoted constant strings are always null-terminated)
return
String
(
str
,
N
-
1
);
}
template
<
typename
T
,
size_t
N
>
RAPIDJSON_ENABLEIF_RETURN
((
internal
::
IsSame
<
Ch
,
T
>
),
(
bool
))
Key
(
const
T
(
&
str
)[
N
])
{
RAPIDJSON_ASSERT
(
str
[
N
-
1
]
==
'\0'
);
// you must pass in a null-terminated string (quoted constant strings are always null-terminated)
return
Key
(
str
,
N
-
1
);
}
//@}
//! Write a raw JSON value.
...
...
test/unittest/writertest.cpp
View file @
5b593bba
...
...
@@ -100,6 +100,19 @@ TEST(Writer, String) {
#endif
}
TEST
(
Writer
,
Issue_889
)
{
char
buf
[
100
]
=
"Hello"
;
StringBuffer
buffer
;
Writer
<
StringBuffer
>
writer
(
buffer
);
writer
.
StartArray
();
writer
.
String
(
buf
);
writer
.
EndArray
();
EXPECT_STREQ
(
"[
\"
Hello
\"
]"
,
buffer
.
GetString
());
EXPECT_TRUE
(
writer
.
IsComplete
());
\
}
TEST
(
Writer
,
ScanWriteUnescapedString
)
{
const
char
json
[]
=
"[
\"
\\\"
0123456789ABCDEF
\"
]"
;
// ^ scanning stops here.
...
...
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