#include <health_monitor_util.h>
|
| static double | percent (double part, double whole) |
| | Compute (part / whole) * 100, clamped to [0, 100]. More...
|
| |
| static double | change_percent (uint64_t previous, uint64_t current) |
| | Return the absolute percentage change, or zero without a baseline. More...
|
| |
| static bool | stoi (const std::string &s, int &result) |
| | Safe conversion functions. More...
|
| |
| static bool | stoul (const std::string &s, uint64_t &result) |
| |
| static bool | stoll (const std::string &s, int64_t &result) |
| |
| static bool | stod (const std::string &s, double &result) |
| |
| static std::string | trim (const std::string &s) |
| |
| static int | convert_timestamp (const std::string &ts_str, time_t &result) |
| | Convert a Unix-style timestamp to time_t. More...
|
| |
◆ utl()
◆ change_percent()
| static double hm::utl::change_percent |
( |
uint64_t |
previous, |
|
|
uint64_t |
current |
|
) |
| |
|
inlinestatic |
Return the absolute percentage change, or zero without a baseline.
◆ convert_timestamp()
| int hm::utl::convert_timestamp |
( |
const std::string & |
ts_str, |
|
|
time_t & |
result |
|
) |
| |
|
static |
Convert a Unix-style timestamp to time_t.
- Parameters
-
| [in] | ts_str | Unix timestamp string, e.g. "2022-01-01 12:00:00" |
| [out] | result | Converted timestamp |
- Returns
- 0 on success, non-zero otherwise
◆ percent()
| double hm::utl::percent |
( |
double |
part, |
|
|
double |
whole |
|
) |
| |
|
static |
Compute (part / whole) * 100, clamped to [0, 100].
- Parameters
-
| part | The numerator (e.g. MB used) |
| whole | The denominator (e.g. MB available) |
- Returns
- Percentage in range [0.0, 100.0]
◆ stod()
| bool hm::utl::stod |
( |
const std::string & |
s, |
|
|
double & |
result |
|
) |
| |
|
static |
◆ stoi()
| bool hm::utl::stoi |
( |
const std::string & |
s, |
|
|
int & |
result |
|
) |
| |
|
static |
Safe conversion functions.
- Parameters
-
| s | The input string to be converted |
| result | Result of the conversion |
- Returns
- false if successful, true otherwise
- Note
- The functions check if the entire string is consumed during the conversion. If the string is empty or contains non-numeric characters, the function returns true.
◆ stoll()
| bool hm::utl::stoll |
( |
const std::string & |
s, |
|
|
int64_t & |
result |
|
) |
| |
|
static |
◆ stoul()
| bool hm::utl::stoul |
( |
const std::string & |
s, |
|
|
uint64_t & |
result |
|
) |
| |
|
static |
◆ trim()
| std::string hm::utl::trim |
( |
const std::string & |
s | ) |
|
|
static |
The documentation for this class was generated from the following files: