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
ec8f26e6
Commit
ec8f26e6
authored
Jul 05, 2014
by
Philipp A. Hartmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(Pretty)Writer: improve doxygen documentation
parent
7972f22f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
46 additions
and
25 deletions
+46
-25
prettywriter.h
include/rapidjson/prettywriter.h
+15
-8
writer.h
include/rapidjson/writer.h
+31
-17
No files found.
include/rapidjson/prettywriter.h
View file @
ec8f26e6
...
...
@@ -24,9 +24,9 @@ public:
typedef
typename
Base
::
Ch
Ch
;
//! Constructor
/*! \param os Output
os
.
/*! \param os Output
stream
.
\param allocator User supplied allocator. If it is null, it will create a private one.
\param levelDepth Initial capacity of
\param levelDepth Initial capacity of
stack.
*/
PrettyWriter
(
OutputStream
&
os
,
Allocator
*
allocator
=
0
,
size_t
levelDepth
=
Base
::
kDefaultLevelDepth
)
:
Base
(
os
,
allocator
,
levelDepth
),
indentChar_
(
' '
),
indentCharCount_
(
4
)
{}
...
...
@@ -46,7 +46,9 @@ public:
return
*
this
;
}
//@name Implementation of Handler.
/*! @name Implementation of Handler
\see Handler
*/
//@{
PrettyWriter
&
Null
()
{
PrettyPrefix
(
kNullType
);
Base
::
WriteNull
();
return
*
this
;
}
...
...
@@ -56,11 +58,6 @@ public:
PrettyWriter
&
Int64
(
int64_t
i64
)
{
PrettyPrefix
(
kNumberType
);
Base
::
WriteInt64
(
i64
);
return
*
this
;
}
PrettyWriter
&
Uint64
(
uint64_t
u64
)
{
PrettyPrefix
(
kNumberType
);
Base
::
WriteUint64
(
u64
);
return
*
this
;
}
PrettyWriter
&
Double
(
double
d
)
{
PrettyPrefix
(
kNumberType
);
Base
::
WriteDouble
(
d
);
return
*
this
;
}
//! Overridden for fluent API, see \ref Writer::Double()
PrettyWriter
&
Double
(
double
d
,
int
precision
)
{
int
oldPrecision
=
Base
::
GetDoublePrecision
();
return
SetDoublePrecision
(
precision
).
Double
(
d
).
SetDoublePrecision
(
oldPrecision
);
}
PrettyWriter
&
String
(
const
Ch
*
str
,
SizeType
length
,
bool
copy
=
false
)
{
(
void
)
copy
;
...
...
@@ -117,9 +114,19 @@ public:
//@}
/*! @name Convenience extensions */
//@{
//! Simpler but slower overload.
PrettyWriter
&
String
(
const
Ch
*
str
)
{
return
String
(
str
,
internal
::
StrLen
(
str
));
}
//! Overridden for fluent API, see \ref Writer::Double()
PrettyWriter
&
Double
(
double
d
,
int
precision
)
{
int
oldPrecision
=
Base
::
GetDoublePrecision
();
return
SetDoublePrecision
(
precision
).
Double
(
d
).
SetDoublePrecision
(
oldPrecision
);
}
//@}
protected
:
void
PrettyPrefix
(
Type
type
)
{
(
void
)
type
;
...
...
include/rapidjson/writer.h
View file @
ec8f26e6
...
...
@@ -25,8 +25,9 @@ namespace rapidjson {
for example Reader::Parse() and Document::Accept().
\tparam OutputStream Type of output stream.
\tparam SourceEncoding Encoding of both source strings.
\tparam TargetEncoding Encoding of and output stream.
\tparam SourceEncoding Encoding of source string.
\tparam TargetEncoding Encoding of output stream.
\tparam Allocator Type of allocator for allocating memory of stack.
\note implements Handler concept
*/
template
<
typename
OutputStream
,
typename
SourceEncoding
=
UTF8
<>
,
typename
TargetEncoding
=
UTF8
<>
,
typename
Allocator
=
MemoryPoolAllocator
<>
>
...
...
@@ -34,6 +35,11 @@ class Writer {
public
:
typedef
typename
SourceEncoding
::
Ch
Ch
;
//! Constructor
/*! \param os Output stream.
\param allocator User supplied allocator. If it is null, it will create a private one.
\param levelDepth Initial capacity of stack.
*/
Writer
(
OutputStream
&
os
,
Allocator
*
allocator
=
0
,
size_t
levelDepth
=
kDefaultLevelDepth
)
:
os_
(
os
),
level_stack_
(
allocator
,
levelDepth
*
sizeof
(
Level
)),
doublePrecision_
(
kDefaultDoublePrecision
)
{}
...
...
@@ -53,8 +59,11 @@ public:
//! \see SetDoublePrecision()
int
GetDoublePrecision
()
const
{
return
doublePrecision_
;
}
//@name Implementation of Handler
/*!@name Implementation of Handler
\see Handler
*/
//@{
Writer
&
Null
()
{
Prefix
(
kNullType
);
WriteNull
();
return
*
this
;
}
Writer
&
Bool
(
bool
b
)
{
Prefix
(
b
?
kTrueType
:
kFalseType
);
WriteBool
(
b
);
return
*
this
;
}
Writer
&
Int
(
int
i
)
{
Prefix
(
kNumberType
);
WriteInt
(
i
);
return
*
this
;
}
...
...
@@ -75,20 +84,6 @@ public:
*/
Writer
&
Double
(
double
d
)
{
Prefix
(
kNumberType
);
WriteDouble
(
d
);
return
*
this
;
}
//! Writes the given \c double value to the stream (explicit precision)
/*!
The currently set double precision is ignored in favor of the explicitly
given precision for this value.
\see Double(), SetDoublePrecision(), GetDoublePrecision()
\param d The value to be written
\param precision The number of significant digits for this value
\return The Writer itself for fluent API.
*/
Writer
&
Double
(
double
d
,
int
precision
)
{
int
oldPrecision
=
GetDoublePrecision
();
return
SetDoublePrecision
(
precision
).
Double
(
d
).
SetDoublePrecision
(
oldPrecision
);
}
Writer
&
String
(
const
Ch
*
str
,
SizeType
length
,
bool
copy
=
false
)
{
(
void
)
copy
;
Prefix
(
kStringType
);
...
...
@@ -133,9 +128,28 @@ public:
}
//@}
/*! @name Convenience extensions */
//@{
//! Writes the given \c double value to the stream (explicit precision)
/*!
The currently set double precision is ignored in favor of the explicitly
given precision for this value.
\see Double(), SetDoublePrecision(), GetDoublePrecision()
\param d The value to be written
\param precision The number of significant digits for this value
\return The Writer itself for fluent API.
*/
Writer
&
Double
(
double
d
,
int
precision
)
{
int
oldPrecision
=
GetDoublePrecision
();
return
SetDoublePrecision
(
precision
).
Double
(
d
).
SetDoublePrecision
(
oldPrecision
);
}
//! Simpler but slower overload.
Writer
&
String
(
const
Ch
*
str
)
{
return
String
(
str
,
internal
::
StrLen
(
str
));
}
//@}
protected
:
//! Information for each nested level
struct
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