// file : libbutl/base64.mxx -*- C++ -*- // license : MIT; see accompanying LICENSE file #ifndef __cpp_modules_ts #pragma once #endif // C includes. #ifndef __cpp_lib_modules_ts #include #include #include #endif // Other includes. #ifdef __cpp_modules_ts export module butl.base64; #ifdef __cpp_lib_modules_ts import std.core; import std.io; #endif #endif #include LIBBUTL_MODEXPORT 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&); }