Provide a value-semantic attribute class for encoder options.
More...
Namespaces |
namespace | bdlde |
namespace | bsl |
Detailed Description
- Outline
-
-
- Purpose:
- Provide a value-semantic attribute class for encoder options.
-
- Classes:
-
- See also:
- bdlde_base64encorderoptions, bdlde_base64decorderoptions, Component bdlde_base64encoder, Component bdlde_base64decoder Component bdlde_base64alphabet
-
- Description:
- This component provides a value-semantic attribute class for specifying options for
bdlde::Base64Encoder
.
- 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:
- In this section we show intended use of this component.
-
- Example 1:
- Suppose we want a
Base64EncoderOptions
object configured for MIME encoding, meaning maxLineLength == 76
, alphabet == e_BASIC
, and isPadded == true
.
- First, it turns out that those are the default values of the attributes, so all we have to do is default construct an object, and we're done. Then, we check the attributes:
assert(mimeOptions.maxLineLength() == 76);
assert(mimeOptions.alphabet() == bdlde::Base64Alphabet::e_BASIC);
assert(mimeOptions.isPadded() == true);
Now, we stream the object: Finally, we observe the output: [
maxLineLength = 76
alphabet = BASIC
isPadded = true
]
-
- Example 2:
- Suppose we want a
Base64EncoderOptions
object configured for translating URL's. That would mean a maxLineLength == 0
, alphabet == e_URL
, and isPadded == false
.
- First, the class method
urlSafe
returns an object configured exactly that way, so we simply call it: Then, we check the attributes: Now, we stream the object: Finally, we observe the output: [
maxLineLength = 0
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: Then, we check the attributes: assert(standardOptions.maxLineLength() == 0);
assert(standardOptions.alphabet() == bdlde::Base64Alphabet::e_BASIC);
assert(standardOptions.isPadded() == true);
Now, we stream the object: standardOptions.print(cout);
Finally, we observe the output: [
maxLineLength = 0
alphabet = BASIC
isPadded = true
]
-
- Example 4:
- Suppose we want a really strangely configured options object with
maxLineLength == 200
, alphabet == e_URL
, and padding.
- First, we can simply call the
custom
class method: Then, we check the attributes: assert(customOptions.maxLineLength() == 200);
assert(customOptions.alphabet() == bdlde::Base64Alphabet::e_URL);
assert(customOptions.isPadded() == true);
Now, we stream the object: cout << customOptions << endl;
Finally, we observe the output: [ maxLineLength = 200 alphabet = URL isPadded = true ]