BDE 4.14.0 Production release
Loading...
Searching...
No Matches
bdlde_base64alphabet

Detailed Description

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:135
@ e_URL
Definition bdlde_base64alphabet.h:137
@ e_BASIC
Definition bdlde_base64alphabet.h:136

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;
Definition bslstl_ostringstream.h:175

Finally, we observe the output of the streaming:

assert(ossBasic.str() == "BASIC");
assert(ossUrl.str() == "URL");
assert(ossBasic.str() == asciiBasic);
assert(ossUrl.str() == asciiUrl);
void str(const StringType &value)
Definition bslstl_ostringstream.h:581