19 #ifndef GRPC_INTERNAL_COMPILER_RUBY_GENERATOR_STRING_INL_H
20 #define GRPC_INTERNAL_COMPILER_RUBY_GENERATOR_STRING_INL_H
35 std::vector<std::string>* elems) {
36 std::stringstream ss(s);
38 while (getline(ss, item, delim)) {
39 elems->push_back(item);
46 std::vector<std::string> elems;
47 Split(s, delim, &elems);
54 size_t start_pos = s.find(
from);
55 if (start_pos == std::string::npos) {
58 s.replace(start_pos,
from.length(),
to);
66 while ((
pos = s.find(
search,
pos)) != std::string::npos) {
68 pos += replace.length();
76 size_t start_pos = s->find(
from);
77 if (start_pos == std::string::npos || start_pos != 0) {
80 s->replace(start_pos,
from.length(),
to);
90 bool was_last_underscore =
false;
91 new_string.append(1, ::toupper(s[0]));
92 for (std::string::size_type
i = 1;
i < s.size(); ++
i) {
93 if (was_last_underscore && s[
i] !=
'_') {
94 new_string.append(1, ::toupper(s[
i]));
95 }
else if (s[
i] !=
'_') {
96 new_string.append(1, s[
i]);
98 was_last_underscore = s[
i] ==
'_';
106 if (
file->options().has_ruby_package()) {
107 package_name =
file->options().ruby_package();
113 package_name =
ReplaceAll(package_name,
"::",
".");
121 if (
descriptor->file()->options().has_ruby_package()) {
128 if (res.find(
'.') == std::string::npos) {
131 std::vector<std::string> prefixes_and_type =
Split(res,
'.');
133 for (
unsigned int i = 0;
i < prefixes_and_type.size(); ++
i) {
137 if (
i < prefixes_and_type.size() - 1) {
140 res += prefixes_and_type[
i];
149 #endif // GRPC_INTERNAL_COMPILER_RUBY_GENERATOR_STRING_INL_H