summaryrefslogtreecommitdiffstats
path: root/contrib/libs/grpc/src/compiler/ruby_generator_string-inl.h
diff options
context:
space:
mode:
authorheretic <[email protected]>2022-02-10 16:45:43 +0300
committerDaniil Cherednik <[email protected]>2022-02-10 16:45:43 +0300
commit397cbe258b9e064f49c4ca575279f02f39fef76e (patch)
treea0b0eb3cca6a14e4e8ea715393637672fa651284 /contrib/libs/grpc/src/compiler/ruby_generator_string-inl.h
parent43f5a35593ebc9f6bcea619bb170394ea7ae468e (diff)
Restoring authorship annotation for <[email protected]>. Commit 1 of 2.
Diffstat (limited to 'contrib/libs/grpc/src/compiler/ruby_generator_string-inl.h')
-rw-r--r--contrib/libs/grpc/src/compiler/ruby_generator_string-inl.h56
1 files changed, 28 insertions, 28 deletions
diff --git a/contrib/libs/grpc/src/compiler/ruby_generator_string-inl.h b/contrib/libs/grpc/src/compiler/ruby_generator_string-inl.h
index 956539f392a..04f9924268b 100644
--- a/contrib/libs/grpc/src/compiler/ruby_generator_string-inl.h
+++ b/contrib/libs/grpc/src/compiler/ruby_generator_string-inl.h
@@ -31,10 +31,10 @@ using std::transform;
namespace grpc_ruby_generator {
// Split splits a string using char into elems.
-inline std::vector<TString>& Split(const TString& s, char delim,
- std::vector<TString>* elems) {
+inline std::vector<TString>& Split(const TString& s, char delim,
+ std::vector<TString>* elems) {
std::stringstream ss(s);
- TString item;
+ TString item;
while (getline(ss, item, delim)) {
elems->push_back(item);
}
@@ -42,17 +42,17 @@ inline std::vector<TString>& Split(const TString& s, char delim,
}
// Split splits a string using char, returning the result in a vector.
-inline std::vector<TString> Split(const TString& s, char delim) {
- std::vector<TString> elems;
+inline std::vector<TString> Split(const TString& s, char delim) {
+ std::vector<TString> elems;
Split(s, delim, &elems);
return elems;
}
// Replace replaces from with to in s.
-inline TString Replace(TString s, const TString& from,
- const TString& to) {
+inline TString Replace(TString s, const TString& from,
+ const TString& to) {
size_t start_pos = s.find(from);
- if (start_pos == TString::npos) {
+ if (start_pos == TString::npos) {
return s;
}
s.replace(start_pos, from.length(), to);
@@ -60,10 +60,10 @@ inline TString Replace(TString s, const TString& from,
}
// ReplaceAll replaces all instances of search with replace in s.
-inline TString ReplaceAll(TString s, const TString& search,
- const TString& replace) {
+inline TString ReplaceAll(TString s, const TString& search,
+ const TString& replace) {
size_t pos = 0;
- while ((pos = s.find(search, pos)) != TString::npos) {
+ while ((pos = s.find(search, pos)) != TString::npos) {
s.replace(pos, search.length(), replace);
pos += replace.length();
}
@@ -71,10 +71,10 @@ inline TString ReplaceAll(TString s, const TString& search,
}
// ReplacePrefix replaces from with to in s if search is a prefix of s.
-inline bool ReplacePrefix(TString* s, const TString& from,
- const TString& to) {
+inline bool ReplacePrefix(TString* s, const TString& from,
+ const TString& to) {
size_t start_pos = s->find(from);
- if (start_pos == TString::npos || start_pos != 0) {
+ if (start_pos == TString::npos || start_pos != 0) {
return false;
}
s->replace(start_pos, from.length(), to);
@@ -82,14 +82,14 @@ inline bool ReplacePrefix(TString* s, const TString& from,
}
// Modularize converts a string into a ruby module compatible name
-inline TString Modularize(TString s) {
+inline TString Modularize(TString s) {
if (s.empty()) {
return s;
}
- TString new_string = "";
+ TString new_string = "";
bool was_last_underscore = false;
new_string.append(1, ::toupper(s[0]));
- for (TString::size_type i = 1; i < s.size(); ++i) {
+ for (TString::size_type i = 1; i < s.size(); ++i) {
if (was_last_underscore && s[i] != '_') {
new_string.append(1, ::toupper(s[i]));
} else if (s[i] != '_') {
@@ -101,8 +101,8 @@ inline TString Modularize(TString s) {
}
// RubyPackage gets the ruby package in either proto or ruby_package format
-inline TString RubyPackage(const grpc::protobuf::FileDescriptor* file) {
- TString package_name = file->package();
+inline TString RubyPackage(const grpc::protobuf::FileDescriptor* file) {
+ TString package_name = file->package();
if (file->options().has_ruby_package()) {
package_name = file->options().ruby_package();
@@ -116,19 +116,19 @@ inline TString RubyPackage(const grpc::protobuf::FileDescriptor* file) {
}
// RubyTypeOf updates a proto type to the required ruby equivalent.
-inline TString RubyTypeOf(const grpc::protobuf::Descriptor* descriptor) {
- TString proto_type = descriptor->full_name();
+inline TString RubyTypeOf(const grpc::protobuf::Descriptor* descriptor) {
+ TString proto_type = descriptor->full_name();
if (descriptor->file()->options().has_ruby_package()) {
- // remove the leading package if present
- ReplacePrefix(&proto_type, descriptor->file()->package(), "");
- ReplacePrefix(&proto_type, ".", ""); // remove the leading . (no package)
- proto_type = RubyPackage(descriptor->file()) + "." + proto_type;
+ // remove the leading package if present
+ ReplacePrefix(&proto_type, descriptor->file()->package(), "");
+ ReplacePrefix(&proto_type, ".", ""); // remove the leading . (no package)
+ proto_type = RubyPackage(descriptor->file()) + "." + proto_type;
}
- TString res("." + proto_type);
- if (res.find('.') == TString::npos) {
+ TString res("." + proto_type);
+ if (res.find('.') == TString::npos) {
return res;
} else {
- std::vector<TString> prefixes_and_type = Split(res, '.');
+ std::vector<TString> prefixes_and_type = Split(res, '.');
res.clear();
for (unsigned int i = 0; i < prefixes_and_type.size(); ++i) {
if (i != 0) {