Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
JsonxWriter< OutputStream > Class Template Reference

Public Member Functions

 JsonxWriter (OutputStream &os)
 
bool Null ()
 
bool Bool (bool b)
 
bool Int (int i)
 
bool Uint (unsigned i)
 
bool Int64 (int64_t i)
 
bool Uint64 (uint64_t i)
 
bool Double (double d)
 
bool RawNumber (const char *str, SizeType length, bool)
 
bool String (const char *str, SizeType length, bool)
 
bool StartObject ()
 
bool Key (const char *str, SizeType length, bool)
 
bool EndObject (SizeType)
 
bool StartArray ()
 
bool EndArray (SizeType)
 

Detailed Description

template<typename OutputStream>
class JsonxWriter< OutputStream >

Definition at line 19 of file jsonx.cpp.

Constructor & Destructor Documentation

◆ JsonxWriter()

template<typename OutputStream >
JsonxWriter< OutputStream >::JsonxWriter ( OutputStream & os)
inline

Definition at line 21 of file jsonx.cpp.

21 : os_(os), name_(), level_(0), hasName_(false) {
22 }
os_t os

Member Function Documentation

◆ Bool()

template<typename OutputStream >
bool JsonxWriter< OutputStream >::Bool ( bool b)
inline

Definition at line 28 of file jsonx.cpp.

28 {
29 return
30 WriteStartElement("boolean") &&
31 WriteString(b ? "true" : "false") &&
32 WriteEndElement("boolean");
33 }

◆ Double()

template<typename OutputStream >
bool JsonxWriter< OutputStream >::Double ( double d)
inline

Definition at line 55 of file jsonx.cpp.

55 {
56 char buffer[30];
57 return WriteNumberElement(buffer, sprintf(buffer, "%.17g", d));
58 }

◆ EndArray()

template<typename OutputStream >
bool JsonxWriter< OutputStream >::EndArray ( SizeType )
inline

Definition at line 95 of file jsonx.cpp.

95 {
96 return WriteEndElement("array");
97 }

◆ EndObject()

template<typename OutputStream >
bool JsonxWriter< OutputStream >::EndObject ( SizeType )
inline

Definition at line 87 of file jsonx.cpp.

87 {
88 return WriteEndElement("object");
89 }

◆ Int()

template<typename OutputStream >
bool JsonxWriter< OutputStream >::Int ( int i)
inline

Definition at line 35 of file jsonx.cpp.

35 {
36 char buffer[12];
37 return WriteNumberElement(buffer, sprintf(buffer, "%d", i));
38 }

◆ Int64()

template<typename OutputStream >
bool JsonxWriter< OutputStream >::Int64 ( int64_t i)
inline

Definition at line 45 of file jsonx.cpp.

45 {
46 char buffer[21];
47 return WriteNumberElement(buffer, sprintf(buffer, "%" PRId64, i));
48 }
#define PRId64
Definition inttypes.h:88

◆ Key()

template<typename OutputStream >
bool JsonxWriter< OutputStream >::Key ( const char * str,
SizeType length,
bool  )
inline

Definition at line 78 of file jsonx.cpp.

78 {
79 // backup key to name_
80 name_.Clear();
81 for (SizeType i = 0; i < length; i++)
82 name_.Put(str[i]);
83 hasName_ = true;
84 return true;
85 }
RAPIDJSON_NAMESPACE_BEGIN typedef unsigned SizeType
Size type (for string lengths, array sizes, etc.)
Definition rapidjson.h:384
Here is the call graph for this function:

◆ Null()

template<typename OutputStream >
bool JsonxWriter< OutputStream >::Null ( )
inline

Definition at line 24 of file jsonx.cpp.

24 {
25 return WriteStartElement("null", true);
26 }

◆ RawNumber()

template<typename OutputStream >
bool JsonxWriter< OutputStream >::RawNumber ( const char * str,
SizeType length,
bool  )
inline

Definition at line 60 of file jsonx.cpp.

60 {
61 return
62 WriteStartElement("number") &&
63 WriteEscapedText(str, length) &&
64 WriteEndElement("number");
65 }

◆ StartArray()

template<typename OutputStream >
bool JsonxWriter< OutputStream >::StartArray ( )
inline

Definition at line 91 of file jsonx.cpp.

91 {
92 return WriteStartElement("array");
93 }

◆ StartObject()

template<typename OutputStream >
bool JsonxWriter< OutputStream >::StartObject ( )
inline

Definition at line 74 of file jsonx.cpp.

74 {
75 return WriteStartElement("object");
76 }

◆ String()

template<typename OutputStream >
bool JsonxWriter< OutputStream >::String ( const char * str,
SizeType length,
bool  )
inline

Definition at line 67 of file jsonx.cpp.

67 {
68 return
69 WriteStartElement("string") &&
70 WriteEscapedText(str, length) &&
71 WriteEndElement("string");
72 }

◆ Uint()

template<typename OutputStream >
bool JsonxWriter< OutputStream >::Uint ( unsigned i)
inline

Definition at line 40 of file jsonx.cpp.

40 {
41 char buffer[11];
42 return WriteNumberElement(buffer, sprintf(buffer, "%u", i));
43 }

◆ Uint64()

template<typename OutputStream >
bool JsonxWriter< OutputStream >::Uint64 ( uint64_t i)
inline

Definition at line 50 of file jsonx.cpp.

50 {
51 char buffer[21];
52 return WriteNumberElement(buffer, sprintf(buffer, "%" PRIu64, i));
53 }
#define PRIu64
Definition inttypes.h:142

The documentation for this class was generated from the following file: