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

Detailed Description

Outline

Purpose

Provide value-semantic attribute class for decoder options.

Classes

See also
bdlde_base64decoderoptions, bdlde_base64decoder, bdlde_base64encoder, bdlde_base64alphabet

Description

This component provides a value-semantic attribute class for specifying options for bdlde::Base64Decoder.

This class supports default-generated copy construction and copy assignment, but the constructor is private. To create an object one must call one of the class methods, which will return a newly-constructed object by value. Specialized class methods are provided to create objects configured for the mime, urlSafe, and standard configurations.

Other configurations may be obtained by specifying arguments to the custom class method, or by calling the setters after the object is created.

Usage

This section illustrates intended use of this component.

Example 1: Basic Usage

Suppose we want a Base64DecoderOptions object configured for MIME encoding, meaning alphabet == e_BASIC, isPadded == true, and ignoreMode = e_IGNORE_WHITESPACE.

First, we call the mime class method, and we're done.

const bdlde::Base64DecoderOptions& mimeOptions =
Definition bdlde_base64decoderoptions.h:222
static Base64DecoderOptions mime(IgnoreMode::Enum ignoreMode=IgnoreMode::e_IGNORE_WHITESPACE)
Definition bdlde_base64decoderoptions.h:408

Then, we check the attributes:

assert(mimeOptions.ignoreMode() ==
assert(mimeOptions.alphabet() == bdlde::Base64Alphabet::e_BASIC);
assert(mimeOptions.isPadded() == true);
Base64Alphabet::Enum alphabet() const
Return the value of the alphabet attribute.
Definition bdlde_base64decoderoptions.h:460
IgnoreMode::Enum ignoreMode() const
Return the value of the ignoreMode attribute.
Definition bdlde_base64decoderoptions.h:466
bool isPadded() const
Return the value of the isPadded attribute.
Definition bdlde_base64decoderoptions.h:472
@ e_BASIC
Definition bdlde_base64alphabet.h:136
@ e_IGNORE_WHITESPACE
Definition bdlde_base64ignoremode.h:139

Now, we stream the object:

mimeOptions.print(cout);
bsl::ostream & print(bsl::ostream &stream, int level=0, int spacesPerLevel=4) const

Finally, we observe the output:

[
ignoreMode = IGNORE_WHITESPACE
alphabet = BASIC
isPadded = true
]

Example 2:

Suppose we want a Base64DecoderOptions object configured for translating URL's. That would mean alphabet == e_URL, isPadded == false, and ignoring neither unrecognized characters nor whitespace.

First, the class method urlSafe returns an object configured exactly that way, so we simply call it:

const bdlde::Base64DecoderOptions& urlOptions =
static Base64DecoderOptions urlSafe(IgnoreMode::Enum ignoreMode=IgnoreMode::e_IGNORE_NONE, bool padded=false)
Definition bdlde_base64decoderoptions.h:426

Then, we check the attributes:

assert(urlOptions.alphabet() == bdlde::Base64Alphabet::e_URL);
assert(urlOptions.isPadded() == false);
@ e_URL
Definition bdlde_base64alphabet.h:137
@ e_IGNORE_NONE
Definition bdlde_base64ignoremode.h:136

Now, we stream the object:

urlOptions.print(cout);

Finally, we observe the output:

[
ignoreMode = IGNORE_NONE
alphabet = URL
isPadded = false
]

Example 3:

Suppose we want an options object configured for standard Base64:

First, we can simply call the standard class method:

const bdlde::Base64DecoderOptions& standardOptions =
static Base64DecoderOptions standard(IgnoreMode::Enum ignoreMode=IgnoreMode::e_IGNORE_NONE, bool padded=true)
Definition bdlde_base64decoderoptions.h:416

Then, we check the attributes:

assert(standardOptions.ignoreMode() ==
assert(standardOptions.alphabet() ==
assert(standardOptions.isPadded() == true);

Now, we stream the object:

standardOptions.print(cout);

Finally, we observe the output:

[
ignoreMode = IGNORE_NONE
alphabet = BASIC
isPadded = true
]

Example 4:

Suppose we want a really strangely configured options object with alphabet == e_URL, and padding, and ignoring neither unrecognized characters nor whitespace.

First, we can simply call the custom class method. The padded and unrecognizedIsError == true arguments are last, and they default to true, so we don't have to pass that.

const bdlde::Base64DecoderOptions& customOptions =
true);
static Base64DecoderOptions custom(IgnoreMode::Enum ignoreMode, Base64Alphabet::Enum alphabet, bool padded)
Definition bdlde_base64decoderoptions.h:397

Then, we check the attributes:

assert(customOptions.ignoreMode() ==
assert(customOptions.alphabet() == bdlde::Base64Alphabet::e_URL);
assert(customOptions.isPadded() == true);

Now, we stream the object:

cout << customOptions << endl;

Finally, we observe the output:

[ ignoreMode = IGNORE_NONE alphabet = URL isPadded = true ]