using-string.patch 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. --- a/src/google/protobuf/stubs/port.h (index)
  2. +++ b/src/google/protobuf/stubs/port.h (working tree)
  3. @@ -119,6 +119,8 @@
  4. #error "Protobuf requires at least C++11."
  5. #endif
  6. +using TProtoStringType = TString;
  7. +
  8. namespace google {
  9. namespace protobuf {
  10. --- a/src/google/protobuf/map_field.h (index)
  11. +++ b/src/google/protobuf/map_field.h (working tree)
  12. @@ -36,6 +36,7 @@
  13. #include <type_traits>
  14. #include "google/protobuf/arena.h"
  15. +#include <google/protobuf/stubs/port.h>
  16. #include "google/protobuf/port.h"
  17. #include "absl/synchronization/mutex.h"
  18. #include "google/protobuf/descriptor.h"
  19. --- a/src/google/protobuf/generated_message_util.cc (index)
  20. +++ b/src/google/protobuf/generated_message_util.cc (working tree)
  21. @@ -62,7 +62,7 @@ void DestroyMessage(const void* message) {
  22. static_cast<const MessageLite*>(message)->~MessageLite();
  23. }
  24. void DestroyString(const void* s) {
  25. - static_cast<const TProtoStringType*>(s)->~basic_string();
  26. + static_cast<const TProtoStringType*>(s)->~TBasicString();
  27. }
  28. PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT
  29. --- a/src/google/protobuf/util/type_resolver_util.h (index)
  30. +++ b/src/google/protobuf/util/type_resolver_util.h (working tree)
  31. @@ -35,6 +35,8 @@
  32. #include "absl/strings/string_view.h"
  33. +#include <google/protobuf/stubs/port.h>
  34. +
  35. // Must be included last.
  36. #include "google/protobuf/port_def.inc"
  37. --- a/src/google/protobuf/compiler/cpp/options.h (index)
  38. +++ b/src/google/protobuf/compiler/cpp/options.h (working tree)
  39. @@ -37,6 +37,8 @@
  40. #include "absl/container/flat_hash_set.h"
  41. +#include <google/protobuf/stubs/port.h>
  42. +
  43. namespace google {
  44. namespace protobuf {
  45. namespace compiler {
  46. --- a/src/google/protobuf/compiler/command_line_interface.cc
  47. +++ b/src/google/protobuf/compiler/command_line_interface.cc
  48. @@ -1174,10 +1174,10 @@ bool CommandLineInterface::ExpandArgumentFile(const string& file,
  49. if (!file_stream.is_open()) {
  50. return false;
  51. }
  52. - TProtoStringType argument;
  53. + std::string argument;
  54. // We don't support any kind of shell expansion right now.
  55. while (std::getline(file_stream, argument)) {
  56. - arguments->push_back(argument);
  57. + arguments->emplace_back(argument);
  58. }
  59. return true;
  60. }
  61. --- a/src/google/protobuf/compiler/plugin.h (index)
  62. +++ b/src/google/protobuf/compiler/plugin.h (working tree)
  63. @@ -63,6 +63,7 @@
  64. #define GOOGLE_PROTOBUF_COMPILER_PLUGIN_H__
  65. #include <string>
  66. +#include <google/protobuf/stubs/port.h>
  67. // Must be included last.
  68. #include <google/protobuf/port_def.inc>
  69. --- a/src/google/protobuf/compiler/objectivec/helpers.cc
  70. +++ b/src/google/protobuf/compiler/objectivec/helpers.cc
  71. @@ -43,6 +43,7 @@
  72. #include "google/protobuf/compiler/objectivec/names.h"
  73. #include "google/protobuf/io/strtod.h"
  74. #include "google/protobuf/stubs/common.h"
  75. +#include <google/protobuf/stubs/port.h>
  76. // NOTE: src/google/protobuf/compiler/plugin.cc makes use of cerr for some
  77. // error cases, so it seems to be ok to use as a back door for errors.
  78. --- a/src/google/protobuf/compiler/php/php_generator.cc
  79. +++ b/src/google/protobuf/compiler/php/php_generator.cc
  80. @@ -49,6 +49,9 @@
  81. #include "google/protobuf/descriptor.pb.h"
  82. #include "google/protobuf/io/printer.h"
  83. #include "google/protobuf/io/zero_copy_stream.h"
  84. +#include <google/protobuf/stubs/port.h>
  85. +
  86. +#include <util/string/cast.h>
  87. constexpr absl::string_view kDescriptorFile =
  88. "google/protobuf/descriptor.proto";
  89. @@ -289,7 +292,7 @@ TProtoStringType GeneratedMetadataFileName(const FileDescriptor* file,
  90. file->options().php_metadata_namespace();
  91. if (!php_metadata_namespace.empty() && php_metadata_namespace != "\\") {
  92. absl::StrAppend(&result, php_metadata_namespace);
  93. - std::replace(result.begin(), result.end(), '\\', '/');
  94. + std::replace(result.begin(), result.vend(), '\\', '/');
  95. if (result.at(result.size() - 1) != '/') {
  96. absl::StrAppend(&result, "/");
  97. }
  98. --- a/src/google/protobuf/compiler/ruby/ruby_generator.cc
  99. +++ b/src/google/protobuf/compiler/ruby/ruby_generator.cc
  100. @@ -64,7 +64,7 @@ template<class numeric_type>
  101. TProtoStringType NumberToString(numeric_type value) {
  102. std::ostringstream os;
  103. os << value;
  104. - return os.str();
  105. + return TProtoStringType{os.str()};
  106. }
  107. TProtoStringType GetRequireName(const TProtoStringType& proto_file) {
  108. @@ -163,7 +163,7 @@ TProtoStringType DefaultValueForField(const FieldDescriptor* field) {
  109. os << "\".force_encoding(\"ASCII-8BIT\")";
  110. }
  111. - return os.str();
  112. + return TProtoStringType{os.str()};
  113. }
  114. default: assert(false); return "";
  115. }
  116. --- a/src/google/protobuf/compiler/php/php_generator.cc
  117. +++ b/src/google/protobuf/compiler/php/php_generator.cc
  118. @@ -433,7 +434,7 @@ TProtoStringType GeneratedServiceFileName(const ServiceDescriptor* service,
  119. TProtoStringType IntToString(int32 value) {
  120. std::ostringstream os;
  121. os << value;
  122. - return os.str();
  123. + return TProtoStringType{os.str()};
  124. }
  125. TProtoStringType LabelForField(const FieldDescriptor* field) {
  126. @@ -1919,7 +1920,7 @@ void GenerateCEnum(const EnumDescriptor* desc, io::Printer* printer) {
  127. " strlen(\"$name$\"), $num$);\n",
  128. "c_name", c_name,
  129. "name", value->name(),
  130. - "num", std::to_string(value->number()));
  131. + "num", ToString(value->number()));
  132. }
  133. printer->Print(
  134. @@ -2140,7 +2141,7 @@ void GenerateCWellKnownTypes(const std::vector<const FileDescriptor*>& files,
  135. "filename", file->name(),
  136. "c_name", c_name,
  137. "metadata_c_name", metadata_c_name,
  138. - "size", std::to_string(serialized.size()));
  139. + "size", ToString(serialized.size()));
  140. for (size_t i = 0; i < serialized.size();) {
  141. for (size_t j = 0; j < 25 && i < serialized.size(); ++i, ++j) {
  142. --- a/src/google/protobuf/io/io_win32.cc (index)
  143. +++ b/src/google/protobuf/io/io_win32.cc (working tree)
  144. @@ -77,7 +77,7 @@ namespace io {
  145. namespace win32 {
  146. namespace {
  147. -using TProtoStringType;
  148. +using string = TProtoStringType;
  149. using std::wstring;
  150. template <typename char_type>
  151. --- a/src/google/protobuf/io/io_win32.h
  152. +++ b/src/google/protobuf/io/io_win32.h
  153. @@ -52,6 +52,7 @@
  154. #include <functional>
  155. #include <string>
  156. +#include <google/protobuf/stubs/port.h>
  157. #include "google/protobuf/port.h"
  158. // Must be included last.
  159. diff --git a/src/google/protobuf/compiler/objectivec/objectivec_generator.cc b/src/google/protobuf/compiler/objectivec/objectivec_generator.cc
  160. index 16dd7b9..371234a 100644
  161. --- a/src/google/protobuf/compiler/objectivec/generator.cc
  162. +++ b/src/google/protobuf/compiler/objectivec/generator.cc
  163. @@ -183,9 +183,9 @@ bool ObjectiveCGenerator::GenerateAll(
  164. if (getenv("GPB_OBJC_SKIP_IMPLS_FILE") != NULL) {
  165. std::ifstream skip_file(getenv("GPB_OBJC_SKIP_IMPLS_FILE"));
  166. if (skip_file.is_open()) {
  167. - TProtoStringType line;
  168. + std::string line;
  169. while (std::getline(skip_file, line)) {
  170. - skip_impls.insert(line);
  171. + skip_impls.insert(line.c_str());
  172. }
  173. } else {
  174. *error = "error: Failed to open GPB_OBJC_SKIP_IMPLS_FILE file";
  175. --- a/src/google/protobuf/arenaz_sampler.h
  176. +++ b/src/google/protobuf/arenaz_sampler.h
  177. @@ -37,6 +37,7 @@
  178. #include <cstdint>
  179. #include <utility>
  180. +#include <google/protobuf/stubs/port.h>
  181. // Must be included last.
  182. #include "google/protobuf/port_def.inc"
  183. --- a/src/google/protobuf/io/printer.h (index)
  184. +++ b/src/google/protobuf/io/printer.h (working tree)
  185. @@ -50,6 +50,7 @@
  186. #include "absl/functional/function_ref.h"
  187. #include "absl/log/absl_check.h"
  188. #include "absl/meta/type_traits.h"
  189. +#include "absl/strings/str_cat.h"
  190. #include "absl/strings/str_format.h"
  191. #include "absl/strings/string_view.h"
  192. #include "absl/types/optional.h"
  193. --- a/src/google/protobuf/io/strtod.h (index)
  194. +++ b/src/google/protobuf/io/strtod.h (working tree)
  195. @@ -35,11 +35,13 @@
  196. #ifndef GOOGLE_PROTOBUF_IO_STRTOD_H__
  197. #define GOOGLE_PROTOBUF_IO_STRTOD_H__
  198. -#include <string>
  199. +#include <util/generic/string.h>
  200. // Must be included last.
  201. #include "google/protobuf/port_def.inc"
  202. +using TProtoStringType = TString;
  203. +
  204. namespace google {
  205. namespace protobuf {
  206. namespace io {
  207. --- a/src/google/protobuf/port.h (index)
  208. +++ b/src/google/protobuf/port.h (working tree)
  209. @@ -40,7 +40,7 @@
  210. #include <cstddef>
  211. #include <cstdint>
  212. #include <new>
  213. -#include <string>
  214. +#include <util/generic/string.h>
  215. #include <type_traits>
  216. #if PROTOBUF_RTTI
  217. @@ -55,6 +55,7 @@
  218. // must be last
  219. #include "google/protobuf/port_def.inc"
  220. +using TProtoStringType = TString;
  221. namespace google {
  222. namespace protobuf {