BDE 4.39.x Production Release
Loading...
Searching...
No Matches
baljsn_encoder.h
Go to the documentation of this file.
1/// @file baljsn_encoder.h
2///
3/// The content of this file has been pre-processed for Doxygen.
4///
5
6
7// baljsn_encoder.h -*-C++-*-
8#ifndef INCLUDED_BALJSN_ENCODER
9#define INCLUDED_BALJSN_ENCODER
10
11#include <bsls_ident.h>
12BSLS_IDENT("$Id: $")
13
14/// @defgroup baljsn_encoder baljsn_encoder
15/// @brief Provide a JSON encoder for `bdlat`-compatible types.
16/// @addtogroup bal
17/// @{
18/// @addtogroup baljsn
19/// @{
20/// @addtogroup baljsn_encoder
21/// @{
22///
23/// <h1> Outline </h1>
24/// * <a href="#baljsn_encoder-purpose"> Purpose</a>
25/// * <a href="#baljsn_encoder-classes"> Classes </a>
26/// * <a href="#baljsn_encoder-description"> Description </a>
27/// * <a href="#baljsn_encoder-usage"> Usage </a>
28/// * <a href="#baljsn_encoder-example-1-encoding-a-bas_codegen-pl-generated-object-into-json"> Example 1: Encoding a bas_codegen.pl-Generated Object into JSON </a>
29///
30/// # Purpose {#baljsn_encoder-purpose}
31/// Provide a JSON encoder for `bdlat`-compatible types.
32///
33/// # Classes {#baljsn_encoder-classes}
34///
35/// - baljsn::Encoder: JSON decoder for `bdlat`-compliant types
36///
37/// @see baljsn_decoder, baljsn_printutil
38///
39/// # Description {#baljsn_encoder-description}
40/// This component provides a class, `baljsn::Encoder`, for
41/// encoding value-semantic objects in the JSON format. In particular, the
42/// `class` contains a parameterized `encode` function that encodes an object
43/// into a specified stream. There are two overloaded versions of this
44/// function:
45///
46/// * one that writes to a `bsl::streambuf`
47/// * one that writes to an `bsl::ostream`
48///
49/// This component can be used with types that support the `bdlat` framework
50/// (see the `bdlat` package for details), which is a compile-time interface for
51/// manipulating struct-like and union-like objects. In particular, types
52/// generated by the `bas_codegen.pl` tool, and other dynamic types, can be
53/// encoded using this `class`. The `encode` function can be invoked on any
54/// object that satisfies the requirements of a sequence, choice, or array
55/// object as defined in the @ref bdlat_sequencefunctions , @ref bdlat_choicefunctions ,
56/// and @ref bdlat_arrayfunctions components.
57///
58/// Although the JSON format is easy to read and write and is very useful for
59/// debugging, it is relatively expensive to encode and decode and relatively
60/// bulky to transmit. It is more efficient to use a binary encoding (such as
61/// BER) if the encoding format is under your control (see @ref balber_berencoder ).
62///
63/// Refer to the details of the JSON encoding format supported by this encoder
64/// in the package documentation file (doc/baljsn.txt).
65///
66/// ## Usage {#baljsn_encoder-usage}
67///
68///
69/// This section illustrates intended use of this component.
70///
71/// ## Example 1: Encoding a bas_codegen.pl-Generated Object into JSON {#baljsn_encoder-example-1-encoding-a-bas_codegen-pl-generated-object-into-json}
72///
73///
74/// Consider that we want to exchange an employee's information between two
75/// processes. To allow this information exchange we will define the XML schema
76/// representation for that class, use `bas_codegen.pl` to create the `Employee`
77/// `class` for storing that information, populate an `Employee` object, and
78/// encode that object using the `baljsn` encoder.
79///
80/// First, we will define the XML schema inside a file called `employee.xsd`:
81/// @code
82/// <?xml version='1.0' encoding='UTF-8'?>
83/// <xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema'
84/// xmlns:test='http://bloomberg.com/schemas/test'
85/// targetNamespace='http://bloomberg.com/schemas/test'
86/// elementFormDefault='unqualified'>
87///
88/// <xs:complexType name='Address'>
89/// <xs:sequence>
90/// <xs:element name='street' type='xs:string'/>
91/// <xs:element name='city' type='xs:string'/>
92/// <xs:element name='state' type='xs:string'/>
93/// </xs:sequence>
94/// </xs:complexType>
95///
96/// <xs:complexType name='Employee'>
97/// <xs:sequence>
98/// <xs:element name='name' type='xs:string'/>
99/// <xs:element name='homeAddress' type='test:Address'/>
100/// <xs:element name='age' type='xs:int'/>
101/// </xs:sequence>
102/// </xs:complexType>
103///
104/// <xs:element name='Employee' type='test:Employee'/>
105///
106/// </xs:schema>
107/// @endcode
108/// Then, we will use the `bas_codegen.pl` tool, to generate the C++ classes for
109/// this schema. The following command will generate the header and
110/// implementation files for the all the classes in the @ref test_messages
111/// components in the current directory:
112/// @code
113/// $ bas_codegen.pl -m msg -p test xsdfile.xsd
114/// @endcode
115/// Next, we will populate a `test::Employee` object:
116/// @code
117/// test::Employee employee;
118/// employee.name() = "Bob";
119/// employee.homeAddress().street() = "Lexington Ave";
120/// employee.homeAddress().city() = "New York City";
121/// employee.homeAddress().state() = "New York";
122/// employee.age() = 21;
123/// @endcode
124/// Then, we will create a `baljsn::Encoder` object:
125/// @code
126/// baljsn::Encoder encoder;
127/// @endcode
128/// Now, we will output this object in the JSON format by invoking the `encode`
129/// method of the encoder. We will also create a `baljsn::EncoderOptions`
130/// object that allows us to specify that the encoding should be done in a
131/// pretty format, and what the initial indent level and spaces per level should
132/// be. We will then pass that object to the `encode` method:
133/// @code
134/// bsl::ostringstream os;
135///
136/// baljsn::EncoderOptions options;
137/// options.setEncodingStyle(baljsn::EncoderOptions::e_PRETTY);
138/// options.setInitialIndentLevel(1);
139/// options.setSpacesPerLevel(4);
140///
141/// const int rc = encoder.encode(os, employee, options);
142/// assert(!rc);
143/// assert(os);
144/// @endcode
145/// Finally, we will verify that the output is as expected:
146/// @code
147/// const char EXP_OUTPUT[] = " {\n"
148/// " \"name\" : \"Bob\",\n"
149/// " \"homeAddress\" : {\n"
150/// " \"street\" : \"Lexington Ave\",\n"
151/// " \"city\" : \"New York City\",\n"
152/// " \"state\" : \"New York\"\n"
153/// " },\n"
154/// " \"age\" : 21\n"
155/// " }\n";
156///
157/// assert(EXP_OUTPUT == os.str());
158/// @endcode
159/// @}
160/** @} */
161/** @} */
162
163/** @addtogroup bal
164 * @{
165 */
166/** @addtogroup baljsn
167 * @{
168 */
169/** @addtogroup baljsn_encoder
170 * @{
171 */
172
173#include <balscm_version.h>
174
177#include <baljsn_formatter.h>
178
179#include <bdlar_refutil.h>
180
181#include <bdlat_attributeinfo.h>
184#include <bdlat_enumfunctions.h>
185#include <bdlat_formattingmode.h>
187#include <bdlat_selectioninfo.h>
189#include <bdlat_typecategory.h>
191
192#include <bdlb_print.h>
193
195
196#include <bsla_maybeunused.h>
197#include <bsls_assert.h>
198#include <bsls_types.h>
199
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>
208
209
210namespace baljsn {
211
212 // =============
213 // class Encoder
214 // =============
215
216/// This class provides a mechanism for encoding value-semantic objects in
217/// the JSON format. The `encode` methods are function templates that will
218/// encode any object that meets the requirements of a sequence, choice, or
219/// array object as defined in the @ref bdlat_sequencefunctions ,
220/// @ref bdlat_choicefunctions , and @ref bdlat_choicefunctions components
221/// respectively. These generic frameworks provide a common compile-time
222/// interface for accessing struct-like and union-like objects. In
223/// particular, the types generated by `bas_codegen.pl` provide the
224/// necessary interface and can be encoded using this component.
225///
226/// See @ref baljsn_encoder
227class Encoder {
228
229 // DATA
230 bsl::ostringstream d_logStream; // stream used for logging
231
232 private:
233 // NOT IMPLEMENTED
234 Encoder(const Encoder&);
235
236 // PRIVATE MANIPULATORS
237
238 /// Return the stream for logging.
239 bsl::ostream& logStream();
240
241 public:
242 // CREATORS
243
244 /// Create a encoder object. Optionally specify a `basicAllocator` used
245 /// to supply memory. If `basicAllocator` is 0, the currently installed
246 /// default allocator is used.
247 explicit Encoder(bslma::Allocator *basicAllocator = 0);
248
249 /// Destroy this object.
250 ~Encoder() = default;
251
252 // MANIPULATORS
253
254 /// Encode the specified `value`, of (template parameter) `TYPE`, in the
255 /// JSON format using the specified `options` and output it onto the
256 /// specified `streamBuf`. Specifying a nullptr `options` is equivalent
257 /// to passing a default-constructed EncoderOptions in `options`.
258 /// `TYPE` shall be a `bdlat`-compatible sequence, choice, or array
259 /// type, or a `bdlat`-compatible dynamic type referring to one of those
260 /// types. Return 0 on success, and a non-zero value otherwise.
261 template <class TYPE>
262 int encode(bsl::streambuf *streamBuf,
263 const TYPE& value,
264 const EncoderOptions& options);
265 template <class TYPE>
266 int encode(bsl::streambuf *streamBuf,
267 const TYPE& value,
268 const EncoderOptions *options);
269
270 /// Encode the specified `value`, of (template parameter) `TYPE`, in the
271 /// JSON format using the specified `options` and output it onto the
272 /// specified `stream`. Specifying a nullptr `options` is equivalent to
273 /// passing a default-constructed EncoderOptions in `options`. `TYPE`
274 /// shall be a `bdlat`-compatible choice, or array type, or a
275 /// `bdlat`-compatible dynamic type referring to one of those types.
276 /// Return 0 on success, and a non-zero value otherwise.
277 template <class TYPE>
278 int encode(bsl::ostream& stream,
279 const TYPE& value,
280 const EncoderOptions& options);
281 template <class TYPE>
282 int encode(bsl::ostream& stream,
283 const TYPE& value,
284 const EncoderOptions *options);
285
286 /// Encode the specified `value` of (template parameter) `TYPE` into the
287 /// specified `streamBuf`. Return 0 on success, and a non-zero value
288 /// otherwise.
289 ///
290 /// @deprecated Use @ref encode function passed a reference to a
291 /// non-modifiable `EncoderOptions` object instead.
292 template <class TYPE>
293 int encode(bsl::streambuf *streamBuf, const TYPE& value);
294
295 /// Encode the specified `value` of (template parameter) `TYPE` into the
296 /// specified `stream`. Return 0 on success, and a non-zero value otherwise.
297 ///
298 /// \note Note that `stream` will be invalidated if the encoding
299 /// failed.
300 ///
301 /// @deprecated Use @ref encode function passed a reference to a
302 /// non-modifiable `EncoderOptions` object instead.
303 template <class TYPE>
304 int encode(bsl::ostream& stream, const TYPE& value);
305
306 /// Encode the specified `value`, of (template parameter) `TYPE`, in the
307 /// JSON format using the specified `options` and output it onto the
308 /// specified `streamBuf`. Specifying a nullptr `options` is equivalent to
309 /// passing a default-constructed DecoderOptions in `options`. `TYPE`
310 /// shall be a `bdlat`-compatible sequence, choice, or array type, or a
311 /// `bdlat`-compatible dynamic type referring to one of those types. Return 0 on success, and a non-zero value otherwise.
312 ///
313 /// \note Note that this
314 /// function behaves identically to `encode`, but does not instantiate any
315 /// templates at compile time at the expense of being slightly slower at
316 /// runtime; see the `baljsn` package documentation for more details.
317 template <class TYPE>
318 int encodeAny(bsl::streambuf *streamBuf,
319 const TYPE& value,
320 const EncoderOptions& options);
321 template <class TYPE>
322 int encodeAny(bsl::streambuf *streamBuf,
323 const TYPE& value,
324 const EncoderOptions *options = 0);
325 int encodeAny(bsl::streambuf *streamBuf,
326 const bdlar::AnyConstRef& any,
327 const EncoderOptions& options);
328 int encodeAny(bsl::streambuf *streamBuf,
329 const bdlar::AnyConstRef& any,
330 const EncoderOptions *options = 0);
331
332 /// Encode the specified `value`, of (template parameter) `TYPE`, in the
333 /// JSON format using the specified `options` and output it onto the
334 /// specified `stream`. Specifying a nullptr `options` is equivalent to
335 /// passing a default-constructed DecoderOptions in `options`. `TYPE`
336 /// shall be a `bdlat`-compatible choice, or array type, or a
337 /// `bdlat`-compatible dynamic type referring to one of those types. Return 0 on success, and a non-zero value otherwise.
338 ///
339 /// \note Note that this
340 /// function behaves identically to `encode`, but does not instantiate any
341 /// templates at compile time at the expense of being slightly slower at
342 /// runtime; see the `baljsn` package documentation for more details.
343 template <class TYPE>
344 int encodeAny(bsl::ostream& stream,
345 const TYPE& value,
346 const EncoderOptions& options);
347 template <class TYPE>
348 int encodeAny(bsl::ostream& stream,
349 const TYPE& value,
350 const EncoderOptions *options = 0);
351 int encodeAny(bsl::ostream& stream,
352 const bdlar::AnyConstRef& any,
353 const EncoderOptions& options);
354 int encodeAny(bsl::ostream& stream,
355 const bdlar::AnyConstRef& any,
356 const EncoderOptions *options = 0);
357
358 // ACCESSORS
359
360 /// Return a string containing any error, warning, or trace messages
361 /// that were logged during the last call to the `encode` method. The
362 /// log is reset each time `encode` is called.
364};
365
366// ============================================================================
367// INLINE DEFINITIONS
368// ============================================================================
369
370 // -------------
371 // class Encoder
372 // -------------
373
374// PRIVATE MANIPULATORS
375inline
376bsl::ostream& Encoder::logStream()
377{
378 return d_logStream;
379}
380
381// CREATORS
382inline
383Encoder::Encoder(bslma::Allocator *basicAllocator)
384: d_logStream(basicAllocator)
385{
386}
387
388// MANIPULATORS
389template <class TYPE>
390inline
391int Encoder::encode(bsl::streambuf *streamBuf, const TYPE& value)
392{
393 const EncoderOptions options;
394 return encode(streamBuf, value, options);
395}
396
397template <class TYPE>
398inline
399int Encoder::encode(bsl::ostream& stream, const TYPE& value)
400{
401 const EncoderOptions options;
402 return encode(stream, value, options);
403}
404
405template <class TYPE>
406int Encoder::encode(bsl::streambuf *streamBuf,
407 const TYPE& value,
408 const EncoderOptions& options)
409{
410 BSLS_ASSERT(streamBuf);
411
412 d_logStream.clear();
413 d_logStream.str("");
414
420 logStream()
421 << "Encoded object must be a Sequence, Choice, or Array type."
422 << bsl::endl;
423 return -1; // RETURN
424 }
425
426 bsl::ostream outputStream(streamBuf);
427 EncodeImplUtil<Formatter>::openDocument(&outputStream, options);
428
429 const int rc = EncodeImplUtil<Formatter>::encode(&d_logStream,
430 &outputStream,
431 value,
432 options);
433 if (0 != rc) {
434 streamBuf->pubsync();
435 return rc; // RETURN
436 }
437
438 EncodeImplUtil<Formatter>::closeDocument(&outputStream, options);
439
440 if (!outputStream) {
441 logStream()
442 << "An error occurred when writing to the supplied output stream"
443 " or stream buffer."
444 << bsl::endl;
445 streamBuf->pubsync();
446 return -1; // RETURN
447 }
448
449 streamBuf->pubsync();
450
451 return 0;
452}
453
454template <class TYPE>
455int Encoder::encode(bsl::streambuf *streamBuf,
456 const TYPE& value,
457 const EncoderOptions *options)
458{
459 EncoderOptions localOpts;
460 return encode(streamBuf, value, options ? *options : localOpts);
461}
462
463template <class TYPE>
464int Encoder::encode(bsl::ostream& stream,
465 const TYPE& value,
466 const EncoderOptions& options)
467{
468 if (!stream.good()) {
469 logStream() << "Invalid stream." << bsl::endl;
470 return -1; // RETURN
471 }
472
473 const int rc = this->encode(stream.rdbuf(), value, options);
474 if (rc) {
475 stream.setstate(bsl::ios_base::failbit);
476 return rc; // RETURN
477 }
478
479 return 0;
480}
481
482template <class TYPE>
483inline
484int Encoder::encode(bsl::ostream& stream,
485 const TYPE& value,
486 const EncoderOptions *options)
487{
488 EncoderOptions localOpts;
489 return encode(stream, value, options ? *options : localOpts);
490}
491
492template <class TYPE>
493inline
494int Encoder::encodeAny(bsl::streambuf *streamBuf,
495 const TYPE& value,
496 const EncoderOptions& options)
497{
498 return encodeAny(streamBuf,
500 options);
501}
502
503template <class TYPE>
504inline
505int Encoder::encodeAny(bsl::streambuf *streamBuf,
506 const TYPE& value,
507 const EncoderOptions *options)
508{
509 return encodeAny(streamBuf, value, options ? *options : EncoderOptions());
510}
511
512inline
513int Encoder::encodeAny(bsl::streambuf *streamBuf,
514 const bdlar::AnyConstRef& any,
515 const EncoderOptions *options)
516{
517 return encodeAny(streamBuf, any, options ? *options : EncoderOptions());
518}
519
520template <class TYPE>
521inline
522int Encoder::encodeAny(bsl::ostream& stream,
523 const TYPE& value,
524 const EncoderOptions& options)
525{
526 return encodeAny(stream,
528 options);
529}
530
531template <class TYPE>
532inline
533int Encoder::encodeAny(bsl::ostream& stream,
534 const TYPE& value,
535 const EncoderOptions *options)
536{
537 return encodeAny(stream, value, options ? *options : EncoderOptions());
538}
539
540inline
541int Encoder::encodeAny(bsl::ostream& stream,
542 const bdlar::AnyConstRef& any,
543 const EncoderOptions *options)
544{
545 return encodeAny(stream, any, options ? *options : EncoderOptions());
546}
547
548// ACCESSORS
549inline
551{
552 return d_logStream.str();
553}
554
555// The 'Encoder_Formatter' 'class' has been replaced by the 'baljsn::Formatter'
556// 'class' in the @ref baljsn_formatter component. Clients should use that
557// 'class' instead. The following 'class' definition is provided for
558// backwards-compatibility for users that have written code using this
559// component-private 'class'.
560
561 // =======================
562 // class Encoder_Formatter
563 // =======================
564
565/// This class implements a formatter providing operations for rending JSON
566/// text elements to an output stream (supplied at construction) according
567/// to a set of formatting options (also supplied at construction). This is
568/// a component-private class and should not be used outside of this
569/// component.
570///
571/// @deprecated Use @ref baljsn::Formatter instead.
572///
573/// See @ref baljsn_encoder
575
576 // DATA
577 bsl::ostream& d_outputStream; // stream for output (held, not owned)
578 bool d_usePrettyStyle; // encoding style
579 int d_indentLevel; // initial indent level
580 int d_spacesPerLevel; // spaces per level
581 bool d_isArrayElement; // is current element part of an array
582
583 public:
584 // CREATORS
585
586 /// Create a `Encoder_Formatter` object using the specified `stream` and
587 /// `options`.
588 Encoder_Formatter(bsl::ostream& stream, const EncoderOptions& options);
589
591 // Destroy this object.
592
593 // MANIPULATORS
594
595 /// Print onto the stream supplied at construction the sequence of
596 /// characters designating the start of an object.
598
599 /// Print onto the stream supplied at construction the sequence of
600 /// characters designating the end of an object.
602
603 /// Print onto the stream supplied at construction the sequence of
604 /// characters designating the start of an array. Optionally specify
605 /// `formatAsEmptyArrayFlag` denoting if the array being opened should
606 /// be formatted as an empty array. If `formatAsEmptyArrayFlag` is not
607 /// specified then the array being opened is formatted as an array having elements.
608 ///
609 /// \note Note that the formatting (and as a consequence the
610 /// `formatAsEmptyArrayFlag`) is relevant only if this formatter encodes
611 /// in the pretty style and is ignored otherwise.
612 void openArray(bool formatAsEmptyArrayFlag = false);
613
614 /// Print onto the stream supplied at construction the sequence of
615 /// characters designating the end of an array. Optionally specify
616 /// `formatAsEmptyArrayFlag` denoting if the array being closed should
617 /// be formatted as an empty array. If `formatAsEmptyArrayFlag` is not
618 /// specified then the array being closed is formatted as an array having elements.
619 ///
620 /// \note Note that the formatting (and as a consequence the
621 /// `formatAsEmptyArrayFlag`) is relevant only if this formatter encodes
622 /// in the pretty style and is ignored otherwise.
623 void closeArray(bool formatAsEmptyArrayFlag = false);
624
625 /// Print onto the stream supplied at construction the sequence of
626 /// whitespace characters for the proper indentation of an element given
627 /// the encoding options supplied at construction.
628 void indent();
629
630 /// Print onto the stream supplied at construction the sequence of
631 /// characters designating the start of an element having the specified
632 /// `name`. Return 0 on success and a non-zero value otherwise.
633 int openElement(const bsl::string& name);
634
635 /// Print onto the stream supplied at construction the sequence of
636 /// characters designating the end of an element.
638
639 /// Print onto the stream supplied at construction the sequence of
640 /// characters designating the start of the document.
642
643 /// Print onto the stream supplied at construction the sequence of
644 /// characters designating the end of the document.
646
647 /// Set the flag denoting if the current element refers to an array
648 /// element to the specified `isArrayElement`.
650
651 // ACCESSORS
652
653 /// Return the value of the flag denoting if the current element refers
654 /// to an array element.
655 bool isArrayElement() const;
656};
657
658 // -----------------------
659 // class Encoder_Formatter
660 // -----------------------
661
662// MANIPULATORS
663inline
665{
666 d_isArrayElement = isArrayElement;
667}
668
669// ACCESSORS
670inline
672{
673 return d_isArrayElement;
674}
675
676} // close package namespace
677
678
679#endif
680
681// ----------------------------------------------------------------------------
682// Copyright 2015 Bloomberg Finance L.P.
683//
684// Licensed under the Apache License, Version 2.0 (the "License");
685// you may not use this file except in compliance with the License.
686// You may obtain a copy of the License at
687//
688// http://www.apache.org/licenses/LICENSE-2.0
689//
690// Unless required by applicable law or agreed to in writing, software
691// distributed under the License is distributed on an "AS IS" BASIS,
692// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
693// See the License for the specific language governing permissions and
694// limitations under the License.
695// ----------------------------- END-OF-FILE ----------------------------------
696
697/** @} */
698/** @} */
699/** @} */
Definition baljsn_encoderoptions.h:290
Definition baljsn_encoder.h:574
void openArray(bool formatAsEmptyArrayFlag=false)
int openElement(const bsl::string &name)
void setIsArrayElement(bool isArrayElement)
Definition baljsn_encoder.h:664
void closeArray(bool formatAsEmptyArrayFlag=false)
bool isArrayElement() const
Definition baljsn_encoder.h:671
Encoder_Formatter(bsl::ostream &stream, const EncoderOptions &options)
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