A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://www.ncbi.nlm.nih.gov/IEB/ToolBox/CPP_DOC/doxyhtml/prettywriter_8h_source.html below:

NCBI C++ ToolKit: include/misc/jsonwrapp/rapidjson11/prettywriter.h Source File

15 #ifndef RAPIDJSON_PRETTYWRITER_H_ 16 #define RAPIDJSON_PRETTYWRITER_H_ 22

RAPIDJSON_DIAG_OFF(effc++)

25 #if defined(__clang__) 27

RAPIDJSON_DIAG_OFF(c++98-compat)

47 template

<

typename

OutputStream,

typename

SourceEncoding = UTF8<>,

typename

TargetEncoding = UTF8<>,

typename

StackAllocator = CrtAllocator,

unsigned

writeFlags = kWriteDefaultFlags>

48 class PrettyWriter

:

public Writer

<OutputStream, SourceEncoding, TargetEncoding, StackAllocator, writeFlags> {

58  explicit PrettyWriter

(OutputStream& os, StackAllocator* allocator = 0,

size_t

levelDepth = Base::kDefaultLevelDepth) :

59  Base

(os, allocator, levelDepth), indentChar_(

' '

), indentCharCount_(4), formatOptions_(

kFormatDefault

), eol_(

true

) {}

62  explicit PrettyWriter

(StackAllocator* allocator = 0,

size_t

levelDepth = Base::kDefaultLevelDepth) :

63  Base

(allocator, levelDepth), indentChar_(

' '

), indentCharCount_(4), eol_(

true

) {}

65 #if RAPIDJSON_HAS_CXX11_RVALUE_REFS 67

Base(std::forward<

PrettyWriter

>(rhs)), indentChar_(rhs.indentChar_), indentCharCount_(rhs.indentCharCount_), formatOptions_(rhs.formatOptions_), eol_(

true

) {}

76  RAPIDJSON_ASSERT

(indentChar ==

' '

|| indentChar ==

'\t'

|| indentChar ==

'\n'

|| indentChar ==

'\r'

);

77

indentChar_ = indentChar;

78

indentCharCount_ = indentCharCount;

92

formatOptions_ = options;

113  return

Base::WriteString(

str

, length);

120  return

Base::WriteString(

str

, length);

123 #if RAPIDJSON_HAS_STDSTRING 124  bool

String(

const

std::basic_string<Ch>&

str

) {

131  new

(Base::level_stack_.template Push<typename Base::Level>())

typename Base::Level

(

false

);

132  return

Base::WriteStartObject();

137 #if RAPIDJSON_HAS_STDSTRING 138  bool

Key(

const

std::basic_string<Ch>&

str

) {

146  RAPIDJSON_ASSERT

(!Base::level_stack_.

template

Top<typename Base::Level>()->inArray);

147  bool empty

= Base::level_stack_.template Pop<typename Base::Level>(1)->valueCount == 0;

153  bool

ret = Base::WriteEndObject();

156  if

(Base::level_stack_.

Empty

())

163  new

(Base::level_stack_.template Push<typename Base::Level>())

typename Base::Level

(

true

);

164  return

Base::WriteStartArray();

170  RAPIDJSON_ASSERT

(Base::level_stack_.

template

Top<typename Base::Level>()->inArray);

171  bool empty

= Base::level_stack_.template Pop<typename Base::Level>(1)->valueCount == 0;

177  bool

ret = Base::WriteEndArray();

180  if

(Base::level_stack_.

Empty

())

207

PrettyPrefix(

type

);

208  return

Base::WriteRawValue(json, length);

214  if

(Base::level_stack_.GetSize() != 0) {

215  typename Base::Level

* level = Base::level_stack_.template Top<typename Base::Level>();

219

Base::os_->Put(

','

);

221

Base::os_->Put(

' '

);

232

Base::os_->Put(

','

);

236

Base::os_->Put(

':'

);

237

Base::os_->Put(

' '

);

252

Base::hasRoot_ =

true

;

257  size_t count

= (Base::level_stack_.GetSize() /

sizeof

(

typename Base::Level

)) * indentCharCount_;

258  PutN

(*Base::os_,

static_cast<

typename OutputStream::Ch

>

(indentChar_),

count

);

265

Base::os_->Put(

'\n'

);

282 #if defined(__clang__)

Writer with indentation and spacing.

PrettyWriter & SetWriteEol(bool eol)

bool RawNumber(const Ch *str, SizeType length, bool copy=false)

PrettyWriter & SetIndent(Ch indentChar, unsigned indentCharCount)

Set custom indentation.

PrettyFormatOptions formatOptions_

PrettyWriter(StackAllocator *allocator=0, size_t levelDepth=Base::kDefaultLevelDepth)

bool RawValue(const Ch *json, size_t length, Type type)

Write a raw JSON value.

bool String(const Ch *str)

Simpler but slower overload.

bool Uint64(uint64_t u64)

PrettyWriter(const PrettyWriter &)

Writer< OutputStream, SourceEncoding, TargetEncoding, StackAllocator > Base

PrettyWriter(OutputStream &os, StackAllocator *allocator=0, size_t levelDepth=Base::kDefaultLevelDepth)

Constructor.

bool EndArray(SizeType memberCount=0)

PrettyWriter & operator=(const PrettyWriter &)

unsigned indentCharCount_

bool EndObject(SizeType memberCount=0)

PrettyWriter & SetFormatOptions(PrettyFormatOptions options)

Set pretty writer formatting options.

bool Key(const Ch *str, SizeType length, bool copy=false)

bool String(const Ch *str, SizeType length, bool copy=false)

void PrettyPrefix(Type type)

bool Empty(const CNcbiOstrstream &src)

static const char * str(char *buf, int n)

#define RAPIDJSON_ASSERT(x)

Assertion.

#define RAPIDJSON_NAMESPACE_BEGIN

provide custom rapidjson namespace (opening expression)

#define RAPIDJSON_NAMESPACE_END

provide custom rapidjson namespace (closing expression)

constexpr bool empty(list< Ts... >) noexcept

PrettyFormatOptions

Combination of PrettyWriter format flags.

@ kFormatSingleLineArray

Format arrays on a single line.

@ kFormatDefault

Default pretty formatting.

void PutN(FileWriteStream &stream, char c, size_t n)

Implement specialized version of PutN() with memset() for better performance.

unsigned SizeType

Size type (for string lengths, array sizes, etc.)

void copy(Njn::Matrix< S > *matrix_, const Njn::Matrix< T > &matrix0_)

Information for each nested level.

bool inArray

true if in array, otherwise in object

size_t valueCount

number of values in this level


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4