grpc 1.26.0 → 1.27.0.pre1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of grpc might be problematic. Click here for more details.

Files changed (209) hide show
  1. checksums.yaml +4 -4
  2. data/Makefile +1654 -1519
  3. data/etc/roots.pem +44 -0
  4. data/include/grpc/grpc_security.h +37 -15
  5. data/include/grpc/grpc_security_constants.h +27 -0
  6. data/include/grpc/impl/codegen/grpc_types.h +14 -0
  7. data/include/grpc/impl/codegen/port_platform.h +1 -1
  8. data/src/core/ext/filters/client_channel/client_channel.cc +0 -20
  9. data/src/core/ext/filters/client_channel/http_proxy.cc +4 -4
  10. data/src/core/ext/filters/client_channel/lb_policy.cc +4 -3
  11. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +191 -201
  12. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_balancer_addresses.cc +89 -0
  13. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_balancer_addresses.h +40 -0
  14. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.cc +3 -2
  15. data/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc +88 -121
  16. data/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h +28 -57
  17. data/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h +0 -7
  18. data/src/core/ext/filters/client_channel/lb_policy/xds/cds.cc +8 -9
  19. data/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc +53 -34
  20. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc +18 -5
  21. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc +24 -19
  22. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h +2 -1
  23. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc +4 -2
  24. data/src/core/ext/filters/client_channel/server_address.cc +6 -9
  25. data/src/core/ext/filters/client_channel/server_address.h +3 -10
  26. data/src/core/ext/filters/client_channel/xds/xds_api.cc +394 -150
  27. data/src/core/ext/filters/client_channel/xds/xds_api.h +75 -35
  28. data/src/core/ext/filters/client_channel/xds/xds_bootstrap.cc +59 -22
  29. data/src/core/ext/filters/client_channel/xds/xds_bootstrap.h +13 -9
  30. data/src/core/ext/filters/client_channel/xds/xds_channel_secure.cc +8 -6
  31. data/src/core/ext/filters/client_channel/xds/xds_client.cc +456 -175
  32. data/src/core/ext/filters/client_channel/xds/xds_client.h +33 -21
  33. data/src/core/ext/filters/client_channel/xds/xds_client_stats.cc +5 -8
  34. data/src/core/ext/filters/client_channel/xds/xds_client_stats.h +18 -24
  35. data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +2 -2
  36. data/src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.c +13 -5
  37. data/src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.h +34 -0
  38. data/src/core/lib/channel/channelz.h +11 -1
  39. data/src/core/lib/gpr/time_precise.cc +1 -1
  40. data/src/core/lib/gprpp/optional.h +26 -0
  41. data/src/core/lib/gprpp/string_view.h +14 -10
  42. data/src/core/lib/iomgr/executor.cc +1 -1
  43. data/src/core/lib/iomgr/fork_posix.cc +4 -0
  44. data/src/core/lib/iomgr/poller/eventmanager_libuv.cc +87 -0
  45. data/src/core/lib/iomgr/poller/eventmanager_libuv.h +88 -0
  46. data/src/core/lib/iomgr/socket_utils_common_posix.cc +14 -0
  47. data/src/core/lib/iomgr/socket_utils_posix.h +12 -0
  48. data/src/core/lib/iomgr/tcp_custom.h +3 -0
  49. data/src/core/lib/iomgr/tcp_posix.cc +607 -56
  50. data/src/core/lib/iomgr/tcp_server_custom.cc +15 -2
  51. data/src/core/lib/iomgr/tcp_server_utils_posix_common.cc +8 -0
  52. data/src/core/lib/json/json.h +11 -1
  53. data/src/core/lib/json/json_reader.cc +206 -28
  54. data/src/core/lib/json/json_writer.cc +111 -24
  55. data/src/core/lib/security/credentials/composite/composite_credentials.cc +7 -0
  56. data/src/core/lib/security/credentials/composite/composite_credentials.h +5 -1
  57. data/src/core/lib/security/credentials/credentials.h +10 -1
  58. data/src/core/lib/security/credentials/fake/fake_credentials.h +2 -1
  59. data/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc +1 -1
  60. data/src/core/lib/security/credentials/plugin/plugin_credentials.cc +6 -4
  61. data/src/core/lib/security/credentials/plugin/plugin_credentials.h +2 -1
  62. data/src/core/lib/security/credentials/tls/grpc_tls_credentials_options.cc +20 -0
  63. data/src/core/lib/security/credentials/tls/grpc_tls_credentials_options.h +8 -0
  64. data/src/core/lib/security/credentials/tls/{spiffe_credentials.cc → tls_credentials.cc} +23 -24
  65. data/src/core/lib/security/credentials/tls/{spiffe_credentials.h → tls_credentials.h} +9 -9
  66. data/src/core/lib/security/security_connector/alts/alts_security_connector.cc +13 -0
  67. data/src/core/lib/security/security_connector/fake/fake_security_connector.cc +22 -2
  68. data/src/core/lib/security/security_connector/load_system_roots_fallback.cc +2 -2
  69. data/src/core/lib/security/security_connector/load_system_roots_linux.cc +2 -2
  70. data/src/core/lib/security/security_connector/local/local_security_connector.cc +30 -3
  71. data/src/core/lib/security/security_connector/ssl_utils.cc +45 -3
  72. data/src/core/lib/security/security_connector/ssl_utils.h +12 -0
  73. data/src/core/lib/security/security_connector/tls/{spiffe_security_connector.cc → tls_security_connector.cc} +82 -69
  74. data/src/core/lib/security/security_connector/tls/{spiffe_security_connector.h → tls_security_connector.h} +17 -18
  75. data/src/core/lib/security/transport/client_auth_filter.cc +33 -0
  76. data/src/core/lib/surface/completion_queue.cc +22 -1
  77. data/src/core/lib/surface/version.cc +1 -1
  78. data/src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc +11 -1
  79. data/src/core/tsi/alts/handshaker/alts_tsi_handshaker.h +1 -1
  80. data/src/core/tsi/alts/zero_copy_frame_protector/alts_zero_copy_grpc_protector.cc +3 -3
  81. data/src/core/tsi/fake_transport_security.cc +7 -3
  82. data/src/core/tsi/fake_transport_security.h +2 -0
  83. data/src/core/tsi/ssl_transport_security.cc +144 -8
  84. data/src/core/tsi/ssl_transport_security.h +15 -1
  85. data/src/core/tsi/transport_security.cc +13 -0
  86. data/src/core/tsi/transport_security_grpc.cc +2 -2
  87. data/src/core/tsi/transport_security_grpc.h +2 -2
  88. data/src/core/tsi/transport_security_interface.h +12 -0
  89. data/src/ruby/bin/math_pb.rb +5 -5
  90. data/src/ruby/ext/grpc/rb_call_credentials.c +4 -1
  91. data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +2 -0
  92. data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +4 -1
  93. data/src/ruby/lib/grpc/version.rb +1 -1
  94. data/src/ruby/pb/grpc/health/v1/health_pb.rb +3 -3
  95. data/src/ruby/pb/src/proto/grpc/testing/empty_pb.rb +1 -1
  96. data/src/ruby/pb/src/proto/grpc/testing/messages_pb.rb +23 -13
  97. data/third_party/abseil-cpp/absl/algorithm/algorithm.h +159 -0
  98. data/third_party/abseil-cpp/absl/base/attributes.h +609 -0
  99. data/third_party/abseil-cpp/absl/base/call_once.h +226 -0
  100. data/third_party/abseil-cpp/absl/base/casts.h +184 -0
  101. data/third_party/abseil-cpp/absl/base/config.h +622 -0
  102. data/third_party/abseil-cpp/absl/base/const_init.h +76 -0
  103. data/third_party/abseil-cpp/absl/base/dynamic_annotations.cc +129 -0
  104. data/third_party/abseil-cpp/absl/base/dynamic_annotations.h +389 -0
  105. data/third_party/abseil-cpp/absl/base/internal/atomic_hook.h +179 -0
  106. data/third_party/abseil-cpp/absl/base/internal/bits.h +218 -0
  107. data/third_party/abseil-cpp/absl/base/internal/cycleclock.cc +107 -0
  108. data/third_party/abseil-cpp/absl/base/internal/cycleclock.h +94 -0
  109. data/third_party/abseil-cpp/absl/base/internal/endian.h +266 -0
  110. data/third_party/abseil-cpp/absl/base/internal/hide_ptr.h +51 -0
  111. data/third_party/abseil-cpp/absl/base/internal/identity.h +37 -0
  112. data/third_party/abseil-cpp/absl/base/internal/inline_variable.h +107 -0
  113. data/third_party/abseil-cpp/absl/base/internal/invoke.h +187 -0
  114. data/third_party/abseil-cpp/absl/base/internal/low_level_scheduling.h +107 -0
  115. data/third_party/abseil-cpp/absl/base/internal/per_thread_tls.h +52 -0
  116. data/third_party/abseil-cpp/absl/base/internal/raw_logging.cc +237 -0
  117. data/third_party/abseil-cpp/absl/base/internal/raw_logging.h +179 -0
  118. data/third_party/abseil-cpp/absl/base/internal/scheduling_mode.h +58 -0
  119. data/third_party/abseil-cpp/absl/base/internal/spinlock.cc +233 -0
  120. data/third_party/abseil-cpp/absl/base/internal/spinlock.h +243 -0
  121. data/third_party/abseil-cpp/absl/base/internal/spinlock_akaros.inc +35 -0
  122. data/third_party/abseil-cpp/absl/base/internal/spinlock_linux.inc +67 -0
  123. data/third_party/abseil-cpp/absl/base/internal/spinlock_posix.inc +46 -0
  124. data/third_party/abseil-cpp/absl/base/internal/spinlock_wait.cc +81 -0
  125. data/third_party/abseil-cpp/absl/base/internal/spinlock_wait.h +93 -0
  126. data/third_party/abseil-cpp/absl/base/internal/spinlock_win32.inc +37 -0
  127. data/third_party/abseil-cpp/absl/base/internal/sysinfo.cc +414 -0
  128. data/third_party/abseil-cpp/absl/base/internal/sysinfo.h +66 -0
  129. data/third_party/abseil-cpp/absl/base/internal/thread_annotations.h +271 -0
  130. data/third_party/abseil-cpp/absl/base/internal/thread_identity.cc +140 -0
  131. data/third_party/abseil-cpp/absl/base/internal/thread_identity.h +250 -0
  132. data/third_party/abseil-cpp/absl/base/internal/throw_delegate.cc +108 -0
  133. data/third_party/abseil-cpp/absl/base/internal/throw_delegate.h +75 -0
  134. data/third_party/abseil-cpp/absl/base/internal/tsan_mutex_interface.h +66 -0
  135. data/third_party/abseil-cpp/absl/base/internal/unaligned_access.h +158 -0
  136. data/third_party/abseil-cpp/absl/base/internal/unscaledcycleclock.cc +103 -0
  137. data/third_party/abseil-cpp/absl/base/internal/unscaledcycleclock.h +124 -0
  138. data/third_party/abseil-cpp/absl/base/log_severity.cc +27 -0
  139. data/third_party/abseil-cpp/absl/base/log_severity.h +121 -0
  140. data/third_party/abseil-cpp/absl/base/macros.h +220 -0
  141. data/third_party/abseil-cpp/absl/base/optimization.h +181 -0
  142. data/third_party/abseil-cpp/absl/base/options.h +214 -0
  143. data/third_party/abseil-cpp/absl/base/policy_checks.h +111 -0
  144. data/third_party/abseil-cpp/absl/base/port.h +26 -0
  145. data/third_party/abseil-cpp/absl/base/thread_annotations.h +280 -0
  146. data/third_party/abseil-cpp/absl/container/inlined_vector.h +848 -0
  147. data/third_party/abseil-cpp/absl/container/internal/compressed_tuple.h +265 -0
  148. data/third_party/abseil-cpp/absl/container/internal/inlined_vector.h +892 -0
  149. data/third_party/abseil-cpp/absl/memory/memory.h +695 -0
  150. data/third_party/abseil-cpp/absl/meta/type_traits.h +759 -0
  151. data/third_party/abseil-cpp/absl/numeric/int128.cc +404 -0
  152. data/third_party/abseil-cpp/absl/numeric/int128.h +1091 -0
  153. data/third_party/abseil-cpp/absl/numeric/int128_have_intrinsic.inc +302 -0
  154. data/third_party/abseil-cpp/absl/numeric/int128_no_intrinsic.inc +308 -0
  155. data/third_party/abseil-cpp/absl/strings/ascii.cc +200 -0
  156. data/third_party/abseil-cpp/absl/strings/ascii.h +241 -0
  157. data/third_party/abseil-cpp/absl/strings/charconv.cc +985 -0
  158. data/third_party/abseil-cpp/absl/strings/charconv.h +119 -0
  159. data/third_party/abseil-cpp/absl/strings/escaping.cc +949 -0
  160. data/third_party/abseil-cpp/absl/strings/escaping.h +164 -0
  161. data/third_party/abseil-cpp/absl/strings/internal/char_map.h +156 -0
  162. data/third_party/abseil-cpp/absl/strings/internal/charconv_bigint.cc +359 -0
  163. data/third_party/abseil-cpp/absl/strings/internal/charconv_bigint.h +421 -0
  164. data/third_party/abseil-cpp/absl/strings/internal/charconv_parse.cc +504 -0
  165. data/third_party/abseil-cpp/absl/strings/internal/charconv_parse.h +99 -0
  166. data/third_party/abseil-cpp/absl/strings/internal/escaping.cc +180 -0
  167. data/third_party/abseil-cpp/absl/strings/internal/escaping.h +58 -0
  168. data/third_party/abseil-cpp/absl/strings/internal/memutil.cc +112 -0
  169. data/third_party/abseil-cpp/absl/strings/internal/memutil.h +148 -0
  170. data/third_party/abseil-cpp/absl/strings/internal/ostringstream.cc +36 -0
  171. data/third_party/abseil-cpp/absl/strings/internal/ostringstream.h +89 -0
  172. data/third_party/abseil-cpp/absl/strings/internal/resize_uninitialized.h +73 -0
  173. data/third_party/abseil-cpp/absl/strings/internal/stl_type_traits.h +248 -0
  174. data/third_party/abseil-cpp/absl/strings/internal/str_join_internal.h +314 -0
  175. data/third_party/abseil-cpp/absl/strings/internal/str_split_internal.h +455 -0
  176. data/third_party/abseil-cpp/absl/strings/internal/utf8.cc +53 -0
  177. data/third_party/abseil-cpp/absl/strings/internal/utf8.h +50 -0
  178. data/third_party/abseil-cpp/absl/strings/match.cc +40 -0
  179. data/third_party/abseil-cpp/absl/strings/match.h +90 -0
  180. data/third_party/abseil-cpp/absl/strings/numbers.cc +916 -0
  181. data/third_party/abseil-cpp/absl/strings/numbers.h +263 -0
  182. data/third_party/abseil-cpp/absl/strings/str_cat.cc +246 -0
  183. data/third_party/abseil-cpp/absl/strings/str_cat.h +408 -0
  184. data/third_party/abseil-cpp/absl/strings/str_join.h +293 -0
  185. data/third_party/abseil-cpp/absl/strings/str_replace.cc +82 -0
  186. data/third_party/abseil-cpp/absl/strings/str_replace.h +219 -0
  187. data/third_party/abseil-cpp/absl/strings/str_split.cc +139 -0
  188. data/third_party/abseil-cpp/absl/strings/str_split.h +513 -0
  189. data/third_party/abseil-cpp/absl/strings/string_view.cc +235 -0
  190. data/third_party/abseil-cpp/absl/strings/string_view.h +615 -0
  191. data/third_party/abseil-cpp/absl/strings/strip.h +91 -0
  192. data/third_party/abseil-cpp/absl/strings/substitute.cc +171 -0
  193. data/third_party/abseil-cpp/absl/strings/substitute.h +693 -0
  194. data/third_party/abseil-cpp/absl/types/bad_optional_access.cc +48 -0
  195. data/third_party/abseil-cpp/absl/types/bad_optional_access.h +78 -0
  196. data/third_party/abseil-cpp/absl/types/internal/optional.h +396 -0
  197. data/third_party/abseil-cpp/absl/types/internal/span.h +128 -0
  198. data/third_party/abseil-cpp/absl/types/optional.h +776 -0
  199. data/third_party/abseil-cpp/absl/types/span.h +713 -0
  200. data/third_party/abseil-cpp/absl/utility/utility.h +350 -0
  201. data/third_party/upb/upb/decode.c +4 -0
  202. data/third_party/upb/upb/port.c +0 -1
  203. data/third_party/upb/upb/port_def.inc +1 -3
  204. data/third_party/upb/upb/table.c +2 -1
  205. metadata +147 -43
  206. data/src/core/lib/json/json_common.h +0 -34
  207. data/src/core/lib/json/json_reader.h +0 -146
  208. data/src/core/lib/json/json_string.cc +0 -367
  209. data/src/core/lib/json/json_writer.h +0 -84
