BDE 4.14.0 Production release
Loading...
Searching...
No Matches
bdlde_base64alphabet.h
Go to the documentation of this file.
1/// @file bdlde_base64alphabet.h
2///
3/// The content of this file has been pre-processed for Doxygen.
4///
5
6
7// bdlde_base64alphabet.h -*-C++-*-
8
9#ifndef INCLUDED_BDLDE_BASE64ALPHABET
10#define INCLUDED_BDLDE_BASE64ALPHABET
11
12#include <bsls_ident.h>
13BSLS_IDENT("$Id: $")
14
15/// @defgroup bdlde_base64alphabet bdlde_base64alphabet
16/// @brief Provide an enumeration of the set of possible base 64 alphabets.
17/// @addtogroup bdl
18/// @{
19/// @addtogroup bdlde
20/// @{
21/// @addtogroup bdlde_base64alphabet
22/// @{
23///
24/// <h1> Outline </h1>
25/// * <a href="#bdlde_base64alphabet-purpose"> Purpose</a>
26/// * <a href="#bdlde_base64alphabet-classes"> Classes </a>
27/// * <a href="#bdlde_base64alphabet-description"> Description </a>
28/// * <a href="#bdlde_base64alphabet-enumerators"> Enumerators </a>
29/// * <a href="#bdlde_base64alphabet-usage"> Usage </a>
30/// * <a href="#bdlde_base64alphabet-example-1-basic-usage"> Example 1: Basic Usage </a>
31///
32/// # Purpose {#bdlde_base64alphabet-purpose}
33/// Provide an enumeration of the set of possible base 64 alphabets.
34///
35/// # Classes {#bdlde_base64alphabet-classes}
36///
37/// - bdlde::Base64Alphabet: namespace for an alphabet `enum`
38///
39/// @see bdlde_base64encoderoptions, bdlde_base64decoderoptions,
40/// bdlde_base64encoder, bdlde_base64decoder
41///
42/// # Description {#bdlde_base64alphabet-description}
43/// This component provides a namespace for the `enum` type
44/// `bdlde::Base64Alphabet::Enum`, which enumerates the set of possible
45/// alphabets.
46///
47/// ## Enumerators {#bdlde_base64alphabet-enumerators}
48///
49///
50///
51/// | Name | Description |
52/// | --------------- | ----------- |
53/// | e_BASIC | standard base64 alphabet |
54/// | e_URL | URL-safe base64 alphabet |
55///
56///
57/// ## Usage {#bdlde_base64alphabet-usage}
58///
59///
60/// This section illustrates intended use of this component.
61///
62/// ### Example 1: Basic Usage {#bdlde_base64alphabet-example-1-basic-usage}
63///
64///
65/// The following snippets of code provide a simple illustration of
66/// `bdlde::Base64Alphabet` usage.
67///
68/// First, we create variable of type `bdlde::Base64Alphabet::Enum` and
69/// initialize it with the enumerator values:
70/// @code
71/// const bdlde::Base64Alphabet::Enum basic = bdlde::Base64Alphabet::e_BASIC;
72/// const bdlde::Base64Alphabet::Enum url = bdlde::Base64Alphabet::e_URL;
73/// @endcode
74/// Next, we store a pointer to their ASCII representation in variables of type
75/// `const char *`:
76/// @code
77/// const char *asciiBasic = bdlde::Base64Alphabet::toAscii(basic);
78/// const char *asciiUrl = bdlde::Base64Alphabet::toAscii(url);
79/// assert(0 == bsl::strcmp(asciiBasic, "BASIC"));
80/// assert(0 == bsl::strcmp(asciiUrl, "URL"));
81/// @endcode
82/// Now, we stream some `Enum`s to `ostream`s:
83/// @code
84/// bsl::ostringstream ossBasic, ossUrl;
85///
86/// ossBasic << basic;
87/// ossUrl << url;
88/// @endcode
89/// Finally, we observe the output of the streaming:
90/// @code
91/// assert(ossBasic.str() == "BASIC");
92/// assert(ossUrl.str() == "URL");
93///
94/// assert(ossBasic.str() == asciiBasic);
95/// assert(ossUrl.str() == asciiUrl);
96/// @endcode
97/// @}
98/** @} */
99/** @} */
100
101/** @addtogroup bdl
102 * @{
103 */
104/** @addtogroup bdlde
105 * @{
106 */
107/** @addtogroup bdlde_base64alphabet
108 * @{
109 */
110
111#include <bdlscm_version.h>
112
113#include <bsls_platform.h>
114
115#include <bsl_iosfwd.h>
116
117
118namespace bdlde {
119
120 // =====================
121 // struct Base64Alphabet
122 // =====================
123
124/// This `struct` provides a namespace for enumerating the set of alphabets.
125/// See `Enum` in the TYPES sub-section for details.
126///
127/// This class:
128/// * supports a complete set of *enumeration* operations
129/// - except for `bdex` serialization
130/// For terminology see @ref bsldoc_glossary .
132
133 public:
134 // TYPES
135 enum Enum {
137 e_URL
138 };
139
140 public:
141 // CLASS METHODS
142
143 /// Write the string representation of the specified enumeration `value`
144 /// to the specified output `stream`, and return a reference to
145 /// `stream`. Optionally specify an initial indentation `level`, whose
146 /// absolute value is incremented recursively for nested objects. If
147 /// `level` is specified, optionally specify `spacesPerLevel`, whose
148 /// absolute value indicates the number of spaces per indentation level
149 /// for this and all of its nested objects. If `level` is negative,
150 /// suppress indentation of the first line. If `spacesPerLevel` is
151 /// negative, format the entire output on one line, suppressing all but
152 /// the initial indentation (as governed by `level`). See `toAscii` for
153 /// what constitutes the string representation of a
154 /// `ByteOrder::Enum` value.
155 static bsl::ostream& print(bsl::ostream& stream,
156 Enum value,
157 int level = 0,
158 int spacesPerLevel = 4);
159
160 /// Return the non-modifiable string representation corresponding to the
161 /// specified enumeration `value`, if it exists, and a unique (error)
162 /// string otherwise. The string representation of `value` matches the
163 /// name of its corresponding base enumeration with the "e_" prefix
164 /// elided. For example:
165 /// @code
166 /// bsl::cout << ByteOrder::toAscii(ByteOrder::e_URL);
167 /// @endcode
168 /// will print the following on standard output:
169 /// @code
170 /// URL
171 /// @endcode
172 /// Note that specifying a `value` that does not match any of the
173 /// enumerators will result in a string representation that is distinct
174 /// from any of those corresponding to the enumerators, but is otherwise
175 /// unspecified.
176 static const char *toAscii(Enum value);
177};
178
179// FREE OPERATORS
180
181/// Write the string representation of the specified enumeration `value` to
182/// the specified output `stream` in a single-line format, and return a
183/// reference to `stream`. See `toAscii` for what constitutes the string
184/// representation of a `bdlde::Base64Alphabet::Enum` value. Note that this
185/// method has the same behavior as
186/// @code
187/// bdlde::Base64Alphabet::print(stream, value, 0, -1);
188/// @endcode
189bsl::ostream& operator<<(bsl::ostream& stream, Base64Alphabet::Enum value);
190
191} // close package namespace
192
193
194#endif
195
196// ----------------------------------------------------------------------------
197// Copyright 2022 Bloomberg Finance L.P.
198//
199// Licensed under the Apache License, Version 2.0 (the "License");
200// you may not use this file except in compliance with the License.
201// You may obtain a copy of the License at
202//
203// http://www.apache.org/licenses/LICENSE-2.0
204//
205// Unless required by applicable law or agreed to in writing, software
206// distributed under the License is distributed on an "AS IS" BASIS,
207// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
208// See the License for the specific language governing permissions and
209// limitations under the License.
210// ----------------------------- END-OF-FILE ----------------------------------
211
212/** @} */
213/** @} */
214/** @} */
#define BSLS_IDENT(str)
Definition bsls_ident.h:195
Definition bdlde_base64alphabet.h:118
bsl::ostream & operator<<(bsl::ostream &stream, Base64Alphabet::Enum value)
Definition bdlde_base64alphabet.h:131
static bsl::ostream & print(bsl::ostream &stream, Enum value, int level=0, int spacesPerLevel=4)
static const char * toAscii(Enum value)
Enum
Definition bdlde_base64alphabet.h:135
@ e_URL
Definition bdlde_base64alphabet.h:137
@ e_BASIC
Definition bdlde_base64alphabet.h:136