diff options
author | Karen Arutyunov <karen@codesynthesis.com> | 2017-05-01 16:08:43 +0300 |
---|---|---|
committer | Karen Arutyunov <karen@codesynthesis.com> | 2017-05-01 16:59:24 +0300 |
commit | 61377c582e0f2675baa5f5e6e30a35d1a4164b33 (patch) | |
tree | 11cdca992834d7f7f197f72856712fbcb3020e3d /libbutl/base64.hxx | |
parent | 442c1a6790e52baa0c081f310d4d9e9b6f1ff638 (diff) |
Add hxx extension for headers and lib prefix for library dir
Diffstat (limited to 'libbutl/base64.hxx')
-rw-r--r-- | libbutl/base64.hxx | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/libbutl/base64.hxx b/libbutl/base64.hxx new file mode 100644 index 0000000..29c6198 --- /dev/null +++ b/libbutl/base64.hxx @@ -0,0 +1,50 @@ +// file : libbutl/base64.hxx -*- C++ -*- +// copyright : Copyright (c) 2014-2017 Code Synthesis Ltd +// license : MIT; see accompanying LICENSE file + +#ifndef LIBBUTL_BASE64_HXX +#define LIBBUTL_BASE64_HXX + +#include <iosfwd> +#include <string> +#include <vector> + +#include <libbutl/export.hxx> + +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_EXPORT void + base64_encode (std::ostream&, std::istream&); + + LIBBUTL_EXPORT std::string + base64_encode (std::istream&); + + LIBBUTL_EXPORT std::string + base64_encode (const std::vector<char>&); + + // 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_EXPORT void + base64_decode (std::ostream&, std::istream&); + + LIBBUTL_EXPORT void + base64_decode (std::ostream&, const std::string&); + + LIBBUTL_EXPORT std::vector<char> + base64_decode (const std::string&); +} + +#endif // LIBBUTL_BASE64_HXX |