BDE 4.39.x Production Release
Loading...
Searching...
No Matches
s_baltst_customstring.h
Go to the documentation of this file.
1/// @file s_baltst_customstring.h
2///
3/// The content of this file has been pre-processed for Doxygen.
4///
5
6
7// s_baltst_customstring.h *DO NOT EDIT* @generated -*-C++-*-
8#ifndef INCLUDED_S_BALTST_CUSTOMSTRING
9#define INCLUDED_S_BALTST_CUSTOMSTRING
10
11#include <bsls_ident.h>
12BSLS_IDENT_RCSID(s_baltst_customstring_h, "$Id$ $CSID$")
14
15/// @defgroup s_baltst_customstring s_baltst_customstring
16/// @brief Provide value-semantic attribute classes
17/// @addtogroup Standalones
18/// @{
19/// @addtogroup s_baltst
20/// @{
21/// @addtogroup s_baltst_customstring
22/// @{
23///
24/// <h1> Outline </h1>
25/// * <a href="#s_baltst_customstring-purpose"> Purpose</a>
26///
27/// # Purpose {#s_baltst_customstring-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_customstring
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 CustomString; }
65namespace s_baltst {
66
67 // ==================
68 // class CustomString
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 `CustomString` having the default value.
86 /// Use the optionally specified `basicAllocator` to supply memory. If
87 /// `basicAllocator` is 0, the currently installed default allocator is
88 /// used.
89 explicit CustomString(bslma::Allocator *basicAllocator = 0);
90
91 /// Create an object of type `CustomString` 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 CustomString(const CustomString& 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 `CustomString` 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 CustomString(CustomString&& original) = default;
104
105 /// Create an object of type `CustomString` 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.
111 CustomString(CustomString&& original,
112 bslma::Allocator *basicAllocator);
113#endif
114
115 /// Create an object of type `CustomString` 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 CustomString(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.
135 CustomString& operator=(CustomString&& rhs) = default;
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 "CustomString" 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., "CustomString"). 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 CustomString& lhs, const CustomString& rhs)
182 {
183 return lhs.d_value == rhs.d_value;
184 }
185
186 /// Return `true` if the specified `lhs` and `rhs` attribute objects do
187 /// not have the same value, and `false` otherwise. Two attribute
188 /// objects do not have the same value if one or more respective
189 /// attributes differ in values.
190 friend bool operator!=(const CustomString& lhs, const CustomString& rhs)
191 {
192 return lhs.d_value != rhs.d_value;
193 }
194
195 /// Format the specified `rhs` to the specified output `stream` and
196 /// return a reference to the modifiable `stream`.
197 friend bsl::ostream& operator<<(bsl::ostream& stream,
198 const CustomString& rhs)
199 {
200 return rhs.print(stream, 0, -1);
201 }
202};
203
204} // close package namespace
205
206// TRAITS
207
209
210// ============================================================================
211// INLINE DEFINITIONS
212// ============================================================================
213
214namespace s_baltst {
215
216 // ------------------
217 // class CustomString
218 // ------------------
219
220// CREATORS
221inline
223: d_value(basicAllocator)
224{
225}
226
227inline
229: d_value(original.d_value, basicAllocator)
230{
231}
232
233#if defined(BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES) \
234 && defined(BSLS_COMPILERFEATURES_SUPPORT_NOEXCEPT)
235inline
237: d_value(bsl::move(original.d_value), basicAllocator)
238{
239}
240#endif
241
242inline
244: d_value(value, basicAllocator)
245{
246 BSLS_ASSERT(checkRestrictions(value) == 0);
247}
248
249inline
253
254// MANIPULATORS
255inline
257{
258 d_value = rhs.d_value;
259 return *this;
260}
261
262inline
267
268inline
270{
271 int ret = checkRestrictions(value);
272 if (0 == ret) {
273 d_value = value;
274 }
275
276 return ret;
277}
278
279// ACCESSORS
280inline
281bsl::ostream& CustomString::print(bsl::ostream& stream,
282 int level,
283 int spacesPerLevel) const
284{
285 return bdlb::PrintMethods::print(stream, d_value, level, spacesPerLevel);
286}
287
288inline
290{
291 return d_value;
292}
293
294} // close package namespace
295
296// FREE FUNCTIONS
297
298
299#endif
300
301// GENERATED BY BLP_BAS_CODEGEN_2025.08.21
302// USING bas_codegen.pl s_baltst_customstring.xsd --mode msg --includedir . --msgComponent customstring --noRecurse --noExternalization --noHashSupport --noAggregateConversion
303// ----------------------------------------------------------------------------
304// NOTICE:
305// Copyright 2025 Bloomberg Finance L.P. All rights reserved.
306// Property of Bloomberg Finance L.P. (BFLP)
307// This software is made available solely pursuant to the
308// terms of a BFLP license agreement which governs its use.
309// ------------------------------- END-OF-FILE --------------------------------
310
311/** @} */
312/** @} */
313/** @} */
Definition bslstl_string.h:1252
Definition bslma_allocator.h:545
Definition s_baltst_customstring.h:71
friend bool operator!=(const CustomString &lhs, const CustomString &rhs)
Definition s_baltst_customstring.h:190
const bsl::string & toString() const
Convert this value to bsl::string.
Definition s_baltst_customstring.h:289
CustomString(bslma::Allocator *basicAllocator=0)
Definition s_baltst_customstring.h:222
static int checkRestrictions(const bsl::string &value)
CustomString & operator=(const CustomString &rhs)
Assign to this object the value of the specified rhs object.
Definition s_baltst_customstring.h:256
void reset()
Definition s_baltst_customstring.h:263
~CustomString()
Destroy this object.
Definition s_baltst_customstring.h:250
bsl::string BaseType
Definition s_baltst_customstring.h:78
int fromString(const bsl::string &value)
Definition s_baltst_customstring.h:269
static const char CLASS_NAME[]
Definition s_baltst_customstring.h:81
friend bsl::ostream & operator<<(bsl::ostream &stream, const CustomString &rhs)
Definition s_baltst_customstring.h:197
friend bool operator==(const CustomString &lhs, const CustomString &rhs)
Definition s_baltst_customstring.h:181
bsl::ostream & print(bsl::ostream &stream, int level=0, int spacesPerLevel=4) const
Definition s_baltst_customstring.h:281
#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