libpromeki main
PROfessional MEdia toolKIt
 
Loading...
Searching...
No Matches
Env Class Reference

Provides access to process environment variables. More...

#include <env.h>

Static Public Member Functions

static String get (const char *name)
 Returns the value of an environment variable.
 
static String get (const char *name, const String &defaultValue)
 Returns the value of an environment variable with a default.
 
static bool isSet (const char *name)
 Returns true if the environment variable is set.
 
static bool set (const char *name, const String &value, bool overwrite=true)
 Sets an environment variable.
 
static bool unset (const char *name)
 Removes an environment variable.
 

Detailed Description

Provides access to process environment variables.

Static utility class wrapping standard environment variable operations. All methods return promeki::String for consistent integration with the

Example
String home = Env::get("HOME");
Env::set("MY_APP_DEBUG", "1");
bool exists = Env::contains("PATH");
static String get(const char *name)
Returns the value of an environment variable.
Definition env.h:38
static bool set(const char *name, const String &value, bool overwrite=true)
Sets an environment variable.
Encoding-aware string class with copy-on-write semantics.
Definition string.h:35
rest of the library.

Member Function Documentation

◆ get() [1/2]

static String Env::get ( const char name)
inlinestatic

Returns the value of an environment variable.

Parameters
nameThe variable name.
Returns
The value as a String, or an empty String if not set.

◆ get() [2/2]

static String Env::get ( const char name,
const String defaultValue 
)
inlinestatic

Returns the value of an environment variable with a default.

Parameters
nameThe variable name.
defaultValueValue to return if the variable is not set.
Returns
The value as a String, or defaultValue if not set.

◆ isSet()

static bool Env::isSet ( const char name)
inlinestatic

Returns true if the environment variable is set.

Parameters
nameThe variable name.
Returns
true if the variable exists in the environment.

◆ set()

static bool Env::set ( const char name,
const String value,
bool  overwrite = true 
)
static

Sets an environment variable.

Parameters
nameThe variable name.
valueThe value to set.
overwriteIf true, overwrite an existing value.
Returns
true on success.

◆ unset()

static bool Env::unset ( const char name)
static

Removes an environment variable.

Parameters
nameThe variable name.
Returns
true on success.

The documentation for this class was generated from the following file: