diff options
author | miloyip@gmail.com <miloyip@gmail.com@c5894555-1306-4e8d-425f-1f6f381ee07c> | 2011-12-03 13:57:17 +0400 |
---|---|---|
committer | miloyip@gmail.com <miloyip@gmail.com@c5894555-1306-4e8d-425f-1f6f381ee07c> | 2011-12-03 13:57:17 +0400 |
commit | 7c914a9d4cb39de8e54fbe6c07a7d91072d9ef15 (patch) | |
tree | 7239e84879be57c67ab7f2a3c168fb214f19daea /include/rapidjson/prettywriter.h | |
parent | f516a01769df9e5b7ec686b10e361220929c5630 (diff) |
Added RAPIDJSON_STATIC_ASSERT() and applied it to check size of character types in encodings.
Modified API documentation to previous changes.
Rename Stream to InputStream/OutputStream/InputByteStream/OutputByteStream, and stream to is/os according to the context.
git-svn-id: https://rapidjson.googlecode.com/svn/trunk@49 c5894555-1306-4e8d-425f-1f6f381ee07c
Diffstat (limited to 'include/rapidjson/prettywriter.h')
-rw-r--r-- | include/rapidjson/prettywriter.h | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/include/rapidjson/prettywriter.h b/include/rapidjson/prettywriter.h index 6aba86b0..3f3e4cda 100644 --- a/include/rapidjson/prettywriter.h +++ b/include/rapidjson/prettywriter.h @@ -7,23 +7,23 @@ namespace rapidjson { //! Writer with indentation and spacing.
/*!
- \tparam Stream Type of ouptut stream.
+ \tparam OutputStream Type of ouptut os.
\tparam Encoding Encoding of both source strings and output.
\tparam Allocator Type of allocator for allocating memory of stack.
*/
-template<typename Stream, typename SourceEncoding = UTF8<>, typename TargetEncoding = UTF8<>, typename Allocator = MemoryPoolAllocator<> >
-class PrettyWriter : public Writer<Stream, SourceEncoding, TargetEncoding, Allocator> {
+template<typename OutputStream, typename SourceEncoding = UTF8<>, typename TargetEncoding = UTF8<>, typename Allocator = MemoryPoolAllocator<> >
+class PrettyWriter : public Writer<OutputStream, SourceEncoding, TargetEncoding, Allocator> {
public:
- typedef Writer<Stream, SourceEncoding, TargetEncoding, Allocator> Base;
+ typedef Writer<OutputStream, SourceEncoding, TargetEncoding, Allocator> Base;
typedef typename Base::Ch Ch;
//! Constructor
- /*! \param stream Output stream.
+ /*! \param os Output os.
\param allocator User supplied allocator. If it is null, it will create a private one.
\param levelDepth Initial capacity of
*/
- PrettyWriter(Stream& stream, Allocator* allocator = 0, size_t levelDepth = Base::kDefaultLevelDepth) :
- Base(stream, allocator, levelDepth), indentChar_(' '), indentCharCount_(4) {}
+ PrettyWriter(OutputStream& os, Allocator* allocator = 0, size_t levelDepth = Base::kDefaultLevelDepth) :
+ Base(os, allocator, levelDepth), indentChar_(' '), indentCharCount_(4) {}
//! Set custom indentation.
/*! \param indentChar Character for indentation. Must be whitespace character (' ', '\t', '\n', '\r').
@@ -67,12 +67,12 @@ public: bool empty = Base::level_stack_.template Pop<typename Base::Level>(1)->valueCount == 0;
if (!empty) {
- Base::stream_.Put('\n');
+ Base::os_.Put('\n');
WriteIndent();
}
Base::WriteEndObject();
if (Base::level_stack_.Empty()) // end of json text
- Base::stream_.Flush();
+ Base::os_.Flush();
return *this;
}
@@ -89,12 +89,12 @@ public: bool empty = Base::level_stack_.template Pop<typename Base::Level>(1)->valueCount == 0;
if (!empty) {
- Base::stream_.Put('\n');
+ Base::os_.Put('\n');
WriteIndent();
}
Base::WriteEndArray();
if (Base::level_stack_.Empty()) // end of json text
- Base::stream_.Flush();
+ Base::os_.Flush();
return *this;
}
@@ -110,26 +110,26 @@ protected: if (level->inArray) {
if (level->valueCount > 0) {
- Base::stream_.Put(','); // add comma if it is not the first element in array
- Base::stream_.Put('\n');
+ Base::os_.Put(','); // add comma if it is not the first element in array
+ Base::os_.Put('\n');
}
else
- Base::stream_.Put('\n');
+ Base::os_.Put('\n');
WriteIndent();
}
else { // in object
if (level->valueCount > 0) {
if (level->valueCount % 2 == 0) {
- Base::stream_.Put(',');
- Base::stream_.Put('\n');
+ Base::os_.Put(',');
+ Base::os_.Put('\n');
}
else {
- Base::stream_.Put(':');
- Base::stream_.Put(' ');
+ Base::os_.Put(':');
+ Base::os_.Put(' ');
}
}
else
- Base::stream_.Put('\n');
+ Base::os_.Put('\n');
if (level->valueCount % 2 == 0)
WriteIndent();
@@ -144,7 +144,7 @@ protected: void WriteIndent() {
size_t count = (Base::level_stack_.GetSize() / sizeof(typename Base::Level)) * indentCharCount_;
- PutN(Base::stream_, indentChar_, count);
+ PutN(Base::os_, indentChar_, count);
}
Ch indentChar_;
|