summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
6954b97)
Add an out-of-class `operator+=` to append a `bt2c::CStringView` to an
`std::string`. Without it, I get:
CXX plugins/ctf/fs-src/fs.lo
/home/simark/src/babeltrace/src/plugins/ctf/fs-src/fs.cpp: In function 'void set_trace_name(bt2::Trace, const char*)':
/home/simark/src/babeltrace/src/plugins/ctf/fs-src/fs.cpp:598:14: error: ambiguous overload for 'operator+=' (operand types are 'std::string' {aka 'std::__cxx11::basic_string<char>'} and 'bt2::CommonStringValue<const bt_value>::Value' {aka 'bt2c::CStringView'})
598 | name += val->asString().value();
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/13.2.1/string:54,
from /usr/include/c++/13.2.1/bits/locale_classes.h:40,
from /usr/include/c++/13.2.1/bits/ios_base.h:41,
from /usr/include/c++/13.2.1/ios:44,
from /usr/include/c++/13.2.1/istream:40,
from /usr/include/c++/13.2.1/sstream:40,
from /home/simark/src/babeltrace/src/plugins/ctf/fs-src/fs.cpp:10:
/usr/include/c++/13.2.1/bits/basic_string.h:1354:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator+=(const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
1354 | operator+=(const basic_string& __str)
| ^~~~~~~~
/usr/include/c++/13.2.1/bits/basic_string.h:1364:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator+=(const _CharT*) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
1364 | operator+=(const _CharT* __s)
| ^~~~~~~~
Change-Id: I3f47878658a431f81a129fc9e644efe50608e7ce
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8418
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12354
Tested-by: jenkins <jenkins@lttng.org>
+/*
+ * Appends `rhs` to `lhs`.
+ */
+inline void operator+=(std::string& lhs, bt2c::CStringView rhs)
+{
+ lhs += rhs.data();
+}
+
#endif /* BABELTRACE_CPP_COMMON_BT2C_C_STRING_VIEW_HPP */
#endif /* BABELTRACE_CPP_COMMON_BT2C_C_STRING_VIEW_HPP */
-static int set_trace_name(bt_trace *trace, const char *name_suffix)
+static void set_trace_name(const bt2::Trace trace, const char *name_suffix)
* Check if we have a trace environment string value named `hostname`.
* If so, use it as the trace name's prefix.
*/
* Check if we have a trace environment string value named `hostname`.
* If so, use it as the trace name's prefix.
*/
- const bt_value *val = bt_trace_borrow_environment_entry_value_by_name_const(trace, "hostname");
- if (val && bt_value_is_string(val)) {
- name += bt_value_string_get(val);
+ const auto val = trace.environmentEntry("hostname");
+ if (val && val->isString()) {
+ name += val->asString().value();
if (name_suffix) {
name += G_DIR_SEPARATOR;
if (name_suffix) {
name += G_DIR_SEPARATOR;
- return bt_trace_set_name(trace, name.c_str());
}
static ctf_fs_trace::UP ctf_fs_trace_create(const char *path, const char *name,
}
static ctf_fs_trace::UP ctf_fs_trace_create(const char *path, const char *name,
if (ctf_fs_trace->trace) {
ctf_trace_class_configure_ir_trace(ctf_fs_trace->metadata->tc, *ctf_fs_trace->trace);
if (ctf_fs_trace->trace) {
ctf_trace_class_configure_ir_trace(ctf_fs_trace->metadata->tc, *ctf_fs_trace->trace);
- ret = set_trace_name(ctf_fs_trace->trace->libObjPtr(), name);
- if (ret) {
- return nullptr;
- }
+ set_trace_name(*ctf_fs_trace->trace, name);
}
ret = create_ds_file_groups(ctf_fs_trace.get());
}
ret = create_ds_file_groups(ctf_fs_trace.get());