service_describer.cc
Go to the documentation of this file.
1 /*
2  *
3  * Copyright 2016 gRPC authors.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  */
18 
20 
21 #include <iostream>
22 #include <sstream>
23 #include <string>
24 #include <vector>
25 
26 namespace grpc {
27 namespace testing {
28 
29 std::string DescribeServiceList(std::vector<std::string> service_list,
30  grpc::protobuf::DescriptorPool& desc_pool) {
31  std::stringstream result;
32  for (auto it = service_list.begin(); it != service_list.end(); it++) {
33  auto const& service = *it;
34  const grpc::protobuf::ServiceDescriptor* service_desc =
35  desc_pool.FindServiceByName(service);
36  if (service_desc != nullptr) {
37  result << DescribeService(service_desc);
38  }
39  }
40  return result.str();
41 }
42 
45  if (service->options().deprecated()) {
46  result.append("DEPRECATED\n");
47  }
48  result.append("filename: " + service->file()->name() + "\n");
49 
50  std::string package = service->full_name();
51  size_t pos = package.rfind("." + service->name());
52  if (pos != std::string::npos) {
53  package.erase(pos);
54  result.append("package: " + package + ";\n");
55  }
56  result.append("service " + service->name() + " {\n");
57  for (int i = 0; i < service->method_count(); ++i) {
58  result.append(DescribeMethod(service->method(i)));
59  }
60  result.append("}\n\n");
61  return result;
62 }
63 
65  std::stringstream result;
66  result << " rpc " << method->name()
67  << (method->client_streaming() ? "(stream " : "(")
68  << method->input_type()->full_name() << ") returns "
69  << (method->server_streaming() ? "(stream " : "(")
70  << method->output_type()->full_name() << ") {}\n";
71  if (method->options().deprecated()) {
72  result << " DEPRECATED";
73  }
74  return result.str();
75 }
76 
79  for (int i = 0; i < service->method_count(); ++i) {
80  result.append(SummarizeMethod(service->method(i)));
81  }
82  return result;
83 }
84 
86  std::string result = method->name();
87  result.append("\n");
88  return result;
89 }
90 
91 } // namespace testing
92 } // namespace grpc
_gevent_test_main.result
result
Definition: _gevent_test_main.py:96
testing
Definition: aws_request_signer_test.cc:25
regen-readme.it
it
Definition: regen-readme.py:15
pos
int pos
Definition: libuv/docs/code/tty-gravity/main.c:11
grpc::testing::DescribeService
std::string DescribeService(const grpc::protobuf::ServiceDescriptor *service)
Definition: service_describer.cc:43
grpc
Definition: grpcpp/alarm.h:33
grpc::testing::SummarizeMethod
std::string SummarizeMethod(const grpc::protobuf::MethodDescriptor *method)
Definition: service_describer.cc:85
testing::internal::string
::std::string string
Definition: bloaty/third_party/protobuf/third_party/googletest/googletest/include/gtest/internal/gtest-port.h:881
grpc::testing::SummarizeService
std::string SummarizeService(const grpc::protobuf::ServiceDescriptor *service)
Definition: service_describer.cc:77
grpc::protobuf::DescriptorPool
GRPC_CUSTOM_DESCRIPTORPOOL DescriptorPool
Definition: include/grpcpp/impl/codegen/config_protobuf.h:82
service_describer.h
grpc::protobuf::MethodDescriptor
GRPC_CUSTOM_METHODDESCRIPTOR MethodDescriptor
Definition: include/grpcpp/impl/codegen/config_protobuf.h:87
grpc::testing::DescribeServiceList
std::string DescribeServiceList(std::vector< std::string > service_list, grpc::protobuf::DescriptorPool &desc_pool)
Definition: service_describer.cc:29
grpc::testing::DescribeMethod
std::string DescribeMethod(const grpc::protobuf::MethodDescriptor *method)
Definition: service_describer.cc:64
service
__attribute__((deprecated("Please use GRPCProtoMethod."))) @interface ProtoMethod NSString * service
Definition: ProtoMethod.h:25
method
NSString * method
Definition: ProtoMethod.h:28
grpc::protobuf::ServiceDescriptor
GRPC_CUSTOM_SERVICEDESCRIPTOR ServiceDescriptor
Definition: include/grpcpp/impl/codegen/config_protobuf.h:88
i
uint64_t i
Definition: abseil-cpp/absl/container/btree_benchmark.cc:230


grpc
Author(s):
autogenerated on Fri May 16 2025 03:00:12