(Pretty)Writer: improve doxygen documentation
This commit is contained in:
parent
7972f22fcb
commit
ec8f26e6e5
@ -24,9 +24,9 @@ public:
|
|||||||
typedef typename Base::Ch Ch;
|
typedef typename Base::Ch Ch;
|
||||||
|
|
||||||
//! Constructor
|
//! 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 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) :
|
PrettyWriter(OutputStream& os, Allocator* allocator = 0, size_t levelDepth = Base::kDefaultLevelDepth) :
|
||||||
Base(os, allocator, levelDepth), indentChar_(' '), indentCharCount_(4) {}
|
Base(os, allocator, levelDepth), indentChar_(' '), indentCharCount_(4) {}
|
||||||
@ -46,7 +46,9 @@ public:
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
//@name Implementation of Handler.
|
/*! @name Implementation of Handler
|
||||||
|
\see Handler
|
||||||
|
*/
|
||||||
//@{
|
//@{
|
||||||
|
|
||||||
PrettyWriter& Null() { PrettyPrefix(kNullType); Base::WriteNull(); return *this; }
|
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& Int64(int64_t i64) { PrettyPrefix(kNumberType); Base::WriteInt64(i64); return *this; }
|
||||||
PrettyWriter& Uint64(uint64_t u64) { PrettyPrefix(kNumberType); Base::WriteUint64(u64); 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; }
|
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) {
|
PrettyWriter& String(const Ch* str, SizeType length, bool copy = false) {
|
||||||
(void)copy;
|
(void)copy;
|
||||||
@ -117,9 +114,19 @@ public:
|
|||||||
|
|
||||||
//@}
|
//@}
|
||||||
|
|
||||||
|
/*! @name Convenience extensions */
|
||||||
|
//@{
|
||||||
|
|
||||||
//! Simpler but slower overload.
|
//! Simpler but slower overload.
|
||||||
PrettyWriter& String(const Ch* str) { return String(str, internal::StrLen(str)); }
|
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:
|
protected:
|
||||||
void PrettyPrefix(Type type) {
|
void PrettyPrefix(Type type) {
|
||||||
(void)type;
|
(void)type;
|
||||||
|
@ -25,8 +25,9 @@ namespace rapidjson {
|
|||||||
for example Reader::Parse() and Document::Accept().
|
for example Reader::Parse() and Document::Accept().
|
||||||
|
|
||||||
\tparam OutputStream Type of output stream.
|
\tparam OutputStream Type of output stream.
|
||||||
\tparam SourceEncoding Encoding of both source strings.
|
\tparam SourceEncoding Encoding of source string.
|
||||||
\tparam TargetEncoding Encoding of and output stream.
|
\tparam TargetEncoding Encoding of output stream.
|
||||||
|
\tparam Allocator Type of allocator for allocating memory of stack.
|
||||||
\note implements Handler concept
|
\note implements Handler concept
|
||||||
*/
|
*/
|
||||||
template<typename OutputStream, typename SourceEncoding = UTF8<>, typename TargetEncoding = UTF8<>, typename Allocator = MemoryPoolAllocator<> >
|
template<typename OutputStream, typename SourceEncoding = UTF8<>, typename TargetEncoding = UTF8<>, typename Allocator = MemoryPoolAllocator<> >
|
||||||
@ -34,6 +35,11 @@ class Writer {
|
|||||||
public:
|
public:
|
||||||
typedef typename SourceEncoding::Ch Ch;
|
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) :
|
Writer(OutputStream& os, Allocator* allocator = 0, size_t levelDepth = kDefaultLevelDepth) :
|
||||||
os_(os), level_stack_(allocator, levelDepth * sizeof(Level)),
|
os_(os), level_stack_(allocator, levelDepth * sizeof(Level)),
|
||||||
doublePrecision_(kDefaultDoublePrecision) {}
|
doublePrecision_(kDefaultDoublePrecision) {}
|
||||||
@ -53,8 +59,11 @@ public:
|
|||||||
//! \see SetDoublePrecision()
|
//! \see SetDoublePrecision()
|
||||||
int GetDoublePrecision() const { return doublePrecision_; }
|
int GetDoublePrecision() const { return doublePrecision_; }
|
||||||
|
|
||||||
//@name Implementation of Handler
|
/*!@name Implementation of Handler
|
||||||
|
\see Handler
|
||||||
|
*/
|
||||||
//@{
|
//@{
|
||||||
|
|
||||||
Writer& Null() { Prefix(kNullType); WriteNull(); return *this; }
|
Writer& Null() { Prefix(kNullType); WriteNull(); return *this; }
|
||||||
Writer& Bool(bool b) { Prefix(b ? kTrueType : kFalseType); WriteBool(b); return *this; }
|
Writer& Bool(bool b) { Prefix(b ? kTrueType : kFalseType); WriteBool(b); return *this; }
|
||||||
Writer& Int(int i) { Prefix(kNumberType); WriteInt(i); 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; }
|
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) {
|
Writer& String(const Ch* str, SizeType length, bool copy = false) {
|
||||||
(void)copy;
|
(void)copy;
|
||||||
Prefix(kStringType);
|
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.
|
//! Simpler but slower overload.
|
||||||
Writer& String(const Ch* str) { return String(str, internal::StrLen(str)); }
|
Writer& String(const Ch* str) { return String(str, internal::StrLen(str)); }
|
||||||
|
|
||||||
|
//@}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
//! Information for each nested level
|
//! Information for each nested level
|
||||||
struct Level {
|
struct Level {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user