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
3e2172bd
Commit
3e2172bd
authored
Sep 03, 2016
by
Milo Yip
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add preconditions in writer and string functions
parent
8979c14f
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
2 deletions
+17
-2
strfunc.h
include/rapidjson/internal/strfunc.h
+3
-0
prettywriter.h
include/rapidjson/prettywriter.h
+7
-1
writer.h
include/rapidjson/writer.h
+7
-1
No files found.
include/rapidjson/internal/strfunc.h
View file @
3e2172bd
...
@@ -28,6 +28,7 @@ namespace internal {
...
@@ -28,6 +28,7 @@ namespace internal {
*/
*/
template
<
typename
Ch
>
template
<
typename
Ch
>
inline
SizeType
StrLen
(
const
Ch
*
s
)
{
inline
SizeType
StrLen
(
const
Ch
*
s
)
{
RAPIDJSON_ASSERT
(
s
!=
0
);
const
Ch
*
p
=
s
;
const
Ch
*
p
=
s
;
while
(
*
p
)
++
p
;
while
(
*
p
)
++
p
;
return
SizeType
(
p
-
s
);
return
SizeType
(
p
-
s
);
...
@@ -36,6 +37,8 @@ inline SizeType StrLen(const Ch* s) {
...
@@ -36,6 +37,8 @@ inline SizeType StrLen(const Ch* s) {
//! Returns number of code points in a encoded string.
//! Returns number of code points in a encoded string.
template
<
typename
Encoding
>
template
<
typename
Encoding
>
bool
CountStringCodePoint
(
const
typename
Encoding
::
Ch
*
s
,
SizeType
length
,
SizeType
*
outCount
)
{
bool
CountStringCodePoint
(
const
typename
Encoding
::
Ch
*
s
,
SizeType
length
,
SizeType
*
outCount
)
{
RAPIDJSON_ASSERT
(
s
!=
0
);
RAPIDJSON_ASSERT
(
outCount
!=
0
);
GenericStringStream
<
Encoding
>
is
(
s
);
GenericStringStream
<
Encoding
>
is
(
s
);
const
typename
Encoding
::
Ch
*
end
=
s
+
length
;
const
typename
Encoding
::
Ch
*
end
=
s
+
length
;
SizeType
count
=
0
;
SizeType
count
=
0
;
...
...
include/rapidjson/prettywriter.h
View file @
3e2172bd
...
@@ -91,12 +91,14 @@ public:
...
@@ -91,12 +91,14 @@ public:
bool
Double
(
double
d
)
{
PrettyPrefix
(
kNumberType
);
return
Base
::
WriteDouble
(
d
);
}
bool
Double
(
double
d
)
{
PrettyPrefix
(
kNumberType
);
return
Base
::
WriteDouble
(
d
);
}
bool
RawNumber
(
const
Ch
*
str
,
SizeType
length
,
bool
copy
=
false
)
{
bool
RawNumber
(
const
Ch
*
str
,
SizeType
length
,
bool
copy
=
false
)
{
RAPIDJSON_ASSERT
(
str
!=
0
);
(
void
)
copy
;
(
void
)
copy
;
PrettyPrefix
(
kNumberType
);
PrettyPrefix
(
kNumberType
);
return
Base
::
WriteString
(
str
,
length
);
return
Base
::
WriteString
(
str
,
length
);
}
}
bool
String
(
const
Ch
*
str
,
SizeType
length
,
bool
copy
=
false
)
{
bool
String
(
const
Ch
*
str
,
SizeType
length
,
bool
copy
=
false
)
{
RAPIDJSON_ASSERT
(
str
!=
0
);
(
void
)
copy
;
(
void
)
copy
;
PrettyPrefix
(
kStringType
);
PrettyPrefix
(
kStringType
);
return
Base
::
WriteString
(
str
,
length
);
return
Base
::
WriteString
(
str
,
length
);
...
@@ -184,7 +186,11 @@ public:
...
@@ -184,7 +186,11 @@ public:
\param type Type of the root of json.
\param type Type of the root of json.
\note When using PrettyWriter::RawValue(), the result json may not be indented correctly.
\note When using PrettyWriter::RawValue(), the result json may not be indented correctly.
*/
*/
bool
RawValue
(
const
Ch
*
json
,
size_t
length
,
Type
type
)
{
PrettyPrefix
(
type
);
return
Base
::
WriteRawValue
(
json
,
length
);
}
bool
RawValue
(
const
Ch
*
json
,
size_t
length
,
Type
type
)
{
RAPIDJSON_ASSERT
(
json
!=
0
);
PrettyPrefix
(
type
);
return
Base
::
WriteRawValue
(
json
,
length
);
}
protected
:
protected
:
void
PrettyPrefix
(
Type
type
)
{
void
PrettyPrefix
(
Type
type
)
{
...
...
include/rapidjson/writer.h
View file @
3e2172bd
...
@@ -184,12 +184,14 @@ public:
...
@@ -184,12 +184,14 @@ public:
bool
Double
(
double
d
)
{
Prefix
(
kNumberType
);
return
EndValue
(
WriteDouble
(
d
));
}
bool
Double
(
double
d
)
{
Prefix
(
kNumberType
);
return
EndValue
(
WriteDouble
(
d
));
}
bool
RawNumber
(
const
Ch
*
str
,
SizeType
length
,
bool
copy
=
false
)
{
bool
RawNumber
(
const
Ch
*
str
,
SizeType
length
,
bool
copy
=
false
)
{
RAPIDJSON_ASSERT
(
str
!=
0
);
(
void
)
copy
;
(
void
)
copy
;
Prefix
(
kNumberType
);
Prefix
(
kNumberType
);
return
EndValue
(
WriteString
(
str
,
length
));
return
EndValue
(
WriteString
(
str
,
length
));
}
}
bool
String
(
const
Ch
*
str
,
SizeType
length
,
bool
copy
=
false
)
{
bool
String
(
const
Ch
*
str
,
SizeType
length
,
bool
copy
=
false
)
{
RAPIDJSON_ASSERT
(
str
!=
0
);
(
void
)
copy
;
(
void
)
copy
;
Prefix
(
kStringType
);
Prefix
(
kStringType
);
return
EndValue
(
WriteString
(
str
,
length
));
return
EndValue
(
WriteString
(
str
,
length
));
...
@@ -249,7 +251,11 @@ public:
...
@@ -249,7 +251,11 @@ public:
\param length Length of the json.
\param length Length of the json.
\param type Type of the root of json.
\param type Type of the root of json.
*/
*/
bool
RawValue
(
const
Ch
*
json
,
size_t
length
,
Type
type
)
{
Prefix
(
type
);
return
EndValue
(
WriteRawValue
(
json
,
length
));
}
bool
RawValue
(
const
Ch
*
json
,
size_t
length
,
Type
type
)
{
RAPIDJSON_ASSERT
(
json
!=
0
);
Prefix
(
type
);
return
EndValue
(
WriteRawValue
(
json
,
length
));
}
protected
:
protected
:
//! Information for each nested level
//! Information for each nested level
...
...
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