BDE 4.39.x Production Release
Loading...
Searching...
No Matches
balber_berencoderoptions.h
Go to the documentation of this file.
1/// @file balber_berencoderoptions.h
2///
3/// The content of this file has been pre-processed for Doxygen.
4///
5
6
7// balber_berencoderoptions.h *DO NOT EDIT* @generated -*-C++-*-
8#ifndef INCLUDED_BALBER_BERENCODEROPTIONS
9#define INCLUDED_BALBER_BERENCODEROPTIONS
10
11#include <bsls_ident.h>
12BSLS_IDENT_RCSID(balber_berencoderoptions_h, "$Id$ $CSID$")
14
15/// @defgroup balber_berencoderoptions balber_berencoderoptions
16/// @brief Provide value-semantic attribute classes
17/// @addtogroup bal
18/// @{
19/// @addtogroup balber
20/// @{
21/// @addtogroup balber_berencoderoptions
22/// @{
23///
24/// <h1> Outline </h1>
25/// * <a href="#balber_berencoderoptions-purpose"> Purpose</a>
26///
27/// # Purpose {#balber_berencoderoptions-purpose}
28/// Provide value-semantic attribute classes
29/// @}
30/** @} */
31/** @} */
32
33/** @addtogroup bal
34 * @{
35 */
36/** @addtogroup balber
37 * @{
38 */
39/** @addtogroup balber_berencoderoptions
40 * @{
41 */
42
43#include <bslalg_typetraits.h>
44
45#include <bdlat_attributeinfo.h>
46
47#include <bdlat_selectioninfo.h>
48
49#include <bdlat_typetraits.h>
50
51#include <bsls_objectbuffer.h>
52
55
56#include <bsls_assert.h>
57
58#include <bsl_iosfwd.h>
59#include <bsl_limits.h>
60
61
62
63namespace balber { class BerEncoderOptions; }
64namespace balber {
65
66 // =======================
67 // class BerEncoderOptions
68 // =======================
69
71 // BER encoding options
72
73 // INSTANCE DATA
74 int d_traceLevel;
75 // trace (verbosity) level
76 int d_bdeVersionConformance;
77 // The largest BDE version that can be assumed of the corresponding
78 // decoder for the encoded message, expressed as 10000*majorVersion +
79 // 100*minorVersion + patchVersion (e.g. 1.5.0 is expressed as 10500).
80 //
81 // Ideally, the BER encoder should be permitted to generate any BER
82 // that conforms to X.690 (Basic Encoding Rules) and X.694 (mapping of
83 // XSD to ASN.1). In practice, however, certain unimplemented features
84 // and missunderstandings of these standards have resulted in a decoder
85 // that cannot accept the full range of legal inputs. Even when the
86 // encoder and decoder are both upgraded to a richer subset of BER, the
87 // program receiving the encoded values may not have been recompiled
88 // with the latest version and, thus restricting the encoder to emit
89 // BER that can be understood by the decoder at the other end of the
90 // wire. If it is that the receiver has a more modern decoder, set
91 // this variable to a larger value to allow the encoder to produce BER
92 // that is richer and more standards conformant. The default should be
93 // increased only when old copies of the decoder are completely out of
94 // circulation.
95 int d_datetimeFractionalSecondPrecision;
96 // This option controls the number of decimal places used for seconds
97 // when encoding 'Datetime' and 'DatetimeTz'.
98 bool d_encodeEmptyArrays;
99 // This option allows users to control if empty arrays are encoded. By
100 // default empty arrays are encoded as not encoding empty arrays is
101 // non-compliant with the BER encoding specification.
102 bool d_encodeDateAndTimeTypesAsBinary;
103 // This option allows users to control if date and time types are
104 // encoded as binary integers. By default these types are encoded as
105 // strings in the ISO 8601 format.
106 bool d_disableUnselectedChoiceEncoding;
107 // This encode option allows users to control if it is an error to try
108 // and encoded any element with an unselected choice. By default the
109 // encoder allows unselected choices by eliding them from the encoding.
110 bool d_preserveSignOfNegativeZero;
111 // This *backward*-*compatibility* option controls whether or not
112 // negative zero floating-point values are encoded as the BER
113 // representation of negative zero or positive zero. If this option is
114 // 'true', negative zero floating-point values are encoded as the BER
115 // representation of negative zero, such that they will decode back to
116 // negative zero. If this option is 'false', negative zero
117 // floating-point values are encoded as the BER representation of
118 // positive zero, such they they will decode to positive zero. For
119 // backward-compatibility purposes, the default value of this option is
120 // 'false'. Setting this option to 'true' requires the receiving
121 // decoder to come from BDE release '3.90.x' or later, or otherwise
122 // comply to the ISO/IEC 8825-1:2015 standard. Clients are encouraged
123 // to update their recipients to the latest version of BDE and set this
124 // option to 'true'. Note that the 'false' value of this option will
125 // eventually be deprecated, and the default value changed to 'true'.
126 bool d_encodeArrayLengthHints;
127 // This *backward*-*compatibile* option controls whether or not array
128 // length hints are encoded. For backward-compatibility purposes, the
129 // default value of this option is 'false'. Setting this option to
130 // 'true' requires the receiving decoder to come from BDE release
131 // '4.27.x' or later, or have the 'SkipUnknownElements' decoder option
132 // set to 'true'.
133
134 // PRIVATE ACCESSORS
135 bool isEqualTo(const BerEncoderOptions& rhs) const;
136
137 public:
138 // TYPES
139 enum {
148 };
149
150 enum {
152 };
153
154 enum {
163 };
164
165 // CONSTANTS
166 static const char CLASS_NAME[];
167
169
171
173
175
177
179
181
183
185
186 public:
187 // CLASS METHODS
188 static int maxSupportedBdexVersion(int versionSelector = 0);
189 // Return the most current 'bdex' streaming version number supported by
190 // this class and the specified 'versionSelector'.
191 // See the 'bslx' package-level documentation for more
192 // information on 'bdex' streaming of value-semantic types and
193 // containers.
194
196 // Return attribute information for the attribute indicated by the
197 // specified 'id' if the attribute exists, and 0 otherwise.
198
200 const char *name,
201 int nameLength);
202 // Return attribute information for the attribute indicated by the
203 // specified 'name' of the specified 'nameLength' if the attribute
204 // exists, and 0 otherwise.
205
206 // CREATORS
208 // Create an object of type 'BerEncoderOptions' having the default
209 // value.
210
211
212 // MANIPULATORS
213 template <typename t_STREAM>
214 t_STREAM& bdexStreamIn(t_STREAM& stream, int version);
215 // Assign to this object the value read from the specified input
216 // 'stream' using the specified 'version' format and return a reference
217 // to the modifiable 'stream'. If 'stream' is initially invalid, this
218 // operation has no effect. If 'stream' becomes invalid during this
219 // operation, this object is valid, but its value is undefined. If
220 // 'version' is not supported, 'stream' is marked invalid and this
221 // object is unaltered. Note that no version is read from 'stream'.
222 // See the 'bslx' package-level documentation for more information on
223 // 'bdex' streaming of value-semantic types and containers.
224
225 void reset();
226 // Reset this object to the default value (i.e., its value upon
227 // default construction).
228
229 template <typename t_MANIPULATOR>
230 int manipulateAttributes(t_MANIPULATOR& manipulator);
231 // Invoke the specified 'manipulator' sequentially on the address of
232 // each (modifiable) attribute of this object, supplying 'manipulator'
233 // with the corresponding attribute information structure until such
234 // invocation returns a non-zero value. Return the value from the
235 // last invocation of 'manipulator' (i.e., the invocation that
236 // terminated the sequence).
237
238 template <typename t_MANIPULATOR>
239 int manipulateAttribute(t_MANIPULATOR& manipulator, int id);
240 // Invoke the specified 'manipulator' on the address of
241 // the (modifiable) attribute indicated by the specified 'id',
242 // supplying 'manipulator' with the corresponding attribute
243 // information structure. Return the value returned from the
244 // invocation of 'manipulator' if 'id' identifies an attribute of this
245 // class, and -1 otherwise.
246
247 template <typename t_MANIPULATOR>
248 int manipulateAttribute(t_MANIPULATOR& manipulator,
249 const char *name,
250 int nameLength);
251 // Invoke the specified 'manipulator' on the address of
252 // the (modifiable) attribute indicated by the specified 'name' of the
253 // specified 'nameLength', supplying 'manipulator' with the
254 // corresponding attribute information structure. Return the value
255 // returned from the invocation of 'manipulator' if 'name' identifies
256 // an attribute of this class, and -1 otherwise.
257
258 void setTraceLevel(int value);
259 // Set the "TraceLevel" attribute of this object to the specified
260 // 'value'.
261
263 // Return a reference to the modifiable "BdeVersionConformance"
264 // attribute of this object.
265
266 void setEncodeEmptyArrays(bool value);
267 // Set the "EncodeEmptyArrays" attribute of this object to the
268 // specified 'value'.
269
270 void setEncodeDateAndTimeTypesAsBinary(bool value);
271 // Set the "EncodeDateAndTimeTypesAsBinary" attribute of this object to
272 // the specified 'value'.
273
275 // Set the "DatetimeFractionalSecondPrecision" attribute of this object
276 // to the specified 'value'.
277
278 void setDisableUnselectedChoiceEncoding(bool value);
279 // Set the "DisableUnselectedChoiceEncoding" attribute of this object
280 // to the specified 'value'.
281
282 void setPreserveSignOfNegativeZero(bool value);
283 // Set the "PreserveSignOfNegativeZero" attribute of this object to the
284 // specified 'value'.
285
286 void setEncodeArrayLengthHints(bool value);
287 // Set the "EncodeArrayLengthHints" attribute of this object to the
288 // specified 'value'.
289
290 // ACCESSORS
291 bsl::ostream& print(bsl::ostream& stream,
292 int level = 0,
293 int spacesPerLevel = 4) const;
294 // Format this object to the specified output 'stream' at the
295 // optionally specified indentation 'level' and return a reference to
296 // the modifiable 'stream'. If 'level' is specified, optionally
297 // specify 'spacesPerLevel', the number of spaces per indentation level
298 // for this and all of its nested objects. Each line is indented by
299 // the absolute value of 'level * spacesPerLevel'. If 'level' is
300 // negative, suppress indentation of the first line. If
301 // 'spacesPerLevel' is negative, suppress line breaks and format the
302 // entire output on one line. If 'stream' is initially invalid, this
303 // operation has no effect. Note that a trailing newline is provided
304 // in multiline mode only.
305
306 template <typename t_STREAM>
307 t_STREAM& bdexStreamOut(t_STREAM& stream, int version) const;
308 // Write the value of this object to the specified output 'stream'
309 // using the specified 'version' format and return a reference to the
310 // modifiable 'stream'. If 'version' is not supported, 'stream' is
311 // unmodified. Note that 'version' is not written to 'stream'.
312 // See the 'bslx' package-level documentation for more information
313 // on 'bdex' streaming of value-semantic types and containers.
314
315 template <typename t_ACCESSOR>
316 int accessAttributes(t_ACCESSOR& accessor) const;
317 // Invoke the specified 'accessor' sequentially on each
318 // (non-modifiable) attribute of this object, supplying 'accessor'
319 // with the corresponding attribute information structure until such
320 // invocation returns a non-zero value. Return the value from the
321 // last invocation of 'accessor' (i.e., the invocation that terminated
322 // the sequence).
323
324 template <typename t_ACCESSOR>
325 int accessAttribute(t_ACCESSOR& accessor, int id) const;
326 // Invoke the specified 'accessor' on the (non-modifiable) attribute
327 // of this object indicated by the specified 'id', supplying 'accessor'
328 // with the corresponding attribute information structure. Return the
329 // value returned from the invocation of 'accessor' if 'id' identifies
330 // an attribute of this class, and -1 otherwise.
331
332 template <typename t_ACCESSOR>
333 int accessAttribute(t_ACCESSOR& accessor,
334 const char *name,
335 int nameLength) const;
336 // Invoke the specified 'accessor' on the (non-modifiable) attribute
337 // of this object indicated by the specified 'name' of the specified
338 // 'nameLength', supplying 'accessor' with the corresponding attribute
339 // information structure. Return the value returned from the
340 // invocation of 'accessor' if 'name' identifies an attribute of this
341 // class, and -1 otherwise.
342
343 int traceLevel() const;
344 // Return the value of the "TraceLevel" attribute of this object.
345
346 int bdeVersionConformance() const;
347 // Return the value of the "BdeVersionConformance" attribute of this
348 // object.
349
350 bool encodeEmptyArrays() const;
351 // Return the value of the "EncodeEmptyArrays" attribute of this
352 // object.
353
355 // Return the value of the "EncodeDateAndTimeTypesAsBinary" attribute
356 // of this object.
357
359 // Return the value of the "DatetimeFractionalSecondPrecision"
360 // attribute of this object.
361
363 // Return the value of the "DisableUnselectedChoiceEncoding" attribute
364 // of this object.
365
366 bool preserveSignOfNegativeZero() const;
367 // Return the value of the "PreserveSignOfNegativeZero" attribute of
368 // this object.
369
370 bool encodeArrayLengthHints() const;
371 // Return the value of the "EncodeArrayLengthHints" attribute of this
372 // object.
373
374 // HIDDEN FRIENDS
375 friend bool operator==(const BerEncoderOptions& lhs,
376 const BerEncoderOptions& rhs)
377 // Return 'true' if the specified 'lhs' and 'rhs' attribute objects
378 // have the same value, and 'false' otherwise. Two attribute objects
379 // have the same value if each respective attribute has the same value.
380 {
381 return lhs.isEqualTo(rhs);
382 }
383
384 friend bool operator!=(const BerEncoderOptions& lhs,
385 const BerEncoderOptions& rhs)
386 // Returns '!(lhs == rhs)'
387 {
388 return !(lhs == rhs);
389 }
390
391 friend bsl::ostream& operator<<(bsl::ostream& stream,
392 const BerEncoderOptions& rhs)
393 // Format the specified 'rhs' to the specified output 'stream' and
394 // return a reference to the modifiable 'stream'.
395 {
396 return rhs.print(stream, 0, -1);
397 }
398};
399
400} // close package namespace
401
402// TRAITS
403
405
406// ============================================================================
407// INLINE DEFINITIONS
408// ============================================================================
409
410namespace balber {
411
412 // -----------------------
413 // class BerEncoderOptions
414 // -----------------------
415
416// PRIVATE ACCESSORS
417inline
418bool BerEncoderOptions::isEqualTo(const BerEncoderOptions& rhs) const
419{
420 return this->traceLevel() == rhs.traceLevel() &&
421 this->bdeVersionConformance() == rhs.bdeVersionConformance() &&
422 this->encodeEmptyArrays() == rhs.encodeEmptyArrays() &&
423 this->encodeDateAndTimeTypesAsBinary() == rhs.encodeDateAndTimeTypesAsBinary() &&
424 this->datetimeFractionalSecondPrecision() == rhs.datetimeFractionalSecondPrecision() &&
425 this->disableUnselectedChoiceEncoding() == rhs.disableUnselectedChoiceEncoding() &&
426 this->preserveSignOfNegativeZero() == rhs.preserveSignOfNegativeZero() &&
427 this->encodeArrayLengthHints() == rhs.encodeArrayLengthHints();
428}
429
430// CLASS METHODS
431inline
433{
434 if (versionSelector >= 20250615) {
435 return 3; // RETURN
436 }
437 return 2;
438}
439
440// MANIPULATORS
441template <typename t_STREAM>
442t_STREAM& BerEncoderOptions::bdexStreamIn(t_STREAM& stream, int version)
443{
444 if (stream) {
445#ifdef BSLS_PLATFORM_CMP_GNU
446#pragma GCC diagnostic push
447#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
448#endif
449 switch (version) {
450 case 3: {
451 bslx::InStreamFunctions::bdexStreamIn(stream, d_traceLevel, 1);
452 bslx::InStreamFunctions::bdexStreamIn(stream, d_bdeVersionConformance, 1);
453 bslx::InStreamFunctions::bdexStreamIn(stream, d_encodeEmptyArrays, 1);
454 bslx::InStreamFunctions::bdexStreamIn(stream, d_encodeDateAndTimeTypesAsBinary, 1);
455 bslx::InStreamFunctions::bdexStreamIn(stream, d_datetimeFractionalSecondPrecision, 1);
456 bslx::InStreamFunctions::bdexStreamIn(stream, d_disableUnselectedChoiceEncoding, 1);
457 bslx::InStreamFunctions::bdexStreamIn(stream, d_preserveSignOfNegativeZero, 1);
458 bslx::InStreamFunctions::bdexStreamIn(stream, d_encodeArrayLengthHints, 1);
459 } break;
460 case 2: {
461 bslx::InStreamFunctions::bdexStreamIn(stream, d_traceLevel, 1);
462 bslx::InStreamFunctions::bdexStreamIn(stream, d_bdeVersionConformance, 1);
463 bslx::InStreamFunctions::bdexStreamIn(stream, d_encodeEmptyArrays, 1);
464 bslx::InStreamFunctions::bdexStreamIn(stream, d_encodeDateAndTimeTypesAsBinary, 1);
465 bslx::InStreamFunctions::bdexStreamIn(stream, d_datetimeFractionalSecondPrecision, 1);
466 bslx::InStreamFunctions::bdexStreamIn(stream, d_disableUnselectedChoiceEncoding, 1);
467 bslx::InStreamFunctions::bdexStreamIn(stream, d_preserveSignOfNegativeZero, 1);
468 d_encodeArrayLengthHints = false;
469 } break;
470 case 1: {
471 reset();
472
473 bslx::InStreamFunctions::bdexStreamIn(stream, d_traceLevel, 1);
474 bslx::InStreamFunctions::bdexStreamIn(stream, d_bdeVersionConformance, 1);
475 bslx::InStreamFunctions::bdexStreamIn(stream, d_encodeEmptyArrays, 1);
476 bslx::InStreamFunctions::bdexStreamIn(stream, d_encodeDateAndTimeTypesAsBinary, 1);
477 bslx::InStreamFunctions::bdexStreamIn(stream, d_datetimeFractionalSecondPrecision, 1);
478 bslx::InStreamFunctions::bdexStreamIn(stream, d_disableUnselectedChoiceEncoding, 1);
479 } break;
480 default: {
481 stream.invalidate();
482 }
483 }
484#ifdef BSLS_PLATFORM_CMP_GNU
485#pragma GCC diagnostic pop
486#endif
487 }
488 return stream;
489}
490
491template <typename t_MANIPULATOR>
492int BerEncoderOptions::manipulateAttributes(t_MANIPULATOR& manipulator)
493{
494 int ret;
495
496 ret = manipulator(&d_traceLevel, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_TRACE_LEVEL]);
497 if (ret) {
498 return ret;
499 }
500
501 ret = manipulator(&d_bdeVersionConformance, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_BDE_VERSION_CONFORMANCE]);
502 if (ret) {
503 return ret;
504 }
505
506 ret = manipulator(&d_encodeEmptyArrays, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_ENCODE_EMPTY_ARRAYS]);
507 if (ret) {
508 return ret;
509 }
510
511 ret = manipulator(&d_encodeDateAndTimeTypesAsBinary, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_ENCODE_DATE_AND_TIME_TYPES_AS_BINARY]);
512 if (ret) {
513 return ret;
514 }
515
516 ret = manipulator(&d_datetimeFractionalSecondPrecision, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_DATETIME_FRACTIONAL_SECOND_PRECISION]);
517 if (ret) {
518 return ret;
519 }
520
521 ret = manipulator(&d_disableUnselectedChoiceEncoding, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_DISABLE_UNSELECTED_CHOICE_ENCODING]);
522 if (ret) {
523 return ret;
524 }
525
526 ret = manipulator(&d_preserveSignOfNegativeZero, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_PRESERVE_SIGN_OF_NEGATIVE_ZERO]);
527 if (ret) {
528 return ret;
529 }
530
531 ret = manipulator(&d_encodeArrayLengthHints, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_ENCODE_ARRAY_LENGTH_HINTS]);
532 if (ret) {
533 return ret;
534 }
535
536 return 0;
537}
538
539template <typename t_MANIPULATOR>
540int BerEncoderOptions::manipulateAttribute(t_MANIPULATOR& manipulator, int id)
541{
542 enum { NOT_FOUND = -1 };
543
544 switch (id) {
546 return manipulator(&d_traceLevel, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_TRACE_LEVEL]);
547 }
549 return manipulator(&d_bdeVersionConformance, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_BDE_VERSION_CONFORMANCE]);
550 }
552 return manipulator(&d_encodeEmptyArrays, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_ENCODE_EMPTY_ARRAYS]);
553 }
555 return manipulator(&d_encodeDateAndTimeTypesAsBinary, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_ENCODE_DATE_AND_TIME_TYPES_AS_BINARY]);
556 }
558 return manipulator(&d_datetimeFractionalSecondPrecision, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_DATETIME_FRACTIONAL_SECOND_PRECISION]);
559 }
561 return manipulator(&d_disableUnselectedChoiceEncoding, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_DISABLE_UNSELECTED_CHOICE_ENCODING]);
562 }
564 return manipulator(&d_preserveSignOfNegativeZero, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_PRESERVE_SIGN_OF_NEGATIVE_ZERO]);
565 }
567 return manipulator(&d_encodeArrayLengthHints, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_ENCODE_ARRAY_LENGTH_HINTS]);
568 }
569 default:
570 return NOT_FOUND;
571 }
572}
573
574template <typename t_MANIPULATOR>
576 t_MANIPULATOR& manipulator,
577 const char *name,
578 int nameLength)
579{
580 enum { NOT_FOUND = -1 };
581
582 const bdlat_AttributeInfo *attributeInfo =
583 lookupAttributeInfo(name, nameLength);
584 if (0 == attributeInfo) {
585 return NOT_FOUND;
586 }
587
588 return manipulateAttribute(manipulator, attributeInfo->d_id);
589}
590
591inline
593{
594 d_traceLevel = value;
595}
596
597inline
599{
600 return d_bdeVersionConformance;
601}
602
603inline
605{
606 d_encodeEmptyArrays = value;
607}
608
609inline
611{
612 d_encodeDateAndTimeTypesAsBinary = value;
613}
614
615inline
617{
618 d_datetimeFractionalSecondPrecision = value;
619}
620
621inline
623{
624 d_disableUnselectedChoiceEncoding = value;
625}
626
627inline
629{
630 d_preserveSignOfNegativeZero = value;
631}
632
633inline
635{
636 d_encodeArrayLengthHints = value;
637}
638
639// ACCESSORS
640template <typename t_STREAM>
641t_STREAM& BerEncoderOptions::bdexStreamOut(t_STREAM& stream, int version) const
642{
643 switch (version) {
644 case 3: {
653 } break;
654 case 2: {
662 } break;
663 case 1: {
670 } break;
671 }
672 return stream;
673}
674
675template <typename t_ACCESSOR>
676int BerEncoderOptions::accessAttributes(t_ACCESSOR& accessor) const
677{
678 int ret;
679
680 ret = accessor(d_traceLevel, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_TRACE_LEVEL]);
681 if (ret) {
682 return ret;
683 }
684
685 ret = accessor(d_bdeVersionConformance, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_BDE_VERSION_CONFORMANCE]);
686 if (ret) {
687 return ret;
688 }
689
690 ret = accessor(d_encodeEmptyArrays, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_ENCODE_EMPTY_ARRAYS]);
691 if (ret) {
692 return ret;
693 }
694
695 ret = accessor(d_encodeDateAndTimeTypesAsBinary, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_ENCODE_DATE_AND_TIME_TYPES_AS_BINARY]);
696 if (ret) {
697 return ret;
698 }
699
700 ret = accessor(d_datetimeFractionalSecondPrecision, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_DATETIME_FRACTIONAL_SECOND_PRECISION]);
701 if (ret) {
702 return ret;
703 }
704
705 ret = accessor(d_disableUnselectedChoiceEncoding, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_DISABLE_UNSELECTED_CHOICE_ENCODING]);
706 if (ret) {
707 return ret;
708 }
709
710 ret = accessor(d_preserveSignOfNegativeZero, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_PRESERVE_SIGN_OF_NEGATIVE_ZERO]);
711 if (ret) {
712 return ret;
713 }
714
715 ret = accessor(d_encodeArrayLengthHints, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_ENCODE_ARRAY_LENGTH_HINTS]);
716 if (ret) {
717 return ret;
718 }
719
720 return 0;
721}
722
723template <typename t_ACCESSOR>
724int BerEncoderOptions::accessAttribute(t_ACCESSOR& accessor, int id) const
725{
726 enum { NOT_FOUND = -1 };
727
728 switch (id) {
730 return accessor(d_traceLevel, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_TRACE_LEVEL]);
731 }
733 return accessor(d_bdeVersionConformance, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_BDE_VERSION_CONFORMANCE]);
734 }
736 return accessor(d_encodeEmptyArrays, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_ENCODE_EMPTY_ARRAYS]);
737 }
739 return accessor(d_encodeDateAndTimeTypesAsBinary, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_ENCODE_DATE_AND_TIME_TYPES_AS_BINARY]);
740 }
742 return accessor(d_datetimeFractionalSecondPrecision, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_DATETIME_FRACTIONAL_SECOND_PRECISION]);
743 }
745 return accessor(d_disableUnselectedChoiceEncoding, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_DISABLE_UNSELECTED_CHOICE_ENCODING]);
746 }
748 return accessor(d_preserveSignOfNegativeZero, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_PRESERVE_SIGN_OF_NEGATIVE_ZERO]);
749 }
751 return accessor(d_encodeArrayLengthHints, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_ENCODE_ARRAY_LENGTH_HINTS]);
752 }
753 default:
754 return NOT_FOUND;
755 }
756}
757
758template <typename t_ACCESSOR>
760 t_ACCESSOR& accessor,
761 const char *name,
762 int nameLength) const
763{
764 enum { NOT_FOUND = -1 };
765
766 const bdlat_AttributeInfo *attributeInfo =
767 lookupAttributeInfo(name, nameLength);
768 if (0 == attributeInfo) {
769 return NOT_FOUND;
770 }
771
772 return accessAttribute(accessor, attributeInfo->d_id);
773}
774
775inline
777{
778 return d_traceLevel;
779}
780
781inline
783{
784 return d_bdeVersionConformance;
785}
786
787inline
789{
790 return d_encodeEmptyArrays;
791}
792
793inline
795{
796 return d_encodeDateAndTimeTypesAsBinary;
797}
798
799inline
801{
802 return d_datetimeFractionalSecondPrecision;
803}
804
805inline
807{
808 return d_disableUnselectedChoiceEncoding;
809}
810
811inline
813{
814 return d_preserveSignOfNegativeZero;
815}
816
817inline
819{
820 return d_encodeArrayLengthHints;
821}
822
823} // close package namespace
824
825// FREE FUNCTIONS
826
827
828#endif
829
830// GENERATED BY BLP_BAS_CODEGEN_2025.05.15
831// USING bas_codegen.pl -m msg --msgExpand -p balber --noAggregateConversion --noHashSupport -c berencoderoptions balber.xsd
832// ----------------------------------------------------------------------------
833// NOTICE:
834// Copyright 2025 Bloomberg Finance L.P. All rights reserved.
835// Property of Bloomberg Finance L.P. (BFLP)
836// This software is made available solely pursuant to the
837// terms of a BFLP license agreement which governs its use.
838// ------------------------------- END-OF-FILE --------------------------------
839
840/** @} */
841/** @} */
842/** @} */
Definition balber_berencoderoptions.h:70
int manipulateAttributes(t_MANIPULATOR &manipulator)
Definition balber_berencoderoptions.h:492
static const bdlat_AttributeInfo ATTRIBUTE_INFO_ARRAY[]
Definition balber_berencoderoptions.h:184
static const bool DEFAULT_INITIALIZER_ENCODE_EMPTY_ARRAYS
Definition balber_berencoderoptions.h:172
@ ATTRIBUTE_ID_PRESERVE_SIGN_OF_NEGATIVE_ZERO
Definition balber_berencoderoptions.h:146
@ ATTRIBUTE_ID_ENCODE_EMPTY_ARRAYS
Definition balber_berencoderoptions.h:142
@ ATTRIBUTE_ID_DISABLE_UNSELECTED_CHOICE_ENCODING
Definition balber_berencoderoptions.h:145
@ ATTRIBUTE_ID_TRACE_LEVEL
Definition balber_berencoderoptions.h:140
@ ATTRIBUTE_ID_ENCODE_DATE_AND_TIME_TYPES_AS_BINARY
Definition balber_berencoderoptions.h:143
@ ATTRIBUTE_ID_BDE_VERSION_CONFORMANCE
Definition balber_berencoderoptions.h:141
@ ATTRIBUTE_ID_ENCODE_ARRAY_LENGTH_HINTS
Definition balber_berencoderoptions.h:147
@ ATTRIBUTE_ID_DATETIME_FRACTIONAL_SECOND_PRECISION
Definition balber_berencoderoptions.h:144
static const int DEFAULT_INITIALIZER_DATETIME_FRACTIONAL_SECOND_PRECISION
Definition balber_berencoderoptions.h:176
int accessAttributes(t_ACCESSOR &accessor) const
Definition balber_berencoderoptions.h:676
t_STREAM & bdexStreamIn(t_STREAM &stream, int version)
Definition balber_berencoderoptions.h:442
t_STREAM & bdexStreamOut(t_STREAM &stream, int version) const
Definition balber_berencoderoptions.h:641
static const int DEFAULT_INITIALIZER_TRACE_LEVEL
Definition balber_berencoderoptions.h:168
bool encodeDateAndTimeTypesAsBinary() const
Definition balber_berencoderoptions.h:794
static const bool DEFAULT_INITIALIZER_ENCODE_DATE_AND_TIME_TYPES_AS_BINARY
Definition balber_berencoderoptions.h:174
void setEncodeArrayLengthHints(bool value)
Definition balber_berencoderoptions.h:634
friend bool operator==(const BerEncoderOptions &lhs, const BerEncoderOptions &rhs)
Definition balber_berencoderoptions.h:375
static const bdlat_AttributeInfo * lookupAttributeInfo(const char *name, int nameLength)
friend bool operator!=(const BerEncoderOptions &lhs, const BerEncoderOptions &rhs)
Definition balber_berencoderoptions.h:384
bool preserveSignOfNegativeZero() const
Definition balber_berencoderoptions.h:812
void setPreserveSignOfNegativeZero(bool value)
Definition balber_berencoderoptions.h:628
static const bool DEFAULT_INITIALIZER_DISABLE_UNSELECTED_CHOICE_ENCODING
Definition balber_berencoderoptions.h:178
static const bdlat_AttributeInfo * lookupAttributeInfo(int id)
int traceLevel() const
Definition balber_berencoderoptions.h:776
static const int DEFAULT_INITIALIZER_BDE_VERSION_CONFORMANCE
Definition balber_berencoderoptions.h:170
@ ATTRIBUTE_INDEX_DISABLE_UNSELECTED_CHOICE_ENCODING
Definition balber_berencoderoptions.h:160
@ ATTRIBUTE_INDEX_ENCODE_ARRAY_LENGTH_HINTS
Definition balber_berencoderoptions.h:162
@ ATTRIBUTE_INDEX_ENCODE_EMPTY_ARRAYS
Definition balber_berencoderoptions.h:157
@ ATTRIBUTE_INDEX_DATETIME_FRACTIONAL_SECOND_PRECISION
Definition balber_berencoderoptions.h:159
@ ATTRIBUTE_INDEX_TRACE_LEVEL
Definition balber_berencoderoptions.h:155
@ ATTRIBUTE_INDEX_PRESERVE_SIGN_OF_NEGATIVE_ZERO
Definition balber_berencoderoptions.h:161
@ ATTRIBUTE_INDEX_BDE_VERSION_CONFORMANCE
Definition balber_berencoderoptions.h:156
@ ATTRIBUTE_INDEX_ENCODE_DATE_AND_TIME_TYPES_AS_BINARY
Definition balber_berencoderoptions.h:158
static const bool DEFAULT_INITIALIZER_ENCODE_ARRAY_LENGTH_HINTS
Definition balber_berencoderoptions.h:182
static int maxSupportedBdexVersion(int versionSelector=0)
Definition balber_berencoderoptions.h:432
int datetimeFractionalSecondPrecision() const
Definition balber_berencoderoptions.h:800
int accessAttribute(t_ACCESSOR &accessor, int id) const
Definition balber_berencoderoptions.h:724
bool disableUnselectedChoiceEncoding() const
Definition balber_berencoderoptions.h:806
bsl::ostream & print(bsl::ostream &stream, int level=0, int spacesPerLevel=4) const
void setTraceLevel(int value)
Definition balber_berencoderoptions.h:592
static const bool DEFAULT_INITIALIZER_PRESERVE_SIGN_OF_NEGATIVE_ZERO
Definition balber_berencoderoptions.h:180
friend bsl::ostream & operator<<(bsl::ostream &stream, const BerEncoderOptions &rhs)
Definition balber_berencoderoptions.h:391
void setEncodeEmptyArrays(bool value)
Definition balber_berencoderoptions.h:604
void setEncodeDateAndTimeTypesAsBinary(bool value)
Definition balber_berencoderoptions.h:610
void setDisableUnselectedChoiceEncoding(bool value)
Definition balber_berencoderoptions.h:622
@ NUM_ATTRIBUTES
Definition balber_berencoderoptions.h:151
bool encodeEmptyArrays() const
Definition balber_berencoderoptions.h:788
int & bdeVersionConformance()
Definition balber_berencoderoptions.h:598
int manipulateAttribute(t_MANIPULATOR &manipulator, int id)
Definition balber_berencoderoptions.h:540
static const char CLASS_NAME[]
Definition balber_berencoderoptions.h:166
bool encodeArrayLengthHints() const
Definition balber_berencoderoptions.h:818
void setDatetimeFractionalSecondPrecision(int value)
Definition balber_berencoderoptions.h:616
#define BDLAT_DECL_SEQUENCE_WITH_BITWISEMOVEABLE_TRAITS(ClassName)
Definition bdlat_typetraits.h:294
#define BSLS_IDENT_RCSID(tag, str)
BSLS_IDENT_RCSID() - insert ident str (specific to platform/compiler)
Definition bsls_ident.h:244
#define BSLS_IDENT_PRAGMA_ONCE
BSLS_IDENT_PRAGMA_ONCE - macro to avoid multiple inclusion
Definition bsls_ident.h:263
Definition balber_berconstants.h:84
STREAM & bdexStreamIn(STREAM &stream, VALUE_TYPE &variable)
Definition bslx_instreamfunctions.h:1263
STREAM & bdexStreamOut(STREAM &stream, const TYPE &value)
Definition bslx_outstreamfunctions.h:1004
Definition bdlat_attributeinfo.h:139
int d_id
Definition bdlat_attributeinfo.h:142