BDE 4.14.0 Production release
Loading...
Searching...
No Matches
s_baltst_rawdataswitched.h
Go to the documentation of this file.
1/// @file s_baltst_rawdataswitched.h
2///
3/// The content of this file has been pre-processed for Doxygen.
4///
5
6
7// s_baltst_rawdataswitched.h *DO NOT EDIT* @generated -*-C++-*-
8#ifndef INCLUDED_S_BALTST_RAWDATASWITCHED
9#define INCLUDED_S_BALTST_RAWDATASWITCHED
10
11#include <bsls_ident.h>
12BSLS_IDENT_RCSID(s_baltst_rawdataswitched_h, "$Id$ $CSID$")
14
15/// @defgroup s_baltst_rawdataswitched s_baltst_rawdataswitched
16/// @brief Provide value-semantic attribute classes
17/// @addtogroup Standalones
18/// @{
19/// @addtogroup s_baltst
20/// @{
21/// @addtogroup s_baltst_rawdataswitched
22/// @{
23///
24/// <h1> Outline </h1>
25/// * <a href="#s_baltst_rawdataswitched-purpose"> Purpose</a>
26///
27/// # Purpose {#s_baltst_rawdataswitched-purpose}
28/// Provide value-semantic attribute classes
29/// @}
30/** @} */
31/** @} */
32
33/** @addtogroup Standalones
34 * @{
35 */
36/** @addtogroup s_baltst
37 * @{
38 */
39/** @addtogroup s_baltst_rawdataswitched
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 <bslma_default.h>
54
55#include <bsls_assert.h>
56
57#include <bsl_vector.h>
58
59#include <bsl_iosfwd.h>
60#include <bsl_limits.h>
61
62
63
64namespace bslma { class Allocator; }
65
66namespace s_baltst { class RawDataSwitched; }
67namespace s_baltst {
68
69 // =====================
70 // class RawDataSwitched
71 // =====================
72
74
75 // INSTANCE DATA
77 bsl::vector<char> d_charvec;
78
79 public:
80 // TYPES
81 enum {
84 };
85
86 enum {
88 };
89
90 enum {
93 };
94
95 // CONSTANTS
96 static const char CLASS_NAME[];
97
99
100 public:
101 // CLASS METHODS
102
103 /// Return attribute information for the attribute indicated by the
104 /// specified `id` if the attribute exists, and 0 otherwise.
106
107 /// Return attribute information for the attribute indicated by the
108 /// specified `name` of the specified `nameLength` if the attribute
109 /// exists, and 0 otherwise.
111 const char *name,
112 int nameLength);
113
114 // CREATORS
115
116 /// Create an object of type `RawDataSwitched` having the default value.
117 /// Use the optionally specified `basicAllocator` to supply memory. If
118 /// `basicAllocator` is 0, the currently installed default allocator is
119 /// used.
120 explicit RawDataSwitched(bslma::Allocator *basicAllocator = 0);
121
122 /// Create an object of type `RawDataSwitched` having the value of the
123 /// specified `original` object. Use the optionally specified
124 /// `basicAllocator` to supply memory. If `basicAllocator` is 0, the
125 /// currently installed default allocator is used.
127 bslma::Allocator *basicAllocator = 0);
128
129#if defined(BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES) \
130 && defined(BSLS_COMPILERFEATURES_SUPPORT_NOEXCEPT)
131 /// Create an object of type `RawDataSwitched` having the value of the
132 /// specified `original` object. After performing this action, the
133 /// `original` object will be left in a valid, but unspecified state.
134 RawDataSwitched(RawDataSwitched&& original) noexcept;
135
136 /// Create an object of type `RawDataSwitched` having the value of the
137 /// specified `original` object. After performing this action, the
138 /// `original` object will be left in a valid, but unspecified state.
139 /// Use the optionally specified `basicAllocator` to supply memory. If
140 /// `basicAllocator` is 0, the currently installed default allocator is
141 /// used.
143 bslma::Allocator *basicAllocator);
144#endif
145
146 /// Destroy this object.
148
149 // MANIPULATORS
150
151 /// Assign to this object the value of the specified `rhs` object.
153
154#if defined(BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES) \
155 && defined(BSLS_COMPILERFEATURES_SUPPORT_NOEXCEPT)
156 /// Assign to this object the value of the specified `rhs` object.
157 /// After performing this action, the `rhs` object will be left in a
158 /// valid, but unspecified state.
160#endif
161
162 /// Reset this object to the default value (i.e., its value upon
163 /// default construction).
164 void reset();
165
166 /// Invoke the specified `manipulator` sequentially on the address of
167 /// each (modifiable) attribute of this object, supplying `manipulator`
168 /// with the corresponding attribute information structure until such
169 /// invocation returns a non-zero value. Return the value from the
170 /// last invocation of `manipulator` (i.e., the invocation that
171 /// terminated the sequence).
172 template<class MANIPULATOR>
173 int manipulateAttributes(MANIPULATOR& manipulator);
174
175 /// Invoke the specified `manipulator` on the address of
176 /// the (modifiable) attribute indicated by the specified `id`,
177 /// supplying `manipulator` with the corresponding attribute
178 /// information structure. Return the value returned from the
179 /// invocation of `manipulator` if `id` identifies an attribute of this
180 /// class, and -1 otherwise.
181 template<class MANIPULATOR>
182 int manipulateAttribute(MANIPULATOR& manipulator, int id);
183
184 /// Invoke the specified `manipulator` on the address of
185 /// the (modifiable) attribute indicated by the specified `name` of the
186 /// specified `nameLength`, supplying `manipulator` with the
187 /// corresponding attribute information structure. Return the value
188 /// returned from the invocation of `manipulator` if `name` identifies
189 /// an attribute of this class, and -1 otherwise.
190 template<class MANIPULATOR>
191 int manipulateAttribute(MANIPULATOR& manipulator,
192 const char *name,
193 int nameLength);
194
195 /// Return a reference to the modifiable "Charvec" attribute of this
196 /// object.
198
199 /// Return a reference to the modifiable "Ucharvec" attribute of this
200 /// object.
202
203 // ACCESSORS
204
205 /// Format this object to the specified output `stream` at the
206 /// optionally specified indentation `level` and return a reference to
207 /// the modifiable `stream`. If `level` is specified, optionally
208 /// specify `spacesPerLevel`, the number of spaces per indentation level
209 /// for this and all of its nested objects. Each line is indented by
210 /// the absolute value of `level * spacesPerLevel`. If `level` is
211 /// negative, suppress indentation of the first line. If
212 /// `spacesPerLevel` is negative, suppress line breaks and format the
213 /// entire output on one line. If `stream` is initially invalid, this
214 /// operation has no effect. Note that a trailing newline is provided
215 /// in multiline mode only.
216 bsl::ostream& print(bsl::ostream& stream,
217 int level = 0,
218 int spacesPerLevel = 4) const;
219
220 /// Invoke the specified `accessor` sequentially on each
221 /// (non-modifiable) attribute of this object, supplying `accessor`
222 /// with the corresponding attribute information structure until such
223 /// invocation returns a non-zero value. Return the value from the
224 /// last invocation of `accessor` (i.e., the invocation that terminated
225 /// the sequence).
226 template<class ACCESSOR>
227 int accessAttributes(ACCESSOR& accessor) const;
228
229 /// Invoke the specified `accessor` on the (non-modifiable) attribute
230 /// of this object indicated by the specified `id`, supplying `accessor`
231 /// with the corresponding attribute information structure. Return the
232 /// value returned from the invocation of `accessor` if `id` identifies
233 /// an attribute of this class, and -1 otherwise.
234 template<class ACCESSOR>
235 int accessAttribute(ACCESSOR& accessor, int id) const;
236
237 /// Invoke the specified `accessor` on the (non-modifiable) attribute
238 /// of this object indicated by the specified `name` of the specified
239 /// `nameLength`, supplying `accessor` with the corresponding attribute
240 /// information structure. Return the value returned from the
241 /// invocation of `accessor` if `name` identifies an attribute of this
242 /// class, and -1 otherwise.
243 template<class ACCESSOR>
244 int accessAttribute(ACCESSOR& accessor,
245 const char *name,
246 int nameLength) const;
247
248 /// Return a reference offering non-modifiable access to the "Charvec"
249 /// attribute of this object.
250 const bsl::vector<char>& charvec() const;
251
252 /// Return a reference offering non-modifiable access to the "Ucharvec"
253 /// attribute of this object.
255};
256
257// FREE OPERATORS
258
259/// Return `true` if the specified `lhs` and `rhs` attribute objects have
260/// the same value, and `false` otherwise. Two attribute objects have the
261/// same value if each respective attribute has the same value.
262inline
263bool operator==(const RawDataSwitched& lhs, const RawDataSwitched& rhs);
264
265/// Return `true` if the specified `lhs` and `rhs` attribute objects do not
266/// have the same value, and `false` otherwise. Two attribute objects do
267/// not have the same value if one or more respective attributes differ in
268/// values.
269inline
270bool operator!=(const RawDataSwitched& lhs, const RawDataSwitched& rhs);
271
272/// Format the specified `rhs` to the specified output `stream` and
273/// return a reference to the modifiable `stream`.
274inline
275bsl::ostream& operator<<(bsl::ostream& stream, const RawDataSwitched& rhs);
276
277} // close package namespace
278
279// TRAITS
280
282
283// ============================================================================
284// INLINE FUNCTION DEFINITIONS
285// ============================================================================
286
287namespace s_baltst {
288
289 // ---------------------
290 // class RawDataSwitched
291 // ---------------------
292
293// CLASS METHODS
294// MANIPULATORS
295template <class MANIPULATOR>
296int RawDataSwitched::manipulateAttributes(MANIPULATOR& manipulator)
297{
298 int ret;
299
300 ret = manipulator(&d_charvec, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_CHARVEC]);
301 if (ret) {
302 return ret;
303 }
304
305 ret = manipulator(&d_ucharvec, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_UCHARVEC]);
306 if (ret) {
307 return ret;
308 }
309
310 return 0;
311}
312
313template <class MANIPULATOR>
314int RawDataSwitched::manipulateAttribute(MANIPULATOR& manipulator, int id)
315{
316 enum { NOT_FOUND = -1 };
317
318 switch (id) {
320 return manipulator(&d_charvec, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_CHARVEC]);
321 }
323 return manipulator(&d_ucharvec, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_UCHARVEC]);
324 }
325 default:
326 return NOT_FOUND;
327 }
328}
329
330template <class MANIPULATOR>
332 MANIPULATOR& manipulator,
333 const char *name,
334 int nameLength)
335{
336 enum { NOT_FOUND = -1 };
337
338 const bdlat_AttributeInfo *attributeInfo =
339 lookupAttributeInfo(name, nameLength);
340 if (0 == attributeInfo) {
341 return NOT_FOUND;
342 }
343
344 return manipulateAttribute(manipulator, attributeInfo->d_id);
345}
346
347inline
349{
350 return d_charvec;
351}
352
353inline
355{
356 return d_ucharvec;
357}
358
359// ACCESSORS
360template <class ACCESSOR>
361int RawDataSwitched::accessAttributes(ACCESSOR& accessor) const
362{
363 int ret;
364
365 ret = accessor(d_charvec, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_CHARVEC]);
366 if (ret) {
367 return ret;
368 }
369
370 ret = accessor(d_ucharvec, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_UCHARVEC]);
371 if (ret) {
372 return ret;
373 }
374
375 return 0;
376}
377
378template <class ACCESSOR>
379int RawDataSwitched::accessAttribute(ACCESSOR& accessor, int id) const
380{
381 enum { NOT_FOUND = -1 };
382
383 switch (id) {
385 return accessor(d_charvec, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_CHARVEC]);
386 }
388 return accessor(d_ucharvec, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_UCHARVEC]);
389 }
390 default:
391 return NOT_FOUND;
392 }
393}
394
395template <class ACCESSOR>
397 ACCESSOR& accessor,
398 const char *name,
399 int nameLength) const
400{
401 enum { NOT_FOUND = -1 };
402
403 const bdlat_AttributeInfo *attributeInfo =
404 lookupAttributeInfo(name, nameLength);
405 if (0 == attributeInfo) {
406 return NOT_FOUND;
407 }
408
409 return accessAttribute(accessor, attributeInfo->d_id);
410}
411
412inline
414{
415 return d_charvec;
416}
417
418inline
420{
421 return d_ucharvec;
422}
423
424} // close package namespace
425
426// FREE FUNCTIONS
427
428inline
430 const s_baltst::RawDataSwitched& lhs,
431 const s_baltst::RawDataSwitched& rhs)
432{
433 return lhs.charvec() == rhs.charvec()
434 && lhs.ucharvec() == rhs.ucharvec();
435}
436
437inline
439 const s_baltst::RawDataSwitched& lhs,
440 const s_baltst::RawDataSwitched& rhs)
441{
442 return !(lhs == rhs);
443}
444
445inline
446bsl::ostream& s_baltst::operator<<(
447 bsl::ostream& stream,
448 const s_baltst::RawDataSwitched& rhs)
449{
450 return rhs.print(stream, 0, -1);
451}
452
453
454#endif
455
456// GENERATED BY @BLP_BAS_CODEGEN_VERSION@
457// USING bas_codegen.pl s_baltst_rawdataswitched.xsd --mode msg --includedir . --msgComponent rawdataswitched --noRecurse --noExternalization --noHashSupport --noAggregateConversion
458// ----------------------------------------------------------------------------
459// NOTICE:
460// Copyright 2022 Bloomberg Finance L.P. All rights reserved.
461// Property of Bloomberg Finance L.P. (BFLP)
462// This software is made available solely pursuant to the
463// terms of a BFLP license agreement which governs its use.
464// ------------------------------- END-OF-FILE --------------------------------
465
466/** @} */
467/** @} */
468/** @} */
Definition bslstl_vector.h:1025
Definition bslma_allocator.h:457
Definition s_baltst_rawdataswitched.h:73
@ NUM_ATTRIBUTES
Definition s_baltst_rawdataswitched.h:87
static const bdlat_AttributeInfo ATTRIBUTE_INFO_ARRAY[]
Definition s_baltst_rawdataswitched.h:98
static const bdlat_AttributeInfo * lookupAttributeInfo(int id)
static const bdlat_AttributeInfo * lookupAttributeInfo(const char *name, int nameLength)
int manipulateAttribute(MANIPULATOR &manipulator, int id)
Definition s_baltst_rawdataswitched.h:314
RawDataSwitched & operator=(const RawDataSwitched &rhs)
Assign to this object the value of the specified rhs object.
int accessAttribute(ACCESSOR &accessor, int id) const
Definition s_baltst_rawdataswitched.h:379
@ ATTRIBUTE_ID_UCHARVEC
Definition s_baltst_rawdataswitched.h:83
@ ATTRIBUTE_ID_CHARVEC
Definition s_baltst_rawdataswitched.h:82
bsl::ostream & print(bsl::ostream &stream, int level=0, int spacesPerLevel=4) const
bsl::vector< unsigned char > & ucharvec()
Definition s_baltst_rawdataswitched.h:354
RawDataSwitched(bslma::Allocator *basicAllocator=0)
RawDataSwitched(const RawDataSwitched &original, bslma::Allocator *basicAllocator=0)
~RawDataSwitched()
Destroy this object.
int manipulateAttributes(MANIPULATOR &manipulator)
Definition s_baltst_rawdataswitched.h:296
bsl::vector< char > & charvec()
Definition s_baltst_rawdataswitched.h:348
int accessAttributes(ACCESSOR &accessor) const
Definition s_baltst_rawdataswitched.h:361
@ ATTRIBUTE_INDEX_UCHARVEC
Definition s_baltst_rawdataswitched.h:92
@ ATTRIBUTE_INDEX_CHARVEC
Definition s_baltst_rawdataswitched.h:91
static const char CLASS_NAME[]
Definition s_baltst_rawdataswitched.h:96
#define BDLAT_DECL_SEQUENCE_WITH_ALLOCATOR_BITWISEMOVEABLE_TRAITS(ClassName)
Definition bdlat_typetraits.h:282
#define BSLS_IDENT_RCSID(tag, str)
Definition bsls_ident.h:260
#define BSLS_IDENT_PRAGMA_ONCE
Definition bsls_ident.h:310
Definition balxml_encoderoptions.h:68
Definition s_baltst_address.h:66
bool operator!=(const Address &lhs, const Address &rhs)
bool operator==(const Address &lhs, const Address &rhs)
bsl::ostream & operator<<(bsl::ostream &stream, const Address &rhs)
Definition bdlat_attributeinfo.h:137
int d_id
Definition bdlat_attributeinfo.h:140