# HG changeset patch # User David Demelier # Date 1410596861 -7200 # Node ID 73e5381d7bafcc22955121e9fdb12687f0337657 # Parent a9883eeb97572f6db118c2f83f78ef7952803736 Base64: return output #291 diff -r a9883eeb9757 -r 73e5381d7baf C++/Base64.h --- a/C++/Base64.h Thu Sep 11 21:09:58 2014 +0200 +++ b/C++/Base64.h Sat Sep 13 10:27:41 2014 +0200 @@ -54,10 +54,11 @@ * * @param input the beginning * @param end the end of the data - * @output the output destination + * @param output the output destination + * @return output */ template - static void encode(InputIt input, InputIt end, OutputIt output) + static OutputIt encode(InputIt input, InputIt end, OutputIt output) { while (input != end) { char inputbuf[3] = { 0, 0, 0 }; @@ -71,6 +72,8 @@ *output++ = (count < 2) ? '=' : lookup((inputbuf[1] << 2 & 0x3c) | (inputbuf[2] >> 6 & 0x03)); *output++ = (count < 3) ? '=' : lookup(inputbuf[2] & 0x3f); } + + return output; } /** @@ -80,11 +83,12 @@ * * @param input the beginning * @param end the end of the data - * @output the output destination + * @param output the output destination + * @return output * @throw std::invalid_argument on bad base64 string */ template - static void decode(InputIt input, InputIt end, OutputIt output) + static OutputIt decode(InputIt input, InputIt end, OutputIt output) { while (input != end) { char inputbuf[4] = { 0, 0, 0, 0 }; @@ -105,6 +109,8 @@ if (inputbuf[3] != '=') *output++ = (inputbuf[2] << 6 & 0xc0) | (inputbuf[3] & 0x3f); } + + return output; } /**