![]() |
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 | |
| std::string DPP_EXPORT | bytes (uint64_t c) |
| Convert a byte count to display value. More... | |
| std::string DPP_EXPORT | current_date_time () |
| Returns urrent date and time. More... | |
| std::string DPP_EXPORT | debug_dump (uint8_t *data, size_t length) |
| Output hex values of a section of memory for debugging. More... | |
| void DPP_EXPORT | 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 example. More... | |
| bool DPP_EXPORT | has_voice () |
| Returns true if D++ was built with voice support. More... | |
| std::string DPP_EXPORT | loglevel (dpp::loglevel in) |
| Convert a dpp::loglevel enum value to a string. More... | |
| uint32_t | rgb (float red, float green, float blue) |
| Convert floats to RGB for sending in embeds. More... | |
| uint32_t | rgb (int red, int green, int blue) |
| Convert ints to RGB for sending in embeds. More... | |
| double DPP_EXPORT | 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... | |
| size_t DPP_EXPORT | utf8len (const std::string &str) |
| Returns the length of a UTF-8 string in codepoints. More... | |
| std::string DPP_EXPORT | 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 DPP_EXPORT dpp::utility::bytes | ( | uint64_t | c | ) |
Convert a byte count to display value.
| c | number of bytes |
| std::string DPP_EXPORT dpp::utility::current_date_time | ( | ) |
Returns urrent date and time.
| std::string DPP_EXPORT 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_EXPORT 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 example.
| 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_EXPORT dpp::utility::has_voice | ( | ) |
Returns true if D++ was built with voice support.
| std::string DPP_EXPORT dpp::utility::loglevel | ( | dpp::loglevel | in | ) |
Convert a dpp::loglevel enum value to a string.
| in | log level to convert |
| uint32_t dpp::utility::rgb | ( | float | red, |
| float | green, | ||
| float | blue | ||
| ) |
Convert floats to RGB for sending in embeds.
| red | red value, between 0 and 1 inclusive |
| green | green value, between 0 and 1 inclusive |
| blue | blue value, between 0 and 1 inclusive |
| uint32_t dpp::utility::rgb | ( | int | red, |
| int | green, | ||
| int | blue | ||
| ) |
Convert ints to RGB for sending in embeds.
| red | red value, between 0 and 255 inclusive |
| green | green value, between 0 and 255 inclusive |
| blue | blue value, between 0 and 255 inclusive |
| double DPP_EXPORT 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 DPP_EXPORT 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 DPP_EXPORT 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 |