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 CoreExport | 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 CoreExport | current_date_time () |
Returns urrent date and time. More... | |
std::string CoreExport | loglevel (dpp::loglevel in) |
Convert a dpp::loglevel enum value to a string. More... | |
double CoreExport | time_f () |
Return the current time with fractions of seconds. This is a unix epoch time with the fractional seconds part after the decimal place. More... | |
bool CoreExport | has_voice () |
Returns true if D++ was built with voice support. More... | |
std::string CoreExport | bytes (uint64_t c) |
Convert a byte count to display value. More... | |
void CoreExport | debug_dump (uint8_t *data, size_t length) |
Output hex values of a section of memory for debugging. More... | |
size_t CoreExport | utf8len (const std::string &str) |
Returns the length of a UTF-8 string in codepoints. More... | |
std::string CoreExport | utf8substr (const std::string &str, std::string::size_type start, std::string::size_type length) |
Return substring of a UTF-8 encoded string in codepoints. More... | |
Utility helper functions, generally for logging.
typedef std::function<void(const std::string& output)> dpp::utility::cmd_result_t |
std::string CoreExport dpp::utility::bytes | ( | uint64_t | c | ) |
Convert a byte count to display value.
c | number of bytes |
std::string CoreExport dpp::utility::current_date_time | ( | ) |
Returns urrent date and time.
void CoreExport 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 CoreExport 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 CoreExport dpp::utility::has_voice | ( | ) |
Returns true if D++ was built with voice support.
std::string CoreExport dpp::utility::loglevel | ( | dpp::loglevel | in | ) |
Convert a dpp::loglevel enum value to a string.
in | log level to convert |
double CoreExport dpp::utility::time_f | ( | ) |
Return the current time with fractions of seconds. This is a unix epoch time with the fractional seconds part after the decimal place.
size_t CoreExport dpp::utility::utf8len | ( | const std::string & | str | ) |
Returns the length of a UTF-8 string in codepoints.
str | string to count length of |
std::string CoreExport dpp::utility::utf8substr | ( | const std::string & | str, |
std::string::size_type | start, | ||
std::string::size_type | length | ||
) |
Return substring of a UTF-8 encoded string in codepoints.
str | string to return substring from |
start | start codepoint offset |
length | length in codepoints |