Added parse function in flags namespace for v1::TaskGroupInfo protobuf.

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


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

Branch: refs/heads/master
Commit: 9a9610d0444d97b7226012ec82f9a0eb59a48959
Parents: 4e8ac99
Author: Abhishek Dasgupta <a10gu...@linux.vnet.ibm.com>
Authored: Mon Sep 19 13:31:34 2016 -0700
Committer: Vinod Kone <vinodk...@gmail.com>
Committed: Mon Sep 19 13:31:34 2016 -0700

----------------------------------------------------------------------
 src/common/parse.hpp | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/9a9610d0/src/common/parse.hpp
----------------------------------------------------------------------
diff --git a/src/common/parse.hpp b/src/common/parse.hpp
index 51582a4..62a333c 100644
--- a/src/common/parse.hpp
+++ b/src/common/parse.hpp
@@ -15,6 +15,8 @@
 
 #include <mesos/mesos.hpp>
 
+#include <mesos/v1/mesos.hpp>
+
 #include <mesos/authorizer/acls.hpp>
 
 #include <mesos/module/module.hpp>
@@ -88,6 +90,20 @@ inline Try<mesos::ContainerInfo> parse(const std::string& 
value)
 }
 
 
+template <>
+inline Try<mesos::v1::TaskGroupInfo> parse(const std::string& value)
+{
+  // Convert from string or file to JSON.
+  Try<JSON::Object> json = parse<JSON::Object>(value);
+  if (json.isError()) {
+    return Error(json.error());
+  }
+
+  // Convert from JSON to Protobuf.
+  return protobuf::parse<mesos::v1::TaskGroupInfo>(json.get());
+}
+
+
 // When the same variable is listed multiple times,
 // uses only the last value.
 template <>

Reply via email to