diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2018-06-14 18:13:04 +0200 |
---|---|---|
committer | Karen Arutyunov <karen@codesynthesis.com> | 2018-06-15 14:21:58 +0300 |
commit | 481f9ba1aee62fea092184f2243d210a8686781f (patch) | |
tree | a54fc536d835c5277038e145fabc1255c42ff8ac /libbutl/utility.ixx | |
parent | 5d424ea127333859a32addaf9e28eae07a4dc9f6 (diff) |
Add portable environment variable manipulation functions
Diffstat (limited to 'libbutl/utility.ixx')
-rw-r--r-- | libbutl/utility.ixx | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/libbutl/utility.ixx b/libbutl/utility.ixx index d4aaa65..565a694 100644 --- a/libbutl/utility.ixx +++ b/libbutl/utility.ixx @@ -2,6 +2,10 @@ // copyright : Copyright (c) 2014-2018 Code Synthesis Ltd // license : MIT; see accompanying LICENSE file +#ifndef __cpp_lib_modules +#include <cstdlib> // getenv() +#endif + namespace butl { inline char @@ -199,4 +203,13 @@ namespace butl throw std::istream::failure (""); } + + inline optional<std::string> + getenv (const std::string& name) + { + if (const char* r = std::getenv (name.c_str ())) + return std::string (r); + + return nullopt; + } } |