Miscellaneous utilities.
More...
#include <util.hpp>
Miscellaneous utilities.
Miscellaneous functions that don’t really belong to any other class.
Definition at line 431 of file util.hpp.
◆ chdir()
| static bool uvw::Utilities::chdir |
( |
const std::string & |
dir | ) |
|
|
inlinestaticnoexcept |
Changes the current working directory.
- Parameters
-
| dir | The working directory to be set. |
- Returns
- True in case of success, false otherwise.
Definition at line 850 of file util.hpp.
◆ cpuInfo()
| static std::vector<CPUInfo> uvw::Utilities::cpuInfo |
( |
| ) |
|
|
inlinestaticnoexcept |
Gets information about the CPUs on the system.
This function can be used to query the underlying system and get a set of descriptors of all the available CPUs.
- Returns
- A set of descriptors of all the available CPUs.
Definition at line 624 of file util.hpp.
◆ cwd()
| static std::string uvw::Utilities::cwd |
( |
| ) |
|
|
inlinestaticnoexcept |
Gets the current working directory.
- Returns
- The current working directory, an empty string in case of errors.
Definition at line 841 of file util.hpp.
◆ guessHandle() [1/2]
Gets the type of the handle given a category.
- Parameters
-
| category | A properly initialized handle category. |
- Returns
- The actual type of the handle as defined by HandleType
Definition at line 552 of file util.hpp.
◆ guessHandle() [2/2]
Gets the type of the stream to be used with the given descriptor.
Returns the type of stream that should be used with a given file descriptor.
Usually this will be used during initialization to guess the type of the stdio streams.
- Parameters
-
- Returns
- One of the following types:
HandleType::UNKNOWN
HandleType::PIPE
HandleType::TCP
HandleType::TTY
HandleType::UDP
HandleType::FILE
Definition at line 611 of file util.hpp.
◆ hrtime()
| static uint64_t uvw::Utilities::hrtime |
( |
| ) |
|
|
inlinestaticnoexcept |
Gets the current high-resolution real time.
The time is expressed in nanoseconds. It is relative to an arbitrary time in the past. It is not related to the time of the day and therefore not subject to clock drift. The primary use is for measuring performance between interval.
- Returns
- The current high-resolution real time.
Definition at line 825 of file util.hpp.
◆ indexToIid()
| static std::string uvw::Utilities::indexToIid |
( |
unsigned int |
index | ) |
|
|
inlinestaticnoexcept |
Retrieves a network interface identifier.
See the official documentation for further details.
- Parameters
-
| index | Network interface index. |
- Returns
- Network interface identifier.
Definition at line 707 of file util.hpp.
◆ indexToName()
| static std::string uvw::Utilities::indexToName |
( |
unsigned int |
index | ) |
|
|
inlinestaticnoexcept |
IPv6-capable implementation of if_indextoname.
Mapping between network interface names and indexes.
See the official documentation for further details.
- Parameters
-
| index | Network interface index. |
- Returns
- Network interface name.
Definition at line 693 of file util.hpp.
◆ interfaceAddresses()
Gets a set of descriptors of all the available interfaces.
This function can be used to query the underlying system and get a set of descriptors of all the available interfaces, either internal or not.
- Returns
- A set of descriptors of all the available interfaces.
Definition at line 649 of file util.hpp.
◆ loadAverage()
| static std::array<double, 3> uvw::Utilities::loadAverage |
( |
| ) |
|
|
inlinestaticnoexcept |
Gets the load average.
- Returns
[0,0,0] on Windows (not available), the load average otherwise.
Definition at line 741 of file util.hpp.
◆ path()
| static std::string uvw::Utilities::path |
( |
| ) |
|
|
inlinestaticnoexcept |
Gets the executable path.
- Returns
- The executable path, an empty string in case of errors.
Definition at line 833 of file util.hpp.
◆ processTitle() [1/2]
| static std::string uvw::Utilities::processTitle |
( |
| ) |
|
|
inlinestatic |
Gets the title of the current process.
- Returns
- The process title.
Definition at line 762 of file util.hpp.
◆ processTitle() [2/2]
| static bool uvw::Utilities::processTitle |
( |
std::string |
title | ) |
|
|
inlinestatic |
Sets the current process title.
- Parameters
-
| title | The process title to be set. |
- Returns
- True in case of success, false otherwise.
Definition at line 779 of file util.hpp.
◆ replaceAllocator()
| static bool uvw::Utilities::replaceAllocator |
( |
MallocFuncType |
mallocFunc, |
|
|
ReallocFuncType |
reallocFunc, |
|
|
CallocFuncType |
callocFunc, |
|
|
FreeFuncType |
freeFunc |
|
) |
| |
|
inlinestaticnoexcept |
Override the use of some standard library’s functions.
Override the use of the standard library’s memory allocation functions.
This method must be invoked before any other uvw function is called or after all resources have been freed and thus the underlying library doesn’t reference any allocated memory chunk.
If any of the function pointers is null, the invokation will fail.
Note: there is no protection against changing the allocator multiple times. If the user changes it they are responsible for making sure the allocator is changed while no memory was allocated with the previous allocator, or that they are compatible.
- Parameters
-
| mallocFunc | Replacement function for malloc. |
| reallocFunc | Replacement function for realloc. |
| callocFunc | Replacement function for calloc. |
| freeFunc | Replacement function for free. |
- Returns
- True in case of success, false otherwise.
Definition at line 733 of file util.hpp.
◆ rusage()
| static RUsage uvw::Utilities::rusage |
( |
| ) |
|
|
inlinestaticnoexcept |
Gets the resource usage measures for the current process.
- Returns
- Resource usage measures, zeroes-filled object in case of errors.
Definition at line 809 of file util.hpp.
◆ setupArgs()
| static char** uvw::Utilities::setupArgs |
( |
int |
argc, |
|
|
char ** |
argv |
|
) |
| |
|
inlinestatic |
Store the program arguments.
Required for getting / setting the process title.
- Returns
- Arguments that haven't been consumed internally.
Definition at line 754 of file util.hpp.
◆ totalMemory()
| static uint64_t uvw::Utilities::totalMemory |
( |
| ) |
|
|
inlinestaticnoexcept |
Gets memory information (in bytes).
- Returns
- Memory information.
Definition at line 787 of file util.hpp.
◆ uptime()
| static double uvw::Utilities::uptime |
( |
| ) |
|
|
inlinestaticnoexcept |
Gets the current system uptime.
- Returns
- The current system uptime or 0 in case of errors.
Definition at line 795 of file util.hpp.
The documentation for this struct was generated from the following file: