ruby_generator_helpers-inl.h
Go to the documentation of this file.
1 /*
2  *
3  * Copyright 2015 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 
19 #ifndef GRPC_INTERNAL_COMPILER_RUBY_GENERATOR_HELPERS_INL_H
20 #define GRPC_INTERNAL_COMPILER_RUBY_GENERATOR_HELPERS_INL_H
21 
22 #include "src/compiler/config.h"
25 
26 namespace grpc_ruby_generator {
27 
29  std::string* file_name_or_error) {
30  // Get output file name.
31  static const unsigned proto_suffix_length = 6; // length of ".proto"
32  if (file->name().size() > proto_suffix_length &&
33  file->name().find_last_of(".proto") == file->name().size() - 1) {
34  *file_name_or_error =
35  file->name().substr(0, file->name().size() - proto_suffix_length) +
36  "_services_pb.rb";
37  return true;
38  } else {
39  *file_name_or_error = "Invalid proto file name: must end with .proto";
40  return false;
41  }
42 }
43 
46  return Replace(file->name(), ".proto", "_pb");
47 }
48 
49 // Get leading or trailing comments in a string. Comment lines start with "# ".
50 // Leading detached comments are put in front of leading comments.
51 template <typename DescriptorType>
52 inline std::string GetRubyComments(const DescriptorType* desc, bool leading) {
53  return grpc_generator::GetPrefixedComments(desc, leading, "#");
54 }
55 
56 } // namespace grpc_ruby_generator
57 
58 #endif // GRPC_INTERNAL_COMPILER_RUBY_GENERATOR_HELPERS_INL_H
grpc::protobuf::FileDescriptor
GRPC_CUSTOM_FILEDESCRIPTOR FileDescriptor
Definition: include/grpcpp/impl/codegen/config_protobuf.h:85
grpc_generator::GetPrefixedComments
std::string GetPrefixedComments(const DescriptorType *desc, bool leading, const std::string &prefix)
Definition: generator_helpers.h:257
grpc_ruby_generator::MessagesRequireName
std::string MessagesRequireName(const grpc::protobuf::FileDescriptor *file)
Definition: ruby_generator_helpers-inl.h:44
config.h
testing::internal::string
::std::string string
Definition: bloaty/third_party/protobuf/third_party/googletest/googletest/include/gtest/internal/gtest-port.h:881
ruby_generator_string-inl.h
file
Definition: bloaty/third_party/zlib/examples/gzappend.c:170
grpc_ruby_generator::Replace
std::string Replace(std::string s, const std::string &from, const std::string &to)
Definition: ruby_generator_string-inl.h:52
generator_helpers.h
grpc_ruby_generator
Definition: src/compiler/ruby_generator.cc:38
grpc_ruby_generator::GetRubyComments
std::string GetRubyComments(const DescriptorType *desc, bool leading)
Definition: ruby_generator_helpers-inl.h:52
grpc_ruby_generator::ServicesFilename
bool ServicesFilename(const grpc::protobuf::FileDescriptor *file, std::string *file_name_or_error)
Definition: ruby_generator_helpers-inl.h:28
desc
#define desc
Definition: bloaty/third_party/protobuf/src/google/protobuf/extension_set.h:338
file::name
char * name
Definition: bloaty/third_party/zlib/examples/gzappend.c:176


grpc
Author(s):
autogenerated on Thu Mar 13 2025 03:01:13