BDE 4.39.x Production Release
Loading...
Searching...
No Matches
baljsn_decoderoptions.h
Go to the documentation of this file.
1/// @file baljsn_decoderoptions.h
2///
3/// The content of this file has been pre-processed for Doxygen.
4///
5
6
7// baljsn_decoderoptions.h -*-C++-*-
8#ifndef INCLUDED_BALJSN_DECODEROPTIONS
9#define INCLUDED_BALJSN_DECODEROPTIONS
10
11#include <bsls_ident.h>
12BSLS_IDENT("$Id: $")
13
14/// @defgroup baljsn_decoderoptions baljsn_decoderoptions
15/// @brief Provide an attribute class for specifying JSON decoding options.
16/// @addtogroup bal
17/// @{
18/// @addtogroup baljsn
19/// @{
20/// @addtogroup baljsn_decoderoptions
21/// @{
22///
23/// <h1> Outline </h1>
24/// * <a href="#baljsn_decoderoptions-purpose"> Purpose</a>
25/// * <a href="#baljsn_decoderoptions-classes"> Classes </a>
26/// * <a href="#baljsn_decoderoptions-description"> Description </a>
27/// * <a href="#baljsn_decoderoptions-attributes"> Attributes </a>
28/// * <a href="#baljsn_decoderoptions-implementation-note"> Implementation Note </a>
29/// * <a href="#baljsn_decoderoptions-usage"> Usage </a>
30/// * <a href="#baljsn_decoderoptions-example-1-creating-and-populating-an-options-object"> Example 1: Creating and Populating an Options Object </a>
31///
32/// # Purpose {#baljsn_decoderoptions-purpose}
33/// Provide an attribute class for specifying JSON decoding options.
34///
35/// # Classes {#baljsn_decoderoptions-classes}
36///
37/// - baljsn::DecoderOptions: options for decoding objects in the JSON format
38///
39/// @see baljsn_decoder, baljsn_encoderoptions
40///
41/// # Description {#baljsn_decoderoptions-description}
42/// This component provides a single, simply constrained
43/// (value-semantic) attribute class, `baljsn::DecoderOptions`, that is used to
44/// specify options for decoding objects in the JSON format.
45///
46/// ## Attributes {#baljsn_decoderoptions-attributes}
47///
48///
49/// @code
50/// Name Type Default Simple Constraints
51/// ------------------ ---- ------- ------------------
52/// maxDepth int 512 >= 0
53/// skipUnknownElements bool true none
54/// validateInputIsUtf8 bool false none
55/// allowConsecutiveSeparators bool true none
56/// allowFormFeedAsWhitespace bool true none
57/// allowUnescapedControlCharacters bool true none
58/// allowMissingRequiredAttributes bool true none
59/// @endcode
60/// * `maxDepth`: maximum depth of the decoded data
61/// * `skipUnknownElements`: flag specifying if unknown elements are skipped
62/// * `validateInputIsUtf8`: flag specifying whether UTF-8 correctness checking
63/// is enabled.
64/// * `allowConsecutiveSeparators`: flag specifying if multiple consecutive
65/// separators -- e.g., `"a" :: 1`, `[ 1,, 2 ]` -- are accepted and treated
66/// as if one separator had been input.
67/// * `allowFormFeedAsWhitespace`: flag specifying if the form-feed character,
68/// '\\f', is treaded as whitespace in addition to ' ', '\\t', '\\n', '\\r',
69/// and '\\v'.
70/// * `allowUnescapedControlCharacters`: flag specifying if unescaped (raw)
71/// control characters (e.g., '\\n', '\\t') are allowed in JSON strings.
72/// Otherwise, control characters are represented by multi-character
73/// sequences (e.g., '\\t' or '\u000A').
74/// * `allowMissingRequiredAttributes`: flag specifying if non-optional sequence
75/// attributes are allowed to be omitted in the input message.
76///
77/// ### Implementation Note {#baljsn_decoderoptions-implementation-note}
78///
79///
80/// This file was generated from a script and was subsequently modified to add
81/// documentation and to make other changes. The steps to generate and update
82/// this file can be found in the `doc/generating_codec_options.txt` file.
83///
84/// ## Usage {#baljsn_decoderoptions-usage}
85///
86///
87/// This section illustrates intended use of this component.
88///
89/// ### Example 1: Creating and Populating an Options Object {#baljsn_decoderoptions-example-1-creating-and-populating-an-options-object}
90///
91///
92/// This component is designed to be used at a higher level to set the options
93/// for decoding objects in the JSON format. This example shows how to create
94/// and populate an options object.
95///
96/// First, we default-construct a `baljsn::DecoderOptions` object:
97/// @code
98/// const int MAX_DEPTH = 10;
99/// const bool SKIP_UNKNOWN_ELEMENTS = false;
100///
101/// baljsn::DecoderOptions options;
102/// assert(512 == options.maxDepth());
103/// assert(true == options.skipUnknownElements());
104/// @endcode
105/// Next, we populate that object to decode using a different `maxDepth` value
106/// and `skipUnknownElements` value:
107/// @code
108/// options.setMaxDepth(MAX_DEPTH);
109/// assert(MAX_DEPTH == options.maxDepth());
110///
111/// options.setSkipUnknownElements(SKIP_UNKNOWN_ELEMENTS);
112/// assert(SKIP_UNKNOWN_ELEMENTS == options.skipUnknownElements());
113/// @endcode
114/// @}
115/** @} */
116/** @} */
117
118/** @addtogroup bal
119 * @{
120 */
121/** @addtogroup baljsn
122 * @{
123 */
124/** @addtogroup baljsn_decoderoptions
125 * @{
126 */
127
128#include <balscm_version.h>
129
130#include <bslalg_typetraits.h>
131
132#include <bdlat_attributeinfo.h>
133#include <bdlat_selectioninfo.h>
134#include <bdlat_typetraits.h>
135
136#include <bslh_hash.h>
137#include <bsls_assert.h>
138#include <bsls_objectbuffer.h>
139
140#include <bsl_iosfwd.h>
141#include <bsl_limits.h>
142
143
144
145namespace baljsn { class DecoderOptions; }
146namespace baljsn {
147
148 // ====================
149 // class DecoderOptions
150 // ====================
151
152/// Options for controlling the JSON decoding process.
153///
154/// See @ref baljsn_decoderoptions
156
157 // INSTANCE DATA
158
159 // maximum recursion depth
160 int d_maxDepth;
161
162 // option to skip unknown elements
163 bool d_skipUnknownElements;
164
165 // option to check that input is valid UTF-8
166 bool d_validateInputIsUtf8;
167
168 // Option to allow multiple consecutive colons or commas. Set to
169 // `false` for strictly conformining JSON.
170 bool d_allowConsecutiveSeparators;
171
172 // Option to allow '\\f' (form feed) as whitespace in addition to ' ',
173 // '\\n', '\\t', '\\r', and '\\v'. Set to `false` for strictly
174 // conformining JSON.
175 bool d_allowFormFeedAsWhitespace;
176
177 // Option to allow characters in the range `[0x00 .. 0x1F]` (e.g.,
178 // '\\0', '\\t', '\\n') in JSON strings. Set to `false` for strictly
179 // conformining JSON.
180 bool d_allowUnescapedControlCharacters;
181
182 // Option to allow missing non-optional attributes.
183 bool d_allowMissingRequiredAttributes;
184
185 // PRIVATE ACCESSORS
186 template <typename t_HASH_ALGORITHM>
187 void hashAppendImpl(t_HASH_ALGORITHM& hashAlgorithm) const;
188
189 bool isEqualTo(const DecoderOptions& rhs) const;
190
191 public:
192 // TYPES
193 enum {
201 };
202
203 enum {
205 };
206
207 enum {
215 };
216
217 // CONSTANTS
218 static const char CLASS_NAME[];
219
221
223
225
227
229
231
233
235
236 public:
237 // CLASS METHODS
238
239 /// Return attribute information for the attribute indicated by the
240 /// specified `id` if the attribute exists, and 0 otherwise.
242
243 /// Return attribute information for the attribute indicated by the
244 /// specified `name` of the specified `nameLength` if the attribute
245 /// exists, and 0 otherwise.
247 const char *name,
248 int nameLength);
249
250 // CREATORS
251
252 /// Create an object of type `DecoderOptions` having the default value.
254
255 /// Create an object of type `DecoderOptions` having the value of the
256 /// specified `original` object.
258
259#if defined(BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES) \
260 && defined(BSLS_COMPILERFEATURES_SUPPORT_NOEXCEPT)
261 /// Create an object of type `DecoderOptions` having the value of the
262 /// specified `original` object. After performing this action, the
263 /// `original` object will be left in a valid, but unspecified state.
264 DecoderOptions(DecoderOptions&& original) = default;
265#endif
266
267 /// Destroy this object.
269
270 // MANIPULATORS
271
272 /// Assign to this object the value of the specified `rhs` object.
274
275#if defined(BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES) \
276 && defined(BSLS_COMPILERFEATURES_SUPPORT_NOEXCEPT)
277 /// Assign to this object the value of the specified `rhs` object.
278 /// After performing this action, the `rhs` object will be left in a
279 /// valid, but unspecified state.
281#endif
282
283 /// Reset this object to the default value (i.e., its value upon
284 /// default construction).
285 void reset();
286
287 /// Invoke the specified `manipulator` sequentially on the address of
288 /// each (modifiable) attribute of this object, supplying `manipulator`
289 /// with the corresponding attribute information structure until such
290 /// invocation returns a non-zero value. Return the value from the
291 /// last invocation of `manipulator` (i.e., the invocation that
292 /// terminated the sequence).
293 template <typename t_MANIPULATOR>
294 int manipulateAttributes(t_MANIPULATOR& manipulator);
295
296 /// Invoke the specified `manipulator` on the address of
297 /// the (modifiable) attribute indicated by the specified `id`,
298 /// supplying `manipulator` with the corresponding attribute
299 /// information structure. Return the value returned from the
300 /// invocation of `manipulator` if `id` identifies an attribute of this
301 /// class, and -1 otherwise.
302 template <typename t_MANIPULATOR>
303 int manipulateAttribute(t_MANIPULATOR& manipulator, int id);
304
305 /// Invoke the specified `manipulator` on the address of
306 /// the (modifiable) attribute indicated by the specified `name` of the
307 /// specified `nameLength`, supplying `manipulator` with the
308 /// corresponding attribute information structure. Return the value
309 /// returned from the invocation of `manipulator` if `name` identifies
310 /// an attribute of this class, and -1 otherwise.
311 template <typename t_MANIPULATOR>
312 int manipulateAttribute(t_MANIPULATOR& manipulator,
313 const char *name,
314 int nameLength);
315
316 /// Set the "MaxDepth" attribute of this object to the specified `value`.
317 void setMaxDepth(int value);
318
319 /// Set the "SkipUnknownElements" attribute of this object to the specified
320 /// `value`.
321 void setSkipUnknownElements(bool value);
322
323 /// Set the "ValidateInputIsUtf8" attribute of this object to the specified
324 /// `value`.
325 void setValidateInputIsUtf8(bool value);
326
327 /// Set the "AllowConsecutiveSeparators" attribute of this object to the
328 /// specified `value`.
329 void setAllowConsecutiveSeparators(bool value);
330
331 /// Set the "AllowFormFeedAsWhitespace" attribute of this object to the
332 /// specified `value`.
333 void setAllowFormFeedAsWhitespace(bool value);
334
335 /// Set the "AllowUnescapedControlCharacters" attribute of this object to
336 /// the specified `value`.
337 void setAllowUnescapedControlCharacters(bool value);
338
339 /// Set "AllowMissingRequiredAttributes" attribute of this object to the
340 /// specified `value`.
341 void setAllowMissingRequiredAttributes(bool value);
342
343 // ACCESSORS
344
345 /// Format this object to the specified output `stream` at the
346 /// optionally specified indentation `level` and return a reference to
347 /// the modifiable `stream`. If `level` is specified, optionally
348 /// specify `spacesPerLevel`, the number of spaces per indentation level
349 /// for this and all of its nested objects. Each line is indented by
350 /// the absolute value of `level * spacesPerLevel`. If `level` is
351 /// negative, suppress indentation of the first line. If
352 /// `spacesPerLevel` is negative, suppress line breaks and format the
353 /// entire output on one line. If `stream` is initially invalid, this operation has no effect.
354 ///
355 /// \note Note that a trailing newline is provided
356 /// in multiline mode only.
357 bsl::ostream& print(bsl::ostream& stream,
358 int level = 0,
359 int spacesPerLevel = 4) const;
360
361 /// Invoke the specified `accessor` sequentially on each
362 /// (non-modifiable) attribute of this object, supplying `accessor`
363 /// with the corresponding attribute information structure until such
364 /// invocation returns a non-zero value. Return the value from the
365 /// last invocation of `accessor` (i.e., the invocation that terminated
366 /// the sequence).
367 template <typename t_ACCESSOR>
368 int accessAttributes(t_ACCESSOR& accessor) const;
369
370 /// Invoke the specified `accessor` on the (non-modifiable) attribute
371 /// of this object indicated by the specified `id`, supplying `accessor`
372 /// with the corresponding attribute information structure. Return the
373 /// value returned from the invocation of `accessor` if `id` identifies
374 /// an attribute of this class, and -1 otherwise.
375 template <typename t_ACCESSOR>
376 int accessAttribute(t_ACCESSOR& accessor, int id) const;
377
378 /// Invoke the specified `accessor` on the (non-modifiable) attribute
379 /// of this object indicated by the specified `name` of the specified
380 /// `nameLength`, supplying `accessor` with the corresponding attribute
381 /// information structure. Return the value returned from the
382 /// invocation of `accessor` if `name` identifies an attribute of this
383 /// class, and -1 otherwise.
384 template <typename t_ACCESSOR>
385 int accessAttribute(t_ACCESSOR& accessor,
386 const char *name,
387 int nameLength) const;
388
389 /// Return the value of the "MaxDepth" attribute of this object.
390 int maxDepth() const;
391
392 /// Return the value of the "SkipUnknownElements" attribute of this
393 /// object.
394 bool skipUnknownElements() const;
395
396 /// Return the value of the "ValidateInputIsUtf8" attribute of this
397 /// object.
398 bool validateInputIsUtf8() const;
399
400 /// Return the value of the "AllowConsecutiveSeparators" attribute of
401 /// this object.
402 bool allowConsecutiveSeparators() const;
403
404 /// Return the value of the "AllowFormFeedAsWhitespace" attribute of
405 /// this object.
406 bool allowFormFeedAsWhitespace() const;
407
408 /// Return the value of the "AllowUnescapedControlCharacters" attribute
409 /// of this object.
411
412 /// Return the value of the "AllowMissingRequiredAttributes" attribute of
413 /// this object.
415
416 // HIDDEN FRIENDS
417
418 /// Return `true` if the specified `lhs` and `rhs` attribute objects
419 /// have the same value, and `false` otherwise. Two attribute objects
420 /// have the same value if each respective attribute has the same value.
421 friend bool operator==(const DecoderOptions& lhs,
422 const DecoderOptions& rhs)
423 {
424 return lhs.isEqualTo(rhs);
425 }
426
427 /// Returns `!(lhs == rhs)`
428 friend bool operator!=(const DecoderOptions& lhs,
429 const DecoderOptions& rhs)
430 {
431 return !(lhs == rhs);
432 }
433
434 /// Format the specified `rhs` to the specified output `stream` and
435 /// return a reference to the modifiable `stream`.
436 friend bsl::ostream& operator<<(bsl::ostream& stream,
437 const DecoderOptions& rhs)
438 {
439 return rhs.print(stream, 0, -1);
440 }
441
442 /// Pass the specified `object` to the specified `hashAlg`. This function
443 /// integrates with the `bslh` modular hashing system and effectively
444 /// provides a `bsl::hash` specialization for `DecoderOptions`.
445 template <typename t_HASH_ALGORITHM>
446 friend void hashAppend(t_HASH_ALGORITHM& hashAlg,
447 const DecoderOptions& object)
448 {
449 object.hashAppendImpl(hashAlg);
450 }
451};
452
453} // close package namespace
454
455// TRAITS
456
458
459//=============================================================================
460// INLINE DEFINITIONS
461//=============================================================================
462
463namespace baljsn {
464
465 // --------------------
466 // class DecoderOptions
467 // --------------------
468
469// PRIVATE ACCESSORS
470template <typename t_HASH_ALGORITHM>
471void DecoderOptions::hashAppendImpl(t_HASH_ALGORITHM& hashAlgorithm) const
472{
473 using bslh::hashAppend;
474 hashAppend(hashAlgorithm, this->maxDepth());
475 hashAppend(hashAlgorithm, this->skipUnknownElements());
476 hashAppend(hashAlgorithm, this->validateInputIsUtf8());
477 hashAppend(hashAlgorithm, this->allowConsecutiveSeparators());
478 hashAppend(hashAlgorithm, this->allowFormFeedAsWhitespace());
479 hashAppend(hashAlgorithm, this->allowUnescapedControlCharacters());
480 hashAppend(hashAlgorithm, this->allowMissingRequiredAttributes());
481}
482
483inline
484bool DecoderOptions::isEqualTo(const DecoderOptions& rhs) const
485{
486 return this->maxDepth() == rhs.maxDepth() &&
487 this->skipUnknownElements() == rhs.skipUnknownElements() &&
488 this->validateInputIsUtf8() == rhs.validateInputIsUtf8() &&
489 this->allowConsecutiveSeparators() == rhs.allowConsecutiveSeparators() &&
490 this->allowFormFeedAsWhitespace() == rhs.allowFormFeedAsWhitespace() &&
491 this->allowUnescapedControlCharacters() == rhs.allowUnescapedControlCharacters() &&
492 this->allowMissingRequiredAttributes() == rhs.allowMissingRequiredAttributes();
493}
494
495// CLASS METHODS
496// MANIPULATORS
497template <typename t_MANIPULATOR>
498int DecoderOptions::manipulateAttributes(t_MANIPULATOR& manipulator)
499{
500 int ret;
501
502 ret = manipulator(&d_maxDepth, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_MAX_DEPTH]);
503 if (ret) {
504 return ret;
505 }
506
507 ret = manipulator(&d_skipUnknownElements, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_SKIP_UNKNOWN_ELEMENTS]);
508 if (ret) {
509 return ret;
510 }
511
512 ret = manipulator(&d_validateInputIsUtf8, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_VALIDATE_INPUT_IS_UTF8]);
513 if (ret) {
514 return ret;
515 }
516
517 ret = manipulator(&d_allowConsecutiveSeparators, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_ALLOW_CONSECUTIVE_SEPARATORS]);
518 if (ret) {
519 return ret;
520 }
521
522 ret = manipulator(&d_allowFormFeedAsWhitespace, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_ALLOW_FORM_FEED_AS_WHITESPACE]);
523 if (ret) {
524 return ret;
525 }
526
527 ret = manipulator(&d_allowUnescapedControlCharacters, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_ALLOW_UNESCAPED_CONTROL_CHARACTERS]);
528 if (ret) {
529 return ret;
530 }
531
532 ret = manipulator(&d_allowMissingRequiredAttributes, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_ALLOW_MISSING_REQUIRED_ATTRIBUTES]);
533 if (ret) {
534 return ret;
535 }
536
537 return 0;
538}
539
540template <typename t_MANIPULATOR>
541int DecoderOptions::manipulateAttribute(t_MANIPULATOR& manipulator, int id)
542{
543 enum { NOT_FOUND = -1 };
544
545 switch (id) {
547 return manipulator(&d_maxDepth, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_MAX_DEPTH]);
548 }
550 return manipulator(&d_skipUnknownElements, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_SKIP_UNKNOWN_ELEMENTS]);
551 }
553 return manipulator(&d_validateInputIsUtf8, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_VALIDATE_INPUT_IS_UTF8]);
554 }
556 return manipulator(&d_allowConsecutiveSeparators, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_ALLOW_CONSECUTIVE_SEPARATORS]);
557 }
559 return manipulator(&d_allowFormFeedAsWhitespace, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_ALLOW_FORM_FEED_AS_WHITESPACE]);
560 }
562 return manipulator(&d_allowUnescapedControlCharacters, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_ALLOW_UNESCAPED_CONTROL_CHARACTERS]);
563 }
565 return manipulator(&d_allowMissingRequiredAttributes, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_ALLOW_MISSING_REQUIRED_ATTRIBUTES]);
566 }
567 default:
568 return NOT_FOUND;
569 }
570}
571
572template <typename t_MANIPULATOR>
574 t_MANIPULATOR& manipulator,
575 const char *name,
576 int nameLength)
577{
578 enum { NOT_FOUND = -1 };
579
580 const bdlat_AttributeInfo *attributeInfo =
581 lookupAttributeInfo(name, nameLength);
582 if (0 == attributeInfo) {
583 return NOT_FOUND;
584 }
585
586 return manipulateAttribute(manipulator, attributeInfo->d_id);
587}
588
589inline
591{
592 BSLS_ASSERT(0 <= value);
593
594 d_maxDepth = value;
595}
596
597inline
599{
600 d_skipUnknownElements = value;
601}
602
603inline
605{
606 d_validateInputIsUtf8 = value;
607}
608
609inline
611{
612 d_allowConsecutiveSeparators = value;
613}
614
615inline
617{
618 d_allowFormFeedAsWhitespace = value;
619}
620
621inline
623{
624 d_allowUnescapedControlCharacters = value;
625}
626
627inline
629{
630 d_allowMissingRequiredAttributes = value;
631}
632
633// ACCESSORS
634template <typename t_ACCESSOR>
635int DecoderOptions::accessAttributes(t_ACCESSOR& accessor) const
636{
637 int ret;
638
639 ret = accessor(d_maxDepth, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_MAX_DEPTH]);
640 if (ret) {
641 return ret;
642 }
643
644 ret = accessor(d_skipUnknownElements, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_SKIP_UNKNOWN_ELEMENTS]);
645 if (ret) {
646 return ret;
647 }
648
649 ret = accessor(d_validateInputIsUtf8, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_VALIDATE_INPUT_IS_UTF8]);
650 if (ret) {
651 return ret;
652 }
653
654 ret = accessor(d_allowConsecutiveSeparators, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_ALLOW_CONSECUTIVE_SEPARATORS]);
655 if (ret) {
656 return ret;
657 }
658
659 ret = accessor(d_allowFormFeedAsWhitespace, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_ALLOW_FORM_FEED_AS_WHITESPACE]);
660 if (ret) {
661 return ret;
662 }
663
664 ret = accessor(d_allowUnescapedControlCharacters, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_ALLOW_UNESCAPED_CONTROL_CHARACTERS]);
665 if (ret) {
666 return ret;
667 }
668
669 ret = accessor(d_allowMissingRequiredAttributes, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_ALLOW_MISSING_REQUIRED_ATTRIBUTES]);
670 if (ret) {
671 return ret;
672 }
673
674 return 0;
675}
676
677template <typename t_ACCESSOR>
678int DecoderOptions::accessAttribute(t_ACCESSOR& accessor, int id) const
679{
680 enum { NOT_FOUND = -1 };
681
682 switch (id) {
684 return accessor(d_maxDepth, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_MAX_DEPTH]);
685 }
687 return accessor(d_skipUnknownElements, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_SKIP_UNKNOWN_ELEMENTS]);
688 }
690 return accessor(d_validateInputIsUtf8, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_VALIDATE_INPUT_IS_UTF8]);
691 }
693 return accessor(d_allowConsecutiveSeparators, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_ALLOW_CONSECUTIVE_SEPARATORS]);
694 }
696 return accessor(d_allowFormFeedAsWhitespace, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_ALLOW_FORM_FEED_AS_WHITESPACE]);
697 }
699 return accessor(d_allowUnescapedControlCharacters, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_ALLOW_UNESCAPED_CONTROL_CHARACTERS]);
700 }
702 return accessor(d_allowMissingRequiredAttributes, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_ALLOW_MISSING_REQUIRED_ATTRIBUTES]);
703 }
704 default:
705 return NOT_FOUND;
706 }
707}
708
709template <typename t_ACCESSOR>
711 t_ACCESSOR& accessor,
712 const char *name,
713 int nameLength) const
714{
715 enum { NOT_FOUND = -1 };
716
717 const bdlat_AttributeInfo *attributeInfo =
718 lookupAttributeInfo(name, nameLength);
719 if (0 == attributeInfo) {
720 return NOT_FOUND;
721 }
722
723 return accessAttribute(accessor, attributeInfo->d_id);
724}
725
726inline
728{
729 return d_maxDepth;
730}
731
732inline
734{
735 return d_skipUnknownElements;
736}
737
738inline
740{
741 return d_validateInputIsUtf8;
742}
743
744inline
746{
747 return d_allowConsecutiveSeparators;
748}
749
750inline
752{
753 return d_allowFormFeedAsWhitespace;
754}
755
756inline
758{
759 return d_allowUnescapedControlCharacters;
760}
761
762inline
764{
765 return d_allowMissingRequiredAttributes;
766}
767
768} // close package namespace
769
770// FREE FUNCTIONS
771
772
773#endif
774
775// GENERATED BY BLP_BAS_CODEGEN_2024.03.02
776// USING bas_codegen.pl -m msg -p baljsn -E --noExternalization --noAggregateConversion ../baljsn.xsd
777// ----------------------------------------------------------------------------
778// Copyright 2024 Bloomberg Finance L.P.
779//
780// Licensed under the Apache License, Version 2.0 (the "License");
781// you may not use this file except in compliance with the License.
782// You may obtain a copy of the License at
783//
784// http://www.apache.org/licenses/LICENSE-2.0
785//
786// Unless required by applicable law or agreed to in writing, software
787// distributed under the License is distributed on an "AS IS" BASIS,
788// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
789// See the License for the specific language governing permissions and
790// limitations under the License.
791// ----------------------------- END-OF-FILE ----------------------------------
792
793/** @} */
794/** @} */
795/** @} */
Definition baljsn_decoderoptions.h:155
void setMaxDepth(int value)
Set the "MaxDepth" attribute of this object to the specified value.
Definition baljsn_decoderoptions.h:590
DecoderOptions(const DecoderOptions &original)
void setAllowUnescapedControlCharacters(bool value)
Definition baljsn_decoderoptions.h:622
static const bool DEFAULT_INITIALIZER_ALLOW_FORM_FEED_AS_WHITESPACE
Definition baljsn_decoderoptions.h:228
bool validateInputIsUtf8() const
Definition baljsn_decoderoptions.h:739
static const char CLASS_NAME[]
Definition baljsn_decoderoptions.h:218
friend void hashAppend(t_HASH_ALGORITHM &hashAlg, const DecoderOptions &object)
Definition baljsn_decoderoptions.h:446
bool allowUnescapedControlCharacters() const
Definition baljsn_decoderoptions.h:757
bool allowMissingRequiredAttributes() const
Definition baljsn_decoderoptions.h:763
friend bool operator==(const DecoderOptions &lhs, const DecoderOptions &rhs)
Definition baljsn_decoderoptions.h:421
@ ATTRIBUTE_INDEX_ALLOW_CONSECUTIVE_SEPARATORS
Definition baljsn_decoderoptions.h:211
@ ATTRIBUTE_INDEX_MAX_DEPTH
Definition baljsn_decoderoptions.h:208
@ ATTRIBUTE_INDEX_VALIDATE_INPUT_IS_UTF8
Definition baljsn_decoderoptions.h:210
@ ATTRIBUTE_INDEX_ALLOW_MISSING_REQUIRED_ATTRIBUTES
Definition baljsn_decoderoptions.h:214
@ ATTRIBUTE_INDEX_ALLOW_FORM_FEED_AS_WHITESPACE
Definition baljsn_decoderoptions.h:212
@ ATTRIBUTE_INDEX_ALLOW_UNESCAPED_CONTROL_CHARACTERS
Definition baljsn_decoderoptions.h:213
@ ATTRIBUTE_INDEX_SKIP_UNKNOWN_ELEMENTS
Definition baljsn_decoderoptions.h:209
@ NUM_ATTRIBUTES
Definition baljsn_decoderoptions.h:204
void setValidateInputIsUtf8(bool value)
Definition baljsn_decoderoptions.h:604
static const bdlat_AttributeInfo * lookupAttributeInfo(int id)
void setAllowConsecutiveSeparators(bool value)
Definition baljsn_decoderoptions.h:610
int manipulateAttribute(t_MANIPULATOR &manipulator, int id)
Definition baljsn_decoderoptions.h:541
friend bsl::ostream & operator<<(bsl::ostream &stream, const DecoderOptions &rhs)
Definition baljsn_decoderoptions.h:436
@ ATTRIBUTE_ID_ALLOW_CONSECUTIVE_SEPARATORS
Definition baljsn_decoderoptions.h:197
@ ATTRIBUTE_ID_VALIDATE_INPUT_IS_UTF8
Definition baljsn_decoderoptions.h:196
@ ATTRIBUTE_ID_ALLOW_MISSING_REQUIRED_ATTRIBUTES
Definition baljsn_decoderoptions.h:200
@ ATTRIBUTE_ID_ALLOW_UNESCAPED_CONTROL_CHARACTERS
Definition baljsn_decoderoptions.h:199
@ ATTRIBUTE_ID_ALLOW_FORM_FEED_AS_WHITESPACE
Definition baljsn_decoderoptions.h:198
@ ATTRIBUTE_ID_MAX_DEPTH
Definition baljsn_decoderoptions.h:194
@ ATTRIBUTE_ID_SKIP_UNKNOWN_ELEMENTS
Definition baljsn_decoderoptions.h:195
~DecoderOptions()
Destroy this object.
static const bool DEFAULT_INITIALIZER_ALLOW_MISSING_REQUIRED_ATTRIBUTES
Definition baljsn_decoderoptions.h:232
void setAllowFormFeedAsWhitespace(bool value)
Definition baljsn_decoderoptions.h:616
static const bool DEFAULT_INITIALIZER_VALIDATE_INPUT_IS_UTF8
Definition baljsn_decoderoptions.h:224
static const bool DEFAULT_INITIALIZER_ALLOW_UNESCAPED_CONTROL_CHARACTERS
Definition baljsn_decoderoptions.h:230
int manipulateAttributes(t_MANIPULATOR &manipulator)
Definition baljsn_decoderoptions.h:498
bool skipUnknownElements() const
Definition baljsn_decoderoptions.h:733
static const int DEFAULT_INITIALIZER_MAX_DEPTH
Definition baljsn_decoderoptions.h:220
static const bdlat_AttributeInfo * lookupAttributeInfo(const char *name, int nameLength)
bool allowConsecutiveSeparators() const
Definition baljsn_decoderoptions.h:745
friend bool operator!=(const DecoderOptions &lhs, const DecoderOptions &rhs)
Returns !(lhs == rhs)
Definition baljsn_decoderoptions.h:428
void setAllowMissingRequiredAttributes(bool value)
Definition baljsn_decoderoptions.h:628
static const bdlat_AttributeInfo ATTRIBUTE_INFO_ARRAY[]
Definition baljsn_decoderoptions.h:234
static const bool DEFAULT_INITIALIZER_SKIP_UNKNOWN_ELEMENTS
Definition baljsn_decoderoptions.h:222
bsl::ostream & print(bsl::ostream &stream, int level=0, int spacesPerLevel=4) const
int accessAttribute(t_ACCESSOR &accessor, int id) const
Definition baljsn_decoderoptions.h:678
void setSkipUnknownElements(bool value)
Definition baljsn_decoderoptions.h:598
bool allowFormFeedAsWhitespace() const
Definition baljsn_decoderoptions.h:751
DecoderOptions()
Create an object of type DecoderOptions having the default value.
static const bool DEFAULT_INITIALIZER_ALLOW_CONSECUTIVE_SEPARATORS
Definition baljsn_decoderoptions.h:226
int maxDepth() const
Return the value of the "MaxDepth" attribute of this object.
Definition baljsn_decoderoptions.h:727
DecoderOptions & operator=(const DecoderOptions &rhs)
Assign to this object the value of the specified rhs object.
int accessAttributes(t_ACCESSOR &accessor) const
Definition baljsn_decoderoptions.h:635
#define BDLAT_DECL_SEQUENCE_WITH_BITWISEMOVEABLE_TRAITS(ClassName)
Definition bdlat_typetraits.h:294
#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
bsl::enable_if<(bsl::is_integral< TYPE >::value||bsl::is_pointer< TYPE >::value||bsl::is_enum< TYPE >::value)&&!bsl::is_same< TYPE, bool >::value >::type hashAppend(HASH_ALGORITHM &hashAlg, TYPE input)
Definition bslh_hash.h:643
Definition bdlat_attributeinfo.h:139
int d_id
Definition bdlat_attributeinfo.h:142