#include <baljsn_encoder.h>
|
| Encoder (bslma::Allocator *basicAllocator=0) |
|
| ~Encoder ()=default |
| Destroy this object.
|
|
template<class TYPE > |
int | encode (bsl::streambuf *streamBuf, const TYPE &value, const EncoderOptions &options) |
|
template<class TYPE > |
int | encode (bsl::streambuf *streamBuf, const TYPE &value, const EncoderOptions *options) |
|
template<class TYPE > |
int | encode (bsl::ostream &stream, const TYPE &value, const EncoderOptions &options) |
|
template<class TYPE > |
int | encode (bsl::ostream &stream, const TYPE &value, const EncoderOptions *options) |
|
template<class TYPE > |
int | encode (bsl::streambuf *streamBuf, const TYPE &value) |
|
template<class TYPE > |
int | encode (bsl::ostream &stream, const TYPE &value) |
|
bsl::string | loggedMessages () const |
|
This class provides a mechanism for encoding value-semantic objects in the JSON format. The encode
methods are function templates that will encode any object that meets the requirements of a sequence, choice, or array object as defined in the bdlat_sequencefunctions , bdlat_choicefunctions , and bdlat_choicefunctions components respectively. These generic frameworks provide a common compile-time interface for accessing struct-like and union-like objects. In particular, the types generated by bas_codegen.pl
provide the necessary interface and can be encoded using this component.
See baljsn_encoder
◆ Encoder()
Create a encoder object. Optionally specify a basicAllocator
used to supply memory. If basicAllocator
is 0, the currently installed default allocator is used.
◆ ~Encoder()
baljsn::Encoder::~Encoder |
( |
| ) |
|
|
default |
◆ encode() [1/6]
template<class TYPE >
int baljsn::Encoder::encode |
( |
bsl::ostream & |
stream, |
|
|
const TYPE & |
value |
|
) |
| |
|
inline |
Encode the specified value
of (template parameter) TYPE
into the specified stream
. Return 0 on success, and a non-zero value otherwise. Note that stream
will be invalidated if the encoding failed.
- Deprecated:
- Use encode function passed a reference to a non-modifiable
EncoderOptions
object instead.
◆ encode() [2/6]
template<class TYPE >
int baljsn::Encoder::encode |
( |
bsl::ostream & |
stream, |
|
|
const TYPE & |
value, |
|
|
const EncoderOptions & |
options |
|
) |
| |
Encode the specified value
, of (template parameter) TYPE
, in the JSON format using the specified options
and output it onto the specified stream
. Specifying a nullptr options
is equivalent to passing a default-constructed DecoderOptions in options
. TYPE
shall be a bdlat
-compatible choice, or array type, or a bdlat
-compatible dynamic type referring to one of those types. Return 0 on success, and a non-zero value otherwise.
◆ encode() [3/6]
template<class TYPE >
int baljsn::Encoder::encode |
( |
bsl::ostream & |
stream, |
|
|
const TYPE & |
value, |
|
|
const EncoderOptions * |
options |
|
) |
| |
|
inline |
◆ encode() [4/6]
template<class TYPE >
int baljsn::Encoder::encode |
( |
bsl::streambuf * |
streamBuf, |
|
|
const TYPE & |
value |
|
) |
| |
|
inline |
Encode the specified value
of (template parameter) TYPE
into the specified streamBuf
. Return 0 on success, and a non-zero value otherwise.
- Deprecated:
- Use encode function passed a reference to a non-modifiable
EncoderOptions
object instead.
◆ encode() [5/6]
template<class TYPE >
int baljsn::Encoder::encode |
( |
bsl::streambuf * |
streamBuf, |
|
|
const TYPE & |
value, |
|
|
const EncoderOptions & |
options |
|
) |
| |
Encode the specified value
, of (template parameter) TYPE
, in the JSON format using the specified options
and output it onto the specified streamBuf
. Specifying a nullptr options
is equivalent to passing a default-constructed DecoderOptions in options
. TYPE
shall be a bdlat
-compatible sequence, choice, or array type, or a bdlat
-compatible dynamic type referring to one of those types. Return 0 on success, and a non-zero value otherwise.
◆ encode() [6/6]
template<class TYPE >
int baljsn::Encoder::encode |
( |
bsl::streambuf * |
streamBuf, |
|
|
const TYPE & |
value, |
|
|
const EncoderOptions * |
options |
|
) |
| |
◆ loggedMessages()
Return a string containing any error, warning, or trace messages that were logged during the last call to the encode
method. The log is reset each time encode
is called.
The documentation for this class was generated from the following file: