BDE 4.39.x Production Release
Loading...
Searching...
No Matches
bdlde_base64alphabet

Detailed Description

Provide an enumeration of the set of possible base 64 alphabets.

Outline

Purpose

Provide an enumeration of the set of possible base 64 alphabets.

Classes

See also
bdlde_base64encoderoptions, bdlde_base64decoderoptions, bdlde_base64encoder, bdlde_base64decoder

Description

This component provides a namespace for the enum type bdlde::Base64Alphabet::Enum, which enumerates the set of possible alphabets.

Enumerators

Name Description
e_BASIC standard base64 alphabet
e_URL URL-safe base64 alphabet

Usage

This section illustrates intended use of this component.

Example 1: Basic Usage

The following snippets of code provide a simple illustration of bdlde::Base64Alphabet usage.

First, we create variable of type bdlde::Base64Alphabet::Enum and initialize it with the enumerator values:

Enum
Definition bdlde_base64alphabet.h:137
@ e_URL
Definition bdlde_base64alphabet.h:139
@ e_BASIC
Definition bdlde_base64alphabet.h:138

Next, we store a pointer to their ASCII representation in variables of type const char *:

const char *asciiBasic = bdlde::Base64Alphabet::toAscii(basic);
const char *asciiUrl = bdlde::Base64Alphabet::toAscii(url);
assert(0 == bsl::strcmp(asciiBasic, "BASIC"));
assert(0 == bsl::strcmp(asciiUrl, "URL"));
static const char * toAscii(Enum value)

Now, we stream some Enums to ostreams:

bsl::ostringstream ossBasic, ossUrl;
ossBasic << basic;
ossUrl << url;
basic_ostringstream< char, char_traits< char >, allocator< char > > ostringstream
Definition bslstl_iosfwd.h:97

Finally, we observe the output of the streaming:

assert(ossBasic.str() == "BASIC");
assert(ossUrl.str() == "URL");
assert(ossBasic.str() == asciiBasic);
assert(ossUrl.str() == asciiUrl);