RSTools 3.1.0
Versatile C++20 utility library
Loading...
Searching...
No Matches
SystemInfo.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <cstddef>
4#include <cstdint>
5#include <string>
6#include <string_view>
7
8namespace RST::System {
9
12
14 [[nodiscard]] std::size_t getCpuCores() noexcept;
16 [[nodiscard]] std::string getCpuName();
18 [[nodiscard]] constexpr std::string_view getArchitecture() noexcept
19 {
20#if defined(__x86_64__) || defined(_M_X64)
21 return "x86_64";
22#elif defined(__i386__) || defined(_M_IX86)
23 return "x86";
24#elif defined(__aarch64__) || defined(_M_ARM64)
25 return "arm64";
26#elif defined(__arm__) || defined(_M_ARM)
27 return "arm";
28#elif defined(__riscv)
29 return "riscv";
30#elif defined(__wasm__)
31 return "wasm";
32#else
33 return "unknown";
34#endif
35 }
37
41 [[nodiscard]] std::uint64_t getTotalRAM() noexcept;
42 [[nodiscard]] std::uint64_t getAvailableRAM() noexcept;
43
45 [[nodiscard]] std::uint64_t getProcessMemoryUsage() noexcept;
47 [[nodiscard]] std::uint64_t getPeakProcessMemoryUsage() noexcept;
49
52
54 [[nodiscard]] std::string getOSName();
55
57 [[nodiscard]] std::string getHostName();
59
63 [[nodiscard]] std::uint64_t getTotalDiskSpace(const std::string& path = "/");
64 [[nodiscard]] std::uint64_t getAvailableDiskSpace(const std::string& path = "/");
66}
Portable access to system information, environment variables, files and paths.
Definition Environment.hpp:7
constexpr std::string_view getArchitecture() noexcept
Architecture the program was built for: x86_64, x86, arm64, arm, riscv, wasm or unknown.
Definition SystemInfo.hpp:18
std::uint64_t getPeakProcessMemoryUsage() noexcept
Highest physical memory used by this process so far.
std::uint64_t getAvailableDiskSpace(const std::string &path="/")
std::string getOSName()
Operating system family, such as Linux or Windows 64-bit.
std::string getHostName()
Network name of this computer, or an empty string on failure.
std::uint64_t getTotalRAM() noexcept
std::string getCpuName()
CPU model name, or an empty string if unknown.
std::uint64_t getProcessMemoryUsage() noexcept
Physical memory used by this process.
std::uint64_t getTotalDiskSpace(const std::string &path="/")
std::size_t getCpuCores() noexcept
Number of logical cores, at least 1.
std::uint64_t getAvailableRAM() noexcept