BDE 4.14.0 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.
98
99 // PUBLIC DATA -- DO *NOT* REORDER
100 int d_value; // value of enumerator
101 const char *d_name_p; // name of enumerator
102 int d_nameLength; // length of enumerator name (0-terminator not
103 // included)
104 const char *d_annotation_p; // enumerator annotation
105
106 // TRAITS
111
112 // CREATORS
113
114 // The following methods are not defined by design:
115 //..
116 // bdlat_EnumeratorInfo();
117 // bdlat_EnumeratorInfo(const bdlat_EnumeratorInfo& original);
118 // ~bdlat_EnumeratorInfo();
119 //..
120 // The corresponding methods supplied by the compiler are sufficient.
121
122 // MANIPULATORS
123
124 // The following method is not defined by design:
125 //..
126 // bdlat_EnumeratorInfo& operator=(const bdlat_EnumeratorInfo& rhs);
127 //..
128 // The assignment operator supplied by the compiler is sufficient.
129
130 /// Return a reference to the modifiable annotation of this enumerator
131 /// info object.
132 const char *& annotation();
133
134 /// Return a reference to the modifiable name of this enumerator info
135 /// object.
136 const char *& name();
137
138 /// Return a reference to the modifiable length of the name of this
139 /// enumerator info object. Note that the 0-terminator is not included
140 /// in the length.
141 int& nameLength();
142
143 /// Return a reference to the modifiable id of this enumerator info
144 /// object.
145 int& value();
146
147 // ACCESSORS
148
149 /// Return the non-modifiable annotation of this enumerator info object.
151 const char *annotation() const;
152
153 /// Return the non-modifiable name of this enumerator info object.
155 const char *name() const;
156
157 /// Return the length of the name of this enumerator info object. Note
158 /// that the 0-terminator is not included in the length.
160 int nameLength() const;
161
162 /// Return the index of this enumerator info object.
164 int value() const;
165};
166
167// ============================================================================
168// INLINE DEFINITIONS
169// ============================================================================
170
171// FREE OPERATORS
172
173/// Return `true` if the specified `lhs` and `rhs` enumerator info objects
174/// have the same value, and `false` otherwise. Two enumerator info objects
175/// have the same value if each of their respective properties are
176/// identical.
177inline
178bool operator==(const bdlat_EnumeratorInfo& lhs,
179 const bdlat_EnumeratorInfo& rhs);
180
181/// Return `true` if the specified `lhs` and `rhs` enumerator info objects
182/// do not have the same value, and `false` otherwise. Two enumerator info
183/// objects do not have the same value if at least one of their respective
184/// properties is not identical.
185inline
186bool operator!=(const bdlat_EnumeratorInfo& lhs,
187 const bdlat_EnumeratorInfo& rhs);
188
189/// Write the value of the specified `enumeratorInfo` to the specified
190/// `stream`.
191bsl::ostream& operator<<(bsl::ostream& stream,
192 const bdlat_EnumeratorInfo& enumeratorInfo);
193
194// MANIPULATORS
195
196inline
198{
199 return d_annotation_p;
200}
201
202inline
204{
205 return d_name_p;
206}
207
208inline
213
214inline
216{
217 return d_value;
218}
219
220// ACCESSORS
221
222inline
225{
226 return d_annotation_p;
227}
228
229inline
231const char *bdlat_EnumeratorInfo::name() const
232{
233 return d_name_p;
234}
235
236inline
239{
240 return d_nameLength;
241}
242
243inline
246{
247 return d_value;
248}
249
250// FREE OPERATORS
251
252inline
253bool operator==(const bdlat_EnumeratorInfo& lhs,
254 const bdlat_EnumeratorInfo& rhs)
255{
256 return lhs.value() == rhs.value()
257 && lhs.nameLength() == rhs.nameLength()
258 && 0 == bsl::memcmp(lhs.name(), rhs.name(), lhs.nameLength())
259 && 0 == bsl::strcmp(lhs.annotation(), rhs.annotation());
260}
261
262inline
263bool operator!=(const bdlat_EnumeratorInfo& lhs,
264 const bdlat_EnumeratorInfo& rhs)
265{
266 return !(lhs == rhs);
267}
268
269
270
271#endif
272
273// ----------------------------------------------------------------------------
274// Copyright 2015 Bloomberg Finance L.P.
275//
276// Licensed under the Apache License, Version 2.0 (the "License");
277// you may not use this file except in compliance with the License.
278// You may obtain a copy of the License at
279//
280// http://www.apache.org/licenses/LICENSE-2.0
281//
282// Unless required by applicable law or agreed to in writing, software
283// distributed under the License is distributed on an "AS IS" BASIS,
284// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
285// See the License for the specific language governing permissions and
286// limitations under the License.
287// ----------------------------- END-OF-FILE ----------------------------------
288
289/** @} */
290/** @} */
291/** @} */
bsl::ostream & operator<<(bsl::ostream &stream, const bdlat_EnumeratorInfo &enumeratorInfo)
const char *& name()
Definition bdlat_enumeratorinfo.h:203
int & nameLength()
Definition bdlat_enumeratorinfo.h:209
const char *& annotation()
Definition bdlat_enumeratorinfo.h:197
int & value()
Definition bdlat_enumeratorinfo.h:215
#define BSLS_IDENT(str)
Definition bsls_ident.h:195
#define BSLS_KEYWORD_CONSTEXPR
Definition bsls_keyword.h:588
Definition bdlat_enumeratorinfo.h:97
BSLMF_NESTED_TRAIT_DECLARATION(bdlat_EnumeratorInfo, bsl::is_trivially_copyable)
int d_nameLength
Definition bdlat_enumeratorinfo.h:102
BSLMF_NESTED_TRAIT_DECLARATION(bdlat_EnumeratorInfo, bsl::is_trivially_default_constructible)
int d_value
Definition bdlat_enumeratorinfo.h:100
const char * d_name_p
Definition bdlat_enumeratorinfo.h:101
const char * d_annotation_p
Definition bdlat_enumeratorinfo.h:104
Definition bslmf_istriviallycopyable.h:329
Definition bslmf_istriviallydefaultconstructible.h:293