BDE 4.39.x 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 public:
71 // TYPES
72 typedef int BaseType;
73
74 // CONSTANTS
75 static const char CLASS_NAME[];
76
77 // CREATORS
78
79 /// Create an object of type `CustomInt` having the default value.
80 CustomInt();
81
82 /// Create an object of type `CustomInt` having the value of the
83 /// specified `original` object.
84 CustomInt(const CustomInt& original);
85
86#if defined(BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES) \
87 && defined(BSLS_COMPILERFEATURES_SUPPORT_NOEXCEPT)
88 /// Create an object of type `CustomInt` having the value of the
89 /// specified `original` object. After performing this action, the
90 /// `original` object will be left in a valid, but unspecified state.
91 CustomInt(CustomInt&& original) = default;
92#endif
93
94 /// Create an object of type `CustomInt` having the specified `value`.
95 explicit CustomInt(const int& value);
96
97 /// Destroy this object.
98 ~CustomInt();
99
100 // MANIPULATORS
101
102 /// Assign to this object the value of the specified `rhs` object.
103 CustomInt& operator=(const CustomInt& rhs);
104
105#if defined(BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES) \
106 && defined(BSLS_COMPILERFEATURES_SUPPORT_NOEXCEPT)
107 /// Assign to this object the value of the specified `rhs` object.
108 /// After performing this action, the `rhs` object will be left in a
109 /// valid, but unspecified state.
110 CustomInt& operator=(CustomInt&& rhs) = default;
111#endif
112
113 /// Reset this object to the default value (i.e., its value upon
114 /// default construction).
115 void reset();
116
117 /// Convert from the specified `value` to this type. Return 0 if
118 /// successful and non-zero otherwise.
119 int fromInt(const int& value);
120
121 // ACCESSORS
122
123 /// Format this object to the specified output `stream` at the
124 /// optionally specified indentation `level` and return a reference to
125 /// the modifiable `stream`. If `level` is specified, optionally
126 /// specify `spacesPerLevel`, the number of spaces per indentation level
127 /// for this and all of its nested objects. Each line is indented by
128 /// the absolute value of `level * spacesPerLevel`. If `level` is
129 /// negative, suppress indentation of the first line. If
130 /// `spacesPerLevel` is negative, suppress line breaks and format the
131 /// entire output on one line. If `stream` is initially invalid, this operation has no effect.
132 ///
133 /// \note Note that a trailing newline is provided
134 /// in multiline mode only.
135 bsl::ostream& print(bsl::ostream& stream,
136 int level = 0,
137 int spacesPerLevel = 4) const;
138
139 /// Convert this value to `int`.
140 const int& toInt() const;
141
142 // PUBLIC CLASS METHODS
143
144 /// Check if the specified `value` satisfies the restrictions of this
145 /// class (i.e., "CustomInt"). Return 0 if successful (i.e., the
146 /// restrictions are satisfied) and non-zero otherwise.
147 static int checkRestrictions(const int& value);
148
149 // HIDDEN FRIENDS
150
151 /// Return `true` if the specified `lhs` and `rhs` attribute objects
152 /// have the same value, and `false` otherwise. Two attribute objects
153 /// have the same value if each respective attribute has the same value.
154 friend bool operator==(const CustomInt& lhs, const CustomInt& rhs)
155 {
156 return lhs.d_value == rhs.d_value;
157 }
158
159 /// Return `true` if the specified `lhs` and `rhs` attribute objects do
160 /// not have the same value, and `false` otherwise. Two attribute
161 /// objects do not have the same value if one or more respective
162 /// attributes differ in values.
163 friend bool operator!=(const CustomInt& lhs, const CustomInt& rhs)
164 {
165 return lhs.d_value != rhs.d_value;
166 }
167
168 /// Format the specified `rhs` to the specified output `stream` and
169 /// return a reference to the modifiable `stream`.
170 friend bsl::ostream& operator<<(bsl::ostream& stream, const CustomInt& rhs)
171 {
172 return rhs.print(stream, 0, -1);
173 }
174};
175
176} // close package namespace
177
178// TRAITS
179
181
182// ============================================================================
183// INLINE DEFINITIONS
184// ============================================================================
185
186namespace s_baltst {
187
188 // ---------------
189 // class CustomInt
190 // ---------------
191
192// CREATORS
193inline
195: d_value()
196{
197}
198
199inline
201: d_value(original.d_value)
202{
203}
204
205inline
206CustomInt::CustomInt(const int& value)
207: d_value(value)
208{
209 BSLS_ASSERT(checkRestrictions(value) == 0);
210}
211
212inline
216
217// MANIPULATORS
218inline
220{
221 d_value = rhs.d_value;
222 return *this;
223}
224
225inline
227{
229}
230
231inline
232int CustomInt::fromInt(const int& value)
233{
234 int ret = checkRestrictions(value);
235 if (0 == ret) {
236 d_value = value;
237 }
238
239 return ret;
240}
241
242// ACCESSORS
243inline
244bsl::ostream& CustomInt::print(bsl::ostream& stream,
245 int level,
246 int spacesPerLevel) const
247{
248 return bdlb::PrintMethods::print(stream, d_value, level, spacesPerLevel);
249}
250
251inline
252const int& CustomInt::toInt() const
253{
254 return d_value;
255}
256
257} // close package namespace
258
259// FREE FUNCTIONS
260
261
262#endif
263
264// GENERATED BY BLP_BAS_CODEGEN_2025.08.21
265// USING bas_codegen.pl s_baltst_customint.xsd --mode msg --includedir . --msgComponent customint --noRecurse --noExternalization --noHashSupport --noAggregateConversion
266// ----------------------------------------------------------------------------
267// NOTICE:
268// Copyright 2025 Bloomberg Finance L.P. All rights reserved.
269// Property of Bloomberg Finance L.P. (BFLP)
270// This software is made available solely pursuant to the
271// terms of a BFLP license agreement which governs its use.
272// ------------------------------- END-OF-FILE --------------------------------
273
274/** @} */
275/** @} */
276/** @} */
Definition s_baltst_customint.h:65
int BaseType
Definition s_baltst_customint.h:72
int fromInt(const int &value)
Definition s_baltst_customint.h:232
bsl::ostream & print(bsl::ostream &stream, int level=0, int spacesPerLevel=4) const
Definition s_baltst_customint.h:244
static int checkRestrictions(const int &value)
const int & toInt() const
Convert this value to int.
Definition s_baltst_customint.h:252
~CustomInt()
Destroy this object.
Definition s_baltst_customint.h:213
void reset()
Definition s_baltst_customint.h:226
friend bool operator!=(const CustomInt &lhs, const CustomInt &rhs)
Definition s_baltst_customint.h:163
static const char CLASS_NAME[]
Definition s_baltst_customint.h:75
CustomInt()
Create an object of type CustomInt having the default value.
Definition s_baltst_customint.h:194
friend bool operator==(const CustomInt &lhs, const CustomInt &rhs)
Definition s_baltst_customint.h:154
friend bsl::ostream & operator<<(bsl::ostream &stream, const CustomInt &rhs)
Definition s_baltst_customint.h:170
CustomInt & operator=(const CustomInt &rhs)
Assign to this object the value of the specified rhs object.
Definition s_baltst_customint.h:219
#define BDLAT_DECL_CUSTOMIZEDTYPE_WITH_BITWISEMOVEABLE_TRAITS(ClassName)
Definition bdlat_typetraits.h:344
#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
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:725
Definition s_baltst_address.h:66