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