[ 
https://issues.apache.org/jira/browse/MESOS-3405?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14995533#comment-14995533
 ] 

Michael Park commented on MESOS-3405:
-------------------------------------

{noformat}
commit 9c54387db4ebf7c0ddf538a45d1ff58d3da6df44
Author: Klaus Ma <[email protected]>
Date:   Sat Nov 7 21:18:16 2015 -0800

    mesos: Added `JSON::protobuf` for `google::protobuf::RepeatedPtrField`.

    Review: https://reviews.apache.org/r/38335
{noformat}
{noformat}
commit 3e2b192e3aac842dd51add65fa34b6ef4a00ff40
Author: Klaus Ma <[email protected]>
Date:   Sat Nov 7 21:17:54 2015 -0800

    stout: Added `JSON::protobuf` for `google::protobuf::RepeatedPtrField`.

    Review: https://reviews.apache.org/r/38342
{noformat}

> Add JSON::protobuf for google::protobuf::RepeatedPtrField.
> ----------------------------------------------------------
>
>                 Key: MESOS-3405
>                 URL: https://issues.apache.org/jira/browse/MESOS-3405
>             Project: Mesos
>          Issue Type: Task
>          Components: stout
>            Reporter: Michael Park
>            Assignee: Klaus Ma
>             Fix For: 0.26.0
>
>
> Currently, {{stout/protobuf.hpp}} provides a {{JSON::Protobuf}} utility which 
> converts a {{google::protobuf::Message}} into a {{JSON::Object}}.
> We should add the support for {{google::protobuf::RepeatedPtrField<T>}} by 
> introducing overloaded functions.
> {code}
> namespace JSON {
>   Object protobuf(const google::protobuf::Message& message)
>   {
>     Object object;
>     /* Move the body of JSON::Protobuf constructor here. */
>     return object;
>   }
>   template <typename T>
>   Array protobuf(const google::protobuf::RepeatedPtrField<T>& repeated)
>   {
>     static_assert(std::is_convertible<T*, google::protobuf::Message*>::value,
>                   "T must be a google::protobuf::Message");
>     JSON::Array array;
>     array.values.reserve(repeated.size());
>     foreach (const T& elem, repeated) {
>       array.values.push_back(JSON::Protobuf(elem));
>     }
>     return array;
>   }
> }
> {code}
> The new {{RepeatedPtrField}} version can be used in at least the following 
> places:
> * {{src/common/http.cpp}}
> * {{src/master/http.cpp}}
> * {{src/slave/containerizer/mesos/containerizer.cpp}}
> * {{src/tests/reservation_endpoints_tests.cpp}}
> * {{src/tests/resources_tests.cpp}}: {{ResourcesTest.ParsingFromJSON}}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to