utils: add from_gchars
To copy into a std::string & free.
This commit is contained in:
@ -130,6 +130,23 @@ std::string date_to_time_t_string(const std::string& date, bool first);
|
||||
*/
|
||||
std::string date_to_time_t_string(int64_t t);
|
||||
|
||||
/**
|
||||
* Create a std::string by consuming a gchar* array; this takes ownership
|
||||
* of str which should no longer be used.
|
||||
*
|
||||
* @param str a gchar* or NULL (latter taken as "")
|
||||
*
|
||||
* @return a std::string
|
||||
*/
|
||||
static inline std::string
|
||||
from_gchars(gchar*&& str)
|
||||
{
|
||||
std::string s{str ? str : ""};
|
||||
g_free(str);
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
using Clock = std::chrono::steady_clock;
|
||||
using Duration = Clock::duration;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user