19 #ifndef GRPC_INTERNAL_COMPILER_GENERATOR_HELPERS_H
20 #define GRPC_INTERNAL_COMPILER_GENERATOR_HELPERS_H
35 if (
filename->compare(suffix_pos, std::string::npos,
suffix) == 0) {
67 if (
pos == std::string::npos) {
72 }
while (replace_all);
84 std::vector<std::string> tokens;
85 size_t pos, last_pos = 0;
89 pos =
input.find_first_of(delimiters, last_pos);
90 if (
pos == std::string::npos) {
95 tokens.push_back(
input.substr(last_pos,
pos - last_pos));
96 if (
done)
return tokens;
106 s[0] = ::toupper(s[0]);
114 s[0] = ::tolower(s[0]);
119 std::vector<std::string> tokens =
tokenize(
str,
"_");
121 for (
unsigned int i = 0;
i < tokens.size();
i++) {
131 if (include_package_path) {
132 for (
unsigned int i = 0;
i < tokens.size() - 1;
i++) {
154 if (
method->client_streaming()) {
155 if (
method->server_streaming()) {
161 if (
method->server_streaming()) {
170 std::vector<std::string>* append_to) {
171 std::istringstream iss(s);
173 while (std::getline(iss, piece)) {
174 append_to->push_back(piece);
185 template <
typename DescriptorType>
187 std::vector<std::string>*
out) {
189 if (!
desc->GetSourceLocation(&location)) {
194 ? location.leading_comments
195 : location.trailing_comments;
198 for (
unsigned int i = 0;
i < location.leading_detached_comments.size();
200 Split(location.leading_detached_comments[
i],
'\n',
out);
204 std::cerr <<
"Unknown comment type " <<
type << std::endl;
219 std::vector<int>
path;
220 path.push_back(grpc::protobuf::FileDescriptorProto::kSyntaxFieldNumber);
221 if (!
desc->GetSourceLocation(
path, &location)) {
225 Split(location.leading_comments,
'\n',
out);
227 for (
unsigned int i = 0;
i < location.leading_detached_comments.size();
229 Split(location.leading_detached_comments[
i],
'\n',
out);
233 std::cerr <<
"Unknown comment type " <<
type << std::endl;
242 std::ostringstream oss;
243 for (
auto it =
in.begin();
it !=
in.end();
it++) {
247 }
else if (
elem[0] ==
' ') {
256 template <
typename DescriptorType>
259 std::vector<std::string>
out;
263 std::vector<std::string> leading;
266 out.insert(
out.end(), leading.begin(), leading.end());
276 #endif // GRPC_INTERNAL_COMPILER_GENERATOR_HELPERS_H