aboutsummaryrefslogtreecommitdiffstats
path: root/util/system/env.h
diff options
context:
space:
mode:
authorDevtools Arcadia <arcadia-devtools@yandex-team.ru>2022-02-07 18:08:42 +0300
committerDevtools Arcadia <arcadia-devtools@mous.vla.yp-c.yandex.net>2022-02-07 18:08:42 +0300
commit1110808a9d39d4b808aef724c861a2e1a38d2a69 (patch)
treee26c9fed0de5d9873cce7e00bc214573dc2195b7 /util/system/env.h
downloadydb-1110808a9d39d4b808aef724c861a2e1a38d2a69.tar.gz
intermediate changes
ref:cde9a383711a11544ce7e107a78147fb96cc4029
Diffstat (limited to 'util/system/env.h')
-rw-r--r--util/system/env.h32
1 files changed, 32 insertions, 0 deletions
diff --git a/util/system/env.h b/util/system/env.h
new file mode 100644
index 0000000000..e2ccdd1e95
--- /dev/null
+++ b/util/system/env.h
@@ -0,0 +1,32 @@
+#pragma once
+
+#include <util/generic/string.h>
+
+/**
+ * Search the environment list provided by the host environment for associated variable.
+ *
+ * @param key String identifying the name of the environmental variable to look for
+ * @param def String that returns if environmental variable not found by key
+ *
+ * @return String that is associated with the matched environment variable or empty string if
+ * such variable is missing.
+ *
+ * @note Use it only in pair with `SetEnv` as there may be inconsistency in their behaviour
+ * otherwise.
+ * @note Calls to `GetEnv` and `SetEnv` from different threads must be synchronized.
+ * @see SetEnv
+ */
+TString GetEnv(const TString& key, const TString& def = TString());
+
+/**
+ * Add or change environment variable provided by the host environment.
+ *
+ * @key String identifying the name of the environment variable to set or change
+ * @value Value to assign
+
+ * @note Use it only in pair with `GetEnv` as there may be inconsistency in their behaviour
+ * otherwise.
+ * @note Calls to `GetEnv` and `SetEnv` from different threads must be synchronized.
+ * @see GetEnv
+ */
+void SetEnv(const TString& key, const TString& value);