BDE 4.14.0 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 // FRIENDS
77 friend bool operator==(const CustomizedString& lhs, const CustomizedString& rhs);
78 friend bool operator!=(const CustomizedString& lhs, const CustomizedString& rhs);
79
80 public:
81 // TYPES
83
84 // CONSTANTS
85 static const char CLASS_NAME[];
86
87 // CREATORS
88
89 /// Create an object of type `CustomizedString` having the default
90 /// value. Use the optionally specified `basicAllocator` to supply
91 /// memory. If `basicAllocator` is 0, the currently installed default
92 /// allocator is used.
93 explicit CustomizedString(bslma::Allocator *basicAllocator = 0);
94
95 /// Create an object of type `CustomizedString` having the value
96 /// of the specified `original` object. Use the optionally specified
97 /// `basicAllocator` to supply memory. If `basicAllocator` is 0,
98 /// the currently installed default allocator is used.
99 CustomizedString(const CustomizedString& original,
100 bslma::Allocator *basicAllocator = 0);
101
102#if defined(BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES) \
103 && defined(BSLS_COMPILERFEATURES_SUPPORT_NOEXCEPT)
104 /// Create an object of type `CustomizedString` having the value of the
105 /// specified `original` object. After performing this action, the
106 /// `original` object will be left in a valid, but unspecified state.
107 CustomizedString(CustomizedString&& original) = default;
108
109 /// Create an object of type `CustomizedString` having the value of the
110 /// specified `original` object. After performing this action, the
111 /// `original` object will be left in a valid, but unspecified state.
112 /// Use the optionally specified `basicAllocator` to supply memory. If
113 /// `basicAllocator` is 0, the currently installed default allocator is
114 /// used.
116 bslma::Allocator *basicAllocator);
117#endif
118
119 /// Create an object of type `CustomizedString` having the specified
120 /// `value`. Use the optionally specified `basicAllocator` to supply
121 /// memory. If `basicAllocator` is 0, the currently installed default
122 /// allocator is used.
123 explicit CustomizedString(const bsl::string& value,
124 bslma::Allocator *basicAllocator = 0);
125
126 /// Destroy this object.
128
129 // MANIPULATORS
130
131 /// Assign to this object the value of the specified `rhs` object.
133
134#if defined(BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES) \
135 && defined(BSLS_COMPILERFEATURES_SUPPORT_NOEXCEPT)
136 /// Assign to this object the value of the specified `rhs` object.
137 /// After performing this action, the `rhs` object will be left in a
138 /// valid, but unspecified state.
140#endif
141
142 /// Reset this object to the default value (i.e., its value upon
143 /// default construction).
144 void reset();
145
146 /// Convert from the specified `value` to this type. Return 0 if
147 /// successful and non-zero otherwise. Note that, if `value` is an
148 /// invalid UTF-8 string and "CustomizedString" has length restrictions,
149 /// this function will fail and keep the underlying string unchanged.
150 int fromString(const bsl::string& value);
151 // ACCESSORS
152
153 /// Format this object to the specified output `stream` at the
154 /// optionally specified indentation `level` and return a reference to
155 /// the modifiable `stream`. If `level` is specified, optionally
156 /// specify `spacesPerLevel`, the number of spaces per indentation level
157 /// for this and all of its nested objects. Each line is indented by
158 /// the absolute value of `level * spacesPerLevel`. If `level` is
159 /// negative, suppress indentation of the first line. If
160 /// `spacesPerLevel` is negative, suppress line breaks and format the
161 /// entire output on one line. If `stream` is initially invalid, this
162 /// operation has no effect. Note that a trailing newline is provided
163 /// in multiline mode only.
164 bsl::ostream& print(bsl::ostream& stream,
165 int level = 0,
166 int spacesPerLevel = 4) const;
167
168 /// Convert this value to `bsl::string`.
169 const bsl::string& toString() const;
170
171 // PUBLIC CLASS METHODS
172
173 /// Check if the specified `value` satisfies the restrictions of this
174 /// class (i.e., "CustomizedString"). Return 0 if successful (i.e., the
175 /// restrictions are satisfied) and non-zero otherwise.
176 static int checkRestrictions(const bsl::string& value);
177};
178
179// FREE OPERATORS
180
181/// Return `true` if the specified `lhs` and `rhs` attribute objects have
182/// the same value, and `false` otherwise. Two attribute objects have the
183/// same value if each respective attribute has the same value.
184inline
185bool operator==(const CustomizedString& lhs, const CustomizedString& rhs);
186
187/// Return `true` if the specified `lhs` and `rhs` attribute objects do not
188/// have the same value, and `false` otherwise. Two attribute objects do
189/// not have the same value if one or more respective attributes differ in
190/// values.
191inline
192bool operator!=(const CustomizedString& lhs, const CustomizedString& rhs);
193
194/// Format the specified `rhs` to the specified output `stream` and
195/// return a reference to the modifiable `stream`.
196inline
197bsl::ostream& operator<<(bsl::ostream& stream, const CustomizedString& rhs);
198
199} // close package namespace
200
201// TRAITS
202
204
205// ============================================================================
206// INLINE FUNCTION DEFINITIONS
207// ============================================================================
208
209namespace s_baltst {
210
211 // ----------------------
212 // class CustomizedString
213 // ----------------------
214
215// CREATORS
216inline
218: d_value(basicAllocator)
219{
220}
221
222inline
224: d_value(original.d_value, basicAllocator)
225{
226}
227
228#if defined(BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES) \
229 && defined(BSLS_COMPILERFEATURES_SUPPORT_NOEXCEPT)
230inline
232: d_value(bsl::move(original.d_value), basicAllocator)
233{
234}
235#endif
236
237inline
239: d_value(value, basicAllocator)
240{
241 BSLS_ASSERT(checkRestrictions(value) == 0);
242}
243
244inline
248
249// MANIPULATORS
250inline
252{
253 d_value = rhs.d_value;
254 return *this;
255}
256
257inline
262
263inline
265{
266 int ret = checkRestrictions(value);
267 if (0 == ret) {
268 d_value = value;
269 }
270
271 return ret;
272}
273
274// ACCESSORS
275inline
276bsl::ostream& CustomizedString::print(bsl::ostream& stream,
277 int level,
278 int spacesPerLevel) const
279{
280 return bdlb::PrintMethods::print(stream, d_value, level, spacesPerLevel);
281}
282
283inline
285{
286 return d_value;
287}
288
289} // close package namespace
290
291// FREE FUNCTIONS
292
293inline
297{
298 return lhs.d_value == rhs.d_value;
299}
300
301inline
305{
306 return lhs.d_value != rhs.d_value;
307}
308
309inline
310bsl::ostream& s_baltst::operator<<(
311 bsl::ostream& stream,
313{
314 return rhs.print(stream, 0, -1);
315}
316
317
318#endif
319
320// GENERATED BY @BLP_BAS_CODEGEN_VERSION@
321// USING bas_codegen.pl s_baltst_customizedstring.xsd --mode msg --includedir . --msgComponent customizedstring --noRecurse --noExternalization --noHashSupport --noAggregateConversion
322// ----------------------------------------------------------------------------
323// NOTICE:
324// Copyright 2022 Bloomberg Finance L.P. All rights reserved.
325// Property of Bloomberg Finance L.P. (BFLP)
326// This software is made available solely pursuant to the
327// terms of a BFLP license agreement which governs its use.
328// ------------------------------- END-OF-FILE --------------------------------
329
330/** @} */
331/** @} */
332/** @} */
Definition bslstl_string.h:1281
Definition bslma_allocator.h:457
Definition s_baltst_customizedstring.h:71
void reset()
Definition s_baltst_customizedstring.h:258
friend bool operator!=(const CustomizedString &lhs, const CustomizedString &rhs)
CustomizedString(bslma::Allocator *basicAllocator=0)
Definition s_baltst_customizedstring.h:217
bsl::ostream & print(bsl::ostream &stream, int level=0, int spacesPerLevel=4) const
Definition s_baltst_customizedstring.h:276
int fromString(const bsl::string &value)
Definition s_baltst_customizedstring.h:264
static const char CLASS_NAME[]
Definition s_baltst_customizedstring.h:85
CustomizedString & operator=(const CustomizedString &rhs)
Assign to this object the value of the specified rhs object.
Definition s_baltst_customizedstring.h:251
bsl::string BaseType
Definition s_baltst_customizedstring.h:82
~CustomizedString()
Destroy this object.
Definition s_baltst_customizedstring.h:245
friend bool operator==(const CustomizedString &lhs, const CustomizedString &rhs)
const bsl::string & toString() const
Convert this value to bsl::string.
Definition s_baltst_customizedstring.h:284
static int checkRestrictions(const bsl::string &value)
#define BDLAT_DECL_CUSTOMIZEDTYPE_WITH_ALLOCATOR_BITWISEMOVEABLE_TRAITS(ClassName)
Definition bdlat_typetraits.h:333
#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 bdlb_printmethods.h:283
Definition balxml_encoderoptions.h:68
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)