22#include <boost/algorithm/string.hpp>
32#if defined(_GNU_SOURCE)
55void for_each(
const std::function<
void(
const std::string&,
const std::string&)>&
functor)
noexcept(
true)
59 while (
it !=
nullptr && *
it !=
nullptr)
63 line.substr(
line.find_first_of(
'=')+1));
77 ss <<
"Variable with name " <<
key <<
" is not defined in the environment";
78 throw std::runtime_error(
ss.str());
81 return std::string{
result};
84std::string
get(
const std::string&
key,
100 throw std::system_error(
errno, std::system_category());
104 std::error_code&
se)
noexcept(
true)
112 se = std::error_code(
errno, std::system_category());
120 const std::string& value)
128 throw std::system_error(
errno, std::system_category());
132 const std::string &value,
133 std::error_code&
se)
noexcept(
true)
142 se = std::error_code(
errno, std::system_category());
The Process class models a process and possible operations on it.
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.
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 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 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 unset_or_throw(const std::string &key)
unset_or_throw removes the variable with name key from the environment.
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::ostream & cout() noexcept(true)
Access this process's stdout.
CORE_POSIX_DLL_PUBLIC Process parent() noexcept(true)
Query the parent of the process.
CORE_POSIX_DLL_PUBLIC std::ostream & cerr() noexcept(true)
Access this process's stderr.
CORE_POSIX_DLL_PUBLIC Process instance() noexcept(true)
Returns a Process instance corresponding to this process.
CORE_POSIX_DLL_PUBLIC std::istream & cin() noexcept(true)
Access this process's stdin.
Signal
The Signal enum collects the most common POSIX signals.