#include <jsoncons_ext/ubjson/ubjson_encoder.hpp>
template<
class Result>
> class basic_ubjson_encoder : public jsoncons::json_content_handler
basic_ubjson_encoder
is noncopyable and nonmoveable.
Four specializations for common character types and result types are defined:
Type | Definition |
---|---|
ubjson_stream_encoder | basic_ubjson_encoderjsoncons::binary_stream_result |
ubjson_bytes_encoder | basic_ubjson_encoderjsoncons::binary_buffer_result |
Type | Definition |
---|---|
char_type | char |
result_type | Result |
string_view_type |
explicit basic_ubjson_encoder(result_type result)
Constructs a new encoder that writes to the specified result.
virtual ~basic_ubjson_encoder()
Inherited from jsoncons::basic_json_content_handler
bool begin_object(semantic_tag tag=semantic_tag::none,
const ser_context& context=null_ser_context()); // (1)
bool begin_object(size_t length,
semantic_tag tag=semantic_tag::none,
const ser_context& context = null_ser_context()); // (2)
bool end_object(const ser_context& context = null_ser_context()); // (3)
bool begin_array(semantic_tag tag=semantic_tag::none,
const ser_context& context=null_ser_context()); // (4)
bool begin_array(size_t length,
semantic_tag tag=semantic_tag::none,
const ser_context& context=null_ser_context()); // (5)
bool end_array(const ser_context& context=null_ser_context()); // (6)
bool name(const string_view_type& name,
const ser_context& context=null_ser_context()); // (7)
bool null_value(semantic_tag tag = semantic_tag::none,
const ser_context& context=null_ser_context()); // (8)
bool bool_value(bool value,
semantic_tag tag = semantic_tag::none,
const ser_context& context=null_ser_context()); // (9)
bool string_value(const string_view_type& value,
semantic_tag tag = semantic_tag::none,
const ser_context& context=null_ser_context()); // (10)
bool byte_string_value(const byte_string_view& b,
semantic_tag tag=semantic_tag::none,
const ser_context& context=null_ser_context()); // (11)
bool uint64_value(uint64_t value,
semantic_tag tag = semantic_tag::none,
const ser_context& context=null_ser_context()); // (12)
bool int64_value(int64_t value,
semantic_tag tag = semantic_tag::none,
const ser_context& context=null_ser_context()); // (13)
bool half_value(uint16_t value,
semantic_tag tag = semantic_tag::none,
const ser_context& context=null_ser_context()); // (14)
bool double_value(double value,
semantic_tag tag = semantic_tag::none,
const ser_context& context=null_ser_context()); // (15)
bool begin_object(semantic_tag tag,
const ser_context& context,
std::error_code& ec); // (16)
bool begin_object(size_t length,
semantic_tag tag,
const ser_context& context,
std::error_code& ec); // (17)
bool end_object(const ser_context& context,
std::error_code& ec); // (18)
bool begin_array(semantic_tag tag,
const ser_context& context,
std::error_code& ec); // (19)
bool begin_array(size_t length,
semantic_tag tag,
const ser_context& context,
std::error_code& ec); // (20)
bool end_array(const ser_context& context,
std::error_code& ec); // (21)
bool name(const string_view_type& name,
const ser_context& context,
std::error_code& ec); // (22)
bool null_value(semantic_tag tag,
const ser_context& context,
std::error_code& ec); // (23)
bool bool_value(bool value,
semantic_tag tag,
const ser_context& context,
std::error_code& ec); // (24)
bool string_value(const string_view_type& value,
semantic_tag tag,
const ser_context& context,
std::error_code& ec); // (25)
bool byte_string_value(const byte_string_view& b,
semantic_tag tag,
const ser_context& context,
std::error_code& ec); // (26)
bool uint64_value(uint64_t value,
semantic_tag tag,
const ser_context& context,
std::error_code& ec); // (27)
bool int64_value(int64_t value,
semantic_tag tag,
const ser_context& context,
std::error_code& ec); // (28)
bool half_value(uint16_t value,
semantic_tag tag,
const ser_context& context,
std::error_code& ec); // (29)
bool double_value(double value,
semantic_tag tag,
const ser_context& context,
std::error_code& ec); // (30)
(1) Indicates the begining of an object of indefinite length.
Returns true
if the consumer wishes to receive more events, false
otherwise.
Throws a ser_error on parse errors.
(2) Indicates the begining of an object of known length.
Returns true
if the consumer wishes to receive more events, false
otherwise.
Throws a ser_error on parse errors.
(3) Indicates the end of an object.
Returns true
if the consumer wishes to receive more events, false
otherwise.
Throws a ser_error on parse errors.
(4) Indicates the beginning of an indefinite length array.
Returns true
if the consumer wishes to receive more events, false
otherwise.
Throws a ser_error on parse errors.
(5) Indicates the beginning of an array of known length.
Returns true
if the consumer wishes to receive more events, false
otherwise.
Throws a ser_error on parse errors.
(6) Indicates the end of an array.
Returns true
if the consumer wishes to receive more events, false
otherwise.
Throws a ser_error on parse errors.
(7) Writes the name part of an object name-value pair.
Returns true
if the consumer wishes to receive more events, false
otherwise.
Throws a ser_error on parse errors.
(8) Writes a null value.
Returns true
if the consumer wishes to receive more events, false
otherwise.
Throws a ser_error on parse errors.
(9) Writes a boolean value.
Returns true
if the consumer wishes to receive more events, false
otherwise.
Throws a ser_error on parse errors.
(10) Writes a text string value.
Returns true
if the consumer wishes to receive more events, false
otherwise.
Throws a ser_error on parse errors.
(11) Writes a byte string value.
Returns true
if the consumer wishes to receive more events, false
otherwise.
Throws a ser_error on parse errors.
(12) Writes a non-negative integer value.
Returns true
if the consumer wishes to receive more events, false
otherwise.
Throws a ser_error on parse errors.
(13) Writes a signed integer value.
Returns true
if the consumer wishes to receive more events, false
otherwise.
Throws a ser_error on parse errors.
(14) Writes a half precision floating point value.
Returns true
if the consumer wishes to receive more events, false
otherwise.
Throws a ser_error on parse errors.
(15) Writes a double precision floating point value.
Returns true
if the consumer wishes to receive more events, false
otherwise.
Throws a ser_error on parse errors.
(16)-(30) Same as (1)-(15), except sets ec
and returns false
on parse errors.
void flush()
Flushes whatever is buffered to the destination.