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