aboutsummaryrefslogtreecommitdiff
path: root/libbutl/utility.mxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2018-06-14 18:13:04 +0200
committerKaren Arutyunov <karen@codesynthesis.com>2018-06-15 14:21:58 +0300
commit481f9ba1aee62fea092184f2243d210a8686781f (patch)
treea54fc536d835c5277038e145fabc1255c42ff8ac /libbutl/utility.mxx
parent5d424ea127333859a32addaf9e28eae07a4dc9f6 (diff)
Add portable environment variable manipulation functions
Diffstat (limited to 'libbutl/utility.mxx')
-rw-r--r--libbutl/utility.mxx22
1 files changed, 22 insertions, 0 deletions
diff --git a/libbutl/utility.mxx b/libbutl/utility.mxx
index 740b411..252a4b4 100644
--- a/libbutl/utility.mxx
+++ b/libbutl/utility.mxx
@@ -35,6 +35,9 @@ export module butl.utility;
import std.core;
import std.io;
#endif
+import butl.optional;
+#else
+#include <libbutl/optional.mxx>
#endif
#include <libbutl/export.hxx>
@@ -183,6 +186,25 @@ LIBBUTL_MODEXPORT namespace butl
bool
eof (std::istream&);
+ // Environment variables.
+ //
+ optional<std::string>
+ getenv (const std::string&);
+
+ // Throw system_error on failure.
+ //
+ // Note that on Windows setting an empty value usets the variable.
+ //
+ LIBBUTL_SYMEXPORT
+ void
+ setenv (const std::string& name, const std::string& value);
+
+ // Throw system_error on failure.
+ //
+ LIBBUTL_SYMEXPORT
+ void
+ unsetenv (const std::string&);
+
// Key comparators (i.e., to be used in sets, maps, etc).
//
struct compare_c_string