You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by me...@apache.org on 2015/06/19 18:56:23 UTC
mesos git commit: MESOS-1733 Variadic Path Join
Repository: mesos
Updated Branches:
refs/heads/master 1794d4e0f -> 8c3748abd
MESOS-1733 Variadic Path Join
This change takes an un-complicated/naive route (no trimming of values
etc) at making path::join(...) variadic mainly in order to preserve the
earlier over-loaded join functionality.
Review: https://reviews.apache.org/r/35179
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/8c3748ab
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/8c3748ab
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/8c3748ab
Branch: refs/heads/master
Commit: 8c3748abd41650e1cf9db281eb6f85e6b9558eb9
Parents: 1794d4e
Author: Anand Mazumdar <ma...@gmail.com>
Authored: Thu Jun 18 00:53:24 2015 +0000
Committer: Adam B <ad...@mesosphere.io>
Committed: Fri Jun 19 16:55:47 2015 +0000
----------------------------------------------------------------------
.../3rdparty/stout/include/stout/path.hpp | 88 ++------------------
.../3rdparty/stout/tests/path_tests.cpp | 4 +
2 files changed, 11 insertions(+), 81 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/8c3748ab/3rdparty/libprocess/3rdparty/stout/include/stout/path.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/include/stout/path.hpp b/3rdparty/libprocess/3rdparty/stout/include/stout/path.hpp
index d4df650..59595c9 100644
--- a/3rdparty/libprocess/3rdparty/stout/include/stout/path.hpp
+++ b/3rdparty/libprocess/3rdparty/stout/include/stout/path.hpp
@@ -15,6 +15,7 @@
#define __STOUT_PATH_HPP__
#include <string>
+#include <utility>
#include <stout/strings.hpp>
@@ -42,96 +43,21 @@ inline std::ostream& operator << (
namespace path {
+// Base case.
inline std::string join(const std::string& path1, const std::string& path2)
{
- return
- strings::remove(path1, "/", strings::SUFFIX) + "/" +
- strings::remove(path2, "/", strings::PREFIX);
+ return strings::remove(path1, "/", strings::SUFFIX) + "/" +
+ strings::remove(path2, "/", strings::PREFIX);
}
+template <typename... Paths>
inline std::string join(
const std::string& path1,
const std::string& path2,
- const std::string& path3)
+ Paths&&... paths)
{
- return join(path1, join(path2, path3));
-}
-
-
-inline std::string join(
- const std::string& path1,
- const std::string& path2,
- const std::string& path3,
- const std::string& path4)
-{
- return join(path1, join(path2, path3, path4));
-}
-
-
-inline std::string join(
- const std::string& path1,
- const std::string& path2,
- const std::string& path3,
- const std::string& path4,
- const std::string& path5)
-{
- return join(path1, join(path2, path3, path4, path5));
-}
-
-
-inline std::string join(
- const std::string& path1,
- const std::string& path2,
- const std::string& path3,
- const std::string& path4,
- const std::string& path5,
- const std::string& path6)
-{
- return join(path1, join(path2, path3, path4, path5, path6));
-}
-
-
-inline std::string join(
- const std::string& path1,
- const std::string& path2,
- const std::string& path3,
- const std::string& path4,
- const std::string& path5,
- const std::string& path6,
- const std::string& path7)
-{
- return join(path1, join(path2, path3, path4, path5, path6, path7));
-}
-
-
-inline std::string join(
- const std::string& path1,
- const std::string& path2,
- const std::string& path3,
- const std::string& path4,
- const std::string& path5,
- const std::string& path6,
- const std::string& path7,
- const std::string& path8)
-{
- return join(path1, join(path2, path3, path4, path5, path6, path7, path8));
-}
-
-
-inline std::string join(
- const std::string& path1,
- const std::string& path2,
- const std::string& path3,
- const std::string& path4,
- const std::string& path5,
- const std::string& path6,
- const std::string& path7,
- const std::string& path8,
- const std::string& path9)
-{
- return join(path1, join(
- path2, path3, path4, path5, path6, path7, path8, path9));
+ return join(path1, join(path2, std::forward<Paths>(paths)...));
}
http://git-wip-us.apache.org/repos/asf/mesos/blob/8c3748ab/3rdparty/libprocess/3rdparty/stout/tests/path_tests.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/tests/path_tests.cpp b/3rdparty/libprocess/3rdparty/stout/tests/path_tests.cpp
index cf35412..7dd2664 100644
--- a/3rdparty/libprocess/3rdparty/stout/tests/path_tests.cpp
+++ b/3rdparty/libprocess/3rdparty/stout/tests/path_tests.cpp
@@ -36,6 +36,10 @@ TEST(PathTest, Join)
// Interesting corner cases around being the first, middle, last.
EXPECT_EQ("/asdf", path::join("/", "asdf"));
EXPECT_EQ("/", path::join("", "/", ""));
+ EXPECT_EQ("ab/", path::join("ab/", "", "/"));
+ EXPECT_EQ("/ab", path::join("/", "/", "ab"));
+ EXPECT_EQ("ab/", path::join("ab", "/", "/"));
+ EXPECT_EQ("/ab", path::join("/", "", "/ab"));
// Check trailing and leading slashes get cleaned up.
EXPECT_EQ("a/b/c/", path::join("a/", "b/", "c/"));