Boost logo

Boost :

Subject: Re: [boost] Is Boost interested in the Boost-based Base64 library
From: Stewart, Robert (Robert.Stewart_at_[hidden])
Date: 2011-06-09 14:55:51


Denis Shevchenko wrote:
>
> I definitely know many developers looking for a simple,
> ready-to-use, header-only and 'real C++' solution for Base64.

I'm not sure how much need there is for Base64....

> Some examples:
>
> int main() {
> std::string my_text = "My text for encoding!";
> std::string encoded_text = boost::base64().encode(
> my_text);
> std::string my_text_again =
> boost::base64().decode<std::string>(encoded);
> }
>
> For binary data:
>
> int main() {
> typedef std::vector< unsigned char > binary_string;
>
> binary_string my_bin = list_of( 0xFF )( 0xAA )( 0x01 );
> std::string encoded_bin = boost::base64().encode(
> my_bin);
> binary_string my_bin_again =
> boost::base64().decode<binary_string>(encoded);
> }
>
> For streams:
>
> int main() {
> boost::filesystem::ifstream my_jpeg(
> "/some/path/to/my/image");
> // fstream checking omitted...
>
> std::string encoded_jpeg =
> boost::base64().encode(my_jpeg);
>
> boost::filesystem::ofstream my_jpeg_again(
> "/some/path/to/decoded/image");
> // fstream checking omitted...
>
> boost::base64().decode(encoded_jpeg, my_jpeg_again);
> }

That interface is restrictive. Why not take iterators and ranges for input and output iterators for output. That would grant greater flexibility to source and destination: your code would be captured as algorithms.

In the JPEG example, that could mean writing the encoded image straight to disk, instead of to an intermediate string, which would reduce memory pressure, for example.

_____
Rob Stewart robert.stewart_at_[hidden]
Software Engineer using std::disclaimer;
Dev Tools & Components
Susquehanna International Group, LLP http://www.sig.com

IMPORTANT: The information contained in this email and/or its attachments is confidential. If you are not the intended recipient, please notify the sender immediately by reply and immediately delete this message and all its attachments. Any review, use, reproduction, disclosure or dissemination of this message or any attachment by an unintended recipient is strictly prohibited. Neither this message nor any attachment is intended as or should be construed as an offer, solicitation or recommendation to buy or sell any security or other financial instrument. Neither the sender, his or her employer nor any of their respective affiliates makes any warranties as to the completeness or accuracy of any of the information contained herein or that this message or any of its attachments is free of viruses.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk