From df1ef68cd8e8582724ce1192bfc202e0b9aeaf0c Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Tue, 28 Sep 2021 19:24:31 +0300 Subject: Get rid of C++ modules related code and rename *.mxx files to *.hxx --- libbutl/base64.hxx | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 libbutl/base64.hxx (limited to 'libbutl/base64.hxx') diff --git a/libbutl/base64.hxx b/libbutl/base64.hxx new file mode 100644 index 0000000..f38e62f --- /dev/null +++ b/libbutl/base64.hxx @@ -0,0 +1,46 @@ +// file : libbutl/base64.hxx -*- C++ -*- +// license : MIT; see accompanying LICENSE file + +#pragma once + +#include +#include +#include + +#include + +namespace butl +{ + // Base64-encode a stream or a buffer. Split the output into 76 char-long + // lines (new line is the 77th). If reading from a stream, check if it has + // badbit, failbit, or eofbit set and throw invalid_argument if that's the + // case. Otherwise, set eofbit on completion. If writing to a stream, check + // if it has badbit, failbit, or eofbit set and throw invalid_argument if + // that's the case. Otherwise set badbit if the write operation fails. + // + LIBBUTL_SYMEXPORT void + base64_encode (std::ostream&, std::istream&); + + LIBBUTL_SYMEXPORT std::string + base64_encode (std::istream&); + + LIBBUTL_SYMEXPORT std::string + base64_encode (const std::vector&); + + // Base64-decode a stream or a string. Throw invalid_argument if the input + // is not a valid base64 representation. If reading from a stream, check if + // it has badbit, failbit, or eofbit set and throw invalid_argument if + // that's the case. Otherwise, set eofbit on completion. If writing to a + // stream, check if it has badbit, failbit, or eofbit set and throw + // invalid_argument if that's the case. Otherwise set badbit if the write + // operation fails. + // + LIBBUTL_SYMEXPORT void + base64_decode (std::ostream&, std::istream&); + + LIBBUTL_SYMEXPORT void + base64_decode (std::ostream&, const std::string&); + + LIBBUTL_SYMEXPORT std::vector + base64_decode (const std::string&); +} -- cgit v1.1