aboutsummaryrefslogtreecommitdiff
path: root/libbutl/base64.mxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2017-09-22 23:32:28 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2017-09-22 23:32:28 +0200
commitc09cd7512491cee1e82c1ad8128ce9fd4bc3f79b (patch)
treea659ed768d849130ab5780a11b7f791a463a1a91 /libbutl/base64.mxx
parent2a00871f07067f8f9e2de08bb9c8f50e1bf6a650 (diff)
Initial modularization with both Clang and VC hacks
Note: gave up on VC about half way though.
Diffstat (limited to 'libbutl/base64.mxx')
-rw-r--r--libbutl/base64.mxx63
1 files changed, 63 insertions, 0 deletions
diff --git a/libbutl/base64.mxx b/libbutl/base64.mxx
new file mode 100644
index 0000000..ae43ba6
--- /dev/null
+++ b/libbutl/base64.mxx
@@ -0,0 +1,63 @@
+// file : libbutl/base64.mxx -*- C++ -*-
+// copyright : Copyright (c) 2014-2017 Code Synthesis Ltd
+// license : MIT; see accompanying LICENSE file
+
+#ifndef __cpp_modules
+#pragma once
+#endif
+
+// C includes.
+
+#ifndef __cpp_lib_modules
+#include <iosfwd>
+#include <string>
+#include <vector>
+#endif
+
+// Other includes.
+
+#ifdef __cpp_modules
+export module butl.base64;
+#ifdef __cpp_lib_modules
+import std.core;
+import std.io;
+#endif
+#endif
+
+#include <libbutl/export.hxx>
+
+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<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_SYMEXPORT void
+ base64_decode (std::ostream&, std::istream&);
+
+ LIBBUTL_SYMEXPORT void
+ base64_decode (std::ostream&, const std::string&);
+
+ LIBBUTL_SYMEXPORT std::vector<char>
+ base64_decode (const std::string&);
+}