#include <baljsn_decoder.h>
List of all members.
Public Member Functions |
| Decoder (bslma::Allocator *basicAllocator=0) |
template<class TYPE > |
int | decode (bsl::streambuf *streamBuf, TYPE *value, const DecoderOptions &options) |
template<class TYPE > |
int | decode (bsl::streambuf *streamBuf, TYPE *value, const DecoderOptions *options) |
template<class TYPE > |
int | decode (bsl::istream &stream, TYPE *value, const DecoderOptions &options) |
template<class TYPE > |
int | decode (bsl::istream &stream, TYPE *value, const DecoderOptions *options) |
template<class TYPE > |
int | decode (bsl::streambuf *streamBuf, TYPE *value) |
template<class TYPE > |
int | decode (bsl::istream &stream, TYPE *value) |
bsl::string | loggedMessages () const |
Friends |
struct | Decoder_DecodeImpProxy |
struct | Decoder_ElementVisitor |
Detailed Description
This class provides a mechanism for decoding JSON data into value-semantic objects. The decode
methods are function templates that will decode 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 manipulating struct-like and union-like objects. In particular, the types generated by bas_codegen.pl
provide the necessary interface and can be decoded using this component.
See Component baljsn_decoder
Constructor & Destructor Documentation
Construct a decoder object using the optionally specified basicAllocator
. If basicAllocator
is 0, the default allocator is used.
Member Function Documentation
template<class TYPE >
int baljsn::Decoder::decode |
( |
bsl::streambuf * |
streamBuf, |
|
|
TYPE * |
value, |
|
|
const DecoderOptions & |
options | |
|
) |
| | |
template<class TYPE >
int baljsn::Decoder::decode |
( |
bsl::streambuf * |
streamBuf, |
|
|
TYPE * |
value, |
|
|
const DecoderOptions * |
options | |
|
) |
| | |
Decode into the specified value
, of a (template parameter) TYPE
, the JSON data read from the specified streamBuf
and using the specified options
. Specifying a nullptr options
is equivalent to passing a default-constructed DecoderOptions in options
. TYPE
shall be a bdeat
-compatible sequence, choice, or array type, or a bdeat
-compatible dynamic type referring to one of those types. Return 0 on success, and a non-zero value otherwise. Note that this operation internally buffers input from streambuf
, and if decoding is successful, will attempt to update the input position of streambuf
to the last unprocessed byte.
template<class TYPE >
int baljsn::Decoder::decode |
( |
bsl::istream & |
stream, |
|
|
TYPE * |
value, |
|
|
const DecoderOptions & |
options | |
|
) |
| | |
template<class TYPE >
int baljsn::Decoder::decode |
( |
bsl::istream & |
stream, |
|
|
TYPE * |
value, |
|
|
const DecoderOptions * |
options | |
|
) |
| | |
Decode into the specified value
, of a (template parameter) TYPE
, the JSON data read from the specified stream
and using the specified options
. TYPE
shall be a bdeat
-compatible sequence, choice, or array type, or a bdeat
-compatible dynamic type referring to one of those types. Specifying a nullptr options
is equivalent to passing a default-constructed DecoderOptions in options
. Return 0 on success, and a non-zero value otherwise. Note that this operation internally buffers input from stream
, and if decoding is successful, will attempt to update the input position of stream
to the last unprocessed byte.
template<class TYPE >
int baljsn::Decoder::decode |
( |
bsl::streambuf * |
streamBuf, |
|
|
TYPE * |
value | |
|
) |
| | |
Decode an object of (template parameter) TYPE
from the specified streamBuf
and load the result into the specified modifiable value
. Return 0 on success, and a non-zero value otherwise.
DEPRECATED: Use the decode
function passed a reference to a non-modifiable DecoderOptions
object instead.
template<class TYPE >
int baljsn::Decoder::decode |
( |
bsl::istream & |
stream, |
|
|
TYPE * |
value | |
|
) |
| | |
Decode an object of (template parameter) TYPE
from the specified stream
and load the result into the specified modifiable value
. Return 0 on success, and a non-zero value otherwise. Note that stream
will be invalidated if the decoding fails.
DEPRECATED: Use the decode
function passed a reference to a non-modifiable DecoderOptions
object instead.
Return a string containing any error, warning, or trace messages that were logged during the last call to the decode
method. The log is reset each time decode
is called.
Friends And Related Function Documentation
The documentation for this class was generated from the following file: