8#ifndef INCLUDED_BALJSN_ENCODER
9#define INCLUDED_BALJSN_ENCODER
173#include <balscm_version.h>
200#include <bsl_cstddef.h>
201#include <bsl_iostream.h>
202#include <bsl_ostream.h>
203#include <bsl_sstream.h>
204#include <bsl_streambuf.h>
205#include <bsl_string.h>
206#include <bsl_string_view.h>
207#include <bsl_vector.h>
239 bsl::ostream& logStream();
261 template <
class TYPE>
262 int encode(bsl::streambuf *streamBuf,
265 template <
class TYPE>
266 int encode(bsl::streambuf *streamBuf,
277 template <
class TYPE>
278 int encode(bsl::ostream& stream,
281 template <
class TYPE>
282 int encode(bsl::ostream& stream,
292 template <
class TYPE>
293 int encode(bsl::streambuf *streamBuf,
const TYPE& value);
303 template <
class TYPE>
304 int encode(bsl::ostream& stream,
const TYPE& value);
317 template <
class TYPE>
321 template <
class TYPE>
343 template <
class TYPE>
347 template <
class TYPE>
376bsl::ostream& Encoder::logStream()
384: d_logStream(basicAllocator)
394 return encode(streamBuf, value, options);
402 return encode(stream, value, options);
421 <<
"Encoded object must be a Sequence, Choice, or Array type."
426 bsl::ostream outputStream(streamBuf);
434 streamBuf->pubsync();
442 <<
"An error occurred when writing to the supplied output stream"
445 streamBuf->pubsync();
449 streamBuf->pubsync();
460 return encode(streamBuf, value, options ? *options : localOpts);
468 if (!stream.good()) {
469 logStream() <<
"Invalid stream." << bsl::endl;
473 const int rc = this->
encode(stream.rdbuf(), value, options);
475 stream.setstate(bsl::ios_base::failbit);
489 return encode(stream, value, options ? *options : localOpts);
552 return d_logStream.str();
577 bsl::ostream& d_outputStream;
578 bool d_usePrettyStyle;
580 int d_spacesPerLevel;
581 bool d_isArrayElement;
673 return d_isArrayElement;
Definition baljsn_encoderoptions.h:290
Definition baljsn_encoder.h:227
int encode(bsl::streambuf *streamBuf, const TYPE &value, const EncoderOptions &options)
Definition baljsn_encoder.h:406
~Encoder()=default
Destroy this object.
int encodeAny(bsl::streambuf *streamBuf, const TYPE &value, const EncoderOptions &options)
Definition baljsn_encoder.h:494
int encodeAny(bsl::streambuf *streamBuf, const bdlar::AnyConstRef &any, const EncoderOptions &options)
bsl::string loggedMessages() const
Definition baljsn_encoder.h:550
int encodeAny(bsl::ostream &stream, const bdlar::AnyConstRef &any, const EncoderOptions &options)
Definition bdlar_anyref.h:247
static bsl::enable_if<!IsDynamic< t_TYPE >::value, AnyConstRef >::type makeAnyConstRef(const t_TYPE &object)
Make AnyConstRef to the specified object.
Definition bdlar_refutil.h:194
Definition bslstl_string.h:1252
Definition bslma_allocator.h:545
#define BSLS_ASSERT(X)
Definition bsls_assert.h:1976
#define BSLS_IDENT(str)
BSLS_IDENT() - insert string into .comment binary segment (if supported)
Definition bsls_ident.h:238
Definition baljsn_convertfromjsonoptions.h:112
bdlat_TypeCategory::Value select(const TYPE &object)
basic_ostringstream< char, char_traits< char >, allocator< char > > ostringstream
Definition bslstl_iosfwd.h:97
static int encode(bsl::ostream *jsonStream, const TYPE &value, const EncoderOptions &options=EncoderOptions())
Definition baljsn_encodeimplutil.h:1237
static void closeDocument(bsl::ostream *outputStream, const EncoderOptions &options)
Definition baljsn_encodeimplutil.h:1224
static void openDocument(bsl::ostream *outputStream, const EncoderOptions &options)
Definition baljsn_encodeimplutil.h:1212
Value
Definition bdlat_typecategory.h:1046
@ e_ARRAY_CATEGORY
Definition bdlat_typecategory.h:1048
@ e_CHOICE_CATEGORY
Definition bdlat_typecategory.h:1049
@ e_SEQUENCE_CATEGORY
Definition bdlat_typecategory.h:1053