@@ -0,0 +1,408 @@
1
+ //
2
+ // Copyright 2017 The Abseil Authors.
3
+ //
4
+ // Licensed under the Apache License, Version 2.0 (the "License");
5
+ // you may not use this file except in compliance with the License.
6
+ // You may obtain a copy of the License at
7
+ //
8
+ // https://www.apache.org/licenses/LICENSE-2.0
9
+ //
10
+ // Unless required by applicable law or agreed to in writing, software
11
+ // distributed under the License is distributed on an "AS IS" BASIS,
12
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ // See the License for the specific language governing permissions and
14
+ // limitations under the License.
15
+ //
16
+ // -----------------------------------------------------------------------------
17
+ // File: str_cat.h
18
+ // -----------------------------------------------------------------------------
19
+ //
20
+ // This package contains functions for efficiently concatenating and appending
21
+ // strings: `StrCat()` and `StrAppend()`. Most of the work within these routines
22
+ // is actually handled through use of a special AlphaNum type, which was
23
+ // designed to be used as a parameter type that efficiently manages conversion
24
+ // to strings and avoids copies in the above operations.
25
+ //
26
+ // Any routine accepting either a string or a number may accept `AlphaNum`.
27
+ // The basic idea is that by accepting a `const AlphaNum &` as an argument
28
+ // to your function, your callers will automagically convert bools, integers,
29
+ // and floating point values to strings for you.
30
+ //
31
+ // NOTE: Use of `AlphaNum` outside of the //absl/strings package is unsupported
32
+ // except for the specific case of function parameters of type `AlphaNum` or
33
+ // `const AlphaNum &`. In particular, instantiating `AlphaNum` directly as a
34
+ // stack variable is not supported.
35
+ //
36
+ // Conversion from 8-bit values is not accepted because, if it were, then an
37
+ // attempt to pass ':' instead of ":" might result in a 58 ending up in your
38
+ // result.
39
+ //
40
+ // Bools convert to "0" or "1". Pointers to types other than `char *` are not
41
+ // valid inputs. No output is generated for null `char *` pointers.
42
+ //
43
+ // Floating point numbers are formatted with six-digit precision, which is
44
+ // the default for "std::cout <<" or printf "%g" (the same as "%.6g").
45
+ //
46
+ // You can convert to hexadecimal output rather than decimal output using the
47
+ // `Hex` type contained here. To do so, pass `Hex(my_int)` as a parameter to
48
+ // `StrCat()` or `StrAppend()`. You may specify a minimum hex field width using
49
+ // a `PadSpec` enum.
50
+ //
51
+ // -----------------------------------------------------------------------------
52
+
53
+ #ifndef ABSL_STRINGS_STR_CAT_H_
54
+ #define ABSL_STRINGS_STR_CAT_H_
55
+
56
+ #include <array>
57
+ #include <cstdint>
58
+ #include <string>
59
+ #include <type_traits>
60
+ #include <vector>
61
+
62
+ #include "absl/base/port.h"
63
+ #include "absl/strings/numbers.h"
64
+ #include "absl/strings/string_view.h"
65
+
66
+ namespace absl {
67
+ ABSL_NAMESPACE_BEGIN
68
+
69
+ namespace strings_internal {
70
+ // AlphaNumBuffer allows a way to pass a string to StrCat without having to do
71
+ // memory allocation. It is simply a pair of a fixed-size character array, and
72
+ // a size. Please don't use outside of absl, yet.
73
+ template <size_t max_size>
74
+ struct AlphaNumBuffer {
75
+ std::array<char, max_size> data;
76
+ size_t size;
77
+ };
78
+
79
+ } // namespace strings_internal
80
+
81
+ // Enum that specifies the number of significant digits to return in a `Hex` or
82
+ // `Dec` conversion and fill character to use. A `kZeroPad2` value, for example,
83
+ // would produce hexadecimal strings such as "0a","0f" and a 'kSpacePad5' value
84
+ // would produce hexadecimal strings such as " a"," f".
85
+ enum PadSpec : uint8_t {
86
+ kNoPad = 1,
87
+ kZeroPad2,
88
+ kZeroPad3,
89
+ kZeroPad4,
90
+ kZeroPad5,
91
+ kZeroPad6,
92
+ kZeroPad7,
93
+ kZeroPad8,
94
+ kZeroPad9,
95
+ kZeroPad10,
96
+ kZeroPad11,
97
+ kZeroPad12,
98
+ kZeroPad13,
99
+ kZeroPad14,
100
+ kZeroPad15,
101
+ kZeroPad16,
102
+ kZeroPad17,
103
+ kZeroPad18,
104
+ kZeroPad19,
105
+ kZeroPad20,
106
+
107
+ kSpacePad2 = kZeroPad2 + 64,
108
+ kSpacePad3,
109
+ kSpacePad4,
110
+ kSpacePad5,
111
+ kSpacePad6,
112
+ kSpacePad7,
113
+ kSpacePad8,
114
+ kSpacePad9,
115
+ kSpacePad10,
116
+ kSpacePad11,
117
+ kSpacePad12,
118
+ kSpacePad13,
119
+ kSpacePad14,
120
+ kSpacePad15,
121
+ kSpacePad16,
122
+ kSpacePad17,
123
+ kSpacePad18,
124
+ kSpacePad19,
125
+ kSpacePad20,
126
+ };
127
+
128
+ // -----------------------------------------------------------------------------
129
+ // Hex
130
+ // -----------------------------------------------------------------------------
131
+ //
132
+ // `Hex` stores a set of hexadecimal string conversion parameters for use
133
+ // within `AlphaNum` string conversions.
134
+ struct Hex {
135
+ uint64_t value;
136
+ uint8_t width;
137
+ char fill;
138
+
139
+ template <typename Int>
140
+ explicit Hex(
141
+ Int v, PadSpec spec = absl::kNoPad,
142
+ typename std::enable_if<sizeof(Int) == 1 &&
143
+ !std::is_pointer<Int>::value>::type* = nullptr)
144
+ : Hex(spec, static_cast<uint8_t>(v)) {}
145
+ template <typename Int>
146
+ explicit Hex(
147
+ Int v, PadSpec spec = absl::kNoPad,
148
+ typename std::enable_if<sizeof(Int) == 2 &&
149
+ !std::is_pointer<Int>::value>::type* = nullptr)
150
+ : Hex(spec, static_cast<uint16_t>(v)) {}
151
+ template <typename Int>
152
+ explicit Hex(
153
+ Int v, PadSpec spec = absl::kNoPad,
154
+ typename std::enable_if<sizeof(Int) == 4 &&
155
+ !std::is_pointer<Int>::value>::type* = nullptr)
156
+ : Hex(spec, static_cast<uint32_t>(v)) {}
157
+ template <typename Int>
158
+ explicit Hex(
159
+ Int v, PadSpec spec = absl::kNoPad,
160
+ typename std::enable_if<sizeof(Int) == 8 &&
161
+ !std::is_pointer<Int>::value>::type* = nullptr)
162
+ : Hex(spec, static_cast<uint64_t>(v)) {}
163
+ template <typename Pointee>
164
+ explicit Hex(Pointee* v, PadSpec spec = absl::kNoPad)
165
+ : Hex(spec, reinterpret_cast<uintptr_t>(v)) {}
166
+
167
+ private:
168
+ Hex(PadSpec spec, uint64_t v)
169
+ : value(v),
170
+ width(spec == absl::kNoPad
171
+ ? 1
172
+ : spec >= absl::kSpacePad2 ? spec - absl::kSpacePad2 + 2
173
+ : spec - absl::kZeroPad2 + 2),
174
+ fill(spec >= absl::kSpacePad2 ? ' ' : '0') {}
175
+ };
176
+
177
+ // -----------------------------------------------------------------------------
178
+ // Dec
179
+ // -----------------------------------------------------------------------------
180
+ //
181
+ // `Dec` stores a set of decimal string conversion parameters for use
182
+ // within `AlphaNum` string conversions. Dec is slower than the default
183
+ // integer conversion, so use it only if you need padding.
184
+ struct Dec {
185
+ uint64_t value;
186
+ uint8_t width;
187
+ char fill;
188
+ bool neg;
189
+
190
+ template <typename Int>
191
+ explicit Dec(Int v, PadSpec spec = absl::kNoPad,
192
+ typename std::enable_if<(sizeof(Int) <= 8)>::type* = nullptr)
193
+ : value(v >= 0 ? static_cast<uint64_t>(v)
194
+ : uint64_t{0} - static_cast<uint64_t>(v)),
195
+ width(spec == absl::kNoPad
196
+ ? 1
197
+ : spec >= absl::kSpacePad2 ? spec - absl::kSpacePad2 + 2
198
+ : spec - absl::kZeroPad2 + 2),
199
+ fill(spec >= absl::kSpacePad2 ? ' ' : '0'),
200
+ neg(v < 0) {}
201
+ };
202
+
203
+ // -----------------------------------------------------------------------------
204
+ // AlphaNum
205
+ // -----------------------------------------------------------------------------
206
+ //
207
+ // The `AlphaNum` class acts as the main parameter type for `StrCat()` and
208
+ // `StrAppend()`, providing efficient conversion of numeric, boolean, and
209
+ // hexadecimal values (through the `Hex` type) into strings.
210
+
211
+ class AlphaNum {
212
+ public:
213
+ // No bool ctor -- bools convert to an integral type.
214
+ // A bool ctor would also convert incoming pointers (bletch).
215
+
216
+ AlphaNum(int x) // NOLINT(runtime/explicit)
217
+ : piece_(digits_,
218
+ numbers_internal::FastIntToBuffer(x, digits_) - &digits_[0]) {}
219
+ AlphaNum(unsigned int x) // NOLINT(runtime/explicit)
220
+ : piece_(digits_,
221
+ numbers_internal::FastIntToBuffer(x, digits_) - &digits_[0]) {}
222
+ AlphaNum(long x) // NOLINT(*)
223
+ : piece_(digits_,
224
+ numbers_internal::FastIntToBuffer(x, digits_) - &digits_[0]) {}
225
+ AlphaNum(unsigned long x) // NOLINT(*)
226
+ : piece_(digits_,
227
+ numbers_internal::FastIntToBuffer(x, digits_) - &digits_[0]) {}
228
+ AlphaNum(long long x) // NOLINT(*)
229
+ : piece_(digits_,
230
+ numbers_internal::FastIntToBuffer(x, digits_) - &digits_[0]) {}
231
+ AlphaNum(unsigned long long x) // NOLINT(*)
232
+ : piece_(digits_,
233
+ numbers_internal::FastIntToBuffer(x, digits_) - &digits_[0]) {}
234
+
235
+ AlphaNum(float f) // NOLINT(runtime/explicit)
236
+ : piece_(digits_, numbers_internal::SixDigitsToBuffer(f, digits_)) {}
237
+ AlphaNum(double f) // NOLINT(runtime/explicit)
238
+ : piece_(digits_, numbers_internal::SixDigitsToBuffer(f, digits_)) {}
239
+
240
+ AlphaNum(Hex hex); // NOLINT(runtime/explicit)
241
+ AlphaNum(Dec dec); // NOLINT(runtime/explicit)
242
+
243
+ template <size_t size>
244
+ AlphaNum( // NOLINT(runtime/explicit)
245
+ const strings_internal::AlphaNumBuffer<size>& buf)
246
+ : piece_(&buf.data[0], buf.size) {}
247
+
248
+ AlphaNum(const char* c_str) : piece_(c_str) {} // NOLINT(runtime/explicit)
249
+ AlphaNum(absl::string_view pc) : piece_(pc) {} // NOLINT(runtime/explicit)
250
+
251
+ template <typename Allocator>
252
+ AlphaNum( // NOLINT(runtime/explicit)
253
+ const std::basic_string<char, std::char_traits<char>, Allocator>& str)
254
+ : piece_(str) {}
255
+
256
+ // Use std::string literals ":" instead of character literals ':'.
257
+ AlphaNum(char c) = delete; // NOLINT(runtime/explicit)
258
+
259
+ AlphaNum(const AlphaNum&) = delete;
260
+ AlphaNum& operator=(const AlphaNum&) = delete;
261
+
262
+ absl::string_view::size_type size() const { return piece_.size(); }
263
+ const char* data() const { return piece_.data(); }
264
+ absl::string_view Piece() const { return piece_; }
265
+
266
+ // Normal enums are already handled by the integer formatters.
267
+ // This overload matches only scoped enums.
268
+ template <typename T,
269
+ typename = typename std::enable_if<
270
+ std::is_enum<T>{} && !std::is_convertible<T, int>{}>::type>
271
+ AlphaNum(T e) // NOLINT(runtime/explicit)
272
+ : AlphaNum(static_cast<typename std::underlying_type<T>::type>(e)) {}
273
+
274
+ // vector<bool>::reference and const_reference require special help to
275
+ // convert to `AlphaNum` because it requires two user defined conversions.
276
+ template <
277
+ typename T,
278
+ typename std::enable_if<
279
+ std::is_class<T>::value &&
280
+ (std::is_same<T, std::vector<bool>::reference>::value ||
281
+ std::is_same<T, std::vector<bool>::const_reference>::value)>::type* =
282
+ nullptr>
283
+ AlphaNum(T e) : AlphaNum(static_cast<bool>(e)) {} // NOLINT(runtime/explicit)
284
+
285
+ private:
286
+ absl::string_view piece_;
287
+ char digits_[numbers_internal::kFastToBufferSize];
288
+ };
289
+
290
+ // -----------------------------------------------------------------------------
291
+ // StrCat()
292
+ // -----------------------------------------------------------------------------
293
+ //
294
+ // Merges given strings or numbers, using no delimiter(s), returning the merged
295
+ // result as a string.
296
+ //
297
+ // `StrCat()` is designed to be the fastest possible way to construct a string
298
+ // out of a mix of raw C strings, string_views, strings, bool values,
299
+ // and numeric values.
300
+ //
301
+ // Don't use `StrCat()` for user-visible strings. The localization process
302
+ // works poorly on strings built up out of fragments.
303
+ //
304
+ // For clarity and performance, don't use `StrCat()` when appending to a
305
+ // string. Use `StrAppend()` instead. In particular, avoid using any of these
306
+ // (anti-)patterns:
307
+ //
308
+ // str.append(StrCat(...))
309
+ // str += StrCat(...)
310
+ // str = StrCat(str, ...)
311
+ //
312
+ // The last case is the worst, with a potential to change a loop
313
+ // from a linear time operation with O(1) dynamic allocations into a
314
+ // quadratic time operation with O(n) dynamic allocations.
315
+ //
316
+ // See `StrAppend()` below for more information.
317
+
318
+ namespace strings_internal {
319
+
320
+ // Do not call directly - this is not part of the public API.
321
+ std::string CatPieces(std::initializer_list<absl::string_view> pieces);
322
+ void AppendPieces(std::string* dest,
323
+ std::initializer_list<absl::string_view> pieces);
324
+
325
+ } // namespace strings_internal
326
+
327
+ ABSL_MUST_USE_RESULT inline std::string StrCat() { return std::string(); }
328
+
329
+ ABSL_MUST_USE_RESULT inline std::string StrCat(const AlphaNum& a) {
330
+ return std::string(a.data(), a.size());
331
+ }
332
+
333
+ ABSL_MUST_USE_RESULT std::string StrCat(const AlphaNum& a, const AlphaNum& b);
334
+ ABSL_MUST_USE_RESULT std::string StrCat(const AlphaNum& a, const AlphaNum& b,
335
+ const AlphaNum& c);
336
+ ABSL_MUST_USE_RESULT std::string StrCat(const AlphaNum& a, const AlphaNum& b,
337
+ const AlphaNum& c, const AlphaNum& d);
338
+
339
+ // Support 5 or more arguments
340
+ template <typename... AV>
341
+ ABSL_MUST_USE_RESULT inline std::string StrCat(
342
+ const AlphaNum& a, const AlphaNum& b, const AlphaNum& c, const AlphaNum& d,
343
+ const AlphaNum& e, const AV&... args) {
344
+ return strings_internal::CatPieces(
345
+ {a.Piece(), b.Piece(), c.Piece(), d.Piece(), e.Piece(),
346
+ static_cast<const AlphaNum&>(args).Piece()...});
347
+ }
348
+
349
+ // -----------------------------------------------------------------------------
350
+ // StrAppend()
351
+ // -----------------------------------------------------------------------------
352
+ //
353
+ // Appends a string or set of strings to an existing string, in a similar
354
+ // fashion to `StrCat()`.
355
+ //
356
+ // WARNING: `StrAppend(&str, a, b, c, ...)` requires that none of the
357
+ // a, b, c, parameters be a reference into str. For speed, `StrAppend()` does
358
+ // not try to check each of its input arguments to be sure that they are not
359
+ // a subset of the string being appended to. That is, while this will work:
360
+ //
361
+ // std::string s = "foo";
362
+ // s += s;
363
+ //
364
+ // This output is undefined:
365
+ //
366
+ // std::string s = "foo";
367
+ // StrAppend(&s, s);
368
+ //
369
+ // This output is undefined as well, since `absl::string_view` does not own its
370
+ // data:
371
+ //
372
+ // std::string s = "foobar";
373
+ // absl::string_view p = s;
374
+ // StrAppend(&s, p);
375
+
376
+ inline void StrAppend(std::string*) {}
377
+ void StrAppend(std::string* dest, const AlphaNum& a);
378
+ void StrAppend(std::string* dest, const AlphaNum& a, const AlphaNum& b);
379
+ void StrAppend(std::string* dest, const AlphaNum& a, const AlphaNum& b,
380
+ const AlphaNum& c);
381
+ void StrAppend(std::string* dest, const AlphaNum& a, const AlphaNum& b,
382
+ const AlphaNum& c, const AlphaNum& d);
383
+
384
+ // Support 5 or more arguments
385
+ template <typename... AV>
386
+ inline void StrAppend(std::string* dest, const AlphaNum& a, const AlphaNum& b,
387
+ const AlphaNum& c, const AlphaNum& d, const AlphaNum& e,
388
+ const AV&... args) {
389
+ strings_internal::AppendPieces(
390
+ dest, {a.Piece(), b.Piece(), c.Piece(), d.Piece(), e.Piece(),
391
+ static_cast<const AlphaNum&>(args).Piece()...});
392
+ }
393
+
394
+ // Helper function for the future StrCat default floating-point format, %.6g
395
+ // This is fast.
396
+ inline strings_internal::AlphaNumBuffer<
397
+ numbers_internal::kSixDigitsToBufferSize>
398
+ SixDigits(double d) {
399
+ strings_internal::AlphaNumBuffer<numbers_internal::kSixDigitsToBufferSize>
400
+ result;
401
+ result.size = numbers_internal::SixDigitsToBuffer(d, &result.data[0]);
402
+ return result;
403
+ }
404
+
405
+ ABSL_NAMESPACE_END
406
+ } // namespace absl
407
+
408
+ #endif // ABSL_STRINGS_STR_CAT_H_
@@ -0,0 +1,293 @@
1
+ //
2
+ // Copyright 2017 The Abseil Authors.
3
+ //
4
+ // Licensed under the Apache License, Version 2.0 (the "License");
5
+ // you may not use this file except in compliance with the License.
6
+ // You may obtain a copy of the License at
7
+ //
8
+ // https://www.apache.org/licenses/LICENSE-2.0
9
+ //
10
+ // Unless required by applicable law or agreed to in writing, software
11
+ // distributed under the License is distributed on an "AS IS" BASIS,
12
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ // See the License for the specific language governing permissions and
14
+ // limitations under the License.
15
+ //
16
+ // -----------------------------------------------------------------------------
17
+ // File: str_join.h
18
+ // -----------------------------------------------------------------------------
19
+ //
20
+ // This header file contains functions for joining a range of elements and
21
+ // returning the result as a std::string. StrJoin operations are specified by
22
+ // passing a range, a separator string to use between the elements joined, and
23
+ // an optional Formatter responsible for converting each argument in the range
24
+ // to a string. If omitted, a default `AlphaNumFormatter()` is called on the
25
+ // elements to be joined, using the same formatting that `absl::StrCat()` uses.
26
+ // This package defines a number of default formatters, and you can define your
27
+ // own implementations.
28
+ //
29
+ // Ranges are specified by passing a container with `std::begin()` and
30
+ // `std::end()` iterators, container-specific `begin()` and `end()` iterators, a
31
+ // brace-initialized `std::initializer_list`, or a `std::tuple` of heterogeneous
32
+ // objects. The separator string is specified as an `absl::string_view`.
33
+ //
34
+ // Because the default formatter uses the `absl::AlphaNum` class,
35
+ // `absl::StrJoin()`, like `absl::StrCat()`, will work out-of-the-box on
36
+ // collections of strings, ints, floats, doubles, etc.
37
+ //
38
+ // Example:
39
+ //
40
+ // std::vector<std::string> v = {"foo", "bar", "baz"};
41
+ // std::string s = absl::StrJoin(v, "-");
42
+ // EXPECT_EQ("foo-bar-baz", s);
43
+ //
44
+ // See comments on the `absl::StrJoin()` function for more examples.
45
+
46
+ #ifndef ABSL_STRINGS_STR_JOIN_H_
47
+ #define ABSL_STRINGS_STR_JOIN_H_
48
+
49
+ #include <cstdio>
50
+ #include <cstring>
51
+ #include <initializer_list>
52
+ #include <iterator>
53
+ #include <string>
54
+ #include <tuple>
55
+ #include <type_traits>
56
+ #include <utility>
57
+
58
+ #include "absl/base/macros.h"
59
+ #include "absl/strings/internal/str_join_internal.h"
60
+ #include "absl/strings/string_view.h"
61
+
62
+ namespace absl {
63
+ ABSL_NAMESPACE_BEGIN
64
+
65
+ // -----------------------------------------------------------------------------
66
+ // Concept: Formatter
67
+ // -----------------------------------------------------------------------------
68
+ //
69
+ // A Formatter is a function object that is responsible for formatting its
70
+ // argument as a string and appending it to a given output std::string.
71
+ // Formatters may be implemented as function objects, lambdas, or normal
72
+ // functions. You may provide your own Formatter to enable `absl::StrJoin()` to
73
+ // work with arbitrary types.
74
+ //
75
+ // The following is an example of a custom Formatter that simply uses
76
+ // `std::to_string()` to format an integer as a std::string.
77
+ //
78
+ // struct MyFormatter {
79
+ // void operator()(std::string* out, int i) const {
80
+ // out->append(std::to_string(i));
81
+ // }
82
+ // };
83
+ //
84
+ // You would use the above formatter by passing an instance of it as the final
85
+ // argument to `absl::StrJoin()`:
86
+ //
87
+ // std::vector<int> v = {1, 2, 3, 4};
88
+ // std::string s = absl::StrJoin(v, "-", MyFormatter());
89
+ // EXPECT_EQ("1-2-3-4", s);
90
+ //
91
+ // The following standard formatters are provided within this file:
92
+ //
93
+ // - `AlphaNumFormatter()` (the default)
94
+ // - `StreamFormatter()`
95
+ // - `PairFormatter()`
96
+ // - `DereferenceFormatter()`
97
+
98
+ // AlphaNumFormatter()
99
+ //
100
+ // Default formatter used if none is specified. Uses `absl::AlphaNum` to convert
101
+ // numeric arguments to strings.
102
+ inline strings_internal::AlphaNumFormatterImpl AlphaNumFormatter() {
103
+ return strings_internal::AlphaNumFormatterImpl();
104
+ }
105
+
106
+ // StreamFormatter()
107
+ //
108
+ // Formats its argument using the << operator.
109
+ inline strings_internal::StreamFormatterImpl StreamFormatter() {
110
+ return strings_internal::StreamFormatterImpl();
111
+ }
112
+
113
+ // Function Template: PairFormatter(Formatter, absl::string_view, Formatter)
114
+ //
115
+ // Formats a `std::pair` by putting a given separator between the pair's
116
+ // `.first` and `.second` members. This formatter allows you to specify
117
+ // custom Formatters for both the first and second member of each pair.
118
+ template <typename FirstFormatter, typename SecondFormatter>
119
+ inline strings_internal::PairFormatterImpl<FirstFormatter, SecondFormatter>
120
+ PairFormatter(FirstFormatter f1, absl::string_view sep, SecondFormatter f2) {
121
+ return strings_internal::PairFormatterImpl<FirstFormatter, SecondFormatter>(
122
+ std::move(f1), sep, std::move(f2));
123
+ }
124
+
125
+ // Function overload of PairFormatter() for using a default
126
+ // `AlphaNumFormatter()` for each Formatter in the pair.
127
+ inline strings_internal::PairFormatterImpl<
128
+ strings_internal::AlphaNumFormatterImpl,
129
+ strings_internal::AlphaNumFormatterImpl>
130
+ PairFormatter(absl::string_view sep) {
131
+ return PairFormatter(AlphaNumFormatter(), sep, AlphaNumFormatter());
132
+ }
133
+
134
+ // Function Template: DereferenceFormatter(Formatter)
135
+ //
136
+ // Formats its argument by dereferencing it and then applying the given
137
+ // formatter. This formatter is useful for formatting a container of
138
+ // pointer-to-T. This pattern often shows up when joining repeated fields in
139
+ // protocol buffers.
140
+ template <typename Formatter>
141
+ strings_internal::DereferenceFormatterImpl<Formatter> DereferenceFormatter(
142
+ Formatter&& f) {
143
+ return strings_internal::DereferenceFormatterImpl<Formatter>(
144
+ std::forward<Formatter>(f));
145
+ }
146
+
147
+ // Function overload of `DererefenceFormatter()` for using a default
148
+ // `AlphaNumFormatter()`.
149
+ inline strings_internal::DereferenceFormatterImpl<
150
+ strings_internal::AlphaNumFormatterImpl>
151
+ DereferenceFormatter() {
152
+ return strings_internal::DereferenceFormatterImpl<
153
+ strings_internal::AlphaNumFormatterImpl>(AlphaNumFormatter());
154
+ }
155
+
156
+ // -----------------------------------------------------------------------------
157
+ // StrJoin()
158
+ // -----------------------------------------------------------------------------
159
+ //
160
+ // Joins a range of elements and returns the result as a std::string.
161
+ // `absl::StrJoin()` takes a range, a separator string to use between the
162
+ // elements joined, and an optional Formatter responsible for converting each
163
+ // argument in the range to a string.
164
+ //
165
+ // If omitted, the default `AlphaNumFormatter()` is called on the elements to be
166
+ // joined.
167
+ //
168
+ // Example 1:
169
+ // // Joins a collection of strings. This pattern also works with a collection
170
+ // // of `absl::string_view` or even `const char*`.
171
+ // std::vector<std::string> v = {"foo", "bar", "baz"};
172
+ // std::string s = absl::StrJoin(v, "-");
173
+ // EXPECT_EQ("foo-bar-baz", s);
174
+ //
175
+ // Example 2:
176
+ // // Joins the values in the given `std::initializer_list<>` specified using
177
+ // // brace initialization. This pattern also works with an initializer_list
178
+ // // of ints or `absl::string_view` -- any `AlphaNum`-compatible type.
179
+ // std::string s = absl::StrJoin({"foo", "bar", "baz"}, "-");
180
+ // EXPECT_EQ("foo-bar-baz", s);
181
+ //
182
+ // Example 3:
183
+ // // Joins a collection of ints. This pattern also works with floats,
184
+ // // doubles, int64s -- any `StrCat()`-compatible type.
185
+ // std::vector<int> v = {1, 2, 3, -4};
186
+ // std::string s = absl::StrJoin(v, "-");
187
+ // EXPECT_EQ("1-2-3--4", s);
188
+ //
189
+ // Example 4:
190
+ // // Joins a collection of pointer-to-int. By default, pointers are
191
+ // // dereferenced and the pointee is formatted using the default format for
192
+ // // that type; such dereferencing occurs for all levels of indirection, so
193
+ // // this pattern works just as well for `std::vector<int**>` as for
194
+ // // `std::vector<int*>`.
195
+ // int x = 1, y = 2, z = 3;
196
+ // std::vector<int*> v = {&x, &y, &z};
197
+ // std::string s = absl::StrJoin(v, "-");
198
+ // EXPECT_EQ("1-2-3", s);
199
+ //
200
+ // Example 5:
201
+ // // Dereferencing of `std::unique_ptr<>` is also supported:
202
+ // std::vector<std::unique_ptr<int>> v
203
+ // v.emplace_back(new int(1));
204
+ // v.emplace_back(new int(2));
205
+ // v.emplace_back(new int(3));
206
+ // std::string s = absl::StrJoin(v, "-");
207
+ // EXPECT_EQ("1-2-3", s);
208
+ //
209
+ // Example 6:
210
+ // // Joins a `std::map`, with each key-value pair separated by an equals
211
+ // // sign. This pattern would also work with, say, a
212
+ // // `std::vector<std::pair<>>`.
213
+ // std::map<std::string, int> m = {
214
+ // std::make_pair("a", 1),
215
+ // std::make_pair("b", 2),
216
+ // std::make_pair("c", 3)};
217
+ // std::string s = absl::StrJoin(m, ",", absl::PairFormatter("="));
218
+ // EXPECT_EQ("a=1,b=2,c=3", s);
219
+ //
220
+ // Example 7:
221
+ // // These examples show how `absl::StrJoin()` handles a few common edge
222
+ // // cases:
223
+ // std::vector<std::string> v_empty;
224
+ // EXPECT_EQ("", absl::StrJoin(v_empty, "-"));
225
+ //
226
+ // std::vector<std::string> v_one_item = {"foo"};
227
+ // EXPECT_EQ("foo", absl::StrJoin(v_one_item, "-"));
228
+ //
229
+ // std::vector<std::string> v_empty_string = {""};
230
+ // EXPECT_EQ("", absl::StrJoin(v_empty_string, "-"));
231
+ //
232
+ // std::vector<std::string> v_one_item_empty_string = {"a", ""};
233
+ // EXPECT_EQ("a-", absl::StrJoin(v_one_item_empty_string, "-"));
234
+ //
235
+ // std::vector<std::string> v_two_empty_string = {"", ""};
236
+ // EXPECT_EQ("-", absl::StrJoin(v_two_empty_string, "-"));
237
+ //
238
+ // Example 8:
239
+ // // Joins a `std::tuple<T...>` of heterogeneous types, converting each to
240
+ // // a std::string using the `absl::AlphaNum` class.
241
+ // std::string s = absl::StrJoin(std::make_tuple(123, "abc", 0.456), "-");
242
+ // EXPECT_EQ("123-abc-0.456", s);
243
+
244
+ template <typename Iterator, typename Formatter>
245
+ std::string StrJoin(Iterator start, Iterator end, absl::string_view sep,
246
+ Formatter&& fmt) {
247
+ return strings_internal::JoinAlgorithm(start, end, sep, fmt);
248
+ }
249
+
250
+ template <typename Range, typename Formatter>
251
+ std::string StrJoin(const Range& range, absl::string_view separator,
252
+ Formatter&& fmt) {
253
+ return strings_internal::JoinRange(range, separator, fmt);
254
+ }
255
+
256
+ template <typename T, typename Formatter>
257
+ std::string StrJoin(std::initializer_list<T> il, absl::string_view separator,
258
+ Formatter&& fmt) {
259
+ return strings_internal::JoinRange(il, separator, fmt);
260
+ }
261
+
262
+ template <typename... T, typename Formatter>
263
+ std::string StrJoin(const std::tuple<T...>& value, absl::string_view separator,
264
+ Formatter&& fmt) {
265
+ return strings_internal::JoinAlgorithm(value, separator, fmt);
266
+ }
267
+
268
+ template <typename Iterator>
269
+ std::string StrJoin(Iterator start, Iterator end, absl::string_view separator) {
270
+ return strings_internal::JoinRange(start, end, separator);
271
+ }
272
+
273
+ template <typename Range>
274
+ std::string StrJoin(const Range& range, absl::string_view separator) {
275
+ return strings_internal::JoinRange(range, separator);
276
+ }
277
+
278
+ template <typename T>
279
+ std::string StrJoin(std::initializer_list<T> il,
280
+ absl::string_view separator) {
281
+ return strings_internal::JoinRange(il, separator);
282
+ }
283
+
284
+ template <typename... T>
285
+ std::string StrJoin(const std::tuple<T...>& value,
286
+ absl::string_view separator) {
287
+ return strings_internal::JoinAlgorithm(value, separator, AlphaNumFormatter());
288
+ }
289
+
290
+ ABSL_NAMESPACE_END
291
+ } // namespace absl
292
+
293
+ #endif // ABSL_STRINGS_STR_JOIN_H_