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