BDE 4.14.0 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<class MANIPULATOR>
173 int manipulateAttributes(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<class MANIPULATOR>
182 int manipulateAttribute(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<class MANIPULATOR>
191 int manipulateAttribute(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
214 /// operation has no effect. Note that a trailing newline is provided
215 /// in multiline mode only.
216 bsl::ostream& print(bsl::ostream& stream,
217 int level = 0,
218 int spacesPerLevel = 4) const;
219
220 /// Invoke the specified `accessor` sequentially on each
221 /// (non-modifiable) attribute of this object, supplying `accessor`
222 /// with the corresponding attribute information structure until such
223 /// invocation returns a non-zero value. Return the value from the
224 /// last invocation of `accessor` (i.e., the invocation that terminated
225 /// the sequence).
226 template<class ACCESSOR>
227 int accessAttributes(ACCESSOR& accessor) const;
228
229 /// Invoke the specified `accessor` on the (non-modifiable) attribute
230 /// of this object indicated by the specified `id`, supplying `accessor`
231 /// with the corresponding attribute information structure. Return the
232 /// value returned from the invocation of `accessor` if `id` identifies
233 /// an attribute of this class, and -1 otherwise.
234 template<class ACCESSOR>
235 int accessAttribute(ACCESSOR& accessor, int id) const;
236
237 /// Invoke the specified `accessor` on the (non-modifiable) attribute
238 /// of this object indicated by the specified `name` of the specified
239 /// `nameLength`, supplying `accessor` with the corresponding attribute
240 /// information structure. Return the value returned from the
241 /// invocation of `accessor` if `name` identifies an attribute of this
242 /// class, and -1 otherwise.
243 template<class ACCESSOR>
244 int accessAttribute(ACCESSOR& accessor,
245 const char *name,
246 int nameLength) const;
247
248 /// Return a reference offering non-modifiable access to the "Data"
249 /// attribute of this object.
250 const bsl::string& data() const;
251
252 /// Return the value of the "ResponseLength" attribute of this object.
253 int responseLength() const;
254};
255
256// FREE OPERATORS
257
258/// Return `true` if the specified `lhs` and `rhs` attribute objects have
259/// the same value, and `false` otherwise. Two attribute objects have the
260/// same value if each respective attribute has the same value.
261inline
262bool operator==(const SimpleRequest& lhs, const SimpleRequest& rhs);
263
264/// Return `true` if the specified `lhs` and `rhs` attribute objects do not
265/// have the same value, and `false` otherwise. Two attribute objects do
266/// not have the same value if one or more respective attributes differ in
267/// values.
268inline
269bool operator!=(const SimpleRequest& lhs, const SimpleRequest& rhs);
270
271/// Format the specified `rhs` to the specified output `stream` and
272/// return a reference to the modifiable `stream`.
273inline
274bsl::ostream& operator<<(bsl::ostream& stream, const SimpleRequest& rhs);
275
276} // close package namespace
277
278// TRAITS
279
281
282// ============================================================================
283// INLINE FUNCTION DEFINITIONS
284// ============================================================================
285
286namespace s_baltst {
287
288 // -------------------
289 // class SimpleRequest
290 // -------------------
291
292// CLASS METHODS
293// MANIPULATORS
294template <class MANIPULATOR>
295int SimpleRequest::manipulateAttributes(MANIPULATOR& manipulator)
296{
297 int ret;
298
299 ret = manipulator(&d_data, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_DATA]);
300 if (ret) {
301 return ret;
302 }
303
304 ret = manipulator(&d_responseLength, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_RESPONSE_LENGTH]);
305 if (ret) {
306 return ret;
307 }
308
309 return 0;
310}
311
312template <class MANIPULATOR>
313int SimpleRequest::manipulateAttribute(MANIPULATOR& manipulator, int id)
314{
315 enum { NOT_FOUND = -1 };
316
317 switch (id) {
318 case ATTRIBUTE_ID_DATA: {
319 return manipulator(&d_data, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_DATA]);
320 }
322 return manipulator(&d_responseLength, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_RESPONSE_LENGTH]);
323 }
324 default:
325 return NOT_FOUND;
326 }
327}
328
329template <class MANIPULATOR>
331 MANIPULATOR& manipulator,
332 const char *name,
333 int nameLength)
334{
335 enum { NOT_FOUND = -1 };
336
337 const bdlat_AttributeInfo *attributeInfo =
338 lookupAttributeInfo(name, nameLength);
339 if (0 == attributeInfo) {
340 return NOT_FOUND;
341 }
342
343 return manipulateAttribute(manipulator, attributeInfo->d_id);
344}
345
346inline
348{
349 return d_data;
350}
351
352inline
354{
355 return d_responseLength;
356}
357
358// ACCESSORS
359template <class ACCESSOR>
360int SimpleRequest::accessAttributes(ACCESSOR& accessor) const
361{
362 int ret;
363
364 ret = accessor(d_data, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_DATA]);
365 if (ret) {
366 return ret;
367 }
368
369 ret = accessor(d_responseLength, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_RESPONSE_LENGTH]);
370 if (ret) {
371 return ret;
372 }
373
374 return 0;
375}
376
377template <class ACCESSOR>
378int SimpleRequest::accessAttribute(ACCESSOR& accessor, int id) const
379{
380 enum { NOT_FOUND = -1 };
381
382 switch (id) {
383 case ATTRIBUTE_ID_DATA: {
384 return accessor(d_data, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_DATA]);
385 }
387 return accessor(d_responseLength, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_RESPONSE_LENGTH]);
388 }
389 default:
390 return NOT_FOUND;
391 }
392}
393
394template <class ACCESSOR>
396 ACCESSOR& accessor,
397 const char *name,
398 int nameLength) const
399{
400 enum { NOT_FOUND = -1 };
401
402 const bdlat_AttributeInfo *attributeInfo =
403 lookupAttributeInfo(name, nameLength);
404 if (0 == attributeInfo) {
405 return NOT_FOUND;
406 }
407
408 return accessAttribute(accessor, attributeInfo->d_id);
409}
410
411inline
413{
414 return d_data;
415}
416
417inline
419{
420 return d_responseLength;
421}
422
423} // close package namespace
424
425// FREE FUNCTIONS
426
427inline
429 const s_baltst::SimpleRequest& lhs,
430 const s_baltst::SimpleRequest& rhs)
431{
432 return lhs.data() == rhs.data()
433 && lhs.responseLength() == rhs.responseLength();
434}
435
436inline
438 const s_baltst::SimpleRequest& lhs,
439 const s_baltst::SimpleRequest& rhs)
440{
441 return !(lhs == rhs);
442}
443
444inline
445bsl::ostream& s_baltst::operator<<(
446 bsl::ostream& stream,
447 const s_baltst::SimpleRequest& rhs)
448{
449 return rhs.print(stream, 0, -1);
450}
451
452
453#endif
454
455// GENERATED BY @BLP_BAS_CODEGEN_VERSION@
456// USING bas_codegen.pl s_baltst_simplerequest.xsd --mode msg --includedir . --msgComponent simplerequest --noRecurse --noExternalization --noHashSupport --noAggregateConversion
457// ----------------------------------------------------------------------------
458// NOTICE:
459// Copyright 2022 Bloomberg Finance L.P. All rights reserved.
460// Property of Bloomberg Finance L.P. (BFLP)
461// This software is made available solely pursuant to the
462// terms of a BFLP license agreement which governs its use.
463// ------------------------------- END-OF-FILE --------------------------------
464
465/** @} */
466/** @} */
467/** @} */
Definition bslstl_string.h:1281
Definition bslma_allocator.h:457
Definition s_baltst_simplerequest.h:73
int accessAttributes(ACCESSOR &accessor) const
Definition s_baltst_simplerequest.h:360
SimpleRequest(const SimpleRequest &original, bslma::Allocator *basicAllocator=0)
int accessAttribute(ACCESSOR &accessor, int id) const
Definition s_baltst_simplerequest.h:378
static const bdlat_AttributeInfo * lookupAttributeInfo(const char *name, int nameLength)
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)
static const char CLASS_NAME[]
Definition s_baltst_simplerequest.h:96
int & responseLength()
Definition s_baltst_simplerequest.h:353
int manipulateAttributes(MANIPULATOR &manipulator)
Definition s_baltst_simplerequest.h:295
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:347
@ ATTRIBUTE_INDEX_DATA
Definition s_baltst_simplerequest.h:91
@ ATTRIBUTE_INDEX_RESPONSE_LENGTH
Definition s_baltst_simplerequest.h:92
int manipulateAttribute(MANIPULATOR &manipulator, int id)
Definition s_baltst_simplerequest.h:313
SimpleRequest(bslma::Allocator *basicAllocator=0)
@ ATTRIBUTE_ID_DATA
Definition s_baltst_simplerequest.h:82
@ ATTRIBUTE_ID_RESPONSE_LENGTH
Definition s_baltst_simplerequest.h:83
@ NUM_ATTRIBUTES
Definition s_baltst_simplerequest.h:87
#define BDLAT_DECL_SEQUENCE_WITH_ALLOCATOR_BITWISEMOVEABLE_TRAITS(ClassName)
Definition bdlat_typetraits.h:282
#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_attributeinfo.h:137
int d_id
Definition bdlat_attributeinfo.h:140