D++ (DPP)
C++ Discord API Bot Library
|
Utility helper functions, generally for logging. More...
Classes | |
struct | iconhash |
Store a 128 bit icon hash (profile picture, server icon etc) as a 128 bit binary value made of two uint64_t. Has a constructor to build one from a string, and a method to fetch the value back in string form. More... | |
struct | uptime |
A class used to represent an uptime in hours, minutes, seconds and days, with helper functions to convert from time_t and display as a string. More... | |
Typedefs | |
typedef std::function< void(const std::string &output)> | cmd_result_t |
Functions | |
void | exec (const std::string &cmd, std::vector< std::string > parameters={}, cmd_result_t callback={}) |
Run a commandline program asyncronously. The command line program is spawned in a separate std::thread, and when complete, its output from stdout is passed to the callback function in its string prameter. For eample. More... | |
std::string | current_date_time () |
Returns urrent date and time. More... | |
std::string | loglevel (dpp::loglevel in) |
Convert a dpp::loglevel enum value to a string. More... | |
bool | has_voice () |
Returns true if D++ was built with voice support. More... | |
std::string | bytes (uint64_t c) |
Convert a byte count to display value. More... | |
void | debug_dump (uint8_t *data, size_t length) |
Output hex values of a section of memory for debugging. More... | |
Utility helper functions, generally for logging.
typedef std::function<void(const std::string& output)> dpp::utility::cmd_result_t |
std::string dpp::utility::bytes | ( | uint64_t | c | ) |
Convert a byte count to display value.
c | number of bytes |
std::string dpp::utility::current_date_time | ( | ) |
Returns urrent date and time.
void dpp::utility::debug_dump | ( | uint8_t * | data, |
size_t | length | ||
) |
Output hex values of a section of memory for debugging.
data | The start of the data to display |
length | The length of data to display |
void dpp::utility::exec | ( | const std::string & | cmd, |
std::vector< std::string > | parameters = {} , |
||
cmd_result_t | callback = {} |
||
) |
Run a commandline program asyncronously. The command line program is spawned in a separate std::thread, and when complete, its output from stdout is passed to the callback function in its string prameter. For eample.
cmd | The command to run. |
parameters | Command line parameters. Each will be escaped using std::quoted. |
callback | The callback to call on completion. |
bool dpp::utility::has_voice | ( | ) |
Returns true if D++ was built with voice support.
std::string dpp::utility::loglevel | ( | dpp::loglevel | in | ) |
Convert a dpp::loglevel enum value to a string.
in | log level to convert |