common: uuid: add `uuid_to_str` which returns an std::string
[lttng-tools.git] / src / common / uuid.cpp
index a820a8a4191defbef75ae63c2085540f8f5dfcae..d4f0fb2bf1a748d6c9d087bbe83920702f5f430d 100644 (file)
@@ -26,6 +26,18 @@ void lttng_uuid_to_str(const lttng_uuid& uuid, char *uuid_str)
        sprintf(uuid_str, LTTNG_UUID_FMT, LTTNG_UUID_FMT_VALUES(uuid));
 }
 
+std::string lttng::utils::uuid_to_str(const lttng_uuid& uuid)
+{
+       std::string uuid_str(LTTNG_UUID_STR_LEN, '\0');
+
+       ::lttng_uuid_to_str(uuid, &uuid_str[0]);
+
+       /* Don't include '\0' in the C++ string. */
+       uuid_str.resize(uuid_str.size() - 1);
+
+       return uuid_str;
+}
+
 int lttng_uuid_from_str(const char *str_in, lttng_uuid& uuid_out)
 {
        int ret = 0;
This page took 0.023334 seconds and 4 git commands to generate.