BDE 4.39.x Production Release
Loading...
Searching...
No Matches
s_baltst_sequencewithnilonly.h
Go to the documentation of this file.
1/// @file s_baltst_sequencewithnilonly.h
2///
3/// The content of this file has been pre-processed for Doxygen.
4///
5
6
7// s_baltst_sequencewithnilonly.h *DO NOT EDIT* @generated -*-C++-*-
8#ifndef INCLUDED_S_BALTST_SEQUENCEWITHNILONLY
9#define INCLUDED_S_BALTST_SEQUENCEWITHNILONLY
10
11#include <bsls_ident.h>
12BSLS_IDENT_RCSID(s_baltst_sequencewithnilonly_h, "$Id$ $CSID$")
14
15/// @defgroup s_baltst_sequencewithnilonly s_baltst_sequencewithnilonly
16/// @brief Provide value-semantic attribute classes
17/// @addtogroup Standalones
18/// @{
19/// @addtogroup s_baltst
20/// @{
21/// @addtogroup s_baltst_sequencewithnilonly
22/// @{
23///
24/// <h1> Outline </h1>
25/// * <a href="#s_baltst_sequencewithnilonly-purpose"> Purpose</a>
26///
27/// # Purpose {#s_baltst_sequencewithnilonly-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_sequencewithnilonly
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 <bdlb_nullablevalue.h>
58
59#include <bsl_vector.h>
60
61#include <bsl_iosfwd.h>
62#include <bsl_limits.h>
63
64
65
66namespace bslma { class Allocator; }
67
68namespace s_baltst { class SequenceWithNilOnly; }
69namespace s_baltst {
70
71 // =========================
72 // class SequenceWithNilOnly
73 // =========================
74
76
77 // INSTANCE DATA
79
80 public:
81 // TYPES
82 enum {
84 };
85
86 enum {
88 };
89
90 enum {
92 };
93
94 // CONSTANTS
95 static const char CLASS_NAME[];
96
98
99 public:
100 // CLASS METHODS
102 // Return attribute information for the attribute indicated by the
103 // specified 'id' if the attribute exists, and 0 otherwise.
104
106 const char *name,
107 int nameLength);
108 // Return attribute information for the attribute indicated by the
109 // specified 'name' of the specified 'nameLength' if the attribute
110 // exists, and 0 otherwise.
111
112 // CREATORS
113 explicit SequenceWithNilOnly(bslma::Allocator *basicAllocator = 0);
114 // Create an object of type 'SequenceWithNilOnly' having the default
115 // value. Use the optionally specified 'basicAllocator' to supply
116 // memory. If 'basicAllocator' is 0, the currently installed default
117 // allocator is used.
118
120 bslma::Allocator *basicAllocator = 0);
121 // Create an object of type 'SequenceWithNilOnly' having the value of
122 // the specified 'original' object. Use the optionally specified
123 // 'basicAllocator' to supply memory. If 'basicAllocator' is 0, the
124 // currently installed default allocator is used.
125
126#if defined(BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES) \
127 && defined(BSLS_COMPILERFEATURES_SUPPORT_NOEXCEPT)
128 SequenceWithNilOnly(SequenceWithNilOnly&& original) noexcept;
129 // Create an object of type 'SequenceWithNilOnly' having the value of
130 // the specified 'original' object. After performing this action, the
131 // 'original' object will be left in a valid, but unspecified state.
132
134 bslma::Allocator *basicAllocator);
135 // Create an object of type 'SequenceWithNilOnly' having the value of
136 // the specified 'original' object. After performing this action, the
137 // 'original' object will be left in a valid, but unspecified state.
138 // Use the optionally specified 'basicAllocator' to supply memory. If
139 // 'basicAllocator' is 0, the currently installed default allocator is
140 // used.
141#endif
142
144 // Destroy this object.
145
146 // MANIPULATORS
148 // Assign to this object the value of the specified 'rhs' object.
149
150#if defined(BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES) \
151 && defined(BSLS_COMPILERFEATURES_SUPPORT_NOEXCEPT)
153 // Assign to this object the value of the specified 'rhs' object.
154 // After performing this action, the 'rhs' object will be left in a
155 // valid, but unspecified state.
156#endif
157
158 void reset();
159 // Reset this object to the default value (i.e., its value upon
160 // default construction).
161
162 template <typename t_MANIPULATOR>
163 int manipulateAttributes(t_MANIPULATOR& manipulator);
164 // Invoke the specified 'manipulator' sequentially on the address of
165 // each (modifiable) attribute of this object, supplying 'manipulator'
166 // with the corresponding attribute information structure until such
167 // invocation returns a non-zero value. Return the value from the
168 // last invocation of 'manipulator' (i.e., the invocation that
169 // terminated the sequence).
170
171 template <typename t_MANIPULATOR>
172 int manipulateAttribute(t_MANIPULATOR& manipulator, int id);
173 // Invoke the specified 'manipulator' on the address of
174 // the (modifiable) attribute indicated by the specified 'id',
175 // supplying 'manipulator' with the corresponding attribute
176 // information structure. Return the value returned from the
177 // invocation of 'manipulator' if 'id' identifies an attribute of this
178 // class, and -1 otherwise.
179
180 template <typename t_MANIPULATOR>
181 int manipulateAttribute(t_MANIPULATOR& manipulator,
182 const char *name,
183 int nameLength);
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
192 // Return a reference to the modifiable "V" attribute of this object.
193
194 // ACCESSORS
195 bsl::ostream& print(bsl::ostream& stream,
196 int level = 0,
197 int spacesPerLevel = 4) const;
198 // Format this object to the specified output 'stream' at the
199 // optionally specified indentation 'level' and return a reference to
200 // the modifiable 'stream'. If 'level' is specified, optionally
201 // specify 'spacesPerLevel', the number of spaces per indentation level
202 // for this and all of its nested objects. Each line is indented by
203 // the absolute value of 'level * spacesPerLevel'. If 'level' is
204 // negative, suppress indentation of the first line. If
205 // 'spacesPerLevel' is negative, suppress line breaks and format the
206 // entire output on one line. If 'stream' is initially invalid, this
207 // operation has no effect. Note that a trailing newline is provided
208 // in multiline mode only.
209
210 template <typename t_ACCESSOR>
211 int accessAttributes(t_ACCESSOR& accessor) const;
212 // Invoke the specified 'accessor' sequentially on each
213 // (non-modifiable) attribute of this object, supplying 'accessor'
214 // with the corresponding attribute information structure until such
215 // invocation returns a non-zero value. Return the value from the
216 // last invocation of 'accessor' (i.e., the invocation that terminated
217 // the sequence).
218
219 template <typename t_ACCESSOR>
220 int accessAttribute(t_ACCESSOR& accessor, int id) const;
221 // Invoke the specified 'accessor' on the (non-modifiable) attribute
222 // of this object indicated by the specified 'id', supplying 'accessor'
223 // with the corresponding attribute information structure. Return the
224 // value returned from the invocation of 'accessor' if 'id' identifies
225 // an attribute of this class, and -1 otherwise.
226
227 template <typename t_ACCESSOR>
228 int accessAttribute(t_ACCESSOR& accessor,
229 const char *name,
230 int nameLength) const;
231 // Invoke the specified 'accessor' on the (non-modifiable) attribute
232 // of this object indicated by the specified 'name' of the specified
233 // 'nameLength', supplying 'accessor' with the corresponding attribute
234 // information structure. Return the value returned from the
235 // invocation of 'accessor' if 'name' identifies an attribute of this
236 // class, and -1 otherwise.
237
239 // Return a reference offering non-modifiable access to the "V"
240 // attribute of this object.
241
242 // HIDDEN FRIENDS
243 friend bool operator==(const SequenceWithNilOnly& lhs,
244 const SequenceWithNilOnly& rhs)
245 // Return 'true' if the specified 'lhs' and 'rhs' attribute objects
246 // have the same value, and 'false' otherwise. Two attribute objects
247 // have the same value if each respective attribute has the same value.
248 {
249 return lhs.v() == rhs.v();
250 }
251
252 friend bool operator!=(const SequenceWithNilOnly& lhs,
253 const SequenceWithNilOnly& rhs)
254 // Returns '!(lhs == rhs)'
255 {
256 return !(lhs == rhs);
257 }
258
259 friend bsl::ostream& operator<<(bsl::ostream& stream,
260 const SequenceWithNilOnly& rhs)
261 // Format the specified 'rhs' to the specified output 'stream' and
262 // return a reference to the modifiable 'stream'.
263 {
264 return rhs.print(stream, 0, -1);
265 }
266};
267
268} // close package namespace
269
270// TRAITS
271
273
274// ============================================================================
275// INLINE DEFINITIONS
276// ============================================================================
277
278namespace s_baltst {
279
280 // -------------------------
281 // class SequenceWithNilOnly
282 // -------------------------
283
284// CLASS METHODS
285// MANIPULATORS
286template <typename t_MANIPULATOR>
287int SequenceWithNilOnly::manipulateAttributes(t_MANIPULATOR& manipulator)
288{
289 int ret;
290
291 ret = manipulator(&d_v, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_V]);
292 if (ret) {
293 return ret;
294 }
295
296 return 0;
297}
298
299template <typename t_MANIPULATOR>
300int SequenceWithNilOnly::manipulateAttribute(t_MANIPULATOR& manipulator, int id)
301{
302 enum { NOT_FOUND = -1 };
303
304 switch (id) {
305 case ATTRIBUTE_ID_V: {
306 return manipulator(&d_v, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_V]);
307 }
308 default:
309 return NOT_FOUND;
310 }
311}
312
313template <typename t_MANIPULATOR>
315 t_MANIPULATOR& manipulator,
316 const char *name,
317 int nameLength)
318{
319 enum { NOT_FOUND = -1 };
320
321 const bdlat_AttributeInfo *attributeInfo =
322 lookupAttributeInfo(name, nameLength);
323 if (0 == attributeInfo) {
324 return NOT_FOUND;
325 }
326
327 return manipulateAttribute(manipulator, attributeInfo->d_id);
328}
329
330inline
335
336// ACCESSORS
337template <typename t_ACCESSOR>
338int SequenceWithNilOnly::accessAttributes(t_ACCESSOR& accessor) const
339{
340 int ret;
341
342 ret = accessor(d_v, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_V]);
343 if (ret) {
344 return ret;
345 }
346
347 return 0;
348}
349
350template <typename t_ACCESSOR>
351int SequenceWithNilOnly::accessAttribute(t_ACCESSOR& accessor, int id) const
352{
353 enum { NOT_FOUND = -1 };
354
355 switch (id) {
356 case ATTRIBUTE_ID_V: {
357 return accessor(d_v, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_V]);
358 }
359 default:
360 return NOT_FOUND;
361 }
362}
363
364template <typename t_ACCESSOR>
366 t_ACCESSOR& accessor,
367 const char *name,
368 int nameLength) const
369{
370 enum { NOT_FOUND = -1 };
371
372 const bdlat_AttributeInfo *attributeInfo =
373 lookupAttributeInfo(name, nameLength);
374 if (0 == attributeInfo) {
375 return NOT_FOUND;
376 }
377
378 return accessAttribute(accessor, attributeInfo->d_id);
379}
380
381inline
383{
384 return d_v;
385}
386
387} // close package namespace
388
389// FREE FUNCTIONS
390
391
392#endif
393
394// GENERATED BY BLP_BAS_CODEGEN_2025.08.07
395// USING bas_codegen.pl s_baltst_sequencewithnilonly.xsd --mode msg --includedir . --msgComponent sequencewithnilonly --noRecurse --noExternalization --noHashSupport --noAggregateConversion
396// ----------------------------------------------------------------------------
397// NOTICE:
398// Copyright 2025 Bloomberg Finance L.P. All rights reserved.
399// Property of Bloomberg Finance L.P. (BFLP)
400// This software is made available solely pursuant to the
401// terms of a BFLP license agreement which governs its use.
402// ------------------------------- END-OF-FILE --------------------------------
403
404/** @} */
405/** @} */
406/** @} */
Definition bslstl_vector.h:1120
Definition bslma_allocator.h:545
Definition s_baltst_sequencewithnilonly.h:75
SequenceWithNilOnly & operator=(const SequenceWithNilOnly &rhs)
@ NUM_ATTRIBUTES
Definition s_baltst_sequencewithnilonly.h:87
int accessAttribute(t_ACCESSOR &accessor, int id) const
Definition s_baltst_sequencewithnilonly.h:351
int manipulateAttribute(t_MANIPULATOR &manipulator, int id)
Definition s_baltst_sequencewithnilonly.h:300
static const bdlat_AttributeInfo * lookupAttributeInfo(int id)
@ ATTRIBUTE_ID_V
Definition s_baltst_sequencewithnilonly.h:83
int accessAttributes(t_ACCESSOR &accessor) const
Definition s_baltst_sequencewithnilonly.h:338
bsl::vector< bdlb::NullableValue< int > > & v()
Definition s_baltst_sequencewithnilonly.h:331
static const bdlat_AttributeInfo ATTRIBUTE_INFO_ARRAY[]
Definition s_baltst_sequencewithnilonly.h:97
friend bool operator!=(const SequenceWithNilOnly &lhs, const SequenceWithNilOnly &rhs)
Definition s_baltst_sequencewithnilonly.h:252
int manipulateAttributes(t_MANIPULATOR &manipulator)
Definition s_baltst_sequencewithnilonly.h:287
bsl::ostream & print(bsl::ostream &stream, int level=0, int spacesPerLevel=4) const
SequenceWithNilOnly(bslma::Allocator *basicAllocator=0)
SequenceWithNilOnly(const SequenceWithNilOnly &original, bslma::Allocator *basicAllocator=0)
friend bool operator==(const SequenceWithNilOnly &lhs, const SequenceWithNilOnly &rhs)
Definition s_baltst_sequencewithnilonly.h:243
friend bsl::ostream & operator<<(bsl::ostream &stream, const SequenceWithNilOnly &rhs)
Definition s_baltst_sequencewithnilonly.h:259
static const bdlat_AttributeInfo * lookupAttributeInfo(const char *name, int nameLength)
@ ATTRIBUTE_INDEX_V
Definition s_baltst_sequencewithnilonly.h:91
static const char CLASS_NAME[]
Definition s_baltst_sequencewithnilonly.h:95
#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