libpromeki main
PROfessional MEdia toolKIt
 
Loading...
Searching...
No Matches
env.h
Go to the documentation of this file.
1
8#pragma once
9
10#include <cstdlib>
12#include <promeki/core/string.h>
13
15
31class Env {
32 public:
38 static String get(const char *name) {
39 const char *val = std::getenv(name);
40 return val ? String(val) : String();
41 }
42
49 static String get(const char *name, const String &defaultValue) {
50 const char *val = std::getenv(name);
51 return val ? String(val) : defaultValue;
52 }
53
59 static bool isSet(const char *name) {
60 return std::getenv(name) != nullptr;
61 }
62
70 static bool set(const char *name, const String &value, bool overwrite = true);
71
77 static bool unset(const char *name);
78};
79
Provides access to process environment variables.
Definition env.h:31
static String get(const char *name)
Returns the value of an environment variable.
Definition env.h:38
static bool unset(const char *name)
Removes an environment variable.
static bool isSet(const char *name)
Returns true if the environment variable is set.
Definition env.h:59
static bool set(const char *name, const String &value, bool overwrite=true)
Sets an environment variable.
static String get(const char *name, const String &defaultValue)
Returns the value of an environment variable with a default.
Definition env.h:49
Dynamic array container wrapping std::vector.
Definition list.h:40
Encoding-aware string class with copy-on-write semantics.
Definition string.h:35
#define PROMEKI_NAMESPACE_BEGIN
Starts a promeki namespace block.
Definition namespace.h:14
#define PROMEKI_NAMESPACE_END
Ends a promeki namespace block.
Definition namespace.h:19
const T & value(const Result< T > &r)
Returns the value from a Result.
Definition result.h:56