Electroneum
Loading...
Searching...
No Matches
json_archive< true > Struct Reference

#include <json_archive.h>

Inheritance diagram for json_archive< true >:
Collaboration diagram for json_archive< true >:

Public Member Functions

 json_archive (stream_type &s, bool indent=false)
template<class T>
void serialize_int (T v)
void serialize_blob (void *buf, size_t len, const char *delimiter="\"")
void serialize_string (std::string str, const char *delimiter="\"")
template<class T>
void serialize_varint (T &v)
void begin_string (const char *delimiter="\"")
void end_string (const char *delimiter="\"")
void begin_array (size_t s=0)
void delimit_array ()
void end_array ()
void write_variant_tag (const char *t)
Public Member Functions inherited from json_archive_base< std::ostream, true >
 json_archive_base (stream_type &s, bool indent=false)
void tag (const char *tag)
void begin_object ()
void end_object ()
void begin_variant ()
void end_variant ()
std::ostream & stream ()

Static Public Member Functions

template<typename T>
static auto promote_to_printable_integer_type (T v) -> decltype(+v)

Additional Inherited Members

Public Types inherited from json_archive_base< std::ostream, true >
typedef std::ostream stream_type
typedef json_archive_base< std::ostream, IsSaving > base_type
typedef boost::mpl::bool_< IsSaving > is_saving
typedef const char * variant_tag_type
Protected Member Functions inherited from json_archive_base< std::ostream, true >
void make_indent ()
Protected Attributes inherited from json_archive_base< std::ostream, true >
stream_typestream_
bool indent_
bool object_begin
size_t depth_

Detailed Description

Definition at line 115 of file json_archive.h.

Constructor & Destructor Documentation

◆ json_archive()

json_archive< true >::json_archive ( stream_type & s,
bool indent = false )
inline

Definition at line 117 of file json_archive.h.

117: base_type(s, indent), inner_array_size_(0) { }
json_archive_base< std::ostream, IsSaving > base_type
a archive using the JSON standard

Member Function Documentation

◆ begin_array()

void json_archive< true >::begin_array ( size_t s = 0)
inline

Definition at line 164 of file json_archive.h.

165 {
166 inner_array_size_ = s;
167 ++depth_;
168 stream_ << "[ ";
169 }

◆ begin_string()

void json_archive< true >::begin_string ( const char * delimiter = "\"")
inline

Definition at line 154 of file json_archive.h.

155 {
157 }
Here is the caller graph for this function:

◆ delimit_array()

void json_archive< true >::delimit_array ( )
inline

Definition at line 171 of file json_archive.h.

172 {
173 stream_ << ", ";
174 }

◆ end_array()

void json_archive< true >::end_array ( )
inline

Definition at line 176 of file json_archive.h.

177 {
178 --depth_;
179 if (0 < inner_array_size_)
180 {
181 make_indent();
182 }
183 stream_ << "]";
184 }
Here is the call graph for this function:

◆ end_string()

void json_archive< true >::end_string ( const char * delimiter = "\"")
inline

Definition at line 159 of file json_archive.h.

160 {
162 }
Here is the caller graph for this function:

◆ promote_to_printable_integer_type()

template<typename T>
auto json_archive< true >::promote_to_printable_integer_type ( T v) -> decltype(+v)
inlinestatic

Definition at line 120 of file json_archive.h.

121 {
122 // Unary operator '+' performs integral promotion on type T [expr.unary.op].
123 // If T is signed or unsigned char, it's promoted to int and printed as number.
124 return +v;
125 }
Here is the caller graph for this function:

◆ serialize_blob()

void json_archive< true >::serialize_blob ( void * buf,
size_t len,
const char * delimiter = "\"" )
inline

Definition at line 133 of file json_archive.h.

133 {
135 for (size_t i = 0; i < len; i++) {
136 unsigned char c = ((unsigned char *)buf)[i];
137 stream_ << std::hex << std::setw(2) << std::setfill('0') << (int)c;
138 }
140 }
void begin_string(const char *delimiter="\"")
void end_string(const char *delimiter="\"")
Here is the call graph for this function:

◆ serialize_int()

template<class T>
void json_archive< true >::serialize_int ( T v)
inline

Definition at line 128 of file json_archive.h.

129 {
131 }
static auto promote_to_printable_integer_type(T v) -> decltype(+v)
Here is the call graph for this function:

◆ serialize_string()

void json_archive< true >::serialize_string ( std::string str,
const char * delimiter = "\"" )
inline

Definition at line 142 of file json_archive.h.

142 {
144 stream_ << str;
146 }
Here is the call graph for this function:

◆ serialize_varint()

template<class T>
void json_archive< true >::serialize_varint ( T & v)
inline

Definition at line 149 of file json_archive.h.

Here is the call graph for this function:

◆ write_variant_tag()

void json_archive< true >::write_variant_tag ( const char * t)
inline

Definition at line 186 of file json_archive.h.

187 {
188 tag(t);
189 }
Here is the call graph for this function:

The documentation for this struct was generated from the following file:
  • /home/abuild/rpmbuild/BUILD/electroneum-5.1.3.1-build/electroneum-5.1.3.1/src/serialization/json_archive.h