#include "cpp-common/exc.hpp"
#include "cpp-common/make-unique.hpp"
#include <vector>
+#include <sstream>
struct tracer_info
{
bt_self_component_source_as_self_component(component))};
}
-bt2_common::GCharUP ctf_fs_make_port_name(struct ctf_fs_ds_file_group *ds_file_group)
+std::string ctf_fs_make_port_name(struct ctf_fs_ds_file_group *ds_file_group)
{
- GString *name = g_string_new(NULL);
+ std::stringstream name;
/*
* The unique port name is generated by concatenating unique identifiers
char uuid_str[BT_UUID_STR_LEN + 1];
bt_uuid_to_str(ds_file_group->ctf_fs_trace->metadata->tc->uuid, uuid_str);
- g_string_assign(name, uuid_str);
+ name << uuid_str;
} else {
- g_string_assign(name, ds_file_group->ctf_fs_trace->path.c_str());
+ name << ds_file_group->ctf_fs_trace->path;
}
/*
* otherwise, as there will only be a single stream class.
*/
if (ds_file_group->sc->id != UINT64_C(-1)) {
- g_string_append_printf(name, " | %" PRIu64, ds_file_group->sc->id);
+ name << " | " << ds_file_group->sc->id;
}
/* For the stream, use the id if present, else, use the path. */
if (ds_file_group->stream_id != UINT64_C(-1)) {
- g_string_append_printf(name, " | %" PRIu64, ds_file_group->stream_id);
+ name << " | " << ds_file_group->stream_id;
} else {
BT_ASSERT(ds_file_group->ds_file_infos.size() == 1);
const ctf_fs_ds_file_info& ds_file_info = *ds_file_group->ds_file_infos[0];
- g_string_append_printf(name, " | %s", ds_file_info.path.c_str());
+ name << " | " << ds_file_info.path;
}
- return bt2_common::GCharUP {g_string_free(name, FALSE)};
+ return name.str();
}
static int create_one_port_for_trace(struct ctf_fs_component *ctf_fs,
ctf_fs_port_data::UP port_data;
const bt2_common::LogCfg& logCfg = ctf_fs->logCfg;
- bt2_common::GCharUP port_name = ctf_fs_make_port_name(ds_file_group);
- if (!port_name) {
- goto error;
- }
-
- BT_CLOGI("Creating one port named `%s`", port_name.get());
+ std::string port_name = ctf_fs_make_port_name(ds_file_group);
+ BT_CLOGI("Creating one port named `%s`", port_name.c_str());
/* Create output port for this file */
port_data = bt2_common::makeUnique<ctf_fs_port_data>();
port_data->ctf_fs = ctf_fs;
port_data->ds_file_group = ds_file_group;
- ret = bt_self_component_source_add_output_port(self_comp_src, port_name.get(), port_data.get(),
- NULL);
+ ret = bt_self_component_source_add_output_port(self_comp_src, port_name.c_str(),
+ port_data.get(), NULL);
if (ret) {
goto error;
}
add_range(groupInfo, stream_range, "range-ns");
- bt2_common::GCharUP portName = ctf_fs_make_port_name(group);
- if (!portName) {
- BT_CLOGE_APPEND_CAUSE_AND_THROW(bt2_common::Error, "Failed to make port name");
- }
-
- groupInfo.insert("port-name", portName.get());
+ std::string portName = ctf_fs_make_port_name(group);
+ groupInfo.insert("port-name", portName.c_str());
}
static void populate_trace_info(const struct ctf_fs_trace *trace, bt2::MapValue traceInfo,