BDE 4.14.0 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
239 /// operation has no effect. Note that a trailing newline is provided
240 /// in multiline mode only.
241 bsl::ostream& print(bsl::ostream& stream,
242 int level = 0,
243 int spacesPerLevel = 4) const;
244
245 /// Invoke the specified `accessor` sequentially on each
246 /// (non-modifiable) attribute of this object, supplying `accessor`
247 /// with the corresponding attribute information structure until such
248 /// invocation returns a non-zero value. Return the value from the
249 /// last invocation of `accessor` (i.e., the invocation that terminated
250 /// the sequence).
251 template <typename t_ACCESSOR>
252 int accessAttributes(t_ACCESSOR& accessor) const;
253
254 /// Invoke the specified `accessor` on the (non-modifiable) attribute
255 /// of this object indicated by the specified `id`, supplying `accessor`
256 /// with the corresponding attribute information structure. Return the
257 /// value returned from the invocation of `accessor` if `id` identifies
258 /// an attribute of this class, and -1 otherwise.
259 template <typename t_ACCESSOR>
260 int accessAttribute(t_ACCESSOR& accessor, int id) const;
261
262 /// Invoke the specified `accessor` on the (non-modifiable) attribute
263 /// of this object indicated by the specified `name` of the specified
264 /// `nameLength`, supplying `accessor` with the corresponding attribute
265 /// information structure. Return the value returned from the
266 /// invocation of `accessor` if `name` identifies an attribute of this
267 /// class, and -1 otherwise.
268 template <typename t_ACCESSOR>
269 int accessAttribute(t_ACCESSOR& accessor,
270 const char *name,
271 int nameLength) const;
272
273 /// Return the value of the "MaxDepth" attribute of this object.
274 int maxDepth() const;
275
276 /// Return the value of the "FormattingMode" attribute of this object.
277 int formattingMode() const;
278
279 /// Return the value of the "SkipUnknownElements" attribute of this
280 /// object.
281 bool skipUnknownElements() const;
282
283 /// Return the value of the "ValidateInputIsUtf8" attribute of this
284 /// object.
285 bool validateInputIsUtf8() const;
286
287 /// Return the value of the "ValidateRootTag" attribute of this object.
288 bool validateRootTag() const;
289};
290
291// FREE OPERATORS
292
293/// Return `true` if the specified `lhs` and `rhs` attribute objects have
294/// the same value, and `false` otherwise. Two attribute objects have the
295/// same value if each respective attribute has the same value.
296inline
297bool operator==(const DecoderOptions& lhs, const DecoderOptions& rhs);
298
299/// Return `true` if the specified `lhs` and `rhs` attribute objects do not
300/// have the same value, and `false` otherwise. Two attribute objects do
301/// not have the same value if one or more respective attributes differ in
302/// values.
303inline
304bool operator!=(const DecoderOptions& lhs, const DecoderOptions& rhs);
305
306/// Format the specified `rhs` to the specified output `stream` and
307/// return a reference to the modifiable `stream`.
308inline
309bsl::ostream& operator<<(bsl::ostream& stream, const DecoderOptions& rhs);
310
311} // close package namespace
312
313// TRAITS
314
316
317// ============================================================================
318// INLINE FUNCTION DEFINITIONS
319// ============================================================================
320
321namespace balxml {
322
323 // --------------------
324 // class DecoderOptions
325 // --------------------
326
327// CLASS METHODS
328// MANIPULATORS
329template <typename t_MANIPULATOR>
330int DecoderOptions::manipulateAttributes(t_MANIPULATOR& manipulator)
331{
332 int ret;
333
334 ret = manipulator(&d_maxDepth, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_MAX_DEPTH]);
335 if (ret) {
336 return ret;
337 }
338
339 ret = manipulator(&d_formattingMode, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_FORMATTING_MODE]);
340 if (ret) {
341 return ret;
342 }
343
344 ret = manipulator(&d_skipUnknownElements, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_SKIP_UNKNOWN_ELEMENTS]);
345 if (ret) {
346 return ret;
347 }
348
349 ret = manipulator(&d_validateInputIsUtf8, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_VALIDATE_INPUT_IS_UTF8]);
350 if (ret) {
351 return ret;
352 }
353
354 ret = manipulator(&d_validateRootTag, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_VALIDATE_ROOT_TAG]);
355 if (ret) {
356 return ret;
357 }
358
359 return 0;
360}
361
362template <typename t_MANIPULATOR>
363int DecoderOptions::manipulateAttribute(t_MANIPULATOR& manipulator, int id)
364{
365 enum { NOT_FOUND = -1 };
366
367 switch (id) {
369 return manipulator(&d_maxDepth, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_MAX_DEPTH]);
370 }
372 return manipulator(&d_formattingMode, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_FORMATTING_MODE]);
373 }
375 return manipulator(&d_skipUnknownElements, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_SKIP_UNKNOWN_ELEMENTS]);
376 }
378 return manipulator(&d_validateInputIsUtf8, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_VALIDATE_INPUT_IS_UTF8]);
379 }
381 return manipulator(&d_validateRootTag, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_VALIDATE_ROOT_TAG]);
382 }
383 default:
384 return NOT_FOUND;
385 }
386}
387
388template <typename t_MANIPULATOR>
390 t_MANIPULATOR& manipulator,
391 const char *name,
392 int nameLength)
393{
394 enum { NOT_FOUND = -1 };
395
396 const bdlat_AttributeInfo *attributeInfo =
397 lookupAttributeInfo(name, nameLength);
398 if (0 == attributeInfo) {
399 return NOT_FOUND;
400 }
401
402 return manipulateAttribute(manipulator, attributeInfo->d_id);
403}
404
405inline
407{
408 d_maxDepth = value;
409}
410
411inline
413{
414 d_formattingMode = value;
415}
416
417inline
419{
420 d_skipUnknownElements = value;
421}
422
423inline
425{
426 d_validateInputIsUtf8 = value;
427}
428
429inline
431{
432 d_validateRootTag = value;
433}
434
435// ACCESSORS
436template <typename t_ACCESSOR>
437int DecoderOptions::accessAttributes(t_ACCESSOR& accessor) const
438{
439 int ret;
440
441 ret = accessor(d_maxDepth, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_MAX_DEPTH]);
442 if (ret) {
443 return ret;
444 }
445
446 ret = accessor(d_formattingMode, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_FORMATTING_MODE]);
447 if (ret) {
448 return ret;
449 }
450
451 ret = accessor(d_skipUnknownElements, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_SKIP_UNKNOWN_ELEMENTS]);
452 if (ret) {
453 return ret;
454 }
455
456 ret = accessor(d_validateInputIsUtf8, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_VALIDATE_INPUT_IS_UTF8]);
457 if (ret) {
458 return ret;
459 }
460
461 ret = accessor(d_validateRootTag, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_VALIDATE_ROOT_TAG]);
462 if (ret) {
463 return ret;
464 }
465
466 return 0;
467}
468
469template <typename t_ACCESSOR>
470int DecoderOptions::accessAttribute(t_ACCESSOR& accessor, int id) const
471{
472 enum { NOT_FOUND = -1 };
473
474 switch (id) {
476 return accessor(d_maxDepth, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_MAX_DEPTH]);
477 }
479 return accessor(d_formattingMode, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_FORMATTING_MODE]);
480 }
482 return accessor(d_skipUnknownElements, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_SKIP_UNKNOWN_ELEMENTS]);
483 }
485 return accessor(d_validateInputIsUtf8, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_VALIDATE_INPUT_IS_UTF8]);
486 }
488 return accessor(d_validateRootTag, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_VALIDATE_ROOT_TAG]);
489 }
490 default:
491 return NOT_FOUND;
492 }
493}
494
495template <typename t_ACCESSOR>
497 t_ACCESSOR& accessor,
498 const char *name,
499 int nameLength) const
500{
501 enum { NOT_FOUND = -1 };
502
503 const bdlat_AttributeInfo *attributeInfo =
504 lookupAttributeInfo(name, nameLength);
505 if (0 == attributeInfo) {
506 return NOT_FOUND;
507 }
508
509 return accessAttribute(accessor, attributeInfo->d_id);
510}
511
512inline
514{
515 return d_maxDepth;
516}
517
518inline
520{
521 return d_formattingMode;
522}
523
524inline
526{
527 return d_skipUnknownElements;
528}
529
530inline
532{
533 return d_validateInputIsUtf8;
534}
535
536inline
538{
539 return d_validateRootTag;
540}
541
542} // close package namespace
543
544// FREE FUNCTIONS
545
546inline
548 const balxml::DecoderOptions& lhs,
549 const balxml::DecoderOptions& rhs)
550{
551 return lhs.maxDepth() == rhs.maxDepth()
552 && lhs.formattingMode() == rhs.formattingMode()
555 && lhs.validateRootTag() == rhs.validateRootTag();
556}
557
558inline
560 const balxml::DecoderOptions& lhs,
561 const balxml::DecoderOptions& rhs)
562{
563 return !(lhs == rhs);
564}
565
566inline
567bsl::ostream& balxml::operator<<(
568 bsl::ostream& stream,
569 const balxml::DecoderOptions& rhs)
570{
571 return rhs.print(stream, 0, -1);
572}
573
574
575#endif
576
577// GENERATED BY @BLP_BAS_CODEGEN_VERSION@
578// USING bas_codegen.pl -m msg -p balxml -E --noExternalization --noAggregateConversion --noHashSupport balxml.xsd
579// ----------------------------------------------------------------------------
580// NOTICE:
581// Copyright 2023 Bloomberg Finance L.P. All rights reserved.
582// Property of Bloomberg Finance L.P. (BFLP)
583// This software is made available solely pursuant to the
584// terms of a BFLP license agreement which governs its use.
585// ------------------------------- END-OF-FILE --------------------------------
586
587/** @} */
588/** @} */
589/** @} */
Definition balxml_decoderoptions.h:72
int manipulateAttributes(t_MANIPULATOR &manipulator)
Definition balxml_decoderoptions.h:330
int accessAttributes(t_ACCESSOR &accessor) const
Definition balxml_decoderoptions.h:437
DecoderOptions & operator=(const DecoderOptions &rhs)
Assign to this object the value of the specified rhs object.
void setMaxDepth(int value)
Definition balxml_decoderoptions.h:406
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:519
int manipulateAttribute(t_MANIPULATOR &manipulator, int id)
Definition balxml_decoderoptions.h:363
static const char CLASS_NAME[]
Definition balxml_decoderoptions.h:114
void setValidateRootTag(bool value)
Definition balxml_decoderoptions.h:430
@ 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:424
~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:418
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:470
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:412
int maxDepth() const
Return the value of the "MaxDepth" attribute of this object.
Definition balxml_decoderoptions.h:513
@ 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:537
bool validateInputIsUtf8() const
Definition balxml_decoderoptions.h:531
static const int DEFAULT_INITIALIZER_MAX_DEPTH
Definition balxml_decoderoptions.h:116
bool skipUnknownElements() const
Definition balxml_decoderoptions.h:525
@ 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:275
#define BSLS_IDENT_RCSID(tag, str)
Definition bsls_ident.h:260
#define BSLS_IDENT_PRAGMA_ONCE
Definition bsls_ident.h:310
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)
Definition bdlat_attributeinfo.h:137
int d_id
Definition bdlat_attributeinfo.h:140