OS dedicated utilities.
More...
#include <util.h>
|
static PidType | pid () noexcept |
| Returns the current process id. More...
|
|
static PidType | parent () noexcept |
| Returns the parent process id. More...
|
|
static std::string | homedir () noexcept |
| Gets the current user's home directory. More...
|
|
static std::string | tmpdir () noexcept |
| Gets the temp directory. More...
|
|
static std::string | env (const std::string &name) noexcept |
| Retrieves an environment variable. More...
|
|
static bool | env (const std::string &name, const std::string &value) noexcept |
| Creates, updates or deletes an environment variable. More...
|
|
template<typename Func > |
static std::enable_if_t< std::is_invocable_v< Func, std::string_view, std::string_view >, bool > | env (Func func) noexcept |
| Retrieves all environment variables and iterates them. More...
|
|
static std::string | hostname () noexcept |
| Returns the hostname. More...
|
|
static UtsName | uname () noexcept |
| Gets name and information about the current kernel. More...
|
|
static Passwd | passwd () noexcept |
| Gets a subset of the password file entry. More...
|
|
OS dedicated utilities.
Definition at line 462 of file util.h.
◆ env() [1/3]
static std::string uvw::Utilities::OS::env |
( |
const std::string & |
name | ) |
|
|
staticnoexcept |
Retrieves an environment variable.
- Parameters
-
name | The name of the variable to be retrieved. |
- Returns
- The value of the environment variable, an empty string in case of errors.
◆ env() [2/3]
static bool uvw::Utilities::OS::env |
( |
const std::string & |
name, |
|
|
const std::string & |
value |
|
) |
| |
|
staticnoexcept |
Creates, updates or deletes an environment variable.
- Parameters
-
name | The name of the variable to be updated. |
value | The value to be used for the variable (an empty string to unset it). |
- Returns
- True in case of success, false otherwise.
◆ env() [3/3]
template<typename Func >
static std::enable_if_t<std::is_invocable_v<Func, std::string_view, std::string_view>, bool> uvw::Utilities::OS::env |
( |
Func |
func | ) |
|
|
inlinestaticnoexcept |
Retrieves all environment variables and iterates them.
Environment variables are passed one at a time to the callback in the form of std::string_view
s.
The signature of the function call operator must be such that it accepts two parameters, the name and the value of the i-th variable.
- Template Parameters
-
Func | Type of a function object to which to pass environment variables. |
- Parameters
-
func | A function object to which to pass environment variables. |
- Returns
- True in case of success, false otherwise.
Definition at line 540 of file util.h.
◆ homedir()
static std::string uvw::Utilities::OS::homedir |
( |
| ) |
|
|
staticnoexcept |
Gets the current user's home directory.
See the official documentation for further details.
- Returns
- The current user's home directory, an empty string in case of errors.
◆ hostname()
static std::string uvw::Utilities::OS::hostname |
( |
| ) |
|
|
staticnoexcept |
Returns the hostname.
- Returns
- The hostname, an empty string in case of errors.
◆ parent()
static PidType uvw::Utilities::OS::parent |
( |
| ) |
|
|
staticnoexcept |
Returns the parent process id.
See the official documentation for further details.
- Returns
- The parent process id.
◆ passwd()
static Passwd uvw::Utilities::OS::passwd |
( |
| ) |
|
|
staticnoexcept |
Gets a subset of the password file entry.
This function can be used to get the subset of the password file entry for the current effective uid (not the real uid).
See the official documentation for further details.
- Returns
- The accessible subset of the password file entry.
◆ pid()
static PidType uvw::Utilities::OS::pid |
( |
| ) |
|
|
staticnoexcept |
Returns the current process id.
See the official documentation for further details.
- Returns
- The current process id.
◆ tmpdir()
static std::string uvw::Utilities::OS::tmpdir |
( |
| ) |
|
|
staticnoexcept |
Gets the temp directory.
See the official documentation for further details.
- Returns
- The temp directory, an empty string in case of errors.
◆ uname()
static UtsName uvw::Utilities::OS::uname |
( |
| ) |
|
|
staticnoexcept |
Gets name and information about the current kernel.
This function can be used to get name and information about the current kernel. The populated data includes the operating system name, release, version, and machine.
- Returns
- Name and information about the current kernel.
The documentation for this struct was generated from the following file: