BDE 4.39.x Production Release
Loading...
Searching...
No Matches
s_baltst_rawdata.h
Go to the documentation of this file.
1/// @file s_baltst_rawdata.h
2///
3/// The content of this file has been pre-processed for Doxygen.
4///
5
6
7// s_baltst_rawdata.h *DO NOT EDIT* @generated -*-C++-*-
8#ifndef INCLUDED_S_BALTST_RAWDATA
9#define INCLUDED_S_BALTST_RAWDATA
10
11#include <bsls_ident.h>
12BSLS_IDENT_RCSID(s_baltst_rawdata_h, "$Id$ $CSID$")
14
15/// @defgroup s_baltst_rawdata s_baltst_rawdata
16/// @brief Provide value-semantic attribute classes
17/// @addtogroup Standalones
18/// @{
19/// @addtogroup s_baltst
20/// @{
21/// @addtogroup s_baltst_rawdata
22/// @{
23///
24/// <h1> Outline </h1>
25/// * <a href="#s_baltst_rawdata-purpose"> Purpose</a>
26///
27/// # Purpose {#s_baltst_rawdata-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_rawdata
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 RawData; }
67namespace s_baltst {
68
69 // =============
70 // class RawData
71 // =============
72
73class RawData {
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 `RawData` having the default value. Use
117 /// the optionally specified `basicAllocator` to supply memory. If
118 /// `basicAllocator` is 0, the currently installed default allocator is
119 /// used.
120 explicit RawData(bslma::Allocator *basicAllocator = 0);
121
122 /// Create an object of type `RawData` having the value of the specified
123 /// `original` object. Use the optionally specified `basicAllocator` to
124 /// supply memory. If `basicAllocator` is 0, the currently installed
125 /// default allocator is used.
126 RawData(const RawData& original,
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 `RawData` having the value of the specified
132 /// `original` object. After performing this action, the `original`
133 /// object will be left in a valid, but unspecified state.
134 RawData(RawData&& original) noexcept;
135
136 /// Create an object of type `RawData` having the value of the specified
137 /// `original` object. After performing this action, the `original`
138 /// object will be left in a valid, but unspecified state. Use the
139 /// optionally specified `basicAllocator` to supply memory. If
140 /// `basicAllocator` is 0, the currently installed default allocator is
141 /// used.
142 RawData(RawData&& original,
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.
159 RawData& operator=(RawData&& rhs);
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 <typename t_MANIPULATOR>
173 int manipulateAttributes(t_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 <typename t_MANIPULATOR>
182 int manipulateAttribute(t_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 <typename t_MANIPULATOR>
191 int manipulateAttribute(t_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 operation has no effect.
214 ///
215 /// \note Note that a trailing newline is provided
216 /// in multiline mode only.
217 bsl::ostream& print(bsl::ostream& stream,
218 int level = 0,
219 int spacesPerLevel = 4) const;
220
221 /// Invoke the specified `accessor` sequentially on each
222 /// (non-modifiable) attribute of this object, supplying `accessor`
223 /// with the corresponding attribute information structure until such
224 /// invocation returns a non-zero value. Return the value from the
225 /// last invocation of `accessor` (i.e., the invocation that terminated
226 /// the sequence).
227 template <typename t_ACCESSOR>
228 int accessAttributes(t_ACCESSOR& accessor) const;
229
230 /// Invoke the specified `accessor` on the (non-modifiable) attribute
231 /// of this object indicated by the specified `id`, supplying `accessor`
232 /// with the corresponding attribute information structure. Return the
233 /// value returned from the invocation of `accessor` if `id` identifies
234 /// an attribute of this class, and -1 otherwise.
235 template <typename t_ACCESSOR>
236 int accessAttribute(t_ACCESSOR& accessor, int id) const;
237
238 /// Invoke the specified `accessor` on the (non-modifiable) attribute
239 /// of this object indicated by the specified `name` of the specified
240 /// `nameLength`, supplying `accessor` with the corresponding attribute
241 /// information structure. Return the value returned from the
242 /// invocation of `accessor` if `name` identifies an attribute of this
243 /// class, and -1 otherwise.
244 template <typename t_ACCESSOR>
245 int accessAttribute(t_ACCESSOR& accessor,
246 const char *name,
247 int nameLength) const;
248
249 /// Return a reference offering non-modifiable access to the "Charvec"
250 /// attribute of this object.
251 const bsl::vector<char>& charvec() const;
252
253 /// Return a reference offering non-modifiable access to the "Ucharvec"
254 /// attribute of this object.
256
257 // HIDDEN FRIENDS
258
259 /// Return `true` if the specified `lhs` and `rhs` attribute objects
260 /// have the same value, and `false` otherwise. Two attribute objects
261 /// have the same value if each respective attribute has the same value.
262 friend bool operator==(const RawData& lhs, const RawData& rhs)
263 {
264 return lhs.charvec() == rhs.charvec() &&
265 lhs.ucharvec() == rhs.ucharvec();
266 }
267
268 /// Returns `!(lhs == rhs)`
269 friend bool operator!=(const RawData& lhs, const RawData& rhs)
270 {
271 return !(lhs == rhs);
272 }
273
274 /// Format the specified `rhs` to the specified output `stream` and
275 /// return a reference to the modifiable `stream`.
276 friend bsl::ostream& operator<<(bsl::ostream& stream, const RawData& rhs)
277 {
278 return rhs.print(stream, 0, -1);
279 }
280};
281
282} // close package namespace
283
284// TRAITS
285
287template <>
289
290// ============================================================================
291// INLINE DEFINITIONS
292// ============================================================================
293
294namespace s_baltst {
295
296 // -------------
297 // class RawData
298 // -------------
299
300// CLASS METHODS
301// MANIPULATORS
302template <typename t_MANIPULATOR>
303int RawData::manipulateAttributes(t_MANIPULATOR& manipulator)
304{
305 int ret;
306
307 ret = manipulator(&d_charvec, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_CHARVEC]);
308 if (ret) {
309 return ret;
310 }
311
312 ret = manipulator(&d_ucharvec, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_UCHARVEC]);
313 if (ret) {
314 return ret;
315 }
316
317 return 0;
318}
319
320template <typename t_MANIPULATOR>
321int RawData::manipulateAttribute(t_MANIPULATOR& manipulator, int id)
322{
323 enum { NOT_FOUND = -1 };
324
325 switch (id) {
327 return manipulator(&d_charvec, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_CHARVEC]);
328 }
330 return manipulator(&d_ucharvec, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_UCHARVEC]);
331 }
332 default:
333 return NOT_FOUND;
334 }
335}
336
337template <typename t_MANIPULATOR>
339 t_MANIPULATOR& manipulator,
340 const char *name,
341 int nameLength)
342{
343 enum { NOT_FOUND = -1 };
344
345 const bdlat_AttributeInfo *attributeInfo =
346 lookupAttributeInfo(name, nameLength);
347 if (0 == attributeInfo) {
348 return NOT_FOUND;
349 }
350
351 return manipulateAttribute(manipulator, attributeInfo->d_id);
352}
353
354inline
356{
357 return d_charvec;
358}
359
360inline
362{
363 return d_ucharvec;
364}
365
366// ACCESSORS
367template <typename t_ACCESSOR>
368int RawData::accessAttributes(t_ACCESSOR& accessor) const
369{
370 int ret;
371
372 ret = accessor(d_charvec, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_CHARVEC]);
373 if (ret) {
374 return ret;
375 }
376
377 ret = accessor(d_ucharvec, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_UCHARVEC]);
378 if (ret) {
379 return ret;
380 }
381
382 return 0;
383}
384
385template <typename t_ACCESSOR>
386int RawData::accessAttribute(t_ACCESSOR& accessor, int id) const
387{
388 enum { NOT_FOUND = -1 };
389
390 switch (id) {
392 return accessor(d_charvec, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_CHARVEC]);
393 }
395 return accessor(d_ucharvec, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_UCHARVEC]);
396 }
397 default:
398 return NOT_FOUND;
399 }
400}
401
402template <typename t_ACCESSOR>
404 t_ACCESSOR& accessor,
405 const char *name,
406 int nameLength) const
407{
408 enum { NOT_FOUND = -1 };
409
410 const bdlat_AttributeInfo *attributeInfo =
411 lookupAttributeInfo(name, nameLength);
412 if (0 == attributeInfo) {
413 return NOT_FOUND;
414 }
415
416 return accessAttribute(accessor, attributeInfo->d_id);
417}
418
419inline
421{
422 return d_charvec;
423}
424
425inline
427{
428 return d_ucharvec;
429}
430
431} // close package namespace
432
433// FREE FUNCTIONS
434
435
436#endif
437
438// GENERATED BY BLP_BAS_CODEGEN_2025.08.21
439// USING bas_codegen.pl s_baltst_rawdata.xsd --mode msg --includedir . --msgComponent rawdata --noRecurse --noExternalization --noHashSupport --noAggregateConversion
440// ----------------------------------------------------------------------------
441// NOTICE:
442// Copyright 2025 Bloomberg Finance L.P. All rights reserved.
443// Property of Bloomberg Finance L.P. (BFLP)
444// This software is made available solely pursuant to the
445// terms of a BFLP license agreement which governs its use.
446// ------------------------------- END-OF-FILE --------------------------------
447
448/** @} */
449/** @} */
450/** @} */
Definition bslstl_vector.h:1120
Definition bslma_allocator.h:545
Definition s_baltst_rawdata.h:73
friend bool operator!=(const RawData &lhs, const RawData &rhs)
Returns !(lhs == rhs)
Definition s_baltst_rawdata.h:269
static const bdlat_AttributeInfo * lookupAttributeInfo(const char *name, int nameLength)
RawData & operator=(const RawData &rhs)
Assign to this object the value of the specified rhs object.
int manipulateAttribute(t_MANIPULATOR &manipulator, int id)
Definition s_baltst_rawdata.h:321
bsl::vector< char > & charvec()
Definition s_baltst_rawdata.h:355
int accessAttribute(t_ACCESSOR &accessor, int id) const
Definition s_baltst_rawdata.h:386
@ ATTRIBUTE_ID_CHARVEC
Definition s_baltst_rawdata.h:82
@ ATTRIBUTE_ID_UCHARVEC
Definition s_baltst_rawdata.h:83
static const bdlat_AttributeInfo * lookupAttributeInfo(int id)
@ ATTRIBUTE_INDEX_UCHARVEC
Definition s_baltst_rawdata.h:92
@ ATTRIBUTE_INDEX_CHARVEC
Definition s_baltst_rawdata.h:91
@ NUM_ATTRIBUTES
Definition s_baltst_rawdata.h:87
bsl::vector< unsigned char > & ucharvec()
Definition s_baltst_rawdata.h:361
RawData(const RawData &original, bslma::Allocator *basicAllocator=0)
static const bdlat_AttributeInfo ATTRIBUTE_INFO_ARRAY[]
Definition s_baltst_rawdata.h:98
friend bsl::ostream & operator<<(bsl::ostream &stream, const RawData &rhs)
Definition s_baltst_rawdata.h:276
int accessAttributes(t_ACCESSOR &accessor) const
Definition s_baltst_rawdata.h:368
static const char CLASS_NAME[]
Definition s_baltst_rawdata.h:96
friend bool operator==(const RawData &lhs, const RawData &rhs)
Definition s_baltst_rawdata.h:262
int manipulateAttributes(t_MANIPULATOR &manipulator)
Definition s_baltst_rawdata.h:303
bsl::ostream & print(bsl::ostream &stream, int level=0, int spacesPerLevel=4) const
RawData(bslma::Allocator *basicAllocator=0)
~RawData()
Destroy this object.
#define BDLAT_DECL_SEQUENCE_WITH_ALLOCATOR_BITWISEMOVEABLE_TRAITS(ClassName)
Definition bdlat_typetraits.h:301
#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 baljsn_encoder_testtypes.h:76
Definition s_baltst_address.h:66
Definition bdlat_attributeinfo.h:139
int d_id
Definition bdlat_attributeinfo.h:142
Definition bdlat_typetraits.h:146