BDE 4.39.x Production Release
Loading...
Searching...
No Matches
balxml_decoderoptions.h
Go to the documentation of this file.
1/// @file balxml_decoderoptions.h
2///
3/// The content of this file has been pre-processed for Doxygen.
4///
5
6
7// balxml_decoderoptions.h *DO NOT EDIT* @generated -*-C++-*-
8#ifndef INCLUDED_BALXML_DECODEROPTIONS
9#define INCLUDED_BALXML_DECODEROPTIONS
10
11#include <bsls_ident.h>
12BSLS_IDENT_RCSID(balxml_decoderoptions_h, "$Id$ $CSID$")
14
15/// @defgroup balxml_decoderoptions balxml_decoderoptions
16/// @brief Provide value-semantic attribute classes
17/// @addtogroup bal
18/// @{
19/// @addtogroup balxml
20/// @{
21/// @addtogroup balxml_decoderoptions
22/// @{
23///
24/// <h1> Outline </h1>
25/// * <a href="#balxml_decoderoptions-purpose"> Purpose</a>
26///
27/// # Purpose {#balxml_decoderoptions-purpose}
28/// Provide value-semantic attribute classes
29/// @}
30/** @} */
31/** @} */
32
33/** @addtogroup bal
34 * @{
35 */
36/** @addtogroup balxml
37 * @{
38 */
39/** @addtogroup balxml_decoderoptions
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
53#include <bsls_assert.h>
54
55#include <bsl_iosfwd.h>
56#include <bsl_limits.h>
57
58
59
60namespace balxml { class DecoderOptions; }
61namespace balxml {
62
63 // ====================
64 // class DecoderOptions
65 // ====================
66
67/// Options for controlling the XML decoding process.
68/// The generated C++ code for this schema element is created by using
69/// bas_codegen.pl, run by balxml/code_from_xsd.pl with no hand-editing.
70///
71/// See @ref balxml_decoderoptions
73
74 // INSTANCE DATA
75
76 // maximum recursion depth
77 int d_maxDepth;
78
79 // Formatting mode
80 int d_formattingMode;
81
82 // Option to skip unknown elements
83 bool d_skipUnknownElements;
84
85 // option to check that input is valid UTF-8
86 bool d_validateInputIsUtf8;
87
88 // Option to validate the root tag when decoding a structure.
89 bool d_validateRootTag;
90
91 public:
92 // TYPES
93 enum {
99 };
100
101 enum {
103 };
104
105 enum {
111 };
112
113 // CONSTANTS
114 static const char CLASS_NAME[];
115
117
119
121
123
125
127
128 public:
129 // CLASS METHODS
130
131 /// Return attribute information for the attribute indicated by the
132 /// specified `id` if the attribute exists, and 0 otherwise.
134
135 /// Return attribute information for the attribute indicated by the
136 /// specified `name` of the specified `nameLength` if the attribute
137 /// exists, and 0 otherwise.
139 const char *name,
140 int nameLength);
141
142 // CREATORS
143
144 /// Create an object of type `DecoderOptions` having the default value.
146
147 /// Create an object of type `DecoderOptions` having the value of the
148 /// specified `original` object.
150
151#if defined(BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES) \
152 && defined(BSLS_COMPILERFEATURES_SUPPORT_NOEXCEPT)
153 /// Create an object of type `DecoderOptions` having the value of the
154 /// specified `original` object. After performing this action, the
155 /// `original` object will be left in a valid, but unspecified state.
156 DecoderOptions(DecoderOptions&& original) = default;
157#endif
158
159 /// Destroy this object.
161
162 // MANIPULATORS
163
164 /// Assign to this object the value of the specified `rhs` object.
166
167#if defined(BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES) \
168 && defined(BSLS_COMPILERFEATURES_SUPPORT_NOEXCEPT)
169 /// Assign to this object the value of the specified `rhs` object.
170 /// After performing this action, the `rhs` object will be left in a
171 /// valid, but unspecified state.
173#endif
174
175 /// Reset this object to the default value (i.e., its value upon
176 /// default construction).
177 void reset();
178
179 /// Invoke the specified `manipulator` sequentially on the address of
180 /// each (modifiable) attribute of this object, supplying `manipulator`
181 /// with the corresponding attribute information structure until such
182 /// invocation returns a non-zero value. Return the value from the
183 /// last invocation of `manipulator` (i.e., the invocation that
184 /// terminated the sequence).
185 template <typename t_MANIPULATOR>
186 int manipulateAttributes(t_MANIPULATOR& manipulator);
187
188 /// Invoke the specified `manipulator` on the address of
189 /// the (modifiable) attribute indicated by the specified `id`,
190 /// supplying `manipulator` with the corresponding attribute
191 /// information structure. Return the value returned from the
192 /// invocation of `manipulator` if `id` identifies an attribute of this
193 /// class, and -1 otherwise.
194 template <typename t_MANIPULATOR>
195 int manipulateAttribute(t_MANIPULATOR& manipulator, int id);
196
197 /// Invoke the specified `manipulator` on the address of
198 /// the (modifiable) attribute indicated by the specified `name` of the
199 /// specified `nameLength`, supplying `manipulator` with the
200 /// corresponding attribute information structure. Return the value
201 /// returned from the invocation of `manipulator` if `name` identifies
202 /// an attribute of this class, and -1 otherwise.
203 template <typename t_MANIPULATOR>
204 int manipulateAttribute(t_MANIPULATOR& manipulator,
205 const char *name,
206 int nameLength);
207
208 /// Set the "MaxDepth" attribute of this object to the specified
209 /// `value`.
210 void setMaxDepth(int value);
211
212 /// Set the "FormattingMode" attribute of this object to the specified
213 /// `value`.
214 void setFormattingMode(int value);
215
216 /// Set the "SkipUnknownElements" attribute of this object to the
217 /// specified `value`.
218 void setSkipUnknownElements(bool value);
219
220 /// Set the "ValidateInputIsUtf8" attribute of this object to the
221 /// specified `value`.
222 void setValidateInputIsUtf8(bool value);
223
224 /// Set the "ValidateRootTag" attribute of this object to the specified
225 /// `value`.
226 void setValidateRootTag(bool value);
227
228 // ACCESSORS
229
230 /// Format this object to the specified output `stream` at the
231 /// optionally specified indentation `level` and return a reference to
232 /// the modifiable `stream`. If `level` is specified, optionally
233 /// specify `spacesPerLevel`, the number of spaces per indentation level
234 /// for this and all of its nested objects. Each line is indented by
235 /// the absolute value of `level * spacesPerLevel`. If `level` is
236 /// negative, suppress indentation of the first line. If
237 /// `spacesPerLevel` is negative, suppress line breaks and format the
238 /// entire output on one line. If `stream` is initially invalid, this operation has no effect.
239 ///
240 /// \note Note that a trailing newline is provided
241 /// in multiline mode only.
242 bsl::ostream& print(bsl::ostream& stream,
243 int level = 0,
244 int spacesPerLevel = 4) const;
245
246 /// Invoke the specified `accessor` sequentially on each
247 /// (non-modifiable) attribute of this object, supplying `accessor`
248 /// with the corresponding attribute information structure until such
249 /// invocation returns a non-zero value. Return the value from the
250 /// last invocation of `accessor` (i.e., the invocation that terminated
251 /// the sequence).
252 template <typename t_ACCESSOR>
253 int accessAttributes(t_ACCESSOR& accessor) const;
254
255 /// Invoke the specified `accessor` on the (non-modifiable) attribute
256 /// of this object indicated by the specified `id`, supplying `accessor`
257 /// with the corresponding attribute information structure. Return the
258 /// value returned from the invocation of `accessor` if `id` identifies
259 /// an attribute of this class, and -1 otherwise.
260 template <typename t_ACCESSOR>
261 int accessAttribute(t_ACCESSOR& accessor, int id) const;
262
263 /// Invoke the specified `accessor` on the (non-modifiable) attribute
264 /// of this object indicated by the specified `name` of the specified
265 /// `nameLength`, supplying `accessor` with the corresponding attribute
266 /// information structure. Return the value returned from the
267 /// invocation of `accessor` if `name` identifies an attribute of this
268 /// class, and -1 otherwise.
269 template <typename t_ACCESSOR>
270 int accessAttribute(t_ACCESSOR& accessor,
271 const char *name,
272 int nameLength) const;
273
274 /// Return the value of the "MaxDepth" attribute of this object.
275 int maxDepth() const;
276
277 /// Return the value of the "FormattingMode" attribute of this object.
278 int formattingMode() const;
279
280 /// Return the value of the "SkipUnknownElements" attribute of this
281 /// object.
282 bool skipUnknownElements() const;
283
284 /// Return the value of the "ValidateInputIsUtf8" attribute of this
285 /// object.
286 bool validateInputIsUtf8() const;
287
288 /// Return the value of the "ValidateRootTag" attribute of this object.
289 bool validateRootTag() const;
290};
291
292// FREE OPERATORS
293
294/// Return `true` if the specified `lhs` and `rhs` attribute objects have
295/// the same value, and `false` otherwise. Two attribute objects have the
296/// same value if each respective attribute has the same value.
297inline
298bool operator==(const DecoderOptions& lhs, const DecoderOptions& rhs);
299
300/// Return `true` if the specified `lhs` and `rhs` attribute objects do not
301/// have the same value, and `false` otherwise. Two attribute objects do
302/// not have the same value if one or more respective attributes differ in
303/// values.
304inline
305bool operator!=(const DecoderOptions& lhs, const DecoderOptions& rhs);
306
307/// Format the specified `rhs` to the specified output `stream` and
308/// return a reference to the modifiable `stream`.
309inline
310bsl::ostream& operator<<(bsl::ostream& stream, const DecoderOptions& rhs);
311
312} // close package namespace
313
314// TRAITS
315
317
318// ============================================================================
319// INLINE FUNCTION DEFINITIONS
320// ============================================================================
321
322namespace balxml {
323
324 // --------------------
325 // class DecoderOptions
326 // --------------------
327
328// CLASS METHODS
329// MANIPULATORS
330template <typename t_MANIPULATOR>
331int DecoderOptions::manipulateAttributes(t_MANIPULATOR& manipulator)
332{
333 int ret;
334
335 ret = manipulator(&d_maxDepth, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_MAX_DEPTH]);
336 if (ret) {
337 return ret;
338 }
339
340 ret = manipulator(&d_formattingMode, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_FORMATTING_MODE]);
341 if (ret) {
342 return ret;
343 }
344
345 ret = manipulator(&d_skipUnknownElements, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_SKIP_UNKNOWN_ELEMENTS]);
346 if (ret) {
347 return ret;
348 }
349
350 ret = manipulator(&d_validateInputIsUtf8, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_VALIDATE_INPUT_IS_UTF8]);
351 if (ret) {
352 return ret;
353 }
354
355 ret = manipulator(&d_validateRootTag, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_VALIDATE_ROOT_TAG]);
356 if (ret) {
357 return ret;
358 }
359
360 return 0;
361}
362
363template <typename t_MANIPULATOR>
364int DecoderOptions::manipulateAttribute(t_MANIPULATOR& manipulator, int id)
365{
366 enum { NOT_FOUND = -1 };
367
368 switch (id) {
370 return manipulator(&d_maxDepth, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_MAX_DEPTH]);
371 }
373 return manipulator(&d_formattingMode, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_FORMATTING_MODE]);
374 }
376 return manipulator(&d_skipUnknownElements, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_SKIP_UNKNOWN_ELEMENTS]);
377 }
379 return manipulator(&d_validateInputIsUtf8, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_VALIDATE_INPUT_IS_UTF8]);
380 }
382 return manipulator(&d_validateRootTag, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_VALIDATE_ROOT_TAG]);
383 }
384 default:
385 return NOT_FOUND;
386 }
387}
388
389template <typename t_MANIPULATOR>
391 t_MANIPULATOR& manipulator,
392 const char *name,
393 int nameLength)
394{
395 enum { NOT_FOUND = -1 };
396
397 const bdlat_AttributeInfo *attributeInfo =
398 lookupAttributeInfo(name, nameLength);
399 if (0 == attributeInfo) {
400 return NOT_FOUND;
401 }
402
403 return manipulateAttribute(manipulator, attributeInfo->d_id);
404}
405
406inline
408{
409 d_maxDepth = value;
410}
411
412inline
414{
415 d_formattingMode = value;
416}
417
418inline
420{
421 d_skipUnknownElements = value;
422}
423
424inline
426{
427 d_validateInputIsUtf8 = value;
428}
429
430inline
432{
433 d_validateRootTag = value;
434}
435
436// ACCESSORS
437template <typename t_ACCESSOR>
438int DecoderOptions::accessAttributes(t_ACCESSOR& accessor) const
439{
440 int ret;
441
442 ret = accessor(d_maxDepth, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_MAX_DEPTH]);
443 if (ret) {
444 return ret;
445 }
446
447 ret = accessor(d_formattingMode, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_FORMATTING_MODE]);
448 if (ret) {
449 return ret;
450 }
451
452 ret = accessor(d_skipUnknownElements, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_SKIP_UNKNOWN_ELEMENTS]);
453 if (ret) {
454 return ret;
455 }
456
457 ret = accessor(d_validateInputIsUtf8, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_VALIDATE_INPUT_IS_UTF8]);
458 if (ret) {
459 return ret;
460 }
461
462 ret = accessor(d_validateRootTag, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_VALIDATE_ROOT_TAG]);
463 if (ret) {
464 return ret;
465 }
466
467 return 0;
468}
469
470template <typename t_ACCESSOR>
471int DecoderOptions::accessAttribute(t_ACCESSOR& accessor, int id) const
472{
473 enum { NOT_FOUND = -1 };
474
475 switch (id) {
477 return accessor(d_maxDepth, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_MAX_DEPTH]);
478 }
480 return accessor(d_formattingMode, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_FORMATTING_MODE]);
481 }
483 return accessor(d_skipUnknownElements, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_SKIP_UNKNOWN_ELEMENTS]);
484 }
486 return accessor(d_validateInputIsUtf8, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_VALIDATE_INPUT_IS_UTF8]);
487 }
489 return accessor(d_validateRootTag, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_VALIDATE_ROOT_TAG]);
490 }
491 default:
492 return NOT_FOUND;
493 }
494}
495
496template <typename t_ACCESSOR>
498 t_ACCESSOR& accessor,
499 const char *name,
500 int nameLength) const
501{
502 enum { NOT_FOUND = -1 };
503
504 const bdlat_AttributeInfo *attributeInfo =
505 lookupAttributeInfo(name, nameLength);
506 if (0 == attributeInfo) {
507 return NOT_FOUND;
508 }
509
510 return accessAttribute(accessor, attributeInfo->d_id);
511}
512
513inline
515{
516 return d_maxDepth;
517}
518
519inline
521{
522 return d_formattingMode;
523}
524
525inline
527{
528 return d_skipUnknownElements;
529}
530
531inline
533{
534 return d_validateInputIsUtf8;
535}
536
537inline
539{
540 return d_validateRootTag;
541}
542
543} // close package namespace
544
545// FREE FUNCTIONS
546
547inline
549 const balxml::DecoderOptions& lhs,
550 const balxml::DecoderOptions& rhs)
551{
552 return lhs.maxDepth() == rhs.maxDepth()
553 && lhs.formattingMode() == rhs.formattingMode()
554 && lhs.skipUnknownElements() == rhs.skipUnknownElements()
555 && lhs.validateInputIsUtf8() == rhs.validateInputIsUtf8()
556 && lhs.validateRootTag() == rhs.validateRootTag();
557}
558
559inline
561 const balxml::DecoderOptions& lhs,
562 const balxml::DecoderOptions& rhs)
563{
564 return !(lhs == rhs);
565}
566
567inline
568bsl::ostream& balxml::operator<<(
569 bsl::ostream& stream,
570 const balxml::DecoderOptions& rhs)
571{
572 return rhs.print(stream, 0, -1);
573}
574
575
576#endif
577
578// GENERATED BY @BLP_BAS_CODEGEN_VERSION@
579// USING bas_codegen.pl -m msg -p balxml -E --noExternalization --noAggregateConversion --noHashSupport balxml.xsd
580// ----------------------------------------------------------------------------
581// NOTICE:
582// Copyright 2023 Bloomberg Finance L.P. All rights reserved.
583// Property of Bloomberg Finance L.P. (BFLP)
584// This software is made available solely pursuant to the
585// terms of a BFLP license agreement which governs its use.
586// ------------------------------- END-OF-FILE --------------------------------
587
588/** @} */
589/** @} */
590/** @} */
Definition balxml_decoderoptions.h:72
int manipulateAttributes(t_MANIPULATOR &manipulator)
Definition balxml_decoderoptions.h:331
int accessAttributes(t_ACCESSOR &accessor) const
Definition balxml_decoderoptions.h:438
DecoderOptions & operator=(const DecoderOptions &rhs)
Assign to this object the value of the specified rhs object.
void setMaxDepth(int value)
Definition balxml_decoderoptions.h:407
static const bdlat_AttributeInfo ATTRIBUTE_INFO_ARRAY[]
Definition balxml_decoderoptions.h:126
static const bool DEFAULT_INITIALIZER_VALIDATE_ROOT_TAG
Definition balxml_decoderoptions.h:124
int formattingMode() const
Return the value of the "FormattingMode" attribute of this object.
Definition balxml_decoderoptions.h:520
int manipulateAttribute(t_MANIPULATOR &manipulator, int id)
Definition balxml_decoderoptions.h:364
static const char CLASS_NAME[]
Definition balxml_decoderoptions.h:114
void setValidateRootTag(bool value)
Definition balxml_decoderoptions.h:431
@ NUM_ATTRIBUTES
Definition balxml_decoderoptions.h:102
bsl::ostream & print(bsl::ostream &stream, int level=0, int spacesPerLevel=4) const
void setValidateInputIsUtf8(bool value)
Definition balxml_decoderoptions.h:425
~DecoderOptions()
Destroy this object.
static const bool DEFAULT_INITIALIZER_SKIP_UNKNOWN_ELEMENTS
Definition balxml_decoderoptions.h:120
static const bdlat_AttributeInfo * lookupAttributeInfo(int id)
void setSkipUnknownElements(bool value)
Definition balxml_decoderoptions.h:419
static const int DEFAULT_INITIALIZER_FORMATTING_MODE
Definition balxml_decoderoptions.h:118
DecoderOptions(const DecoderOptions &original)
int accessAttribute(t_ACCESSOR &accessor, int id) const
Definition balxml_decoderoptions.h:471
static const bdlat_AttributeInfo * lookupAttributeInfo(const char *name, int nameLength)
static const bool DEFAULT_INITIALIZER_VALIDATE_INPUT_IS_UTF8
Definition balxml_decoderoptions.h:122
void setFormattingMode(int value)
Definition balxml_decoderoptions.h:413
int maxDepth() const
Return the value of the "MaxDepth" attribute of this object.
Definition balxml_decoderoptions.h:514
@ ATTRIBUTE_ID_VALIDATE_INPUT_IS_UTF8
Definition balxml_decoderoptions.h:97
@ ATTRIBUTE_ID_MAX_DEPTH
Definition balxml_decoderoptions.h:94
@ ATTRIBUTE_ID_VALIDATE_ROOT_TAG
Definition balxml_decoderoptions.h:98
@ ATTRIBUTE_ID_SKIP_UNKNOWN_ELEMENTS
Definition balxml_decoderoptions.h:96
@ ATTRIBUTE_ID_FORMATTING_MODE
Definition balxml_decoderoptions.h:95
DecoderOptions()
Create an object of type DecoderOptions having the default value.
bool validateRootTag() const
Return the value of the "ValidateRootTag" attribute of this object.
Definition balxml_decoderoptions.h:538
bool validateInputIsUtf8() const
Definition balxml_decoderoptions.h:532
static const int DEFAULT_INITIALIZER_MAX_DEPTH
Definition balxml_decoderoptions.h:116
bool skipUnknownElements() const
Definition balxml_decoderoptions.h:526
@ ATTRIBUTE_INDEX_VALIDATE_ROOT_TAG
Definition balxml_decoderoptions.h:110
@ ATTRIBUTE_INDEX_VALIDATE_INPUT_IS_UTF8
Definition balxml_decoderoptions.h:109
@ ATTRIBUTE_INDEX_FORMATTING_MODE
Definition balxml_decoderoptions.h:107
@ ATTRIBUTE_INDEX_MAX_DEPTH
Definition balxml_decoderoptions.h:106
@ ATTRIBUTE_INDEX_SKIP_UNKNOWN_ELEMENTS
Definition balxml_decoderoptions.h:108
#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 balxml_base64parser.h:150
bsl::ostream & operator<<(bsl::ostream &stream, const ConfigSchema &schema)
bool operator==(const DecoderOptions &lhs, const DecoderOptions &rhs)
bool operator!=(const DecoderOptions &lhs, const DecoderOptions &rhs)
ALLOCATOR const STRING_VIEW_LIKE_TYPE & rhs
Definition bslstl_string.h:3918
ALLOCATOR & lhs
Definition bslstl_string.h:3917
Definition bdlat_attributeinfo.h:139
int d_id
Definition bdlat_attributeinfo.h:142