From 29c131f79036fc73a9bd909754d1b35aac7c59ac Mon Sep 17 00:00:00 2001 From: Feso Date: Sat, 13 Oct 2018 19:17:26 +0100 Subject: Refactored based on code review --- test/cpp/util/proto_file_parser.h | 64 ++++++++++++++++++++++----------------- 1 file changed, 36 insertions(+), 28 deletions(-) (limited to 'test/cpp/util/proto_file_parser.h') diff --git a/test/cpp/util/proto_file_parser.h b/test/cpp/util/proto_file_parser.h index d2b2bd753e..0758d2f9f3 100644 --- a/test/cpp/util/proto_file_parser.h +++ b/test/cpp/util/proto_file_parser.h @@ -53,37 +53,45 @@ class ProtoFileParser { // used as the argument of Stub::Call() grpc::string GetFormattedMethodName(const grpc::string& method); - grpc::string GetSerializedProtoFromMethodTextFormat( - const grpc::string& method, const grpc::string& text_format_proto, - bool is_request); - - grpc::string GetSerializedProtoFromMethodJsonFormat( - const grpc::string& method, const grpc::string& json_format_proto, - bool is_request); - - grpc::string GetTextFormatFromMethod(const grpc::string& method, - const grpc::string& serialized_proto, - bool is_request); - - grpc::string GetJsonFormatFromMethod(const grpc::string& method, - const grpc::string& serialized_proto, - bool is_request); - - grpc::string GetSerializedProtoFromMessageTypeTextFormat( + /// Converts a text or json string to its binary proto representation for the + /// given method's input or return type. + /// \param method the name of the method (does not need to be fully qualified name) + /// \param formatted_proto the text- or json-formatted proto string + /// \param is_request if \c true the resolved type is that of the input parameter of + /// the method, otherwise it is the output type + /// \param is_json_format if \c true the \c formatted_proto is treated as a + /// json-formatted proto, otherwise it is treated as a text-formatted proto + /// \return the serialised binary proto represenation of \c formatted_proto + grpc::string GetSerializedProtoFromMethod( + const grpc::string& method, const grpc::string& formatted_proto, + bool is_request, bool is_json_format); + + /// Converts a text or json string to its proto representation for the given + /// message type. + /// \param formatted_proto the text- or json-formatted proto string + /// \return the serialised binary proto represenation of \c formatted_proto + grpc::string GetSerializedProtoFromMessageType( const grpc::string& message_type_name, - const grpc::string& text_format_proto); - - grpc::string GetSerializedProtoFromMessageTypeJsonFormat( - const grpc::string& message_type_name, - const grpc::string& json_format_proto); - - grpc::string GetTextFormatFromMessageType( - const grpc::string& message_type_name, - const grpc::string& serialized_proto); + const grpc::string& formatted_proto, + bool is_json_format); + + /// Converts a binary proto string to its text or json string representation + /// for the given method's input or return type. + /// \param method the name of the method (does not need to be a fully qualified name) + /// \param the serialised binary proto representation of type \c message_type_name + /// \return the text- or json-formatted proto string of \c serialized_proto + grpc::string GetFormattedStringFromMethod(const grpc::string& method, + const grpc::string& serialized_proto, + bool is_request, bool is_json_format); - grpc::string GetJsonFormatFromMessageType( + /// Converts a binary proto string to its text or json string representation + /// for the given message type. + /// \param the serialised binary proto representation of type \c message_type_name + /// \return the text- or json-formatted proto string of \c serialized_proto + grpc::string GetFormattedStringFromMessageType( const grpc::string& message_type_name, - const grpc::string& serialized_proto); + const grpc::string& serialized_proto, + bool is_json_format); bool IsStreaming(const grpc::string& method, bool is_request); -- cgit v1.2.3