04-tstring.patch 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. diff --git a/include/grpcpp/impl/codegen/call_op_set.h b/include/grpcpp/impl/codegen/call_op_set.h
  2. index 5ce081a..3793331 100644
  3. --- a/include/grpcpp/impl/call_op_set.h
  4. +++ b/include/grpcpp/impl/call_op_set.h
  5. @@ -804,8 +804,8 @@ class CallOpClientRecvStatus {
  6. Status(static_cast<StatusCode>(status_code_),
  7. GRPC_SLICE_IS_EMPTY(error_message_)
  8. ? TString()
  9. - : TString(GRPC_SLICE_START_PTR(error_message_),
  10. - GRPC_SLICE_END_PTR(error_message_)),
  11. + : TString(reinterpret_cast<const char*>GRPC_SLICE_START_PTR(error_message_),
  12. + reinterpret_cast<const char*>GRPC_SLICE_END_PTR(error_message_)),
  13. metadata_map_->GetBinaryErrorDetails());
  14. if (debug_error_string_ != nullptr) {
  15. client_context_->set_debug_error_string(debug_error_string_);
  16. diff --git a/include/grpcpp/impl/codegen/config.h b/include/grpcpp/impl/codegen/config.h
  17. index c32be67..87f9914 100644
  18. --- a/include/grpcpp/support/config.h
  19. +++ b/include/grpcpp/support/config.h
  20. @@ -37,8 +37,7 @@
  21. // Using grpc::string and grpc::to_string is discouraged in favor of
  22. // TString and ::ToString. This is only for legacy code using
  23. // them explictly.
  24. -using TString; // deprecated // NOLINT(misc-unused-using-decls)
  25. -using ::ToString; // deprecated // NOLINT(misc-unused-using-decls)
  26. +typedef TString string;
  27. } // namespace grpc
  28. diff --git a/include/grpcpp/impl/codegen/string_ref.h b/include/grpcpp/impl/codegen/string_ref.h
  29. index 26b4f37..c5dcd31 100644
  30. --- a/include/grpcpp/support/string_ref.h
  31. +++ b/include/grpcpp/support/string_ref.h
  32. @@ -28,6 +28,8 @@
  33. #include <grpcpp/support/config.h>
  34. +#include <util/stream/output.h>
  35. +
  36. namespace grpc {
  37. /// This class is a non owning reference to a string.
  38. @@ -137,8 +139,9 @@ inline bool operator<=(string_ref x, string_ref y) { return x.compare(y) <= 0; }
  39. inline bool operator>(string_ref x, string_ref y) { return x.compare(y) > 0; }
  40. inline bool operator>=(string_ref x, string_ref y) { return x.compare(y) >= 0; }
  41. -inline std::ostream& operator<<(std::ostream& out, const string_ref& string) {
  42. - return out << TString(string.begin(), string.end());
  43. +inline IOutputStream& operator<<(IOutputStream& out, const string_ref& string) {
  44. + TString t(string.begin(), string.end());
  45. + return out << t;
  46. }
  47. } // namespace grpc
  48. diff --git a/src/compiler/config.h b/src/compiler/config.h
  49. index 52e660c..95213b0 100644
  50. --- a/src/compiler/config.h
  51. +++ b/src/compiler/config.h
  52. @@ -33,8 +33,7 @@
  53. // Using grpc::string and grpc::to_string is discouraged in favor of
  54. // TString and ::ToString. This is only for legacy code using
  55. // them explictly.
  56. -using TString; // deprecated
  57. -using ::ToString; // deprecated
  58. +typedef TString string;
  59. namespace protobuf {
  60. diff --git a/src/compiler/cpp_generator.h b/src/compiler/cpp_generator.h
  61. index 772fd0a..606b850 100644
  62. --- a/src/compiler/cpp_generator.h
  63. +++ b/src/compiler/cpp_generator.h
  64. @@ -39,8 +39,7 @@ namespace grpc {
  65. // Using grpc::string and grpc::to_string is discouraged in favor of
  66. // TString and ::ToString. This is only for legacy code using
  67. // them explictly.
  68. -using TString; // deprecated
  69. -using ::ToString; // deprecated
  70. +typedef TString string; // deprecated
  71. } // namespace grpc
  72. diff --git a/src/compiler/generator_helpers.h b/src/compiler/generator_helpers.h
  73. index 4bfbb4e..265713a 100644
  74. --- a/src/compiler/generator_helpers.h
  75. +++ b/src/compiler/generator_helpers.h
  76. @@ -26,6 +26,9 @@
  77. #include <util/string/cast.h>
  78. #include <vector>
  79. +#include <util/string/split.h>
  80. +#include <util/stream/str.h>
  81. +
  82. #include "src/compiler/config.h"
  83. #include "src/compiler/proto_parser_helper.h"
  84. @@ -166,15 +170,26 @@ inline MethodType GetMethodType(
  85. }
  86. }
  87. -inline void Split(const TString& s, char /*delim*/,
  88. - std::vector<TString>* append_to) {
  89. +template <typename TStringType>
  90. +inline void Split(const TStringType& s, char /*delim*/,
  91. + std::vector<TStringType>* append_to) {
  92. std::istringstream iss(s);
  93. - TString piece;
  94. + TStringType piece;
  95. while (std::getline(iss, piece)) {
  96. append_to->push_back(piece);
  97. }
  98. }
  99. +template <>
  100. +inline void Split(const TString &s, char delim,
  101. + std::vector<TString> *append_to) {
  102. + TVector<TString> parts;
  103. + Split(s, TString(1, delim), parts);
  104. + for (auto& p : parts) {
  105. + append_to->push_back(std::move(p));
  106. + }
  107. +}
  108. +
  109. enum CommentType {
  110. COMMENTTYPE_LEADING,
  111. COMMENTTYPE_TRAILING,
  112. diff --git a/src/compiler/schema_interface.h b/src/compiler/schema_interface.h
  113. index 3d624a9..60b9d33 100644
  114. --- a/src/compiler/schema_interface.h
  115. +++ b/src/compiler/schema_interface.h
  116. @@ -34,8 +34,7 @@ namespace grpc {
  117. // Using grpc::string and grpc::to_string is discouraged in favor of
  118. // TString and ::ToString. This is only for legacy code using
  119. // them explictly.
  120. -using TString; // deprecated
  121. -using ::ToString; // deprecated
  122. +typedef TString string; // deprecated
  123. } // namespace grpc
  124. diff --git a/src/core/ext/xds/xds_routing.cc b/src/core/ext/xds/xds_routing.cc
  125. index f5e9659..b0f5cee 100644
  126. --- a/src/core/ext/xds/xds_routing.cc
  127. +++ b/src/core/ext/xds/xds_routing.cc
  128. @@ -39,10 +39,10 @@ bool DomainMatch(MatchType match_type, y_absl::string_view domain_pattern_in,
  129. // Normalize the args to lower-case. Domain matching is case-insensitive.
  130. TString domain_pattern = TString(domain_pattern_in);
  131. TString expected_host_name = TString(expected_host_name_in);
  132. - std::transform(domain_pattern.begin(), domain_pattern.end(),
  133. + std::transform(domain_pattern.cbegin(), domain_pattern.cend(),
  134. domain_pattern.begin(),
  135. [](unsigned char c) { return std::tolower(c); });
  136. - std::transform(expected_host_name.begin(), expected_host_name.end(),
  137. + std::transform(expected_host_name.cbegin(), expected_host_name.cend(),
  138. expected_host_name.begin(),
  139. [](unsigned char c) { return std::tolower(c); });
  140. if (match_type == EXACT_MATCH) {
  141. --- a/src/core/lib/gprpp/status_helper.cc
  142. +++ b/src/core/lib/gprpp/status_helper.cc
  143. @@ -43,6 +43,8 @@
  144. #include "src/core/lib/slice/percent_encoding.h"
  145. #include "src/core/lib/slice/slice.h"
  146. +#include <util/string/cast.h>
  147. +
  148. namespace grpc_core {
  149. namespace {
  150. --- a/src/core/lib/security/credentials/external/aws_request_signer.cc
  151. +++ b/src/core/lib/security/credentials/external/aws_request_signer.cc
  152. @@ -57,7 +57,7 @@ TString HMAC(const TString& key, const TString& msg) {
  153. HMAC(EVP_sha256(), key.c_str(), key.length(),
  154. reinterpret_cast<const unsigned char*>(msg.c_str()), msg.length(),
  155. digest, &len);
  156. - return TString(digest, digest + len);
  157. + return TString(reinterpret_cast<const char*>(digest), reinterpret_cast<const char*>(digest + len));
  158. }
  159. } // namespace
  160. diff --git a/src/cpp/server/server_cc.cc b/src/cpp/server/server_cc.cc
  161. index 7576121..c2a911c 100644
  162. --- a/src/cpp/server/server_cc.cc
  163. +++ b/src/cpp/server/server_cc.cc
  164. @@ -53,6 +53,8 @@
  165. #include "src/cpp/server/health/default_health_check_service.h"
  166. #include "src/cpp/thread_manager/thread_manager.h"
  167. +#include <util/stream/str.h>
  168. +
  169. namespace grpc {
  170. namespace {
  171. @@ -1053,10 +1055,10 @@ bool Server::RegisterService(const TString* host, grpc::Service* service) {
  172. // Parse service name.
  173. if (method_name != nullptr) {
  174. std::stringstream ss(method_name);
  175. - TString service_name;
  176. + std::string service_name;
  177. if (std::getline(ss, service_name, '/') &&
  178. std::getline(ss, service_name, '/')) {
  179. - services_.push_back(service_name);
  180. + services_.push_back(service_name.c_str());
  181. }
  182. }
  183. return true;