Boost logo

Boost Users :

From: Anatoli Sakhnik (sakhnik_at_[hidden])
Date: 2007-04-12 03:18:58


Hi, Robert!

Yes, the question was about the end iterator while decoding from
base64. As I understand now, the problem refers to the transform_width
iterator rather to the binary_from_base64. The former feeds another
unnnecessary byte, which by the fact is equal 0, to the latter. And
fixing something in the binary_from_base64 would be wrong.

I've written a little test to show this:

///////////////////////////////////////////////////////////////////////////////
#include <boost/test/test_tools.hpp>
#include <boost/archive/iterators/transform_width.hpp>
#include <string>
#include <vector>

using namespace std;
using namespace boost::archive::iterators;

typedef transform_width<string::const_iterator, 6, 8> ForwardT;
typedef transform_width<string::const_iterator, 8, 6> BackwardT;

int test_main(int, char*[])
{
    string str("Hello, world!");
    string enc(ForwardT(str.begin()), ForwardT(str.end()));
    string dec(BackwardT(enc.begin()), BackwardT(enc.end()));
    BOOST_CHECK_EQUAL(dec.length(), str.length());
    BOOST_CHECK_EQUAL_COLLECTIONS(str.begin(), str.end(), dec.begin());
    return 0;
}
//////////////////////////////////////////////////////////////////////////////

It's evident, that it should pass, isn't it? But it fails, the lengths
of dec and str differ. Can the problem be solved?

-- Anatoli Sakhnik.

On 12/04/07, Robert Ramey <ramey_at_[hidden]> wrote:
> I'm not sure I understood the question - but that won't inhibit
> me from commenting.
>
> I had a lot of problem with this due to the fact that number of
> bas 64 octets didn't always come out to an integral number of
> bytes. I think i had to avoid the usage of an end iterator to
> make things work as I wanted. Sorry I don't know what
> more I could tell you.
>
> Robert Ramey
>


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net