BDE 4.39.x Production Release
Loading...
Searching...
No Matches
s_baltst_simplerequest.h
Go to the documentation of this file.
1/// @file s_baltst_simplerequest.h
2///
3/// The content of this file has been pre-processed for Doxygen.
4///
5
6
7// s_baltst_simplerequest.h *DO NOT EDIT* @generated -*-C++-*-
8#ifndef INCLUDED_S_BALTST_SIMPLEREQUEST
9#define INCLUDED_S_BALTST_SIMPLEREQUEST
10
11#include <bsls_ident.h>
12BSLS_IDENT_RCSID(s_baltst_simplerequest_h, "$Id$ $CSID$")
14
15/// @defgroup s_baltst_simplerequest s_baltst_simplerequest
16/// @brief Provide value-semantic attribute classes
17/// @addtogroup Standalones
18/// @{
19/// @addtogroup s_baltst
20/// @{
21/// @addtogroup s_baltst_simplerequest
22/// @{
23///
24/// <h1> Outline </h1>
25/// * <a href="#s_baltst_simplerequest-purpose"> Purpose</a>
26///
27/// # Purpose {#s_baltst_simplerequest-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_simplerequest
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_string.h>
58
59#include <bsl_iosfwd.h>
60#include <bsl_limits.h>
61
62
63
64namespace bslma { class Allocator; }
65
66namespace s_baltst { class SimpleRequest; }
67namespace s_baltst {
68
69 // ===================
70 // class SimpleRequest
71 // ===================
72
74
75 // INSTANCE DATA
76 bsl::string d_data;
77 int d_responseLength;
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 `SimpleRequest` 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 SimpleRequest(bslma::Allocator *basicAllocator = 0);
121
122 /// Create an object of type `SimpleRequest` 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 `SimpleRequest` 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 SimpleRequest(SimpleRequest&& original) noexcept;
135
136 /// Create an object of type `SimpleRequest` 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.
142 SimpleRequest(SimpleRequest&& 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.
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 "Data" attribute of this
196 /// object.
197 bsl::string& data();
198
199 /// Return a reference to the modifiable "ResponseLength" attribute of
200 /// this object.
201 int& responseLength();
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 "Data"
250 /// attribute of this object.
251 const bsl::string& data() const;
252
253 /// Return the value of the "ResponseLength" attribute of this object.
254 int responseLength() const;
255
256 // HIDDEN FRIENDS
257
258 /// Return `true` if the specified `lhs` and `rhs` attribute objects
259 /// have the same value, and `false` otherwise. Two attribute objects
260 /// have the same value if each respective attribute has the same value.
261 friend bool operator==(const SimpleRequest& lhs, const SimpleRequest& rhs)
262 {
263 return lhs.data() == rhs.data() &&
264 lhs.responseLength() == rhs.responseLength();
265 }
266
267 /// Returns `!(lhs == rhs)`
268 friend bool operator!=(const SimpleRequest& lhs, const SimpleRequest& rhs)
269 {
270 return !(lhs == rhs);
271 }
272
273 /// Format the specified `rhs` to the specified output `stream` and
274 /// return a reference to the modifiable `stream`.
275 friend bsl::ostream& operator<<(bsl::ostream& stream,
276 const SimpleRequest& 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 SimpleRequest
298 // -------------------
299
300// CLASS METHODS
301// MANIPULATORS
302template <typename t_MANIPULATOR>
303int SimpleRequest::manipulateAttributes(t_MANIPULATOR& manipulator)
304{
305 int ret;
306
307 ret = manipulator(&d_data, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_DATA]);
308 if (ret) {
309 return ret;
310 }
311
312 ret = manipulator(&d_responseLength, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_RESPONSE_LENGTH]);
313 if (ret) {
314 return ret;
315 }
316
317 return 0;
318}
319
320template <typename t_MANIPULATOR>
321int SimpleRequest::manipulateAttribute(t_MANIPULATOR& manipulator, int id)
322{
323 enum { NOT_FOUND = -1 };
324
325 switch (id) {
326 case ATTRIBUTE_ID_DATA: {
327 return manipulator(&d_data, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_DATA]);
328 }
330 return manipulator(&d_responseLength, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_RESPONSE_LENGTH]);
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_data;
358}
359
360inline
362{
363 return d_responseLength;
364}
365
366// ACCESSORS
367template <typename t_ACCESSOR>
368int SimpleRequest::accessAttributes(t_ACCESSOR& accessor) const
369{
370 int ret;
371
372 ret = accessor(d_data, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_DATA]);
373 if (ret) {
374 return ret;
375 }
376
377 ret = accessor(d_responseLength, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_RESPONSE_LENGTH]);
378 if (ret) {
379 return ret;
380 }
381
382 return 0;
383}
384
385template <typename t_ACCESSOR>
386int SimpleRequest::accessAttribute(t_ACCESSOR& accessor, int id) const
387{
388 enum { NOT_FOUND = -1 };
389
390 switch (id) {
391 case ATTRIBUTE_ID_DATA: {
392 return accessor(d_data, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_DATA]);
393 }
395 return accessor(d_responseLength, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_RESPONSE_LENGTH]);
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_data;
423}
424
425inline
427{
428 return d_responseLength;
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_simplerequest.xsd --mode msg --includedir . --msgComponent simplerequest --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_string.h:1252
Definition bslma_allocator.h:545
Definition s_baltst_simplerequest.h:73
@ ATTRIBUTE_INDEX_DATA
Definition s_baltst_simplerequest.h:91
@ ATTRIBUTE_INDEX_RESPONSE_LENGTH
Definition s_baltst_simplerequest.h:92
SimpleRequest(const SimpleRequest &original, bslma::Allocator *basicAllocator=0)
@ ATTRIBUTE_ID_DATA
Definition s_baltst_simplerequest.h:82
@ ATTRIBUTE_ID_RESPONSE_LENGTH
Definition s_baltst_simplerequest.h:83
static const bdlat_AttributeInfo * lookupAttributeInfo(const char *name, int nameLength)
int manipulateAttribute(t_MANIPULATOR &manipulator, int id)
Definition s_baltst_simplerequest.h:321
bsl::ostream & print(bsl::ostream &stream, int level=0, int spacesPerLevel=4) const
SimpleRequest & operator=(const SimpleRequest &rhs)
Assign to this object the value of the specified rhs object.
static const bdlat_AttributeInfo * lookupAttributeInfo(int id)
int manipulateAttributes(t_MANIPULATOR &manipulator)
Definition s_baltst_simplerequest.h:303
friend bsl::ostream & operator<<(bsl::ostream &stream, const SimpleRequest &rhs)
Definition s_baltst_simplerequest.h:275
static const char CLASS_NAME[]
Definition s_baltst_simplerequest.h:96
friend bool operator==(const SimpleRequest &lhs, const SimpleRequest &rhs)
Definition s_baltst_simplerequest.h:261
int accessAttributes(t_ACCESSOR &accessor) const
Definition s_baltst_simplerequest.h:368
int & responseLength()
Definition s_baltst_simplerequest.h:361
friend bool operator!=(const SimpleRequest &lhs, const SimpleRequest &rhs)
Returns !(lhs == rhs)
Definition s_baltst_simplerequest.h:268
@ NUM_ATTRIBUTES
Definition s_baltst_simplerequest.h:87
static const bdlat_AttributeInfo ATTRIBUTE_INFO_ARRAY[]
Definition s_baltst_simplerequest.h:98
~SimpleRequest()
Destroy this object.
bsl::string & data()
Definition s_baltst_simplerequest.h:355
int accessAttribute(t_ACCESSOR &accessor, int id) const
Definition s_baltst_simplerequest.h:386
SimpleRequest(bslma::Allocator *basicAllocator=0)
#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