![]() |
ImFusion SDK 4.3
|
Selection of platform-specific functions. More...
Selection of platform-specific functions.
Classes | |
struct | MemoryInfo |
Structure storing information about the available main memory as reported Platform::memoryInfo(). More... | |
Functions | |
std::string | stacktrace () |
Generates a platform-dependent call stack of the current execution environment. | |
void | signalDebugTrap () |
Generates a platform-dependent trap signal that can be caught by an attached debugger to interrupt the program. | |
MemoryInfo | memoryInfo () |
Returns the currently available system memory and the total amount of memory. | |
Filesystem::Path | executablePath () |
Returns the absolute path to the current executable (including the name of the executable) | |
Filesystem::Path | libraryPath (const std::string &libName) |
Returns the absolute path to the given library (including the full name of the library). | |
Handling of Environment Variables | |
std::string | getEnvironmentVariable (const std::string &variableName, const std::string &defaultValue, bool reset=false) |
Reads an environment variable passed to the program at launch. | |
void | setEnvironmentVariable (const std::string &variableName, const std::string &newValue) |
Writes an environment variable. | |
Handling of crashes | |
void | installCrashHandler () |
Install OS-specific hooks to catch and handle critical signals/exceptions. | |
void | resetCrashHandler () |
Remove crash hooks again. | |
Changing the byte order (endianness) | |
void | swapEndianness (uint16_t *buffer, int64_t numElements) |
Reverses the order of bytes in the given buffer of 16-bit integers. | |
void | swapEndianness (uint32_t *buffer, int64_t numElements) |
Reverses the order of bytes in the given buffer of 32-bit integers. | |
void | swapEndianness (uint64_t *buffer, int64_t numElements) |
Reverses the order of bytes in the given buffer of 64-bit integers. | |
template<typename T> | |
void | swapEndianness (T *buffer, int64_t numElements) |
Reverses the order of bytes in the given buffer of integers. | |
Type names | |
std::optional< std::string > | demangleTypeName (const std::type_info &typeInfo) |
Returns the demangled name of the type represented by the given type_info object. | |
template<typename T> | |
std::optional< std::string > | demangleTypeName () |
Returns the demangled name of the type T . | |
std::string getEnvironmentVariable | ( | const std::string & | variableName, |
const std::string & | defaultValue, | ||
bool | reset = false ) |
#include <ImFusion/Core/Platform.h>
Reads an environment variable passed to the program at launch.
The environment variable is read only the first time that the function is called with a given variable name. The result is cached for subsequent calls. The cache can be reset with the respective parameter.
Setting the empty value for an environment variable equals to unsetting it. In this case, the default value will be returned.
The cache is automatically updated when a variable is modified through setEnvironmentVariable().
variableName | The name of the environment variable to be read |
defaultValue | The default value to be returned if the variable value was not set |
reset | If true, the cached value for the environment variable will be deleted |
void setEnvironmentVariable | ( | const std::string & | variableName, |
const std::string & | newValue ) |
#include <ImFusion/Core/Platform.h>
Writes an environment variable.
Updates the environment value table for the current process, setting the provided value for the specified variable.
To unset the variable, the empty string should be specified as new value. readEnvironmentVariable() will then return the default when the variable is queried.
The cache used by getEnvironmentVariable() is also updated in the process, so no further action is required.
variableName | The name of the environment variable to be written |
newValue | The new value that is to be assumed by the variable |
MemoryInfo memoryInfo | ( | ) |
#include <ImFusion/Core/Platform.h>
Returns the currently available system memory and the total amount of memory.
Filesystem::Path libraryPath | ( | const std::string & | libName | ) |
#include <ImFusion/Core/Platform.h>
Returns the absolute path to the given library (including the full name of the library).
The library must be loaded by the current process. An empty string is returned if the library could not be found.
libName | Filename of the library to resolve without extension, e.g. ImFusionCore or ImFusionLib . On Unix platforms this function will automatically prepend the lib prefix to libName during lookup. On Linux, this function will match library names of the form "*.so{.versioning}" with the constraint that the optional versioning is of the form "1.23.312", i.e. three digits. Comparison is performed in a case-sensitive fashion. |
void installCrashHandler | ( | ) |
#include <ImFusion/Core/Platform.h>
Install OS-specific hooks to catch and handle critical signals/exceptions.
The handler will write the current stacktrace() to the log and flush it to ensure that all pending writes of the log are completed in case the application terminates.
void swapEndianness | ( | T * | buffer, |
int64_t | numElements ) |
#include <ImFusion/Core/Platform.h>
Reverses the order of bytes in the given buffer of integers.
T
must be an integral type of 16, 32, or 64 bit width.
std::optional< std::string > demangleTypeName | ( | const std::type_info & | typeInfo | ) |
#include <ImFusion/Core/Platform.h>
Returns the demangled name of the type represented by the given type_info object.
Returns an empty optional if demangling fails.
std::optional< std::string > demangleTypeName | ( | ) |
#include <ImFusion/Core/Platform.h>
Returns the demangled name of the type T
.
Returns an empty optional if demangling fails.