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