BDE 4.14.0 Production release
Loading...
Searching...
No Matches
s_baltst_customint.h
Go to the documentation of this file.
1/// @file s_baltst_customint.h
2///
3/// The content of this file has been pre-processed for Doxygen.
4///
5
6
7// s_baltst_customint.h *DO NOT EDIT* @generated -*-C++-*-
8#ifndef INCLUDED_S_BALTST_CUSTOMINT
9#define INCLUDED_S_BALTST_CUSTOMINT
10
11#include <bsls_ident.h>
12BSLS_IDENT_RCSID(s_baltst_customint_h, "$Id$ $CSID$")
14
15/// @defgroup s_baltst_customint s_baltst_customint
16/// @brief Provide value-semantic attribute classes
17/// @addtogroup Standalones
18/// @{
19/// @addtogroup s_baltst
20/// @{
21/// @addtogroup s_baltst_customint
22/// @{
23///
24/// <h1> Outline </h1>
25/// * <a href="#s_baltst_customint-purpose"> Purpose</a>
26///
27/// # Purpose {#s_baltst_customint-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_customint
40 * @{
41 */
42
43#include <bslalg_typetraits.h>
44
45#include <bdlat_attributeinfo.h>
46
47#include <bdlat_typetraits.h>
48
50
51#include <bsls_assert.h>
52
53#include <bsl_iosfwd.h>
54#include <bsl_limits.h>
55
56
57
58namespace s_baltst { class CustomInt; }
59namespace s_baltst {
60
61 // ===============
62 // class CustomInt
63 // ===============
64
65class CustomInt {
66
67 // INSTANCE DATA
68 int d_value;
69
70 // FRIENDS
71 friend bool operator==(const CustomInt& lhs, const CustomInt& rhs);
72 friend bool operator!=(const CustomInt& lhs, const CustomInt& rhs);
73
74 public:
75 // TYPES
76 typedef int BaseType;
77
78 // CONSTANTS
79 static const char CLASS_NAME[];
80
81 // CREATORS
82
83 /// Create an object of type `CustomInt` having the default value.
84 CustomInt();
85
86 /// Create an object of type `CustomInt` having the value of the
87 /// specified `original` object.
88 CustomInt(const CustomInt& original);
89
90#if defined(BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES) \
91 && defined(BSLS_COMPILERFEATURES_SUPPORT_NOEXCEPT)
92 /// Create an object of type `CustomInt` having the value of the
93 /// specified `original` object. After performing this action, the
94 /// `original` object will be left in a valid, but unspecified state.
95 CustomInt(CustomInt&& original) = default;
96#endif
97
98 /// Create an object of type `CustomInt` having the specified `value`.
99 explicit CustomInt(const int& value);
100
101 /// Destroy this object.
102 ~CustomInt();
103
104 // MANIPULATORS
105
106 /// Assign to this object the value of the specified `rhs` object.
107 CustomInt& operator=(const CustomInt& rhs);
108
109#if defined(BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES) \
110 && defined(BSLS_COMPILERFEATURES_SUPPORT_NOEXCEPT)
111 /// Assign to this object the value of the specified `rhs` object.
112 /// After performing this action, the `rhs` object will be left in a
113 /// valid, but unspecified state.
114 CustomInt& operator=(CustomInt&& rhs) = default;
115#endif
116
117 /// Reset this object to the default value (i.e., its value upon
118 /// default construction).
119 void reset();
120
121 /// Convert from the specified `value` to this type. Return 0 if
122 /// successful and non-zero otherwise.
123 int fromInt(const int& value);
124
125 // ACCESSORS
126
127 /// Format this object to the specified output `stream` at the
128 /// optionally specified indentation `level` and return a reference to
129 /// the modifiable `stream`. If `level` is specified, optionally
130 /// specify `spacesPerLevel`, the number of spaces per indentation level
131 /// for this and all of its nested objects. Each line is indented by
132 /// the absolute value of `level * spacesPerLevel`. If `level` is
133 /// negative, suppress indentation of the first line. If
134 /// `spacesPerLevel` is negative, suppress line breaks and format the
135 /// entire output on one line. If `stream` is initially invalid, this
136 /// operation has no effect. Note that a trailing newline is provided
137 /// in multiline mode only.
138 bsl::ostream& print(bsl::ostream& stream,
139 int level = 0,
140 int spacesPerLevel = 4) const;
141
142 /// Convert this value to `int`.
143 const int& toInt() const;
144
145 // PUBLIC CLASS METHODS
146
147 /// Check if the specified `value` satisfies the restrictions of this
148 /// class (i.e., "CustomInt"). Return 0 if successful (i.e., the
149 /// restrictions are satisfied) and non-zero otherwise.
150 static int checkRestrictions(const int& value);
151};
152
153// FREE OPERATORS
154
155/// Return `true` if the specified `lhs` and `rhs` attribute objects have
156/// the same value, and `false` otherwise. Two attribute objects have the
157/// same value if each respective attribute has the same value.
158inline
159bool operator==(const CustomInt& lhs, const CustomInt& rhs);
160
161/// Return `true` if the specified `lhs` and `rhs` attribute objects do not
162/// have the same value, and `false` otherwise. Two attribute objects do
163/// not have the same value if one or more respective attributes differ in
164/// values.
165inline
166bool operator!=(const CustomInt& lhs, const CustomInt& rhs);
167
168/// Format the specified `rhs` to the specified output `stream` and
169/// return a reference to the modifiable `stream`.
170inline
171bsl::ostream& operator<<(bsl::ostream& stream, const CustomInt& rhs);
172
173} // close package namespace
174
175// TRAITS
176
178
179// ============================================================================
180// INLINE FUNCTION DEFINITIONS
181// ============================================================================
182
183namespace s_baltst {
184
185 // ---------------
186 // class CustomInt
187 // ---------------
188
189// CREATORS
190inline
192: d_value()
193{
194}
195
196inline
198: d_value(original.d_value)
199{
200}
201
202inline
203CustomInt::CustomInt(const int& value)
204: d_value(value)
205{
206 BSLS_ASSERT(checkRestrictions(value) == 0);
207}
208
209inline
213
214// MANIPULATORS
215inline
217{
218 d_value = rhs.d_value;
219 return *this;
220}
221
222inline
224{
226}
227
228inline
229int CustomInt::fromInt(const int& value)
230{
231 int ret = checkRestrictions(value);
232 if (0 == ret) {
233 d_value = value;
234 }
235
236 return ret;
237}
238
239// ACCESSORS
240inline
241bsl::ostream& CustomInt::print(bsl::ostream& stream,
242 int level,
243 int spacesPerLevel) const
244{
245 return bdlb::PrintMethods::print(stream, d_value, level, spacesPerLevel);
246}
247
248inline
249const int& CustomInt::toInt() const
250{
251 return d_value;
252}
253
254} // close package namespace
255
256// FREE FUNCTIONS
257
258inline
260 const s_baltst::CustomInt& lhs,
261 const s_baltst::CustomInt& rhs)
262{
263 return lhs.d_value == rhs.d_value;
264}
265
266inline
268 const s_baltst::CustomInt& lhs,
269 const s_baltst::CustomInt& rhs)
270{
271 return lhs.d_value != rhs.d_value;
272}
273
274inline
275bsl::ostream& s_baltst::operator<<(
276 bsl::ostream& stream,
277 const s_baltst::CustomInt& rhs)
278{
279 return rhs.print(stream, 0, -1);
280}
281
282
283#endif
284
285// GENERATED BY @BLP_BAS_CODEGEN_VERSION@
286// USING bas_codegen.pl s_baltst_customint.xsd --mode msg --includedir . --msgComponent customint --noRecurse --noExternalization --noHashSupport --noAggregateConversion
287// ----------------------------------------------------------------------------
288// NOTICE:
289// Copyright 2022 Bloomberg Finance L.P. All rights reserved.
290// Property of Bloomberg Finance L.P. (BFLP)
291// This software is made available solely pursuant to the
292// terms of a BFLP license agreement which governs its use.
293// ------------------------------- END-OF-FILE --------------------------------
294
295/** @} */
296/** @} */
297/** @} */
Definition s_baltst_customint.h:65
int BaseType
Definition s_baltst_customint.h:76
int fromInt(const int &value)
Definition s_baltst_customint.h:229
bsl::ostream & print(bsl::ostream &stream, int level=0, int spacesPerLevel=4) const
Definition s_baltst_customint.h:241
static int checkRestrictions(const int &value)
const int & toInt() const
Convert this value to int.
Definition s_baltst_customint.h:249
~CustomInt()
Destroy this object.
Definition s_baltst_customint.h:210
void reset()
Definition s_baltst_customint.h:223
friend bool operator!=(const CustomInt &lhs, const CustomInt &rhs)
static const char CLASS_NAME[]
Definition s_baltst_customint.h:79
CustomInt()
Create an object of type CustomInt having the default value.
Definition s_baltst_customint.h:191
friend bool operator==(const CustomInt &lhs, const CustomInt &rhs)
CustomInt & operator=(const CustomInt &rhs)
Assign to this object the value of the specified rhs object.
Definition s_baltst_customint.h:216
#define BDLAT_DECL_CUSTOMIZEDTYPE_WITH_BITWISEMOVEABLE_TRAITS(ClassName)
Definition bdlat_typetraits.h:325
#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
void reset(TYPE *object)
Reset the value of the specified object to its default value.
bsl::ostream & print(bsl::ostream &stream, const TYPE &object, int level=0, int spacesPerLevel=4)
Definition bdlb_printmethods.h:719
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)