powerd++
0.4.4
|
This is a specialisation of Sysctl for sysctls using symbolic names. More...
#include <sysctl.hpp>
Public Member Functions | |
constexpr | Sysctl () |
The default constructor. More... | |
Sysctl (char const *const name) | |
Initialise the MIB address from a character string. More... | |
size_t | size () const |
The size of the sysctl. More... | |
void | get (void *const buf, size_t const bufsize) const |
Update the given buffer with a value retrieved from the sysctl. More... | |
template<typename T > | |
void | get (T &value) const |
Update the given value with a value retreived from the sysctl. More... | |
template<typename T > | |
std::unique_ptr< T[]> | get () const |
Retrieve an array from the sysctl address. More... | |
void | set (void const *const buf, size_t const bufsize) |
Update the the sysctl value with the given buffer. More... | |
template<typename T > | |
void | set (T const &value) |
Update the the sysctl value with the given value. More... | |
Private Attributes | |
mib_t | mib [CTL_MAXNAME] |
Stores the MIB address. | |
size_t | depth |
The MIB depth. | |
This is a specialisation of Sysctl for sysctls using symbolic names.
A Sysctl instance created with the default constructor is unitialised, initialisation can be deferred to a later moment by using copy assignment. This can be used to create globals but construct them inline where exceptions can be handled.
|
inlineconstexpr |
The default constructor.
This is available to defer initialisation to a later moment.
|
inline |
Initialise the MIB address from a character string.
name | The symbolic name of the sysctl |
sys::sc_error<error> | May throw an exception if the addressed sysct does not exist or if the address is too long to store |
|
inline |
Retrieve an array from the sysctl address.
This is useful to retrieve variable length sysctls, like characer strings.
T | The type stored in the array |
sys::sc_error<error> | May throw if the size of the sysctl increases after the length was queried |
|
inline |
Update the given value with a value retreived from the sysctl.
T | The type store the sysctl value in |
value | A reference to the target value |
sys::sc_error<error> | Throws if value retrieval fails or is incomplete, e.g. because the value does not fit into the target type |
|
inline |
Update the given buffer with a value retrieved from the sysctl.
buf,bufsize | The target buffer and its size |
sys::sc_error<error> | Throws if value retrieval fails or is incomplete, e.g. because the value does not fit into the target buffer |
|
inline |
Update the the sysctl value with the given value.
T | The value type |
value | The value to set the sysctl to |
|
inline |
Update the the sysctl value with the given buffer.
buf,bufsize | The source buffer |
sys::sc_error<error> | If the source buffer cannot be stored in the sysctl |
|
inline |
The size of the sysctl.