Moved http::path::parse from header to .cpp file.

Review: https://reviews.apache.org/r/32339


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/87bece8a
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/87bece8a
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/87bece8a

Branch: refs/heads/master
Commit: 87bece8acdac674dbacc39ecf930bb72daedc5a5
Parents: f9961e3
Author: Benjamin Mahler <[email protected]>
Authored: Tue Mar 17 12:49:21 2015 -0700
Committer: Benjamin Mahler <[email protected]>
Committed: Tue Mar 24 16:47:18 2015 -0700

----------------------------------------------------------------------
 3rdparty/libprocess/include/process/http.hpp | 37 ++-------------------
 3rdparty/libprocess/src/http.cpp             | 40 +++++++++++++++++++++++
 2 files changed, 42 insertions(+), 35 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/87bece8a/3rdparty/libprocess/include/process/http.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/include/process/http.hpp 
b/3rdparty/libprocess/include/process/http.hpp
index ca1bedc..1c7b752 100644
--- a/3rdparty/libprocess/include/process/http.hpp
+++ b/3rdparty/libprocess/include/process/http.hpp
@@ -431,42 +431,9 @@ namespace path {
 //   books: "books"
 //   isbn: "0304827484"
 //   chapters: "chapters"
-inline Try<hashmap<std::string, std::string> > parse(
+Try<hashmap<std::string, std::string> > parse(
     const std::string& pattern,
-    const std::string& path)
-{
-  // Split the pattern by '/' into keys.
-  std::vector<std::string> keys = strings::tokenize(pattern, "/");
-
-  // Split the path by '/' into segments.
-  std::vector<std::string> segments = strings::tokenize(path, "/");
-
-  hashmap<std::string, std::string> result;
-
-  while (!segments.empty()) {
-    if (keys.empty()) {
-      return Error(
-          "Not expecting suffix '" + strings::join("/", segments) + "'");
-    }
-
-    std::string key = keys.front();
-
-    if (strings::startsWith(key, "{") &&
-        strings::endsWith(key, "}")) {
-      key = strings::remove(key, "{", strings::PREFIX);
-      key = strings::remove(key, "}", strings::SUFFIX);
-    } else if (key != segments.front()) {
-      return Error("Expecting '" + key + "' not '" + segments.front() + "'");
-    }
-
-    result[key] = segments.front();
-
-    keys.erase(keys.begin());
-    segments.erase(segments.begin());
-  }
-
-  return result;
-}
+    const std::string& path);
 
 } // namespace path {
 

http://git-wip-us.apache.org/repos/asf/mesos/blob/87bece8a/3rdparty/libprocess/src/http.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/src/http.cpp b/3rdparty/libprocess/src/http.cpp
index f56c88e..1df8824 100644
--- a/3rdparty/libprocess/src/http.cpp
+++ b/3rdparty/libprocess/src/http.cpp
@@ -307,6 +307,46 @@ Future<Nothing> Pipe::Writer::readerClosed()
 }
 
 
+namespace path {
+
+Try<hashmap<string, string> > parse(const string& pattern, const string& path)
+{
+  // Split the pattern by '/' into keys.
+  vector<string> keys = strings::tokenize(pattern, "/");
+
+  // Split the path by '/' into segments.
+  vector<string> segments = strings::tokenize(path, "/");
+
+  hashmap<string, string> result;
+
+  while (!segments.empty()) {
+    if (keys.empty()) {
+      return Error(
+          "Not expecting suffix '" + strings::join("/", segments) + "'");
+    }
+
+    string key = keys.front();
+
+    if (strings::startsWith(key, "{") &&
+        strings::endsWith(key, "}")) {
+      key = strings::remove(key, "{", strings::PREFIX);
+      key = strings::remove(key, "}", strings::SUFFIX);
+    } else if (key != segments.front()) {
+      return Error("Expecting '" + key + "' not '" + segments.front() + "'");
+    }
+
+    result[key] = segments.front();
+
+    keys.erase(keys.begin());
+    segments.erase(segments.begin());
+  }
+
+  return result;
+}
+
+} // namespace path {
+
+
 string encode(const string& s)
 {
   ostringstream out;

Reply via email to