Subject: [Boost-bugs] [Boost C++ Libraries] #5629: base64 encode/decode for std::istreambuf_iterator/std::ostreambuf_iterator
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2011-06-22 13:29:41
#5629: base64 encode/decode for std::istreambuf_iterator/std::ostreambuf_iterator
-------------------------------+--------------------------------------------
Reporter: nen777w@⦠| Owner: dave
Type: Bugs | Status: new
Milestone: To Be Determined | Component: iterator
Version: Boost 1.45.0 | Severity: Problem
Keywords: |
-------------------------------+--------------------------------------------
MSVS 2008
The code:
{{{
#include "boost/archive/iterators/base64_from_binary.hpp"
#include "boost/archive/iterators/binary_from_base64.hpp"
#include "boost/archive/iterators/transform_width.hpp"
//typedefs
typedef std::istreambuf_iterator<char> my_istream_iterator;
typedef std::ostreambuf_iterator<char> my_ostream_iterator;
typedef boost::archive::iterators::base64_from_binary<
boost::archive::iterators::transform_width< my_istream_iterator,
6, 8>
> bin_to_base64;
typedef boost::archive::iterators::transform_width<
boost::archive::iterators::binary_from_base64< my_istream_iterator >,
8, 6
> base64_to_bin;
void test()
{
{
//INPUT FILE!!!
std::ifstream ifs("test.zip",
std::ios_base::in|std::ios_base::binary);
std::ofstream ofs("test.arc",
std::ios_base::out|std::ios_base::binary);
std::copy(
bin_to_base64( my_istream_iterator(ifs >> std::noskipws) ),
bin_to_base64( my_istream_iterator() ),
my_ostream_iterator(ofs)
);
}
{
std::ifstream ifs("test.arc",
std::ios_base::in|std::ios_base::binary);
std::ofstream ofs("test.rez",
std::ios_base::out|std::ios_base::binary);
std::copy(
base64_to_bin( my_istream_iterator(ifs >> std::noskipws) ),
base64_to_bin( my_istream_iterator() ),
my_ostream_iterator(ofs)
);
}
}
}}}
Result:
1) If the INPUT FILE will be any of ZIP-file format. The result was:
a) _DEBUG_ERROR("istreambuf_iterator is not dereferencable"); //it can
be disabled or ignored
b) The encoded file "test.rez" will have one superfluous byte than
INPUT FILE
2) If the INPUT FILE will any other file (binary or text) all will be OK.
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/5629> Boost C++ Libraries <http://www.boost.org/> Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:06 UTC