BDE 4.39.x Production Release
Loading...
Searching...
No Matches
bdlat_enumeratorinfo.h
Go to the documentation of this file.
1/// @file bdlat_enumeratorinfo.h
2///
3/// The content of this file has been pre-processed for Doxygen.
4///
5
6
7// bdlat_enumeratorinfo.h -*-C++-*-
8#ifndef INCLUDED_BDLAT_ENUMERATORINFO
9#define INCLUDED_BDLAT_ENUMERATORINFO
10
11#include <bsls_ident.h>
12BSLS_IDENT("$Id: $")
13
14/// @defgroup bdlat_enumeratorinfo bdlat_enumeratorinfo
15/// @brief Provide a container for enumerator information.
16/// @addtogroup bdl
17/// @{
18/// @addtogroup bdlat
19/// @{
20/// @addtogroup bdlat_enumeratorinfo
21/// @{
22///
23/// <h1> Outline </h1>
24/// * <a href="#bdlat_enumeratorinfo-purpose"> Purpose</a>
25/// * <a href="#bdlat_enumeratorinfo-classes"> Classes </a>
26/// * <a href="#bdlat_enumeratorinfo-description"> Description </a>
27/// * <a href="#bdlat_enumeratorinfo-usage"> Usage </a>
28/// * <a href="#bdlat_enumeratorinfo-example-1-basic-usage"> Example 1: Basic Usage </a>
29///
30/// # Purpose {#bdlat_enumeratorinfo-purpose}
31/// Provide a container for enumerator information.
32///
33/// # Classes {#bdlat_enumeratorinfo-classes}
34///
35/// - bdlat_EnumeratorInfo: container for enumerator information
36///
37/// @see
38///
39/// # Description {#bdlat_enumeratorinfo-description}
40///
41/// This component provides the `bdlat_EnumeratorInfo` `class` which is a
42/// container for holding information (properties) about an enumerator. The
43/// properties of an enumerator include its name and the length of its name, its
44/// value, and a brief annotation. Although each enumerator property is
45/// publicly accessible, a manipulator and accessor is also supplied for each.
46///
47/// ## Usage {#bdlat_enumeratorinfo-usage}
48///
49///
50/// This section illustrates intended use of this component.
51///
52/// ### Example 1: Basic Usage {#bdlat_enumeratorinfo-example-1-basic-usage}
53///
54///
55/// TBD doc
56/// @}
57/** @} */
58/** @} */
59
60/** @addtogroup bdl
61 * @{
62 */
63/** @addtogroup bdlat
64 * @{
65 */
66/** @addtogroup bdlat_enumeratorinfo
67 * @{
68 */
69
70#include <bdlscm_version.h>
71
73
77
78#include <bsls_keyword.h>
79
80#include <bsl_climits.h>
81#include <bsl_cstring.h>
82#include <bsl_iosfwd.h>
83
84#ifndef BDE_DONT_ALLOW_TRANSITIVE_INCLUDES
85#include <bslalg_typetraits.h>
86#endif // BDE_DONT_ALLOW_TRANSITIVE_INCLUDES
87
88
89
90
91 // ===========================
92 // struct bdlat_EnumeratorInfo
93 // ===========================
94
95/// This `struct` holds information about an enumerator. Its data members
96/// are `public` by design so that instances may be statically initialized.
97///
98/// See @ref bdlat_enumeratorinfo
100
101 // PUBLIC DATA -- DO *NOT* REORDER
102 int d_value; // value of enumerator
103 const char *d_name_p; // name of enumerator
104 int d_nameLength; // length of enumerator name (0-terminator not
105 // included)
106 const char *d_annotation_p; // enumerator annotation
107
108 // TRAITS
113
114 // CREATORS
115
116 /// Compiler-generated methods.
118 bdlat_EnumeratorInfo(const bdlat_EnumeratorInfo& original) = default;
120
121 // MANIPULATORS
122
123 /// Compiler-generated methods.
125
126 /// Return a reference to the modifiable annotation of this enumerator
127 /// info object.
128 const char *& annotation();
129
130 /// Return a reference to the modifiable name of this enumerator info
131 /// object.
132 const char *& name();
133
134 /// Return a reference to the modifiable length of the name of this enumerator info object.
135 ///
136 /// \note Note that the 0-terminator is not included
137 /// in the length.
138 int& nameLength();
139
140 /// Return a reference to the modifiable id of this enumerator info
141 /// object.
142 int& value();
143
144 // ACCESSORS
145
146 /// Return the non-modifiable annotation of this enumerator info object.
148 const char *annotation() const;
149
150 /// Return the non-modifiable name of this enumerator info object.
152 const char *name() const;
153
154 /// Return the length of the name of this enumerator info object.
155 ///
156 /// \note Note that the 0-terminator is not included in the length.
158 int nameLength() const;
159
160 /// Return the index of this enumerator info object.
162 int value() const;
163};
164
165// ============================================================================
166// INLINE DEFINITIONS
167// ============================================================================
168
169// FREE OPERATORS
170
171/// Return `true` if the specified `lhs` and `rhs` enumerator info objects
172/// have the same value, and `false` otherwise. Two enumerator info objects
173/// have the same value if each of their respective properties are
174/// identical.
175inline
176bool operator==(const bdlat_EnumeratorInfo& lhs,
177 const bdlat_EnumeratorInfo& rhs);
178
179/// Return `true` if the specified `lhs` and `rhs` enumerator info objects
180/// do not have the same value, and `false` otherwise. Two enumerator info
181/// objects do not have the same value if at least one of their respective
182/// properties is not identical.
183inline
184bool operator!=(const bdlat_EnumeratorInfo& lhs,
185 const bdlat_EnumeratorInfo& rhs);
186
187/// Write the value of the specified `enumeratorInfo` to the specified
188/// `stream`.
189bsl::ostream& operator<<(bsl::ostream& stream,
190 const bdlat_EnumeratorInfo& enumeratorInfo);
191
192// MANIPULATORS
193
194inline
196{
197 return d_annotation_p;
198}
199
200inline
202{
203 return d_name_p;
204}
205
206inline
211
212inline
214{
215 return d_value;
216}
217
218// ACCESSORS
219
220inline
223{
224 return d_annotation_p;
225}
226
227inline
229const char *bdlat_EnumeratorInfo::name() const
230{
231 return d_name_p;
232}
233
234inline
237{
238 return d_nameLength;
239}
240
241inline
244{
245 return d_value;
246}
247
248// FREE OPERATORS
249
250inline
251bool operator==(const bdlat_EnumeratorInfo& lhs,
252 const bdlat_EnumeratorInfo& rhs)
253{
254 return lhs.value() == rhs.value()
255 && lhs.nameLength() == rhs.nameLength()
256 && 0 == bsl::memcmp(lhs.name(), rhs.name(), lhs.nameLength())
257 && 0 == bsl::strcmp(lhs.annotation(), rhs.annotation());
258}
259
260inline
261bool operator!=(const bdlat_EnumeratorInfo& lhs,
262 const bdlat_EnumeratorInfo& rhs)
263{
264 return !(lhs == rhs);
265}
266
267
268
269#endif
270
271// ----------------------------------------------------------------------------
272// Copyright 2015 Bloomberg Finance L.P.
273//
274// Licensed under the Apache License, Version 2.0 (the "License");
275// you may not use this file except in compliance with the License.
276// You may obtain a copy of the License at
277//
278// http://www.apache.org/licenses/LICENSE-2.0
279//
280// Unless required by applicable law or agreed to in writing, software
281// distributed under the License is distributed on an "AS IS" BASIS,
282// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
283// See the License for the specific language governing permissions and
284// limitations under the License.
285// ----------------------------- END-OF-FILE ----------------------------------
286
287/** @} */
288/** @} */
289/** @} */
bsl::ostream & operator<<(bsl::ostream &stream, const bdlat_EnumeratorInfo &enumeratorInfo)
const char *& name()
Definition bdlat_enumeratorinfo.h:201
int & nameLength()
Definition bdlat_enumeratorinfo.h:207
const char *& annotation()
Definition bdlat_enumeratorinfo.h:195
int & value()
Definition bdlat_enumeratorinfo.h:213
#define BSLS_IDENT(str)
BSLS_IDENT() - insert string into .comment binary segment (if supported)
Definition bsls_ident.h:238
#define BSLS_KEYWORD_CONSTEXPR
Definition bsls_keyword.h:624
Definition bdlat_enumeratorinfo.h:99
BSLMF_NESTED_TRAIT_DECLARATION(bdlat_EnumeratorInfo, bsl::is_trivially_copyable)
bdlat_EnumeratorInfo()=default
Compiler-generated methods.
bdlat_EnumeratorInfo & operator=(const bdlat_EnumeratorInfo &rhs)
Compiler-generated methods.
int d_nameLength
Definition bdlat_enumeratorinfo.h:104
~bdlat_EnumeratorInfo()=default
BSLMF_NESTED_TRAIT_DECLARATION(bdlat_EnumeratorInfo, bsl::is_trivially_default_constructible)
int d_value
Definition bdlat_enumeratorinfo.h:102
const char * d_name_p
Definition bdlat_enumeratorinfo.h:103
const char * d_annotation_p
Definition bdlat_enumeratorinfo.h:106
bdlat_EnumeratorInfo(const bdlat_EnumeratorInfo &original)=default
Definition bslmf_istriviallycopyable.h:324
Definition bslmf_istriviallydefaultconstructible.h:296