1

I have a code base with just one use of boost, which decodes 64bit data... it's very old code and I do not know what expected inputs or outputs look like, but if I can remove dependency on boost I'd like to:

#include <boost/archive/iterators/binary_from_base64.hpp>
#include <boost/archive/iterators/transform_width.hpp>

namespace ai = boost::archive::iterators;
typedef ai::transform_width< ai::binary_from_base64<std::string::const_iterator >, 8, 6 > It;

void base64_to_byte(const std::string& in, std::vector<char>& out)
{
  out.assign(It(in.begin()), It(in.end()));
}

It and all this template-driven approach is something I'm struggling to get my head around, is this an area of Boost which has a direct C++14/17/20 parallel? What is it doing?

I can't even find documentation for it on https://www.boost.org/doc/libs/1_76_0, archive isn't listed as a library?

(If there is not an easy replacement, I will not make changes)

Mr. Boy
  • 60,845
  • 93
  • 320
  • 589
  • 1
    it is the Serialization lib https://www.boost.org/doc/libs/1_76_0/libs/serialization/doc/index.html – 463035818_is_not_an_ai Jul 09 '21 at 14:21
  • I wish they'd align namespace/directories with library name! Thanks :) – Mr. Boy Jul 09 '21 at 14:24
  • 1
    You can try to Google for "C++ serialization without Boost". There are definitely alternatives ... but I'm not aware of anything in the standard libraries. – paulsm4 Jul 09 '21 at 14:26
  • 1
    afaik there is no replacement for this in the stadnard library currently or foreseen in near future. I guess you better stay with it when it does what it should do – 463035818_is_not_an_ai Jul 09 '21 at 14:27
  • @463035818_is_not_a_number that's a valid answer I would say. Sometimes easier not to 'fix' things. – Mr. Boy Jul 09 '21 at 14:28
  • half valid, because I am not 100% sure, I am not quite up to date on the latest standards or what comes next, I just thought if serialization would be in I think I would have heard of it – 463035818_is_not_an_ai Jul 09 '21 at 14:30
  • This question covers the same topic but is rather old so I'm not sure if it's a dupe. Cereal is mentioned in newer answers but it seems STL doesn't provide this natively: https://stackoverflow.com/questions/234724/is-it-possible-to-serialize-and-deserialize-a-class-in-c – Mr. Boy Jul 09 '21 at 14:33
  • 1
    In any case if you just need Base 64 encoding-decoding check this https://stackoverflow.com/questions/180947/base64-decode-snippet-in-c – Victor Gubin Jul 09 '21 at 16:02

0 Answers0