MySQL 26.10.0
Source Code Documentation
hm::utl Class Reference

#include <health_monitor_util.h>

Public Member Functions

 utl ()=delete
 

Static Public Member Functions

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...
 

Constructor & Destructor Documentation

◆ utl()

hm::utl::utl ( )
delete

Member Function Documentation

◆ 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_strUnix timestamp string, e.g. "2022-01-01 12:00:00"
[out]resultConverted 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
partThe numerator (e.g. MB used)
wholeThe 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
sThe input string to be converted
resultResult 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: