BDE 4.39.x Production Release
Loading...
Searching...
No Matches
s_baltst_request.h
Go to the documentation of this file.
1/// @file s_baltst_request.h
2///
3/// The content of this file has been pre-processed for Doxygen.
4///
5
6
7// s_baltst_request.h *DO NOT EDIT* @generated -*-C++-*-
8#ifndef INCLUDED_S_BALTST_REQUEST
9#define INCLUDED_S_BALTST_REQUEST
10
11#include <bsls_ident.h>
12BSLS_IDENT_RCSID(s_baltst_request_h, "$Id$ $CSID$")
14
15/// @defgroup s_baltst_request s_baltst_request
16/// @brief Provide value-semantic attribute classes
17/// @addtogroup Standalones
18/// @{
19/// @addtogroup s_baltst
20/// @{
21/// @addtogroup s_baltst_request
22/// @{
23///
24/// <h1> Outline </h1>
25/// * <a href="#s_baltst_request-purpose"> Purpose</a>
26///
27/// # Purpose {#s_baltst_request-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_request
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
58
60
61#include <bsl_iosfwd.h>
62#include <bsl_limits.h>
63
64
65
66namespace bslma { class Allocator; }
67
68namespace s_baltst { class Request; }
69namespace s_baltst {
70
71 // =============
72 // class Request
73 // =============
74
75class Request {
76
77 // INSTANCE DATA
78 union {
81 };
82
83 int d_selectionId;
84 bslma::Allocator *d_allocator_p;
85
86 // PRIVATE ACCESSORS
87 bool isEqualTo(const Request& rhs) const;
88
89 public:
90 // TYPES
91
92 enum {
96 };
97
98 enum {
100 };
101
102 enum {
105 };
106
107 // CONSTANTS
108 static const char CLASS_NAME[];
109
111
112 // CLASS METHODS
113
114 /// Return selection information for the selection indicated by the
115 /// specified `id` if the selection exists, and 0 otherwise.
117
118 /// Return selection information for the selection indicated by the
119 /// specified `name` of the specified `nameLength` if the selection
120 /// exists, and 0 otherwise.
122 const char *name,
123 int nameLength);
124
125 // CREATORS
126
127 /// Create an object of type `Request` having the default value. Use
128 /// the optionally specified `basicAllocator` to supply memory. If
129 /// `basicAllocator` is 0, the currently installed default allocator is
130 /// used.
131 explicit Request(bslma::Allocator *basicAllocator = 0);
132
133 /// Create an object of type `Request` having the value of the specified
134 /// `original` object. Use the optionally specified `basicAllocator` to
135 /// supply memory. If `basicAllocator` is 0, the currently installed
136 /// default allocator is used.
137 Request(const Request& original,
138 bslma::Allocator *basicAllocator = 0);
139
140#if defined(BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES) \
141 && defined(BSLS_COMPILERFEATURES_SUPPORT_NOEXCEPT)
142 /// Create an object of type `Request` having the value of the specified
143 /// `original` object. After performing this action, the `original`
144 /// object will be left in a valid, but unspecified state.
145 Request(Request&& original) noexcept;
146
147 /// Create an object of type `Request` having the value of the specified
148 /// `original` object. After performing this action, the `original`
149 /// object will be left in a valid, but unspecified state. Use the
150 /// optionally specified `basicAllocator` to supply memory. If
151 /// `basicAllocator` is 0, the currently installed default allocator is
152 /// used.
153 Request(Request&& original,
154 bslma::Allocator *basicAllocator);
155#endif
156
157 /// Destroy this object.
158 ~Request();
159
160 // MANIPULATORS
161
162 /// Assign to this object the value of the specified `rhs` object.
164
165#if defined(BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES) \
166 && defined(BSLS_COMPILERFEATURES_SUPPORT_NOEXCEPT)
167 /// Assign to this object the value of the specified `rhs` object.
168 /// After performing this action, the `rhs` object will be left in a
169 /// valid, but unspecified state.
170 Request& operator=(Request&& rhs);
171#endif
172
173 /// Reset this object to the default value (i.e., its value upon default
174 /// construction).
175 void reset();
176
177 /// Set the value of this object to be the default for the selection
178 /// indicated by the specified `selectionId`. Return 0 on success, and
179 /// non-zero value otherwise (i.e., the selection is not found).
181
182 /// Set the value of this object to be the default for the selection
183 /// indicated by the specified `name` of the specified `nameLength`.
184 /// Return 0 on success, and non-zero value otherwise (i.e., the
185 /// selection is not found).
186 int makeSelection(const char *name, int nameLength);
187
190#if defined(BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES) \
191 && defined(BSLS_COMPILERFEATURES_SUPPORT_NOEXCEPT)
193#endif
194 // Set the value of this object to be a "SimpleRequest" value.
195 // Optionally specify the 'value' of the "SimpleRequest". If 'value'
196 // is not specified, the default "SimpleRequest" value is used.
197
200#if defined(BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES) \
201 && defined(BSLS_COMPILERFEATURES_SUPPORT_NOEXCEPT)
203#endif
204 // Set the value of this object to be a "FeatureRequest" value.
205 // Optionally specify the 'value' of the "FeatureRequest". If 'value'
206 // is not specified, the default "FeatureRequest" value is used.
207
208 /// Invoke the specified `manipulator` on the address of the modifiable
209 /// selection, supplying `manipulator` with the corresponding selection
210 /// information structure. Return the value returned from the
211 /// invocation of `manipulator` if this object has a defined selection,
212 /// and -1 otherwise.
213 template <typename t_MANIPULATOR>
214 int manipulateSelection(t_MANIPULATOR& manipulator);
215
216 /// Return a reference to the modifiable "SimpleRequest" selection of
217 /// this object if "SimpleRequest" is the current selection.
218 ///
219 /// \pre The behavior is undefined unless "SimpleRequest" is the selection of
220 /// this object.
222
223 /// Return a reference to the modifiable "FeatureRequest" selection of
224 /// this object if "FeatureRequest" is the current selection.
225 ///
226 /// \pre The behavior is undefined unless "FeatureRequest" is the selection of
227 /// this object.
229
230 // ACCESSORS
231
232 /// Format this object to the specified output `stream` at the
233 /// optionally specified indentation `level` and return a reference to
234 /// the modifiable `stream`. If `level` is specified, optionally
235 /// specify `spacesPerLevel`, the number of spaces per indentation level
236 /// for this and all of its nested objects. Each line is indented by
237 /// the absolute value of `level * spacesPerLevel`. If `level` is
238 /// negative, suppress indentation of the first line. If
239 /// `spacesPerLevel` is negative, suppress line breaks and format the
240 /// entire output on one line. If `stream` is initially invalid, this operation has no effect.
241 ///
242 /// \note Note that a trailing newline is provided
243 /// in multiline mode only.
244 bsl::ostream& print(bsl::ostream& stream,
245 int level = 0,
246 int spacesPerLevel = 4) const;
247
248 /// Return the id of the current selection if the selection is defined,
249 /// and -1 otherwise.
250 int selectionId() const;
251
252 /// Invoke the specified `accessor` on the non-modifiable selection,
253 /// supplying `accessor` with the corresponding selection information
254 /// structure. Return the value returned from the invocation of
255 /// `accessor` if this object has a defined selection, and -1 otherwise.
256 template <typename t_ACCESSOR>
257 int accessSelection(t_ACCESSOR& accessor) const;
258
259 /// Return a reference to the non-modifiable "SimpleRequest" selection
260 /// of this object if "SimpleRequest" is the current selection.
261 ///
262 /// \pre The behavior is undefined unless "SimpleRequest" is the selection of
263 /// this object.
265
266 /// Return a reference to the non-modifiable "FeatureRequest" selection
267 /// of this object if "FeatureRequest" is the current selection.
268 ///
269 /// \pre The behavior is undefined unless "FeatureRequest" is the selection of
270 /// this object.
272
273 /// Return `true` if the value of this object is a "SimpleRequest"
274 /// value, and return `false` otherwise.
275 bool isSimpleRequestValue() const;
276
277 /// Return `true` if the value of this object is a "FeatureRequest"
278 /// value, and return `false` otherwise.
279 bool isFeatureRequestValue() const;
280
281 /// Return `true` if the value of this object is undefined, and `false`
282 /// otherwise.
283 bool isUndefinedValue() const;
284
285 /// Return the symbolic name of the current selection of this object.
286 const char *selectionName() const;
287
288 // HIDDEN FRIENDS
289
290 /// Return `true` if the specified `lhs` and `rhs` objects have the same
291 /// value, and `false` otherwise. Two `Request` objects have the same
292 /// value if either the selections in both objects have the same ids and
293 /// the same values, or both selections are undefined.
294 friend bool operator==(const Request& lhs, const Request& rhs)
295 {
296 return lhs.isEqualTo(rhs);
297 }
298
299 /// Return `true` if the specified `lhs` and `rhs` objects do not have
300 /// the same values, as determined by `operator==`, and `false`
301 /// otherwise.
302 friend bool operator!=(const Request& lhs, const Request& rhs)
303 {
304 return !(lhs == rhs);
305 }
306
307 /// Format the specified `rhs` to the specified output `stream` and
308 /// return a reference to the modifiable `stream`.
309 friend bsl::ostream& operator<<(bsl::ostream& stream, const Request& rhs)
310 {
311 return rhs.print(stream, 0, -1);
312 }
313};
314
315} // close package namespace
316
317// TRAITS
318
320
321// ============================================================================
322// INLINE DEFINITIONS
323// ============================================================================
324
325namespace s_baltst {
326
327 // -------------
328 // class Request
329 // -------------
330
331// CLASS METHODS
332// PRIVATE ACCESSORS
333inline
334bool Request::isEqualTo(const Request& rhs) const
335{
336 typedef Request Class;
337 if (this->selectionId() == rhs.selectionId()) {
338 switch (rhs.selectionId()) {
339 case Class::SELECTION_ID_SIMPLE_REQUEST:
340 return this->simpleRequest() == rhs.simpleRequest();
341 case Class::SELECTION_ID_FEATURE_REQUEST:
342 return this->featureRequest() == rhs.featureRequest();
343 default:
344 BSLS_ASSERT(Class::SELECTION_ID_UNDEFINED == rhs.selectionId());
345 return true;
346 }
347 }
348 else {
349 return false;
350 }
351}
352
353// CREATORS
354inline
356: d_selectionId(SELECTION_ID_UNDEFINED)
357, d_allocator_p(bslma::Default::allocator(basicAllocator))
358{
359}
360
361inline
363{
364 reset();
365}
366
367// MANIPULATORS
368template <typename t_MANIPULATOR>
369int Request::manipulateSelection(t_MANIPULATOR& manipulator)
370{
371 switch (d_selectionId) {
373 return manipulator(&d_simpleRequest.object(),
376 return manipulator(&d_featureRequest.object(),
378 default:
380 return -1;
381 }
382}
383
384inline
390
391inline
397
398// ACCESSORS
399inline
401{
402 return d_selectionId;
403}
404
405template <typename t_ACCESSOR>
406int Request::accessSelection(t_ACCESSOR& accessor) const
407{
408 switch (d_selectionId) {
410 return accessor(d_simpleRequest.object(),
413 return accessor(d_featureRequest.object(),
415 default:
416 BSLS_ASSERT(SELECTION_ID_UNDEFINED == d_selectionId);
417 return -1;
418 }
419}
420
421inline
427
428inline
434
435inline
437{
438 return SELECTION_ID_SIMPLE_REQUEST == d_selectionId;
439}
440
441inline
443{
444 return SELECTION_ID_FEATURE_REQUEST == d_selectionId;
445}
446
447inline
449{
450 return SELECTION_ID_UNDEFINED == d_selectionId;
451}
452} // close package namespace
453
454// FREE FUNCTIONS
455
456
457#endif
458
459// GENERATED BY BLP_BAS_CODEGEN_2025.08.21
460// USING bas_codegen.pl s_baltst_request.xsd --mode msg --includedir . --msgComponent request --noRecurse --noExternalization --noHashSupport --noAggregateConversion
461// ----------------------------------------------------------------------------
462// NOTICE:
463// Copyright 2025 Bloomberg Finance L.P. All rights reserved.
464// Property of Bloomberg Finance L.P. (BFLP)
465// This software is made available solely pursuant to the
466// terms of a BFLP license agreement which governs its use.
467// ------------------------------- END-OF-FILE --------------------------------
468
469/** @} */
470/** @} */
471/** @} */
Definition bslma_allocator.h:545
Definition s_baltst_featuretestmessage.h:87
Definition s_baltst_request.h:75
bsl::ostream & print(bsl::ostream &stream, int level=0, int spacesPerLevel=4) const
const char * selectionName() const
Return the symbolic name of the current selection of this object.
bsls::ObjectBuffer< s_baltst::FeatureTestMessage > d_featureRequest
Definition s_baltst_request.h:80
bsls::ObjectBuffer< s_baltst::SimpleRequest > d_simpleRequest
Definition s_baltst_request.h:79
static const bdlat_SelectionInfo * lookupSelectionInfo(const char *name, int nameLength)
@ NUM_SELECTIONS
Definition s_baltst_request.h:99
int makeSelection(const char *name, int nameLength)
s_baltst::SimpleRequest & makeSimpleRequest()
int makeSelection(int selectionId)
bool isSimpleRequestValue() const
Definition s_baltst_request.h:436
s_baltst::FeatureTestMessage & makeFeatureRequest(const s_baltst::FeatureTestMessage &value)
s_baltst::SimpleRequest & simpleRequest()
Definition s_baltst_request.h:385
Request(bslma::Allocator *basicAllocator=0)
Definition s_baltst_request.h:355
Request(const Request &original, bslma::Allocator *basicAllocator=0)
int manipulateSelection(t_MANIPULATOR &manipulator)
Definition s_baltst_request.h:369
static const char CLASS_NAME[]
Definition s_baltst_request.h:108
static const bdlat_SelectionInfo SELECTION_INFO_ARRAY[]
Definition s_baltst_request.h:110
bool isUndefinedValue() const
Definition s_baltst_request.h:448
s_baltst::SimpleRequest & makeSimpleRequest(const s_baltst::SimpleRequest &value)
friend bsl::ostream & operator<<(bsl::ostream &stream, const Request &rhs)
Definition s_baltst_request.h:309
~Request()
Destroy this object.
Definition s_baltst_request.h:362
static const bdlat_SelectionInfo * lookupSelectionInfo(int id)
Request & operator=(const Request &rhs)
Assign to this object the value of the specified rhs object.
int selectionId() const
Definition s_baltst_request.h:400
bool isFeatureRequestValue() const
Definition s_baltst_request.h:442
s_baltst::FeatureTestMessage & featureRequest()
Definition s_baltst_request.h:392
friend bool operator!=(const Request &lhs, const Request &rhs)
Definition s_baltst_request.h:302
s_baltst::FeatureTestMessage & makeFeatureRequest()
friend bool operator==(const Request &lhs, const Request &rhs)
Definition s_baltst_request.h:294
int accessSelection(t_ACCESSOR &accessor) const
Definition s_baltst_request.h:406
@ SELECTION_ID_SIMPLE_REQUEST
Definition s_baltst_request.h:94
@ SELECTION_ID_UNDEFINED
Definition s_baltst_request.h:93
@ SELECTION_ID_FEATURE_REQUEST
Definition s_baltst_request.h:95
@ SELECTION_INDEX_SIMPLE_REQUEST
Definition s_baltst_request.h:103
@ SELECTION_INDEX_FEATURE_REQUEST
Definition s_baltst_request.h:104
Definition s_baltst_simplerequest.h:73
#define BDLAT_DECL_CHOICE_WITH_ALLOCATOR_BITWISEMOVEABLE_TRAITS(ClassName)
Definition bdlat_typetraits.h:268
#define BSLS_ASSERT(X)
Definition bsls_assert.h:1976
#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
ALLOCATOR const STRING_VIEW_LIKE_TYPE & rhs
Definition bslstl_string.h:3918
Definition baljsn_encoder_testtypes.h:76
Definition s_baltst_address.h:66
Definition bdlat_selectioninfo.h:138
TYPE & object()
Definition bsls_objectbuffer.h:352