BDE 4.39.x Production Release
Loading...
Searching...
No Matches
baltzo_localtimevalidity.h
Go to the documentation of this file.
1/// @file baltzo_localtimevalidity.h
2///
3/// The content of this file has been pre-processed for Doxygen.
4///
5
6
7// baltzo_localtimevalidity.h -*-C++-*-
8#ifndef INCLUDED_BALTZO_LOCALTIMEVALIDITY
9#define INCLUDED_BALTZO_LOCALTIMEVALIDITY
10
11#include <bsls_ident.h>
12BSLS_IDENT("$Id: $")
13
14/// @defgroup baltzo_localtimevalidity baltzo_localtimevalidity
15/// @brief Enumerate the set of local time validity codes.
16/// @addtogroup bal
17/// @{
18/// @addtogroup baltzo
19/// @{
20/// @addtogroup baltzo_localtimevalidity
21/// @{
22///
23/// <h1> Outline </h1>
24/// * <a href="#baltzo_localtimevalidity-purpose"> Purpose</a>
25/// * <a href="#baltzo_localtimevalidity-classes"> Classes </a>
26/// * <a href="#baltzo_localtimevalidity-description"> Description </a>
27/// * <a href="#baltzo_localtimevalidity-enumerators"> Enumerators </a>
28/// * <a href="#baltzo_localtimevalidity-usage"> Usage </a>
29/// * <a href="#baltzo_localtimevalidity-example-1-basic-syntax"> Example 1: Basic Syntax </a>
30///
31/// # Purpose {#baltzo_localtimevalidity-purpose}
32/// Enumerate the set of local time validity codes.
33///
34/// # Classes {#baltzo_localtimevalidity-classes}
35///
36/// - baltzo::LocalTimeValidity: namespace for local time validity `enum`
37///
38/// @see baltzo_localtimedescriptor, baltzo_timezoneutil
39///
40/// # Description {#baltzo_localtimevalidity-description}
41/// This component provides a namespace,
42/// `baltzo::LocalTimeValidity`, for the `enum` type
43/// `baltzo::LocalTimeValidity::Enum`, which enumerates the set of validity
44/// codes that can be attributed to a local time. Due to the vagaries of time
45/// zones, and transitions among daylight-saving time and standard time, a
46/// particular representation of local clock time may be deemed to be strictly
47/// invalid, or (uniquely or ambiguously) valid.
48///
49/// ## Enumerators {#baltzo_localtimevalidity-enumerators}
50///
51///
52/// @code
53/// Name Description
54/// ----------------- ---------------------------------------
55/// e_VALID_UNIQUE Local time is *valid* and *unique*.
56/// e_VALID_AMBIGUOUS Local time is *valid*, but *ambiguous*.
57/// e_INVALID Local time is *invalid*.
58/// @endcode
59/// For example, consider the following purported New York local times and their
60/// corresponding `baltzo::LocalTimeValidity::Enum` values:
61/// @code
62/// New York Local Time Validity Code
63/// ------------------- ----------------------
64/// Jan 1, 2010 2:30am e_VALID_UNIQUE
65/// Mar 14, 2010 2:30am e_INVALID
66/// Nov 7, 2010 1:30am e_VALID_AMBIGUOUS
67/// @endcode
68/// On January 1, 2010 in New York, Eastern Standard Time (EST) was in effect
69/// and the transition to Eastern Daylight-Saving Time (EDT) was still weeks
70/// away; "Jan 1, 2010 2:30am" is a patently valid -- and unique -- New York
71/// local time. The transition to EDT in New York in 2010 occurred on March 14
72/// as of 2:00am EST, or more precisely, as of 7:00am UTC (which would have been
73/// 2:00am EST, but became 3:00am EDT). Consequently, "Mar 14, 2010 2:30am" is
74/// an invalid New York local time, since clocks were advanced by one hour as of
75/// 2:00am EST. The change from EDT back to EST in New York in 2010 occurred on
76/// November 7 as of 2:00am EDT. Due to this transition, "Nov 7, 2010 1:30am"
77/// is a valid New York local time. However, that local time is ambiguous
78/// because it corresponds to two possible clock times, 1:30am EDT and 1:30am
79/// EST, since clocks were regressed by one hour as of 2:00am EDT (7:00am UTC).
80///
81/// ## Usage {#baltzo_localtimevalidity-usage}
82///
83///
84/// This section illustrates intended use of this component.
85///
86/// ### Example 1: Basic Syntax {#baltzo_localtimevalidity-example-1-basic-syntax}
87///
88///
89/// The following snippets of code provide a simple illustration of
90/// `baltzo::LocalTimeValidity` usage.
91///
92/// First, we create a variable `value` of type
93/// `baltzo::LocalTimeValidity::Enum` and initialize it with the enumerator
94/// value `baltzo::LocalTimeValidity::e_VALID_AMBIGUOUS`:
95/// @code
96/// baltzo::LocalTimeValidity::Enum value =
97/// baltzo::LocalTimeValidity::e_VALID_AMBIGUOUS;
98/// @endcode
99/// Now, we store a pointer to its ASCII representation in a variable
100/// `asciiValue` of type `const char *`:
101/// @code
102/// const char *asciiValue = baltzo::LocalTimeValidity::toAscii(value);
103/// assert(0 == bsl::strcmp(asciiValue, "VALID_AMBIGUOUS"));
104/// @endcode
105/// Finally, we print `value` to `bsl::cout`.
106/// @code
107/// bsl::cout << value << bsl::endl;
108/// @endcode
109/// This statement produces the following output on `stdout`:
110/// @code
111/// VALID_AMBIGUOUS
112/// @endcode
113/// @}
114/** @} */
115/** @} */
116
117/** @addtogroup bal
118 * @{
119 */
120/** @addtogroup baltzo
121 * @{
122 */
123/** @addtogroup baltzo_localtimevalidity
124 * @{
125 */
126
127#include <balscm_version.h>
128
129#include <bsl_iosfwd.h>
130
131
132namespace baltzo {
133 // ========================
134 // struct LocalTimeValidity
135 // ========================
136
137/// This `struct` provides a namespace for enumerating the set of validity
138/// codes that can be attributed to local time values. See `Enum` in the
139/// TYPES sub-section for details.
140///
141/// This class:
142/// * supports a complete set of *enumeration* operations
143/// - except for `bdex` serialization
144/// For terminology see @ref bsldoc_glossary .
145///
146/// See @ref baltzo_localtimevalidity
148
149 public:
150 // TYPES
151 enum Enum {
152 e_VALID_UNIQUE, // Local time is *valid* and *unique*.
153 e_VALID_AMBIGUOUS, // Local time is *valid*, but *ambiguous*.
154 e_INVALID // Local time is *invalid*.
155
156#ifndef BDE_OMIT_INTERNAL_DEPRECATED
160#endif // BDE_OMIT_INTERNAL_DEPRECATED
161
162 };
163
164 public:
165 // CLASS METHODS
166
167 /// Write the string representation of the specified enumeration `value`
168 /// to the specified output `stream`, and return a reference to
169 /// `stream`. Optionally specify an initial indentation `level`, whose
170 /// absolute value is incremented recursively for nested objects. If
171 /// `level` is specified, optionally specify `spacesPerLevel`, whose
172 /// absolute value indicates the number of spaces per indentation level
173 /// for this and all of its nested objects. If `level` is negative,
174 /// suppress indentation of the first line. If `spacesPerLevel` is
175 /// negative, format the entire output on one line, suppressing all but
176 /// the initial indentation (as governed by `level`). See `toAscii` for
177 /// what constitutes the string representation of a
178 /// `LocalTimeValidity::Enum` value.
179 static bsl::ostream& print(bsl::ostream& stream,
180 Enum value,
181 int level = 0,
182 int spacesPerLevel = 4);
183
184 /// Return the non-modifiable string representation corresponding to the
185 /// specified enumeration `value`, if it exists, and a unique (error)
186 /// string otherwise. The string representation of `value` matches its
187 /// corresponding enumerator name with the "e_" prefix elided. For
188 /// example:
189 /// @code
190 /// bsl::cout << LocalTimeValidity::toAscii(
191 /// LocalTimeValidity::e_VALID_UNIQUE);
192 /// @endcode
193 /// will print the following on standard output:
194 /// @code
195 /// VALID_UNIQUE
196 /// @endcode
197 ///
198 /// \note Note that specifying a `value` that does not match any of the
199 /// enumerators will result in a string representation that is distinct
200 /// from any of those corresponding to the enumerators, but is otherwise
201 /// unspecified.
202 static const char *toAscii(Enum value);
203};
204
205// FREE OPERATORS
206
207/// Write the string representation of the specified enumeration `value` to
208/// the specified output `stream` in a single-line format, and return a
209/// reference to `stream`. See `toAscii` for what constitutes the string
210/// representation of a `baltzo::LocalTimeValidity::Enum` value.
211///
212/// \note Note that this method has the same behavior as
213/// @code
214/// baltzo::LocalTimeValidity::print(stream, value, 0, -1);
215/// @endcode
216bsl::ostream& operator<<(bsl::ostream& stream, LocalTimeValidity::Enum value);
217
218} // close package namespace
219
220// ============================================================================
221// INLINE DEFINITIONS
222// ============================================================================
223
224 // ------------------------
225 // struct LocalTimeValidity
226 // ------------------------
227
228// FREE OPERATORS
229inline
230bsl::ostream& baltzo::operator<<(bsl::ostream& stream,
231 LocalTimeValidity::Enum value)
232{
233 return LocalTimeValidity::print(stream, value, 0, -1);
234}
235
236
237
238#endif
239
240// ----------------------------------------------------------------------------
241// Copyright 2015 Bloomberg Finance L.P.
242//
243// Licensed under the Apache License, Version 2.0 (the "License");
244// you may not use this file except in compliance with the License.
245// You may obtain a copy of the License at
246//
247// http://www.apache.org/licenses/LICENSE-2.0
248//
249// Unless required by applicable law or agreed to in writing, software
250// distributed under the License is distributed on an "AS IS" BASIS,
251// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
252// See the License for the specific language governing permissions and
253// limitations under the License.
254// ----------------------------- END-OF-FILE ----------------------------------
255
256/** @} */
257/** @} */
258/** @} */
#define BSLS_IDENT(str)
BSLS_IDENT() - insert string into .comment binary segment (if supported)
Definition bsls_ident.h:238
Definition baltzo_datafileloader.h:259
bsl::ostream & operator<<(bsl::ostream &stream, DstPolicy::Enum value)
Definition baltzo_localtimevalidity.h:147
static const char * toAscii(Enum value)
Enum
Definition baltzo_localtimevalidity.h:151
@ BAETZO_INVALID
Definition baltzo_localtimevalidity.h:159
@ e_VALID_AMBIGUOUS
Definition baltzo_localtimevalidity.h:153
@ BAETZO_VALID_AMBIGUOUS
Definition baltzo_localtimevalidity.h:158
@ e_VALID_UNIQUE
Definition baltzo_localtimevalidity.h:152
@ e_INVALID
Definition baltzo_localtimevalidity.h:154
@ BAETZO_VALID_UNIQUE
Definition baltzo_localtimevalidity.h:157
static bsl::ostream & print(bsl::ostream &stream, Enum value, int level=0, int spacesPerLevel=4)