BDE 4.14.0 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 .
146
147 public:
148 // TYPES
149 enum Enum {
150 e_VALID_UNIQUE, // Local time is *valid* and *unique*.
151 e_VALID_AMBIGUOUS, // Local time is *valid*, but *ambiguous*.
152 e_INVALID // Local time is *invalid*.
153
154#ifndef BDE_OMIT_INTERNAL_DEPRECATED
158#endif // BDE_OMIT_INTERNAL_DEPRECATED
159
160 };
161
162 public:
163 // CLASS METHODS
164
165 /// Write the string representation of the specified enumeration `value`
166 /// to the specified output `stream`, and return a reference to
167 /// `stream`. Optionally specify an initial indentation `level`, whose
168 /// absolute value is incremented recursively for nested objects. If
169 /// `level` is specified, optionally specify `spacesPerLevel`, whose
170 /// absolute value indicates the number of spaces per indentation level
171 /// for this and all of its nested objects. If `level` is negative,
172 /// suppress indentation of the first line. If `spacesPerLevel` is
173 /// negative, format the entire output on one line, suppressing all but
174 /// the initial indentation (as governed by `level`). See `toAscii` for
175 /// what constitutes the string representation of a
176 /// `LocalTimeValidity::Enum` value.
177 static bsl::ostream& print(bsl::ostream& stream,
178 Enum value,
179 int level = 0,
180 int spacesPerLevel = 4);
181
182 /// Return the non-modifiable string representation corresponding to the
183 /// specified enumeration `value`, if it exists, and a unique (error)
184 /// string otherwise. The string representation of `value` matches its
185 /// corresponding enumerator name with the "e_" prefix elided. For
186 /// example:
187 /// @code
188 /// bsl::cout << LocalTimeValidity::toAscii(
189 /// LocalTimeValidity::e_VALID_UNIQUE);
190 /// @endcode
191 /// will print the following on standard output:
192 /// @code
193 /// VALID_UNIQUE
194 /// @endcode
195 /// Note that specifying a `value` that does not match any of the
196 /// enumerators will result in a string representation that is distinct
197 /// from any of those corresponding to the enumerators, but is otherwise
198 /// unspecified.
199 static const char *toAscii(Enum value);
200};
201
202// FREE OPERATORS
203
204/// Write the string representation of the specified enumeration `value` to
205/// the specified output `stream` in a single-line format, and return a
206/// reference to `stream`. See `toAscii` for what constitutes the string
207/// representation of a `baltzo::LocalTimeValidity::Enum` value. Note that
208/// this method has the same behavior as
209/// @code
210/// baltzo::LocalTimeValidity::print(stream, value, 0, -1);
211/// @endcode
212bsl::ostream& operator<<(bsl::ostream& stream, LocalTimeValidity::Enum value);
213
214} // close package namespace
215
216// ============================================================================
217// INLINE DEFINITIONS
218// ============================================================================
219
220 // ------------------------
221 // struct LocalTimeValidity
222 // ------------------------
223
224// FREE OPERATORS
225inline
226bsl::ostream& baltzo::operator<<(bsl::ostream& stream,
227 LocalTimeValidity::Enum value)
228{
229 return LocalTimeValidity::print(stream, value, 0, -1);
230}
231
232
233
234#endif
235
236// ----------------------------------------------------------------------------
237// Copyright 2015 Bloomberg Finance L.P.
238//
239// Licensed under the Apache License, Version 2.0 (the "License");
240// you may not use this file except in compliance with the License.
241// You may obtain a copy of the License at
242//
243// http://www.apache.org/licenses/LICENSE-2.0
244//
245// Unless required by applicable law or agreed to in writing, software
246// distributed under the License is distributed on an "AS IS" BASIS,
247// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
248// See the License for the specific language governing permissions and
249// limitations under the License.
250// ----------------------------- END-OF-FILE ----------------------------------
251
252/** @} */
253/** @} */
254/** @} */
#define BSLS_IDENT(str)
Definition bsls_ident.h:195
Definition baltzo_datafileloader.h:263
bsl::ostream & operator<<(bsl::ostream &stream, DstPolicy::Enum value)
Definition baltzo_localtimevalidity.h:145
static const char * toAscii(Enum value)
Enum
Definition baltzo_localtimevalidity.h:149
@ BAETZO_INVALID
Definition baltzo_localtimevalidity.h:157
@ e_VALID_AMBIGUOUS
Definition baltzo_localtimevalidity.h:151
@ BAETZO_VALID_AMBIGUOUS
Definition baltzo_localtimevalidity.h:156
@ e_VALID_UNIQUE
Definition baltzo_localtimevalidity.h:150
@ e_INVALID
Definition baltzo_localtimevalidity.h:152
@ BAETZO_VALID_UNIQUE
Definition baltzo_localtimevalidity.h:155
static bsl::ostream & print(bsl::ostream &stream, Enum value, int level=0, int spacesPerLevel=4)