A reference type refering to an environment variable.
More...
#include <env.hpp>
|
template<size_t Size> |
| Var (char const (&name)[Size]) |
| Construct an environment variable reference. More...
|
|
| Var (Var const &)=delete |
| Do not permit copy construction.
|
|
Var & | operator= (Var const &)=delete |
| Do not permit copy assignment.
|
|
| operator char const * () const |
| Retrieve the value of the environment variable. More...
|
|
Var & | operator= (char const *const assign) |
| Assign a new value to the environment variable. More...
|
|
Var & | erase () |
| Explicitly deletes the environment variable. More...
|
|
const char * | c_str () const |
| Explicitly retrieve the value as a character array. More...
|
|
|
const char *const | name |
| A pointer to the variable name.
|
|
A reference type refering to an environment variable.
To avoid issues with the lifetime of the name string this is not copy constructible or assignable.
◆ Var()
template<size_t Size>
sys::env::Var::Var |
( |
char const (&) |
name[Size] | ) |
|
|
inline |
Construct an environment variable reference.
- Template Parameters
-
Size | The size of the name buffer |
- Parameters
-
name | The name of the environment variable |
◆ c_str()
const char* sys::env::Var::c_str |
( |
| ) |
const |
|
inline |
Explicitly retrieve the value as a character array.
- Returns
- A pointer to the character array with the variable value
- Return values
-
nullptr | The variable does not exist |
◆ erase()
Var& sys::env::Var::erase |
( |
| ) |
|
|
inline |
Explicitly deletes the environment variable.
- Returns
- A self-reference
- Exceptions
-
sc_error<error>{EINVAL} | Invalid variable name |
sc_error<error>{ENOMEM} | Failed to allocate memory when updating the environment |
◆ operator char const *()
sys::env::Var::operator char const * |
( |
| ) |
const |
|
inline |
Retrieve the value of the environment variable.
- Returns
- A pointer to the character array with the variable value
- Return values
-
nullptr | The variable does not exist |
◆ operator=()
Var& sys::env::Var::operator= |
( |
char const *const |
assign | ) |
|
|
inline |
Assign a new value to the environment variable.
Deletes the variable if nullptr is assigned.
- Parameters
-
- Returns
- A self-reference
- Exceptions
-
sc_error<error>{EINVAL} | Invalid variable name |
sc_error<error>{ENOMEM} | Failed to allocate memory when updating the environment |
The documentation for this class was generated from the following file: