[glibmm/glibmm-2-64] Add a templated Glib::build_filename() overload
- From: Kjell Ahlstedt <kjellahl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glibmm/glibmm-2-64] Add a templated Glib::build_filename() overload
- Date: Mon, 16 Mar 2020 09:44:07 +0000 (UTC)
commit 36e765338a11897e3c22814086685ab406fbed79
Author: Kjell Ahlstedt <kjellahlstedt gmail com>
Date: Mon Mar 16 10:18:24 2020 +0100
Add a templated Glib::build_filename() overload
that uses Glib::StdStringView. It avoids some unnecessary string copies.
Fixes #34
glib/src/miscutils.hg | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
---
diff --git a/glib/src/miscutils.hg b/glib/src/miscutils.hg
index 2d7b0df3..a606447d 100644
--- a/glib/src/miscutils.hg
+++ b/glib/src/miscutils.hg
@@ -362,6 +362,26 @@ std::string path_get_dirname(const std::string& filename);
GLIBMM_API
std::string build_filename(const Glib::ArrayHandle<std::string>& elements);
+/** Creates a filename from one or more elements using the correct separator for filenames.
+ * No attempt is made to force the resulting filename to be an absolute path.
+ * If the first element is a relative path, the result will be a relative path.
+ * @tparam Strings std::string or const char*.
+ * @param strings The path elements.
+ * @return The resulting path.
+ *
+ * @newin{2,64}
+ */
+template <typename... Strings>
+std::string build_filename(const Strings&... strings)
+{
+ return Glib::convert_return_gchar_ptr_to_stdstring(
+ g_build_filename(StdStringView(strings).c_str()..., nullptr));
+}
+
+// When the templated build_filename() overload was added, the following
+// build_filename() overloads became unnecessary.
+//TODO: They can be removed when we can break ABI.
+
/** Creates a filename from two elements using the correct separator for filenames.
* No attempt is made to force the resulting filename to be an absolute path.
* If the first element is a relative path, the result will be a relative path.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]