core::posix::this_process::env Namespace Reference

## Functions

CORE_POSIX_DLL_PUBLIC void | for_each (const std::function< void(const std::string &, const std::string &)> &functor) noexcept(true)
| for_each invokes a functor for every key-value pair in the environment.
CORE_POSIX_DLL_PUBLIC std::string | get_or_throw (const std::string &key)
| get queries the value of an environment variable.
CORE_POSIX_DLL_PUBLIC std::string | get (const std::string &key, const std::string &default_value=std::string()) noexcept(true)
| get queries the value of an environment variable.
CORE_POSIX_DLL_PUBLIC void | unset_or_throw (const std::string &key)
| unset_or_throw removes the variable with name key from the environment.
CORE_POSIX_DLL_PUBLIC bool | unset (const std::string &key, std::error_code &se) noexcept(true)
| unset removes the variable with name key from the environment.
CORE_POSIX_DLL_PUBLIC void | set_or_throw (const std::string &key, const std::string &value)
| set_or_throw will adjust the contents of the variable identified by key to the provided value.
CORE_POSIX_DLL_PUBLIC bool | set (const std::string &key, const std::string &value, std::error_code &se) noexcept(true)
| set will adjust the contents of the variable identified by key to the provided value.

## Function Documentation

## for_each()

void core::posix::this_process::env::for_each | ( | const std::function< void(const std::string &, const std::string &)> & | functor | ) |

noexcept

for_each invokes a functor for every key-value pair in the environment.

Parameters

  [in] | functor | Invoked for every key-value pair.

Definition at line 55 of file this_process.cpp.

References environ.

Referenced by TEST(), TEST(), TEST(), TEST(), and TEST().

## get()

std::string core::posix::this_process::env::get | ( | const std::string & | key,
|  | const std::string & | default_value = std::string() )

noexcept

get queries the value of an environment variable.

Parameters

  [in] | key | Name of the variable to query the value for.
  [in] | default_value | Default value to return when key is not present in the environment.

Returns
  Contents of the variable or an empty string if the variable is not defined.

Definition at line 84 of file this_process.cpp.

Referenced by TEST(), TEST(), TEST(), and TEST().

## get_or_throw()

std::string core::posix::this_process::env::get_or_throw | ( | const std::string & | key | ) |

get queries the value of an environment variable.

Exceptions

  std::runtime_error | if there is no variable with the given key defined in the env.

Parameters

  [in] | key | Name of the variable to query the value for.

Returns
  Contents of the variable.

Definition at line 68 of file this_process.cpp.

## set()

bool core::posix::this_process::env::set | ( | const std::string & | key,
|  | const std::string & | value,
|  | std::error_code & | se )

noexcept

set will adjust the contents of the variable identified by key to the provided value.

Returns
  false in case of errors, true otherwise.

Parameters

  [in] | key | Name of the variable to set the value for.
  [in] | value | New contents of the variable.
  [out] | se | Receives the details in case of errors.

Definition at line 131 of file this_process.cpp.

## set_or_throw()

void core::posix::this_process::env::set_or_throw | ( | const std::string & | key,
|  | const std::string & | value )

set_or_throw will adjust the contents of the variable identified by key to the provided value.

Exceptions

  std::system_error | in case of errors.

Parameters

  [in] | key | Name of the variable to set the value for.
  [in] | value | New contents of the variable.

Definition at line 119 of file this_process.cpp.

Referenced by TEST(), and TEST().

## unset()

bool core::posix::this_process::env::unset | ( | const std::string & | key,
|  | std::error_code & | se )

noexcept

unset removes the variable with name key from the environment.

Returns
  false in case of errors, true otherwise.

Parameters

  [in] | key | Name of the variable to unset.
  [out] | se | Receives error details if unset returns false.

Definition at line 103 of file this_process.cpp.

## unset_or_throw()

void core::posix::this_process::env::unset_or_throw | ( | const std::string & | key | ) |

unset_or_throw removes the variable with name key from the environment.

Exceptions

  std::system_error | in case of errors.

Parameters

  [in] | key | Name of the variable to unset.

Definition at line 93 of file this_process.cpp.

Referenced by TEST().