grpc 1.31.0.pre1 → 1.33.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 (614) hide show
  1. checksums.yaml +4 -4
  2. data/Makefile +693 -16022
  3. data/include/grpc/grpc.h +0 -5
  4. data/include/grpc/grpc_security.h +47 -14
  5. data/include/grpc/impl/codegen/README.md +22 -0
  6. data/include/grpc/impl/codegen/grpc_types.h +0 -5
  7. data/include/grpc/impl/codegen/port_platform.h +6 -1
  8. data/src/core/ext/filters/client_channel/backup_poller.cc +3 -2
  9. data/src/core/ext/filters/client_channel/client_channel.cc +264 -186
  10. data/src/core/ext/filters/client_channel/client_channel.h +1 -1
  11. data/src/core/ext/filters/client_channel/client_channel_channelz.h +0 -3
  12. data/src/core/ext/filters/client_channel/config_selector.cc +0 -4
  13. data/src/core/ext/filters/client_channel/config_selector.h +34 -5
  14. data/src/core/ext/filters/client_channel/health/health_check_client.cc +6 -1
  15. data/src/core/ext/filters/client_channel/http_connect_handshaker.cc +2 -3
  16. data/src/core/ext/filters/client_channel/lb_policy.h +3 -1
  17. data/src/core/ext/filters/client_channel/lb_policy/address_filtering.cc +48 -35
  18. data/src/core/ext/filters/client_channel/lb_policy/address_filtering.h +7 -5
  19. data/src/core/ext/filters/client_channel/lb_policy/child_policy_handler.cc +9 -6
  20. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +126 -119
  21. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_balancer_addresses.cc +0 -13
  22. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_balancer_addresses.h +0 -3
  23. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.cc +1 -37
  24. data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +21 -15
  25. data/src/core/ext/filters/client_channel/lb_policy/priority/priority.cc +32 -13
  26. data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +8 -7
  27. data/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h +9 -32
  28. data/src/core/ext/filters/client_channel/lb_policy/weighted_target/weighted_target.cc +26 -16
  29. data/src/core/ext/filters/client_channel/lb_policy/xds/cds.cc +207 -129
  30. data/src/core/ext/filters/client_channel/lb_policy/xds/eds.cc +453 -255
  31. data/src/core/ext/filters/client_channel/lb_policy/xds/eds_drop.cc +571 -0
  32. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_manager.cc +727 -0
  33. data/src/core/ext/filters/client_channel/lb_policy_registry.cc +8 -1
  34. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc +1 -1
  35. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc +3 -3
  36. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc +1 -1
  37. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc +1 -1
  38. data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc +1 -1
  39. data/src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc +1 -1
  40. data/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc +602 -58
  41. data/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.h +28 -0
  42. data/src/core/ext/filters/client_channel/resolver_result_parsing.cc +8 -39
  43. data/src/core/ext/filters/client_channel/resolver_result_parsing.h +4 -3
  44. data/src/core/ext/filters/client_channel/resolving_lb_policy.cc +49 -47
  45. data/src/core/ext/filters/client_channel/resolving_lb_policy.h +5 -9
  46. data/src/core/ext/filters/client_channel/server_address.cc +120 -7
  47. data/src/core/ext/filters/client_channel/server_address.h +48 -21
  48. data/src/core/ext/filters/client_channel/service_config.cc +16 -13
  49. data/src/core/ext/filters/client_channel/service_config.h +7 -4
  50. data/src/core/ext/filters/client_channel/service_config_channel_arg_filter.cc +2 -2
  51. data/src/core/ext/filters/client_channel/service_config_parser.cc +8 -6
  52. data/src/core/ext/filters/client_channel/service_config_parser.h +8 -5
  53. data/src/core/ext/filters/client_channel/subchannel.cc +64 -23
  54. data/src/core/ext/filters/client_channel/subchannel.h +16 -4
  55. data/src/core/ext/filters/client_channel/subchannel_interface.h +44 -0
  56. data/src/core/ext/filters/max_age/max_age_filter.cc +2 -1
  57. data/src/core/ext/filters/message_size/message_size_filter.cc +2 -1
  58. data/src/core/ext/filters/message_size/message_size_filter.h +2 -1
  59. data/src/core/ext/transport/chttp2/client/chttp2_connector.cc +87 -31
  60. data/src/core/ext/transport/chttp2/client/chttp2_connector.h +18 -1
  61. data/src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc +10 -35
  62. data/src/core/ext/transport/chttp2/server/chttp2_server.cc +19 -25
  63. data/src/core/ext/transport/chttp2/server/chttp2_server.h +2 -1
  64. data/src/core/ext/transport/chttp2/server/insecure/server_chttp2.cc +2 -2
  65. data/src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.cc +6 -6
  66. data/src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.cc +3 -2
  67. data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +256 -287
  68. data/src/core/ext/transport/chttp2/transport/flow_control.cc +11 -3
  69. data/src/core/ext/transport/chttp2/transport/flow_control.h +10 -0
  70. data/src/core/ext/transport/chttp2/transport/frame_settings.cc +2 -2
  71. data/src/core/ext/transport/chttp2/transport/internal.h +10 -1
  72. data/src/core/ext/transport/chttp2/transport/parsing.cc +17 -30
  73. data/src/core/ext/transport/chttp2/transport/writing.cc +6 -5
  74. data/src/core/ext/transport/inproc/inproc_transport.cc +12 -12
  75. data/src/core/ext/upb-generated/envoy/config/accesslog/v3/accesslog.upb.c +244 -0
  76. data/src/core/ext/upb-generated/envoy/config/accesslog/v3/accesslog.upb.h +766 -0
  77. data/src/core/ext/upb-generated/envoy/config/cluster/v3/circuit_breaker.upb.c +74 -0
  78. data/src/core/ext/upb-generated/envoy/config/cluster/v3/circuit_breaker.upb.h +226 -0
  79. data/src/core/ext/upb-generated/envoy/config/cluster/v3/cluster.upb.c +458 -0
  80. data/src/core/ext/upb-generated/envoy/config/cluster/v3/cluster.upb.h +1635 -0
  81. data/src/core/ext/upb-generated/envoy/{api/v2/cluster → config/cluster/v3}/filter.upb.c +8 -8
  82. data/src/core/ext/upb-generated/envoy/config/cluster/v3/filter.upb.h +69 -0
  83. data/src/core/ext/upb-generated/envoy/{api/v2/cluster → config/cluster/v3}/outlier_detection.upb.c +8 -8
  84. data/src/core/ext/upb-generated/envoy/config/cluster/v3/outlier_detection.upb.h +323 -0
  85. data/src/core/ext/upb-generated/envoy/config/core/v3/address.upb.c +124 -0
  86. data/src/core/ext/upb-generated/envoy/config/core/v3/address.upb.h +379 -0
  87. data/src/core/ext/upb-generated/envoy/{api/v2/core → config/core/v3}/backoff.upb.c +8 -8
  88. data/src/core/ext/upb-generated/envoy/config/core/v3/backoff.upb.h +79 -0
  89. data/src/core/ext/upb-generated/envoy/config/core/v3/base.upb.c +310 -0
  90. data/src/core/ext/upb-generated/envoy/config/core/v3/base.upb.h +869 -0
  91. data/src/core/ext/upb-generated/envoy/config/core/v3/config_source.upb.c +103 -0
  92. data/src/core/ext/upb-generated/envoy/config/core/v3/config_source.upb.h +351 -0
  93. data/src/core/ext/upb-generated/envoy/config/core/v3/event_service_config.upb.c +34 -0
  94. data/src/core/ext/upb-generated/envoy/config/core/v3/event_service_config.upb.h +71 -0
  95. data/src/core/ext/upb-generated/envoy/config/core/v3/extension.upb.c +53 -0
  96. data/src/core/ext/upb-generated/envoy/config/core/v3/extension.upb.h +133 -0
  97. data/src/core/ext/upb-generated/envoy/config/core/v3/grpc_service.upb.c +241 -0
  98. data/src/core/ext/upb-generated/envoy/config/core/v3/grpc_service.upb.h +752 -0
  99. data/src/core/ext/upb-generated/envoy/config/core/v3/health_check.upb.c +170 -0
  100. data/src/core/ext/upb-generated/envoy/config/core/v3/health_check.upb.h +684 -0
  101. data/src/core/ext/upb-generated/envoy/{api/v2/core → config/core/v3}/http_uri.upb.c +8 -8
  102. data/src/core/ext/upb-generated/envoy/config/core/v3/http_uri.upb.h +80 -0
  103. data/src/core/ext/upb-generated/envoy/config/core/v3/protocol.upb.c +176 -0
  104. data/src/core/ext/upb-generated/envoy/config/core/v3/protocol.upb.h +645 -0
  105. data/src/core/ext/upb-generated/envoy/config/core/v3/proxy_protocol.upb.c +28 -0
  106. data/src/core/ext/upb-generated/envoy/config/core/v3/proxy_protocol.upb.h +58 -0
  107. data/src/core/ext/upb-generated/envoy/{api/v2/core → config/core/v3}/socket_option.upb.c +6 -6
  108. data/src/core/ext/upb-generated/envoy/config/core/v3/socket_option.upb.h +88 -0
  109. data/src/core/ext/upb-generated/envoy/config/core/v3/substitution_format_string.upb.c +36 -0
  110. data/src/core/ext/upb-generated/envoy/config/core/v3/substitution_format_string.upb.h +85 -0
  111. data/src/core/ext/upb-generated/envoy/config/endpoint/v3/endpoint.upb.c +91 -0
  112. data/src/core/ext/upb-generated/envoy/config/endpoint/v3/endpoint.upb.h +220 -0
  113. data/src/core/ext/upb-generated/envoy/config/endpoint/v3/endpoint_components.upb.c +91 -0
  114. data/src/core/ext/upb-generated/envoy/config/endpoint/v3/endpoint_components.upb.h +273 -0
  115. data/src/core/ext/upb-generated/envoy/config/endpoint/v3/load_report.upb.c +112 -0
  116. data/src/core/ext/upb-generated/envoy/config/endpoint/v3/load_report.upb.h +332 -0
  117. data/src/core/ext/upb-generated/envoy/config/listener/{v2 → v3}/api_listener.upb.c +8 -8
  118. data/src/core/ext/upb-generated/envoy/config/listener/v3/api_listener.upb.h +65 -0
  119. data/src/core/ext/upb-generated/envoy/config/listener/v3/listener.upb.c +128 -0
  120. data/src/core/ext/upb-generated/envoy/config/listener/v3/listener.upb.h +467 -0
  121. data/src/core/ext/upb-generated/envoy/config/listener/v3/listener_components.upb.c +155 -0
  122. data/src/core/ext/upb-generated/envoy/config/listener/v3/listener_components.upb.h +539 -0
  123. data/src/core/ext/upb-generated/envoy/config/listener/v3/udp_listener_config.upb.c +41 -0
  124. data/src/core/ext/upb-generated/envoy/config/listener/v3/udp_listener_config.upb.h +94 -0
  125. data/src/core/ext/upb-generated/envoy/config/rbac/v3/rbac.upb.c +178 -0
  126. data/src/core/ext/upb-generated/envoy/config/rbac/v3/rbac.upb.h +616 -0
  127. data/src/core/ext/upb-generated/envoy/config/route/v3/route.upb.c +63 -0
  128. data/src/core/ext/upb-generated/envoy/config/route/v3/route.upb.h +204 -0
  129. data/src/core/ext/upb-generated/envoy/config/route/v3/route_components.upb.c +900 -0
  130. data/src/core/ext/upb-generated/envoy/config/route/v3/route_components.upb.h +3290 -0
  131. data/src/core/ext/upb-generated/envoy/config/route/v3/scoped_route.upb.c +60 -0
  132. data/src/core/ext/upb-generated/envoy/config/route/v3/scoped_route.upb.h +139 -0
  133. data/src/core/ext/upb-generated/envoy/config/trace/v3/http_tracer.upb.c +50 -0
  134. data/src/core/ext/upb-generated/envoy/config/trace/v3/http_tracer.upb.h +108 -0
  135. data/src/core/ext/upb-generated/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upb.c +364 -0
  136. data/src/core/ext/upb-generated/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upb.h +1336 -0
  137. data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/cert.upb.c +20 -0
  138. data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/cert.upb.h +34 -0
  139. data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/common.upb.c +110 -0
  140. data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/common.upb.h +387 -0
  141. data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/secret.upb.c +76 -0
  142. data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/secret.upb.h +214 -0
  143. data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/tls.upb.c +147 -0
  144. data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/tls.upb.h +570 -0
  145. data/src/core/ext/upb-generated/envoy/{api/v2 → service/cluster/v3}/cds.upb.c +5 -6
  146. data/src/core/ext/upb-generated/envoy/service/cluster/v3/cds.upb.h +49 -0
  147. data/src/core/ext/upb-generated/envoy/service/discovery/{v2 → v3}/ads.upb.c +5 -4
  148. data/src/core/ext/upb-generated/envoy/service/discovery/v3/ads.upb.h +49 -0
  149. data/src/core/ext/upb-generated/envoy/service/discovery/v3/discovery.upb.c +139 -0
  150. data/src/core/ext/upb-generated/envoy/service/discovery/v3/discovery.upb.h +449 -0
  151. data/src/core/ext/upb-generated/envoy/{api/v2 → service/endpoint/v3}/eds.upb.c +5 -6
  152. data/src/core/ext/upb-generated/envoy/service/endpoint/v3/eds.upb.h +49 -0
  153. data/src/core/ext/upb-generated/envoy/{api/v2 → service/listener/v3}/lds.upb.c +5 -6
  154. data/src/core/ext/upb-generated/envoy/service/listener/v3/lds.upb.h +49 -0
  155. data/src/core/ext/upb-generated/envoy/service/load_stats/v3/lrs.upb.c +55 -0
  156. data/src/core/ext/upb-generated/envoy/service/load_stats/v3/lrs.upb.h +136 -0
  157. data/src/core/ext/upb-generated/envoy/{api/v2 → service/route/v3}/rds.upb.c +5 -6
  158. data/src/core/ext/upb-generated/envoy/service/route/v3/rds.upb.h +49 -0
  159. data/src/core/ext/upb-generated/envoy/{api/v2 → service/route/v3}/srds.upb.c +5 -6
  160. data/src/core/ext/upb-generated/envoy/service/route/v3/srds.upb.h +49 -0
  161. data/src/core/ext/upb-generated/envoy/type/matcher/v3/metadata.upb.c +47 -0
  162. data/src/core/ext/upb-generated/envoy/type/matcher/v3/metadata.upb.h +114 -0
  163. data/src/core/ext/upb-generated/envoy/type/matcher/v3/number.upb.c +35 -0
  164. data/src/core/ext/upb-generated/envoy/type/matcher/v3/number.upb.h +77 -0
  165. data/src/core/ext/upb-generated/envoy/type/matcher/v3/path.upb.c +34 -0
  166. data/src/core/ext/upb-generated/envoy/type/matcher/v3/path.upb.h +71 -0
  167. data/src/core/ext/upb-generated/envoy/type/matcher/v3/regex.upb.c +64 -0
  168. data/src/core/ext/upb-generated/envoy/type/matcher/v3/regex.upb.h +145 -0
  169. data/src/core/ext/upb-generated/envoy/type/matcher/v3/string.upb.c +54 -0
  170. data/src/core/ext/upb-generated/envoy/type/matcher/v3/string.upb.h +133 -0
  171. data/src/core/ext/upb-generated/envoy/type/matcher/v3/value.upb.c +63 -0
  172. data/src/core/ext/upb-generated/envoy/type/matcher/v3/value.upb.h +188 -0
  173. data/src/core/ext/upb-generated/envoy/type/metadata/v3/metadata.upb.c +88 -0
  174. data/src/core/ext/upb-generated/envoy/type/metadata/v3/metadata.upb.h +258 -0
  175. data/src/core/ext/upb-generated/envoy/type/tracing/v3/custom_tag.upb.c +90 -0
  176. data/src/core/ext/upb-generated/envoy/type/tracing/v3/custom_tag.upb.h +250 -0
  177. data/src/core/ext/upb-generated/envoy/type/{http.upb.c → v3/http.upb.c} +2 -2
  178. data/src/core/ext/upb-generated/envoy/type/{http.upb.h → v3/http.upb.h} +8 -8
  179. data/src/core/ext/upb-generated/envoy/type/{percent.upb.c → v3/percent.upb.c} +9 -8
  180. data/src/core/ext/upb-generated/envoy/type/v3/percent.upb.h +86 -0
  181. data/src/core/ext/upb-generated/envoy/type/{range.upb.c → v3/range.upb.c} +12 -11
  182. data/src/core/ext/upb-generated/envoy/type/v3/range.upb.h +111 -0
  183. data/src/core/ext/upb-generated/envoy/type/{semantic_version.upb.c → v3/semantic_version.upb.c} +6 -5
  184. data/src/core/ext/upb-generated/envoy/type/v3/semantic_version.upb.h +61 -0
  185. data/src/core/ext/upb-generated/google/api/expr/v1alpha1/checked.upb.c +242 -0
  186. data/src/core/ext/upb-generated/google/api/expr/v1alpha1/checked.upb.h +753 -0
  187. data/src/core/ext/upb-generated/google/api/expr/v1alpha1/syntax.upb.c +234 -0
  188. data/src/core/ext/upb-generated/google/api/expr/v1alpha1/syntax.upb.h +759 -0
  189. data/src/core/ext/upb-generated/google/protobuf/descriptor.upb.c +36 -36
  190. data/src/core/ext/upb-generated/google/protobuf/struct.upb.h +1 -1
  191. data/src/core/ext/upb-generated/udpa/annotations/security.upb.c +31 -0
  192. data/src/core/ext/upb-generated/udpa/annotations/security.upb.h +57 -0
  193. data/src/core/ext/upb-generated/udpa/annotations/versioning.upb.c +27 -0
  194. data/src/core/ext/upb-generated/udpa/annotations/versioning.upb.h +53 -0
  195. data/src/core/ext/upb-generated/udpa/core/v1/authority.upb.c +28 -0
  196. data/src/core/ext/upb-generated/udpa/core/v1/authority.upb.h +53 -0
  197. data/src/core/ext/upb-generated/udpa/core/v1/collection_entry.upb.c +52 -0
  198. data/src/core/ext/upb-generated/udpa/core/v1/collection_entry.upb.h +129 -0
  199. data/src/core/ext/upb-generated/udpa/core/v1/context_params.upb.c +42 -0
  200. data/src/core/ext/upb-generated/udpa/core/v1/context_params.upb.h +77 -0
  201. data/src/core/ext/upb-generated/udpa/core/v1/resource.upb.c +36 -0
  202. data/src/core/ext/upb-generated/udpa/core/v1/resource.upb.h +85 -0
  203. data/src/core/ext/upb-generated/udpa/core/v1/resource_locator.upb.c +54 -0
  204. data/src/core/ext/upb-generated/udpa/core/v1/resource_locator.upb.h +160 -0
  205. data/src/core/ext/upb-generated/udpa/core/v1/resource_name.upb.c +36 -0
  206. data/src/core/ext/upb-generated/udpa/core/v1/resource_name.upb.h +84 -0
  207. data/src/core/ext/upb-generated/validate/validate.upb.c +11 -11
  208. data/src/core/ext/upb-generated/validate/validate.upb.h +1 -1
  209. data/src/core/ext/xds/certificate_provider_factory.h +59 -0
  210. data/src/core/ext/xds/certificate_provider_registry.cc +103 -0
  211. data/src/core/ext/xds/certificate_provider_registry.h +57 -0
  212. data/src/core/ext/xds/certificate_provider_store.h +50 -0
  213. data/src/core/ext/xds/google_mesh_ca_certificate_provider_factory.cc +377 -0
  214. data/src/core/ext/xds/google_mesh_ca_certificate_provider_factory.h +102 -0
  215. data/src/core/ext/xds/xds_api.cc +2596 -0
  216. data/src/core/ext/xds/xds_api.h +397 -0
  217. data/src/core/ext/{filters/client_channel/xds → xds}/xds_bootstrap.cc +44 -2
  218. data/src/core/ext/{filters/client_channel/xds → xds}/xds_bootstrap.h +8 -3
  219. data/src/core/ext/{filters/client_channel/xds → xds}/xds_channel_args.h +9 -6
  220. data/src/core/ext/{filters/client_channel/xds → xds}/xds_client.cc +541 -785
  221. data/src/core/ext/{filters/client_channel/xds → xds}/xds_client.h +114 -93
  222. data/src/core/ext/{filters/client_channel/xds → xds}/xds_client_stats.cc +20 -14
  223. data/src/core/ext/{filters/client_channel/xds → xds}/xds_client_stats.h +36 -8
  224. data/src/core/lib/channel/channel_args.h +0 -1
  225. data/src/core/lib/channel/channelz.cc +24 -60
  226. data/src/core/lib/channel/channelz.h +12 -20
  227. data/src/core/lib/channel/channelz_registry.cc +15 -12
  228. data/src/core/lib/channel/channelz_registry.h +3 -0
  229. data/src/core/lib/gpr/sync_posix.cc +2 -8
  230. data/src/core/lib/gpr/time_precise.cc +2 -0
  231. data/src/core/lib/gpr/time_precise.h +6 -2
  232. data/src/core/lib/gprpp/dual_ref_counted.h +336 -0
  233. data/src/core/lib/gprpp/ref_counted.h +51 -22
  234. data/src/core/lib/gprpp/ref_counted_ptr.h +153 -0
  235. data/src/core/lib/iomgr/endpoint.cc +5 -1
  236. data/src/core/lib/iomgr/endpoint.h +7 -3
  237. data/src/core/lib/iomgr/endpoint_cfstream.cc +36 -11
  238. data/src/core/lib/iomgr/ev_posix.cc +0 -2
  239. data/src/core/lib/iomgr/exec_ctx.h +10 -8
  240. data/src/core/lib/iomgr/iomgr.cc +0 -10
  241. data/src/core/lib/iomgr/iomgr.h +0 -10
  242. data/src/core/{ext/filters/client_channel → lib/iomgr}/parse_address.cc +1 -1
  243. data/src/core/{ext/filters/client_channel → lib/iomgr}/parse_address.h +3 -3
  244. data/src/core/lib/iomgr/sockaddr_utils.cc +2 -1
  245. data/src/core/lib/iomgr/sockaddr_utils.h +2 -1
  246. data/src/core/lib/iomgr/tcp_custom.cc +32 -16
  247. data/src/core/lib/iomgr/tcp_posix.cc +31 -13
  248. data/src/core/lib/iomgr/tcp_windows.cc +26 -10
  249. data/src/core/lib/json/json_util.cc +58 -0
  250. data/src/core/lib/json/json_util.h +37 -0
  251. data/src/core/lib/security/authorization/authorization_engine.cc +177 -0
  252. data/src/core/lib/security/authorization/authorization_engine.h +84 -0
  253. data/src/core/lib/security/authorization/evaluate_args.cc +153 -0
  254. data/src/core/lib/security/authorization/evaluate_args.h +59 -0
  255. data/src/core/lib/security/authorization/mock_cel/activation.h +57 -0
  256. data/src/core/lib/security/authorization/mock_cel/cel_expr_builder_factory.h +42 -0
  257. data/src/core/lib/security/authorization/mock_cel/cel_expression.h +68 -0
  258. data/src/core/lib/security/authorization/mock_cel/cel_value.h +93 -0
  259. data/src/core/lib/security/authorization/mock_cel/evaluator_core.h +67 -0
  260. data/src/core/lib/security/authorization/mock_cel/flat_expr_builder.h +56 -0
  261. data/src/core/lib/security/authorization/mock_cel/statusor.h +50 -0
  262. data/src/core/lib/security/certificate_provider.h +60 -0
  263. data/src/core/lib/security/credentials/google_default/google_default_credentials.cc +56 -38
  264. data/src/core/lib/security/credentials/tls/grpc_tls_certificate_distributor.cc +321 -0
  265. data/src/core/lib/security/credentials/tls/grpc_tls_certificate_distributor.h +214 -0
  266. data/src/core/lib/security/credentials/xds/xds_credentials.cc +45 -0
  267. data/src/core/lib/security/credentials/xds/xds_credentials.h +51 -0
  268. data/src/core/lib/security/security_connector/fake/fake_security_connector.cc +7 -12
  269. data/src/core/lib/security/security_connector/ssl_utils.h +5 -0
  270. data/src/core/lib/security/transport/secure_endpoint.cc +7 -1
  271. data/src/core/lib/surface/call.cc +12 -12
  272. data/src/core/lib/surface/call.h +2 -1
  273. data/src/core/lib/surface/channel.cc +37 -51
  274. data/src/core/lib/surface/channel.h +18 -3
  275. data/src/core/lib/surface/completion_queue.cc +10 -272
  276. data/src/core/lib/surface/completion_queue.h +0 -8
  277. data/src/core/lib/surface/init.cc +27 -12
  278. data/src/core/lib/surface/server.cc +1066 -1244
  279. data/src/core/lib/surface/server.h +363 -87
  280. data/src/core/lib/surface/version.cc +2 -2
  281. data/src/core/lib/transport/authority_override.cc +38 -0
  282. data/src/core/lib/transport/authority_override.h +32 -0
  283. data/src/core/lib/transport/bdp_estimator.h +2 -1
  284. data/src/core/lib/transport/connectivity_state.cc +18 -13
  285. data/src/core/lib/transport/connectivity_state.h +20 -8
  286. data/src/core/lib/transport/error_utils.cc +13 -0
  287. data/src/core/lib/transport/error_utils.h +6 -0
  288. data/src/core/lib/transport/metadata.cc +11 -1
  289. data/src/core/lib/transport/static_metadata.cc +295 -276
  290. data/src/core/lib/transport/static_metadata.h +80 -73
  291. data/src/core/lib/transport/transport.h +7 -0
  292. data/src/core/lib/uri/uri_parser.cc +23 -21
  293. data/src/core/lib/uri/uri_parser.h +3 -1
  294. data/src/core/plugin_registry/grpc_plugin_registry.cc +35 -20
  295. data/src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc +22 -0
  296. data/src/core/tsi/ssl_transport_security.cc +2 -2
  297. data/src/ruby/bin/math_services_pb.rb +4 -4
  298. data/src/ruby/ext/grpc/rb_channel_credentials.c +9 -0
  299. data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +4 -4
  300. data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +7 -7
  301. data/src/ruby/lib/grpc/generic/client_stub.rb +1 -1
  302. data/src/ruby/lib/grpc/version.rb +1 -1
  303. data/src/ruby/pb/grpc/health/v1/health_services_pb.rb +2 -2
  304. data/src/ruby/pb/src/proto/grpc/testing/messages_pb.rb +5 -0
  305. data/src/ruby/pb/src/proto/grpc/testing/test_services_pb.rb +28 -12
  306. data/src/ruby/spec/channel_credentials_spec.rb +10 -0
  307. data/src/ruby/spec/generic/active_call_spec.rb +19 -8
  308. data/src/ruby/spec/pb/codegen/grpc/testing/same_package_service_name.proto +27 -0
  309. data/src/ruby/spec/pb/codegen/grpc/testing/same_ruby_package_service_name.proto +29 -0
  310. data/src/ruby/spec/pb/codegen/package_option_spec.rb +20 -0
  311. data/src/ruby/spec/user_agent_spec.rb +74 -0
  312. data/third_party/abseil-cpp/absl/algorithm/container.h +1727 -0
  313. data/third_party/abseil-cpp/absl/base/internal/direct_mmap.h +161 -0
  314. data/third_party/abseil-cpp/absl/base/internal/exponential_biased.cc +93 -0
  315. data/third_party/abseil-cpp/absl/base/internal/exponential_biased.h +130 -0
  316. data/third_party/abseil-cpp/absl/base/internal/low_level_alloc.cc +620 -0
  317. data/third_party/abseil-cpp/absl/base/internal/low_level_alloc.h +126 -0
  318. data/third_party/abseil-cpp/absl/container/fixed_array.h +515 -0
  319. data/third_party/abseil-cpp/absl/container/flat_hash_set.h +503 -0
  320. data/third_party/abseil-cpp/absl/container/internal/common.h +202 -0
  321. data/third_party/abseil-cpp/absl/container/internal/container_memory.h +440 -0
  322. data/third_party/abseil-cpp/absl/container/internal/hash_function_defaults.h +146 -0
  323. data/third_party/abseil-cpp/absl/container/internal/hash_policy_traits.h +191 -0
  324. data/third_party/abseil-cpp/absl/container/internal/hashtable_debug_hooks.h +85 -0
  325. data/third_party/abseil-cpp/absl/container/internal/hashtablez_sampler.cc +269 -0
  326. data/third_party/abseil-cpp/absl/container/internal/hashtablez_sampler.h +297 -0
  327. data/third_party/abseil-cpp/absl/container/internal/hashtablez_sampler_force_weak_definition.cc +30 -0
  328. data/third_party/abseil-cpp/absl/container/internal/have_sse.h +49 -0
  329. data/third_party/abseil-cpp/absl/container/internal/layout.h +741 -0
  330. data/third_party/abseil-cpp/absl/container/internal/raw_hash_set.cc +48 -0
  331. data/third_party/abseil-cpp/absl/container/internal/raw_hash_set.h +1882 -0
  332. data/third_party/abseil-cpp/absl/debugging/internal/address_is_readable.cc +138 -0
  333. data/third_party/abseil-cpp/absl/debugging/internal/address_is_readable.h +32 -0
  334. data/third_party/abseil-cpp/absl/debugging/internal/demangle.cc +1895 -0
  335. data/third_party/abseil-cpp/absl/debugging/internal/demangle.h +71 -0
  336. data/third_party/abseil-cpp/absl/debugging/internal/elf_mem_image.cc +382 -0
  337. data/third_party/abseil-cpp/absl/debugging/internal/elf_mem_image.h +134 -0
  338. data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_aarch64-inl.inc +192 -0
  339. data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_arm-inl.inc +125 -0
  340. data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_config.h +70 -0
  341. data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_generic-inl.inc +99 -0
  342. data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_powerpc-inl.inc +248 -0
  343. data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_unimplemented-inl.inc +24 -0
  344. data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_win32-inl.inc +85 -0
  345. data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_x86-inl.inc +346 -0
  346. data/third_party/abseil-cpp/absl/debugging/internal/symbolize.h +128 -0
  347. data/third_party/abseil-cpp/absl/debugging/internal/vdso_support.cc +194 -0
  348. data/third_party/abseil-cpp/absl/debugging/internal/vdso_support.h +158 -0
  349. data/third_party/abseil-cpp/absl/debugging/stacktrace.cc +140 -0
  350. data/third_party/abseil-cpp/absl/debugging/stacktrace.h +231 -0
  351. data/third_party/abseil-cpp/absl/debugging/symbolize.cc +25 -0
  352. data/third_party/abseil-cpp/absl/debugging/symbolize.h +99 -0
  353. data/third_party/abseil-cpp/absl/debugging/symbolize_elf.inc +1480 -0
  354. data/third_party/abseil-cpp/absl/debugging/symbolize_unimplemented.inc +40 -0
  355. data/third_party/abseil-cpp/absl/debugging/symbolize_win32.inc +81 -0
  356. data/third_party/abseil-cpp/absl/functional/function_ref.h +139 -0
  357. data/third_party/abseil-cpp/absl/functional/internal/function_ref.h +106 -0
  358. data/third_party/abseil-cpp/absl/hash/hash.h +324 -0
  359. data/third_party/abseil-cpp/absl/hash/internal/city.cc +346 -0
  360. data/third_party/abseil-cpp/absl/hash/internal/city.h +96 -0
  361. data/third_party/abseil-cpp/absl/hash/internal/hash.cc +55 -0
  362. data/third_party/abseil-cpp/absl/hash/internal/hash.h +988 -0
  363. data/third_party/abseil-cpp/absl/status/status.cc +447 -0
  364. data/third_party/abseil-cpp/absl/status/status.h +428 -0
  365. data/third_party/abseil-cpp/absl/status/status_payload_printer.cc +43 -0
  366. data/third_party/abseil-cpp/absl/status/status_payload_printer.h +51 -0
  367. data/third_party/abseil-cpp/absl/strings/cord.cc +2019 -0
  368. data/third_party/abseil-cpp/absl/strings/cord.h +1121 -0
  369. data/third_party/abseil-cpp/absl/strings/internal/cord_internal.h +151 -0
  370. data/third_party/abseil-cpp/absl/synchronization/barrier.cc +52 -0
  371. data/third_party/abseil-cpp/absl/synchronization/barrier.h +79 -0
  372. data/third_party/abseil-cpp/absl/synchronization/blocking_counter.cc +57 -0
  373. data/third_party/abseil-cpp/absl/synchronization/blocking_counter.h +99 -0
  374. data/third_party/abseil-cpp/absl/synchronization/internal/create_thread_identity.cc +140 -0
  375. data/third_party/abseil-cpp/absl/synchronization/internal/create_thread_identity.h +60 -0
  376. data/third_party/abseil-cpp/absl/synchronization/internal/graphcycles.cc +697 -0
  377. data/third_party/abseil-cpp/absl/synchronization/internal/graphcycles.h +141 -0
  378. data/third_party/abseil-cpp/absl/synchronization/internal/kernel_timeout.h +155 -0
  379. data/third_party/abseil-cpp/absl/synchronization/internal/mutex_nonprod.inc +261 -0
  380. data/third_party/abseil-cpp/absl/synchronization/internal/per_thread_sem.cc +106 -0
  381. data/third_party/abseil-cpp/absl/synchronization/internal/per_thread_sem.h +115 -0
  382. data/third_party/abseil-cpp/absl/synchronization/internal/waiter.cc +484 -0
  383. data/third_party/abseil-cpp/absl/synchronization/internal/waiter.h +159 -0
  384. data/third_party/abseil-cpp/absl/synchronization/mutex.cc +2728 -0
  385. data/third_party/abseil-cpp/absl/synchronization/mutex.h +1056 -0
  386. data/third_party/abseil-cpp/absl/synchronization/notification.cc +78 -0
  387. data/third_party/abseil-cpp/absl/synchronization/notification.h +123 -0
  388. data/third_party/abseil-cpp/absl/types/bad_variant_access.cc +64 -0
  389. data/third_party/abseil-cpp/absl/types/bad_variant_access.h +82 -0
  390. data/third_party/abseil-cpp/absl/types/internal/variant.h +1646 -0
  391. data/third_party/abseil-cpp/absl/types/variant.h +861 -0
  392. data/third_party/boringssl-with-bazel/err_data.c +475 -467
  393. data/third_party/boringssl-with-bazel/src/crypto/asn1/asn1_lib.c +0 -6
  394. data/third_party/boringssl-with-bazel/src/crypto/dsa/dsa.c +9 -43
  395. data/third_party/boringssl-with-bazel/src/crypto/dsa/dsa_asn1.c +55 -4
  396. data/third_party/boringssl-with-bazel/src/crypto/dsa/internal.h +34 -0
  397. data/third_party/boringssl-with-bazel/src/crypto/evp/evp.c +4 -0
  398. data/third_party/boringssl-with-bazel/src/crypto/evp/evp_asn1.c +16 -0
  399. data/third_party/boringssl-with-bazel/src/crypto/evp/p_dsa_asn1.c +6 -2
  400. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/digest/digest.c +2 -0
  401. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/internal.h +4 -0
  402. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/rsa.c +30 -10
  403. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/rsa_impl.c +10 -15
  404. data/third_party/boringssl-with-bazel/src/crypto/hpke/hpke.c +543 -0
  405. data/third_party/boringssl-with-bazel/src/crypto/hpke/internal.h +237 -0
  406. data/third_party/boringssl-with-bazel/src/crypto/trust_token/internal.h +44 -2
  407. data/third_party/boringssl-with-bazel/src/crypto/trust_token/pmbtoken.c +221 -49
  408. data/third_party/boringssl-with-bazel/src/crypto/trust_token/trust_token.c +64 -20
  409. data/third_party/boringssl-with-bazel/src/crypto/x509/a_strex.c +3 -3
  410. data/third_party/boringssl-with-bazel/src/crypto/x509/algorithm.c +0 -8
  411. data/third_party/boringssl-with-bazel/src/crypto/x509/t_crl.c +3 -3
  412. data/third_party/boringssl-with-bazel/src/crypto/x509/t_x509.c +1 -1
  413. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_cmp.c +7 -2
  414. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_ext.c +21 -18
  415. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_obj.c +1 -1
  416. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_set.c +24 -3
  417. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_trs.c +3 -3
  418. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_txt.c +67 -67
  419. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_v3.c +3 -3
  420. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_vfy.c +29 -35
  421. data/third_party/boringssl-with-bazel/src/crypto/x509/x509cset.c +13 -2
  422. data/third_party/boringssl-with-bazel/src/crypto/x509/x509name.c +9 -8
  423. data/third_party/boringssl-with-bazel/src/crypto/x509/x_all.c +10 -10
  424. data/third_party/boringssl-with-bazel/src/crypto/x509/x_crl.c +2 -2
  425. data/third_party/boringssl-with-bazel/src/crypto/x509/x_name.c +28 -40
  426. data/third_party/boringssl-with-bazel/src/crypto/x509/x_sig.c +20 -0
  427. data/third_party/boringssl-with-bazel/src/crypto/x509/x_x509.c +3 -1
  428. data/third_party/boringssl-with-bazel/src/crypto/x509v3/ext_dat.h +1 -4
  429. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_conf.c +7 -3
  430. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_genn.c +2 -2
  431. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_info.c +1 -1
  432. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_purp.c +55 -8
  433. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_skey.c +1 -1
  434. data/third_party/boringssl-with-bazel/src/include/openssl/arm_arch.h +52 -0
  435. data/third_party/boringssl-with-bazel/src/include/openssl/asn1.h +0 -1
  436. data/third_party/boringssl-with-bazel/src/include/openssl/base.h +2 -2
  437. data/third_party/boringssl-with-bazel/src/include/openssl/cipher.h +6 -0
  438. data/third_party/boringssl-with-bazel/src/include/openssl/crypto.h +1 -1
  439. data/third_party/boringssl-with-bazel/src/include/openssl/dh.h +12 -0
  440. data/third_party/boringssl-with-bazel/src/include/openssl/digest.h +9 -0
  441. data/third_party/boringssl-with-bazel/src/include/openssl/evp.h +4 -1
  442. data/third_party/boringssl-with-bazel/src/include/openssl/ssl.h +48 -9
  443. data/third_party/boringssl-with-bazel/src/include/openssl/tls1.h +2 -3
  444. data/third_party/boringssl-with-bazel/src/include/openssl/trust_token.h +26 -6
  445. data/third_party/boringssl-with-bazel/src/include/openssl/x509.h +199 -78
  446. data/third_party/boringssl-with-bazel/src/include/openssl/x509v3.h +52 -43
  447. data/third_party/boringssl-with-bazel/src/ssl/handshake.cc +18 -18
  448. data/third_party/boringssl-with-bazel/src/ssl/handshake_client.cc +2 -3
  449. data/third_party/boringssl-with-bazel/src/ssl/handshake_server.cc +1 -1
  450. data/third_party/boringssl-with-bazel/src/ssl/internal.h +13 -9
  451. data/third_party/boringssl-with-bazel/src/ssl/ssl_cert.cc +3 -6
  452. data/third_party/boringssl-with-bazel/src/ssl/ssl_cipher.cc +8 -9
  453. data/third_party/boringssl-with-bazel/src/ssl/ssl_lib.cc +10 -0
  454. data/third_party/boringssl-with-bazel/src/ssl/t1_lib.cc +34 -9
  455. data/third_party/boringssl-with-bazel/src/ssl/tls13_both.cc +1 -2
  456. data/third_party/boringssl-with-bazel/src/ssl/tls13_client.cc +4 -8
  457. data/third_party/boringssl-with-bazel/src/ssl/tls13_server.cc +7 -2
  458. data/third_party/boringssl-with-bazel/src/ssl/tls_record.cc +5 -3
  459. data/third_party/re2/re2/bitmap256.h +117 -0
  460. data/third_party/re2/re2/bitstate.cc +385 -0
  461. data/third_party/re2/re2/compile.cc +1279 -0
  462. data/third_party/re2/re2/dfa.cc +2130 -0
  463. data/third_party/re2/re2/filtered_re2.cc +121 -0
  464. data/third_party/re2/re2/filtered_re2.h +109 -0
  465. data/third_party/re2/re2/mimics_pcre.cc +197 -0
  466. data/third_party/re2/re2/nfa.cc +713 -0
  467. data/third_party/re2/re2/onepass.cc +623 -0
  468. data/third_party/re2/re2/parse.cc +2464 -0
  469. data/third_party/re2/re2/perl_groups.cc +119 -0
  470. data/third_party/re2/re2/pod_array.h +55 -0
  471. data/third_party/re2/re2/prefilter.cc +710 -0
  472. data/third_party/re2/re2/prefilter.h +108 -0
  473. data/third_party/re2/re2/prefilter_tree.cc +407 -0
  474. data/third_party/re2/re2/prefilter_tree.h +139 -0
  475. data/third_party/re2/re2/prog.cc +988 -0
  476. data/third_party/re2/re2/prog.h +436 -0
  477. data/third_party/re2/re2/re2.cc +1362 -0
  478. data/third_party/re2/re2/re2.h +1002 -0
  479. data/third_party/re2/re2/regexp.cc +980 -0
  480. data/third_party/re2/re2/regexp.h +659 -0
  481. data/third_party/re2/re2/set.cc +154 -0
  482. data/third_party/re2/re2/set.h +80 -0
  483. data/third_party/re2/re2/simplify.cc +657 -0
  484. data/third_party/re2/re2/sparse_array.h +392 -0
  485. data/third_party/re2/re2/sparse_set.h +264 -0
  486. data/third_party/re2/re2/stringpiece.cc +65 -0
  487. data/third_party/re2/re2/stringpiece.h +210 -0
  488. data/third_party/re2/re2/tostring.cc +351 -0
  489. data/third_party/re2/re2/unicode_casefold.cc +582 -0
  490. data/third_party/re2/re2/unicode_casefold.h +78 -0
  491. data/third_party/re2/re2/unicode_groups.cc +6269 -0
  492. data/third_party/re2/re2/unicode_groups.h +67 -0
  493. data/third_party/re2/re2/walker-inl.h +246 -0
  494. data/third_party/re2/util/benchmark.h +156 -0
  495. data/third_party/re2/util/flags.h +26 -0
  496. data/third_party/re2/util/logging.h +109 -0
  497. data/third_party/re2/util/malloc_counter.h +19 -0
  498. data/third_party/re2/util/mix.h +41 -0
  499. data/third_party/re2/util/mutex.h +148 -0
  500. data/third_party/re2/util/pcre.cc +1025 -0
  501. data/third_party/re2/util/pcre.h +681 -0
  502. data/third_party/re2/util/rune.cc +260 -0
  503. data/third_party/re2/util/strutil.cc +149 -0
  504. data/third_party/re2/util/strutil.h +21 -0
  505. data/third_party/re2/util/test.h +50 -0
  506. data/third_party/re2/util/utf.h +44 -0
  507. data/third_party/re2/util/util.h +42 -0
  508. data/third_party/upb/upb/decode.c +64 -15
  509. data/third_party/upb/upb/encode.c +2 -2
  510. data/third_party/upb/upb/msg.h +2 -2
  511. data/third_party/upb/upb/port_def.inc +1 -1
  512. data/third_party/upb/upb/table.c +0 -11
  513. data/third_party/upb/upb/table.int.h +0 -9
  514. data/third_party/upb/upb/upb.c +16 -14
  515. data/third_party/upb/upb/upb.h +26 -0
  516. data/third_party/upb/upb/upb.hpp +2 -0
  517. metadata +340 -153
  518. data/src/core/ext/filters/client_channel/lb_policy/xds/lrs.cc +0 -528
  519. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_routing.cc +0 -1142
  520. data/src/core/ext/filters/client_channel/xds/xds_api.cc +0 -2110
  521. data/src/core/ext/filters/client_channel/xds/xds_api.h +0 -345
  522. data/src/core/ext/filters/client_channel/xds/xds_channel.h +0 -46
  523. data/src/core/ext/filters/client_channel/xds/xds_channel_secure.cc +0 -106
  524. data/src/core/ext/upb-generated/envoy/api/v2/auth/cert.upb.c +0 -21
  525. data/src/core/ext/upb-generated/envoy/api/v2/auth/cert.upb.h +0 -34
  526. data/src/core/ext/upb-generated/envoy/api/v2/auth/common.upb.c +0 -114
  527. data/src/core/ext/upb-generated/envoy/api/v2/auth/common.upb.h +0 -429
  528. data/src/core/ext/upb-generated/envoy/api/v2/auth/secret.upb.c +0 -72
  529. data/src/core/ext/upb-generated/envoy/api/v2/auth/secret.upb.h +0 -198
  530. data/src/core/ext/upb-generated/envoy/api/v2/auth/tls.upb.c +0 -105
  531. data/src/core/ext/upb-generated/envoy/api/v2/auth/tls.upb.h +0 -388
  532. data/src/core/ext/upb-generated/envoy/api/v2/cds.upb.h +0 -52
  533. data/src/core/ext/upb-generated/envoy/api/v2/cluster.upb.c +0 -403
  534. data/src/core/ext/upb-generated/envoy/api/v2/cluster.upb.h +0 -1453
  535. data/src/core/ext/upb-generated/envoy/api/v2/cluster/circuit_breaker.upb.c +0 -74
  536. data/src/core/ext/upb-generated/envoy/api/v2/cluster/circuit_breaker.upb.h +0 -226
  537. data/src/core/ext/upb-generated/envoy/api/v2/cluster/filter.upb.h +0 -69
  538. data/src/core/ext/upb-generated/envoy/api/v2/cluster/outlier_detection.upb.h +0 -323
  539. data/src/core/ext/upb-generated/envoy/api/v2/core/address.upb.c +0 -112
  540. data/src/core/ext/upb-generated/envoy/api/v2/core/address.upb.h +0 -334
  541. data/src/core/ext/upb-generated/envoy/api/v2/core/backoff.upb.h +0 -79
  542. data/src/core/ext/upb-generated/envoy/api/v2/core/base.upb.c +0 -313
  543. data/src/core/ext/upb-generated/envoy/api/v2/core/base.upb.h +0 -891
  544. data/src/core/ext/upb-generated/envoy/api/v2/core/config_source.upb.c +0 -96
  545. data/src/core/ext/upb-generated/envoy/api/v2/core/config_source.upb.h +0 -328
  546. data/src/core/ext/upb-generated/envoy/api/v2/core/event_service_config.upb.c +0 -34
  547. data/src/core/ext/upb-generated/envoy/api/v2/core/event_service_config.upb.h +0 -71
  548. data/src/core/ext/upb-generated/envoy/api/v2/core/grpc_service.upb.c +0 -197
  549. data/src/core/ext/upb-generated/envoy/api/v2/core/grpc_service.upb.h +0 -649
  550. data/src/core/ext/upb-generated/envoy/api/v2/core/health_check.upb.c +0 -172
  551. data/src/core/ext/upb-generated/envoy/api/v2/core/health_check.upb.h +0 -693
  552. data/src/core/ext/upb-generated/envoy/api/v2/core/http_uri.upb.h +0 -80
  553. data/src/core/ext/upb-generated/envoy/api/v2/core/protocol.upb.c +0 -152
  554. data/src/core/ext/upb-generated/envoy/api/v2/core/protocol.upb.h +0 -536
  555. data/src/core/ext/upb-generated/envoy/api/v2/core/socket_option.upb.h +0 -88
  556. data/src/core/ext/upb-generated/envoy/api/v2/discovery.upb.c +0 -129
  557. data/src/core/ext/upb-generated/envoy/api/v2/discovery.upb.h +0 -386
  558. data/src/core/ext/upb-generated/envoy/api/v2/eds.upb.h +0 -52
  559. data/src/core/ext/upb-generated/envoy/api/v2/endpoint.upb.c +0 -92
  560. data/src/core/ext/upb-generated/envoy/api/v2/endpoint.upb.h +0 -224
  561. data/src/core/ext/upb-generated/envoy/api/v2/endpoint/endpoint.upb.c +0 -18
  562. data/src/core/ext/upb-generated/envoy/api/v2/endpoint/endpoint.upb.h +0 -32
  563. data/src/core/ext/upb-generated/envoy/api/v2/endpoint/endpoint_components.upb.c +0 -91
  564. data/src/core/ext/upb-generated/envoy/api/v2/endpoint/endpoint_components.upb.h +0 -273
  565. data/src/core/ext/upb-generated/envoy/api/v2/endpoint/load_report.upb.c +0 -112
  566. data/src/core/ext/upb-generated/envoy/api/v2/endpoint/load_report.upb.h +0 -332
  567. data/src/core/ext/upb-generated/envoy/api/v2/lds.upb.h +0 -52
  568. data/src/core/ext/upb-generated/envoy/api/v2/listener.upb.c +0 -109
  569. data/src/core/ext/upb-generated/envoy/api/v2/listener.upb.h +0 -415
  570. data/src/core/ext/upb-generated/envoy/api/v2/listener/listener.upb.c +0 -18
  571. data/src/core/ext/upb-generated/envoy/api/v2/listener/listener.upb.h +0 -32
  572. data/src/core/ext/upb-generated/envoy/api/v2/listener/listener_components.upb.c +0 -145
  573. data/src/core/ext/upb-generated/envoy/api/v2/listener/listener_components.upb.h +0 -538
  574. data/src/core/ext/upb-generated/envoy/api/v2/listener/udp_listener_config.upb.c +0 -43
  575. data/src/core/ext/upb-generated/envoy/api/v2/listener/udp_listener_config.upb.h +0 -111
  576. data/src/core/ext/upb-generated/envoy/api/v2/rds.upb.h +0 -52
  577. data/src/core/ext/upb-generated/envoy/api/v2/route.upb.c +0 -63
  578. data/src/core/ext/upb-generated/envoy/api/v2/route.upb.h +0 -204
  579. data/src/core/ext/upb-generated/envoy/api/v2/route/route.upb.c +0 -18
  580. data/src/core/ext/upb-generated/envoy/api/v2/route/route.upb.h +0 -32
  581. data/src/core/ext/upb-generated/envoy/api/v2/route/route_components.upb.c +0 -815
  582. data/src/core/ext/upb-generated/envoy/api/v2/route/route_components.upb.h +0 -2984
  583. data/src/core/ext/upb-generated/envoy/api/v2/scoped_route.upb.c +0 -59
  584. data/src/core/ext/upb-generated/envoy/api/v2/scoped_route.upb.h +0 -135
  585. data/src/core/ext/upb-generated/envoy/api/v2/srds.upb.h +0 -52
  586. data/src/core/ext/upb-generated/envoy/config/filter/accesslog/v2/accesslog.upb.c +0 -228
  587. data/src/core/ext/upb-generated/envoy/config/filter/accesslog/v2/accesslog.upb.h +0 -732
  588. data/src/core/ext/upb-generated/envoy/config/filter/network/http_connection_manager/v2/http_connection_manager.upb.c +0 -316
  589. data/src/core/ext/upb-generated/envoy/config/filter/network/http_connection_manager/v2/http_connection_manager.upb.h +0 -1167
  590. data/src/core/ext/upb-generated/envoy/config/listener/v2/api_listener.upb.h +0 -65
  591. data/src/core/ext/upb-generated/envoy/config/trace/v2/http_tracer.upb.c +0 -51
  592. data/src/core/ext/upb-generated/envoy/config/trace/v2/http_tracer.upb.h +0 -125
  593. data/src/core/ext/upb-generated/envoy/service/discovery/v2/ads.upb.h +0 -49
  594. data/src/core/ext/upb-generated/envoy/service/load_stats/v2/lrs.upb.c +0 -54
  595. data/src/core/ext/upb-generated/envoy/service/load_stats/v2/lrs.upb.h +0 -136
  596. data/src/core/ext/upb-generated/envoy/type/matcher/regex.upb.c +0 -63
  597. data/src/core/ext/upb-generated/envoy/type/matcher/regex.upb.h +0 -145
  598. data/src/core/ext/upb-generated/envoy/type/matcher/string.upb.c +0 -53
  599. data/src/core/ext/upb-generated/envoy/type/matcher/string.upb.h +0 -133
  600. data/src/core/ext/upb-generated/envoy/type/metadata/v2/metadata.upb.c +0 -88
  601. data/src/core/ext/upb-generated/envoy/type/metadata/v2/metadata.upb.h +0 -258
  602. data/src/core/ext/upb-generated/envoy/type/percent.upb.h +0 -86
  603. data/src/core/ext/upb-generated/envoy/type/range.upb.h +0 -111
  604. data/src/core/ext/upb-generated/envoy/type/semantic_version.upb.h +0 -61
  605. data/src/core/ext/upb-generated/envoy/type/tracing/v2/custom_tag.upb.c +0 -89
  606. data/src/core/ext/upb-generated/envoy/type/tracing/v2/custom_tag.upb.h +0 -250
  607. data/src/core/ext/upb-generated/gogoproto/gogo.upb.c +0 -17
  608. data/src/core/ext/upb-generated/gogoproto/gogo.upb.h +0 -29
  609. data/src/core/lib/security/transport/target_authority_table.cc +0 -75
  610. data/src/core/lib/security/transport/target_authority_table.h +0 -40
  611. data/src/core/lib/slice/slice_hash_table.h +0 -199
  612. data/src/core/lib/slice/slice_weak_hash_table.h +0 -102
  613. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_pku.c +0 -110
  614. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_sxnet.c +0 -274
@@ -0,0 +1,1121 @@
1
+ // Copyright 2020 The Abseil Authors.
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // https://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+
15
+ // A Cord is a sequence of characters with some unusual access propreties.
16
+ // A Cord supports efficient insertions and deletions at the start and end of
17
+ // the byte sequence, but random access reads are slower, and random access
18
+ // modifications are not supported by the API. Cord also provides cheap copies
19
+ // (using a copy-on-write strategy) and cheap substring operations.
20
+ //
21
+ // Thread safety
22
+ // -------------
23
+ // Cord has the same thread-safety properties as many other types like
24
+ // std::string, std::vector<>, int, etc -- it is thread-compatible. In
25
+ // particular, if no thread may call a non-const method, then it is safe to
26
+ // concurrently call const methods. Copying a Cord produces a new instance that
27
+ // can be used concurrently with the original in arbitrary ways.
28
+ //
29
+ // Implementation is similar to the "Ropes" described in:
30
+ // Ropes: An alternative to strings
31
+ // Hans J. Boehm, Russ Atkinson, Michael Plass
32
+ // Software Practice and Experience, December 1995
33
+
34
+ #ifndef ABSL_STRINGS_CORD_H_
35
+ #define ABSL_STRINGS_CORD_H_
36
+
37
+ #include <algorithm>
38
+ #include <cstddef>
39
+ #include <cstdint>
40
+ #include <cstring>
41
+ #include <iostream>
42
+ #include <iterator>
43
+ #include <string>
44
+
45
+ #include "absl/base/internal/endian.h"
46
+ #include "absl/base/internal/invoke.h"
47
+ #include "absl/base/internal/per_thread_tls.h"
48
+ #include "absl/base/macros.h"
49
+ #include "absl/base/port.h"
50
+ #include "absl/container/inlined_vector.h"
51
+ #include "absl/functional/function_ref.h"
52
+ #include "absl/meta/type_traits.h"
53
+ #include "absl/strings/internal/cord_internal.h"
54
+ #include "absl/strings/internal/resize_uninitialized.h"
55
+ #include "absl/strings/string_view.h"
56
+
57
+ namespace absl {
58
+ ABSL_NAMESPACE_BEGIN
59
+ class Cord;
60
+ class CordTestPeer;
61
+ template <typename Releaser>
62
+ Cord MakeCordFromExternal(absl::string_view, Releaser&&);
63
+ void CopyCordToString(const Cord& src, std::string* dst);
64
+ namespace hash_internal {
65
+ template <typename H>
66
+ H HashFragmentedCord(H, const Cord&);
67
+ }
68
+
69
+ // A Cord is a sequence of characters.
70
+ class Cord {
71
+ private:
72
+ template <typename T>
73
+ using EnableIfString =
74
+ absl::enable_if_t<std::is_same<T, std::string>::value, int>;
75
+
76
+ public:
77
+ // --------------------------------------------------------------------
78
+ // Constructors, destructors and helper factories
79
+
80
+ // Create an empty cord
81
+ constexpr Cord() noexcept;
82
+
83
+ // Cord is copyable and efficiently movable.
84
+ // The moved-from state is valid but unspecified.
85
+ Cord(const Cord& src);
86
+ Cord(Cord&& src) noexcept;
87
+ Cord& operator=(const Cord& x);
88
+ Cord& operator=(Cord&& x) noexcept;
89
+
90
+ // Create a cord out of "src". This constructor is explicit on
91
+ // purpose so that people do not get automatic type conversions.
92
+ explicit Cord(absl::string_view src);
93
+ Cord& operator=(absl::string_view src);
94
+
95
+ // These are templated to avoid ambiguities for types that are convertible to
96
+ // both `absl::string_view` and `std::string`, such as `const char*`.
97
+ //
98
+ // Note that these functions reserve the right to reuse the `string&&`'s
99
+ // memory and that they will do so in the future.
100
+ template <typename T, EnableIfString<T> = 0>
101
+ explicit Cord(T&& src) : Cord(absl::string_view(src)) {}
102
+ template <typename T, EnableIfString<T> = 0>
103
+ Cord& operator=(T&& src);
104
+
105
+ // Destroy the cord
106
+ ~Cord() {
107
+ if (contents_.is_tree()) DestroyCordSlow();
108
+ }
109
+
110
+ // Creates a Cord that takes ownership of external memory. The contents of
111
+ // `data` are not copied.
112
+ //
113
+ // This function takes a callable that is invoked when all Cords are
114
+ // finished with `data`. The data must remain live and unchanging until the
115
+ // releaser is called. The requirements for the releaser are that it:
116
+ // * is move constructible,
117
+ // * supports `void operator()(absl::string_view) const`,
118
+ // * does not have alignment requirement greater than what is guaranteed by
119
+ // ::operator new. This is dictated by alignof(std::max_align_t) before
120
+ // C++17 and __STDCPP_DEFAULT_NEW_ALIGNMENT__ if compiling with C++17 or
121
+ // it is supported by the implementation.
122
+ //
123
+ // Example:
124
+ //
125
+ // Cord MakeCord(BlockPool* pool) {
126
+ // Block* block = pool->NewBlock();
127
+ // FillBlock(block);
128
+ // return absl::MakeCordFromExternal(
129
+ // block->ToStringView(),
130
+ // [pool, block](absl::string_view /*ignored*/) {
131
+ // pool->FreeBlock(block);
132
+ // });
133
+ // }
134
+ //
135
+ // WARNING: It's likely a bug if your releaser doesn't do anything.
136
+ // For example, consider the following:
137
+ //
138
+ // void Foo(const char* buffer, int len) {
139
+ // auto c = absl::MakeCordFromExternal(absl::string_view(buffer, len),
140
+ // [](absl::string_view) {});
141
+ //
142
+ // // BUG: If Bar() copies its cord for any reason, including keeping a
143
+ // // substring of it, the lifetime of buffer might be extended beyond
144
+ // // when Foo() returns.
145
+ // Bar(c);
146
+ // }
147
+ template <typename Releaser>
148
+ friend Cord MakeCordFromExternal(absl::string_view data, Releaser&& releaser);
149
+
150
+ // --------------------------------------------------------------------
151
+ // Mutations
152
+
153
+ void Clear();
154
+
155
+ void Append(const Cord& src);
156
+ void Append(Cord&& src);
157
+ void Append(absl::string_view src);
158
+ template <typename T, EnableIfString<T> = 0>
159
+ void Append(T&& src);
160
+
161
+ void Prepend(const Cord& src);
162
+ void Prepend(absl::string_view src);
163
+ template <typename T, EnableIfString<T> = 0>
164
+ void Prepend(T&& src);
165
+
166
+ void RemovePrefix(size_t n);
167
+ void RemoveSuffix(size_t n);
168
+
169
+ // Returns a new cord representing the subrange [pos, pos + new_size) of
170
+ // *this. If pos >= size(), the result is empty(). If
171
+ // (pos + new_size) >= size(), the result is the subrange [pos, size()).
172
+ Cord Subcord(size_t pos, size_t new_size) const;
173
+
174
+ friend void swap(Cord& x, Cord& y) noexcept;
175
+
176
+ // --------------------------------------------------------------------
177
+ // Accessors
178
+
179
+ size_t size() const;
180
+ bool empty() const;
181
+
182
+ // Returns the approximate number of bytes pinned by this Cord. Note that
183
+ // Cords that share memory could each be "charged" independently for the same
184
+ // shared memory.
185
+ size_t EstimatedMemoryUsage() const;
186
+
187
+ // --------------------------------------------------------------------
188
+ // Comparators
189
+
190
+ // Compares 'this' Cord with rhs. This function and its relatives
191
+ // treat Cords as sequences of unsigned bytes. The comparison is a
192
+ // straightforward lexicographic comparison. Return value:
193
+ // -1 'this' Cord is smaller
194
+ // 0 two Cords are equal
195
+ // 1 'this' Cord is larger
196
+ int Compare(absl::string_view rhs) const;
197
+ int Compare(const Cord& rhs) const;
198
+
199
+ // Does 'this' cord start/end with rhs
200
+ bool StartsWith(const Cord& rhs) const;
201
+ bool StartsWith(absl::string_view rhs) const;
202
+ bool EndsWith(absl::string_view rhs) const;
203
+ bool EndsWith(const Cord& rhs) const;
204
+
205
+ // --------------------------------------------------------------------
206
+ // Conversion to other types
207
+
208
+ explicit operator std::string() const;
209
+
210
+ // Copies the contents from `src` to `*dst`.
211
+ //
212
+ // This function optimizes the case of reusing the destination std::string since it
213
+ // can reuse previously allocated capacity. However, this function does not
214
+ // guarantee that pointers previously returned by `dst->data()` remain valid
215
+ // even if `*dst` had enough capacity to hold `src`. If `*dst` is a new
216
+ // object, prefer to simply use the conversion operator to `std::string`.
217
+ friend void CopyCordToString(const Cord& src, std::string* dst);
218
+
219
+ // --------------------------------------------------------------------
220
+ // Iteration
221
+
222
+ class CharIterator;
223
+
224
+ // Type for iterating over the chunks of a `Cord`. See comments for
225
+ // `Cord::chunk_begin()`, `Cord::chunk_end()` and `Cord::Chunks()` below for
226
+ // preferred usage.
227
+ //
228
+ // Additional notes:
229
+ // * The `string_view` returned by dereferencing a valid, non-`end()`
230
+ // iterator is guaranteed to be non-empty.
231
+ // * A `ChunkIterator` object is invalidated after any non-const
232
+ // operation on the `Cord` object over which it iterates.
233
+ // * Two `ChunkIterator` objects can be equality compared if and only if
234
+ // they remain valid and iterate over the same `Cord`.
235
+ // * This is a proxy iterator. This means the `string_view` returned by the
236
+ // iterator does not live inside the Cord, and its lifetime is limited to
237
+ // the lifetime of the iterator itself. To help prevent issues,
238
+ // `ChunkIterator::reference` is not a true reference type and is
239
+ // equivalent to `value_type`.
240
+ // * The iterator keeps state that can grow for `Cord`s that contain many
241
+ // nodes and are imbalanced due to sharing. Prefer to pass this type by
242
+ // const reference instead of by value.
243
+ class ChunkIterator {
244
+ public:
245
+ using iterator_category = std::input_iterator_tag;
246
+ using value_type = absl::string_view;
247
+ using difference_type = ptrdiff_t;
248
+ using pointer = const value_type*;
249
+ using reference = value_type;
250
+
251
+ ChunkIterator() = default;
252
+
253
+ ChunkIterator& operator++();
254
+ ChunkIterator operator++(int);
255
+ bool operator==(const ChunkIterator& other) const;
256
+ bool operator!=(const ChunkIterator& other) const;
257
+ reference operator*() const;
258
+ pointer operator->() const;
259
+
260
+ friend class Cord;
261
+ friend class CharIterator;
262
+
263
+ private:
264
+ // Constructs a `begin()` iterator from `cord`.
265
+ explicit ChunkIterator(const Cord* cord);
266
+
267
+ // Removes `n` bytes from `current_chunk_`. Expects `n` to be smaller than
268
+ // `current_chunk_.size()`.
269
+ void RemoveChunkPrefix(size_t n);
270
+ Cord AdvanceAndReadBytes(size_t n);
271
+ void AdvanceBytes(size_t n);
272
+ // Iterates `n` bytes, where `n` is expected to be greater than or equal to
273
+ // `current_chunk_.size()`.
274
+ void AdvanceBytesSlowPath(size_t n);
275
+
276
+ // A view into bytes of the current `CordRep`. It may only be a view to a
277
+ // suffix of bytes if this is being used by `CharIterator`.
278
+ absl::string_view current_chunk_;
279
+ // The current leaf, or `nullptr` if the iterator points to short data.
280
+ // If the current chunk is a substring node, current_leaf_ points to the
281
+ // underlying flat or external node.
282
+ absl::cord_internal::CordRep* current_leaf_ = nullptr;
283
+ // The number of bytes left in the `Cord` over which we are iterating.
284
+ size_t bytes_remaining_ = 0;
285
+ absl::InlinedVector<absl::cord_internal::CordRep*, 4>
286
+ stack_of_right_children_;
287
+ };
288
+
289
+ // Returns an iterator to the first chunk of the `Cord`.
290
+ //
291
+ // This is useful for getting a `ChunkIterator` outside the context of a
292
+ // range-based for-loop (in which case see `Cord::Chunks()` below).
293
+ //
294
+ // Example:
295
+ //
296
+ // absl::Cord::ChunkIterator FindAsChunk(const absl::Cord& c,
297
+ // absl::string_view s) {
298
+ // return std::find(c.chunk_begin(), c.chunk_end(), s);
299
+ // }
300
+ ChunkIterator chunk_begin() const;
301
+ // Returns an iterator one increment past the last chunk of the `Cord`.
302
+ ChunkIterator chunk_end() const;
303
+
304
+ // Convenience wrapper over `Cord::chunk_begin()` and `Cord::chunk_end()` to
305
+ // enable range-based for-loop iteration over `Cord` chunks.
306
+ //
307
+ // Prefer to use `Cord::Chunks()` below instead of constructing this directly.
308
+ class ChunkRange {
309
+ public:
310
+ explicit ChunkRange(const Cord* cord) : cord_(cord) {}
311
+
312
+ ChunkIterator begin() const;
313
+ ChunkIterator end() const;
314
+
315
+ private:
316
+ const Cord* cord_;
317
+ };
318
+
319
+ // Returns a range for iterating over the chunks of a `Cord` with a
320
+ // range-based for-loop.
321
+ //
322
+ // Example:
323
+ //
324
+ // void ProcessChunks(const Cord& cord) {
325
+ // for (absl::string_view chunk : cord.Chunks()) { ... }
326
+ // }
327
+ //
328
+ // Note that the ordinary caveats of temporary lifetime extension apply:
329
+ //
330
+ // void Process() {
331
+ // for (absl::string_view chunk : CordFactory().Chunks()) {
332
+ // // The temporary Cord returned by CordFactory has been destroyed!
333
+ // }
334
+ // }
335
+ ChunkRange Chunks() const;
336
+
337
+ // Type for iterating over the characters of a `Cord`. See comments for
338
+ // `Cord::char_begin()`, `Cord::char_end()` and `Cord::Chars()` below for
339
+ // preferred usage.
340
+ //
341
+ // Additional notes:
342
+ // * A `CharIterator` object is invalidated after any non-const
343
+ // operation on the `Cord` object over which it iterates.
344
+ // * Two `CharIterator` objects can be equality compared if and only if
345
+ // they remain valid and iterate over the same `Cord`.
346
+ // * The iterator keeps state that can grow for `Cord`s that contain many
347
+ // nodes and are imbalanced due to sharing. Prefer to pass this type by
348
+ // const reference instead of by value.
349
+ // * This type cannot be a forward iterator because a `Cord` can reuse
350
+ // sections of memory. This violates the requirement that if dereferencing
351
+ // two iterators returns the same object, the iterators must compare
352
+ // equal.
353
+ class CharIterator {
354
+ public:
355
+ using iterator_category = std::input_iterator_tag;
356
+ using value_type = char;
357
+ using difference_type = ptrdiff_t;
358
+ using pointer = const char*;
359
+ using reference = const char&;
360
+
361
+ CharIterator() = default;
362
+
363
+ CharIterator& operator++();
364
+ CharIterator operator++(int);
365
+ bool operator==(const CharIterator& other) const;
366
+ bool operator!=(const CharIterator& other) const;
367
+ reference operator*() const;
368
+ pointer operator->() const;
369
+
370
+ friend Cord;
371
+
372
+ private:
373
+ explicit CharIterator(const Cord* cord) : chunk_iterator_(cord) {}
374
+
375
+ ChunkIterator chunk_iterator_;
376
+ };
377
+
378
+ // Advances `*it` by `n_bytes` and returns the bytes passed as a `Cord`.
379
+ //
380
+ // `n_bytes` must be less than or equal to the number of bytes remaining for
381
+ // iteration. Otherwise the behavior is undefined. It is valid to pass
382
+ // `char_end()` and 0.
383
+ static Cord AdvanceAndRead(CharIterator* it, size_t n_bytes);
384
+
385
+ // Advances `*it` by `n_bytes`.
386
+ //
387
+ // `n_bytes` must be less than or equal to the number of bytes remaining for
388
+ // iteration. Otherwise the behavior is undefined. It is valid to pass
389
+ // `char_end()` and 0.
390
+ static void Advance(CharIterator* it, size_t n_bytes);
391
+
392
+ // Returns the longest contiguous view starting at the iterator's position.
393
+ //
394
+ // `it` must be dereferenceable.
395
+ static absl::string_view ChunkRemaining(const CharIterator& it);
396
+
397
+ // Returns an iterator to the first character of the `Cord`.
398
+ CharIterator char_begin() const;
399
+ // Returns an iterator to one past the last character of the `Cord`.
400
+ CharIterator char_end() const;
401
+
402
+ // Convenience wrapper over `Cord::char_begin()` and `Cord::char_end()` to
403
+ // enable range-based for-loop iterator over the characters of a `Cord`.
404
+ //
405
+ // Prefer to use `Cord::Chars()` below instead of constructing this directly.
406
+ class CharRange {
407
+ public:
408
+ explicit CharRange(const Cord* cord) : cord_(cord) {}
409
+
410
+ CharIterator begin() const;
411
+ CharIterator end() const;
412
+
413
+ private:
414
+ const Cord* cord_;
415
+ };
416
+
417
+ // Returns a range for iterating over the characters of a `Cord` with a
418
+ // range-based for-loop.
419
+ //
420
+ // Example:
421
+ //
422
+ // void ProcessCord(const Cord& cord) {
423
+ // for (char c : cord.Chars()) { ... }
424
+ // }
425
+ //
426
+ // Note that the ordinary caveats of temporary lifetime extension apply:
427
+ //
428
+ // void Process() {
429
+ // for (char c : CordFactory().Chars()) {
430
+ // // The temporary Cord returned by CordFactory has been destroyed!
431
+ // }
432
+ // }
433
+ CharRange Chars() const;
434
+
435
+ // --------------------------------------------------------------------
436
+ // Miscellaneous
437
+
438
+ // Get the "i"th character of 'this' and return it.
439
+ // NOTE: This routine is reasonably efficient. It is roughly
440
+ // logarithmic in the number of nodes that make up the cord. Still,
441
+ // if you need to iterate over the contents of a cord, you should
442
+ // use a CharIterator/CordIterator rather than call operator[] or Get()
443
+ // repeatedly in a loop.
444
+ //
445
+ // REQUIRES: 0 <= i < size()
446
+ char operator[](size_t i) const;
447
+
448
+ // Flattens the cord into a single array and returns a view of the data.
449
+ //
450
+ // If the cord was already flat, the contents are not modified.
451
+ absl::string_view Flatten();
452
+
453
+ private:
454
+ friend class CordTestPeer;
455
+ template <typename H>
456
+ friend H absl::hash_internal::HashFragmentedCord(H, const Cord&);
457
+ friend bool operator==(const Cord& lhs, const Cord& rhs);
458
+ friend bool operator==(const Cord& lhs, absl::string_view rhs);
459
+
460
+ // Call the provided function once for each cord chunk, in order. Unlike
461
+ // Chunks(), this API will not allocate memory.
462
+ void ForEachChunk(absl::FunctionRef<void(absl::string_view)>) const;
463
+
464
+ // Allocates new contiguous storage for the contents of the cord. This is
465
+ // called by Flatten() when the cord was not already flat.
466
+ absl::string_view FlattenSlowPath();
467
+
468
+ // Actual cord contents are hidden inside the following simple
469
+ // class so that we can isolate the bulk of cord.cc from changes
470
+ // to the representation.
471
+ //
472
+ // InlineRep holds either either a tree pointer, or an array of kMaxInline
473
+ // bytes.
474
+ class InlineRep {
475
+ public:
476
+ static const unsigned char kMaxInline = 15;
477
+ static_assert(kMaxInline >= sizeof(absl::cord_internal::CordRep*), "");
478
+ // Tag byte & kMaxInline means we are storing a pointer.
479
+ static const unsigned char kTreeFlag = 1 << 4;
480
+ // Tag byte & kProfiledFlag means we are profiling the Cord.
481
+ static const unsigned char kProfiledFlag = 1 << 5;
482
+
483
+ constexpr InlineRep() : data_{} {}
484
+ InlineRep(const InlineRep& src);
485
+ InlineRep(InlineRep&& src);
486
+ InlineRep& operator=(const InlineRep& src);
487
+ InlineRep& operator=(InlineRep&& src) noexcept;
488
+
489
+ void Swap(InlineRep* rhs);
490
+ bool empty() const;
491
+ size_t size() const;
492
+ const char* data() const; // Returns nullptr if holding pointer
493
+ void set_data(const char* data, size_t n,
494
+ bool nullify_tail); // Discards pointer, if any
495
+ char* set_data(size_t n); // Write data to the result
496
+ // Returns nullptr if holding bytes
497
+ absl::cord_internal::CordRep* tree() const;
498
+ // Discards old pointer, if any
499
+ void set_tree(absl::cord_internal::CordRep* rep);
500
+ // Replaces a tree with a new root. This is faster than set_tree, but it
501
+ // should only be used when it's clear that the old rep was a tree.
502
+ void replace_tree(absl::cord_internal::CordRep* rep);
503
+ // Returns non-null iff was holding a pointer
504
+ absl::cord_internal::CordRep* clear();
505
+ // Convert to pointer if necessary
506
+ absl::cord_internal::CordRep* force_tree(size_t extra_hint);
507
+ void reduce_size(size_t n); // REQUIRES: holding data
508
+ void remove_prefix(size_t n); // REQUIRES: holding data
509
+ void AppendArray(const char* src_data, size_t src_size);
510
+ absl::string_view FindFlatStartPiece() const;
511
+ void AppendTree(absl::cord_internal::CordRep* tree);
512
+ void PrependTree(absl::cord_internal::CordRep* tree);
513
+ void GetAppendRegion(char** region, size_t* size, size_t max_length);
514
+ void GetAppendRegion(char** region, size_t* size);
515
+ bool IsSame(const InlineRep& other) const {
516
+ return memcmp(data_, other.data_, sizeof(data_)) == 0;
517
+ }
518
+ int BitwiseCompare(const InlineRep& other) const {
519
+ uint64_t x, y;
520
+ // Use memcpy to avoid anti-aliasing issues.
521
+ memcpy(&x, data_, sizeof(x));
522
+ memcpy(&y, other.data_, sizeof(y));
523
+ if (x == y) {
524
+ memcpy(&x, data_ + 8, sizeof(x));
525
+ memcpy(&y, other.data_ + 8, sizeof(y));
526
+ if (x == y) return 0;
527
+ }
528
+ return absl::big_endian::FromHost64(x) < absl::big_endian::FromHost64(y)
529
+ ? -1
530
+ : 1;
531
+ }
532
+ void CopyTo(std::string* dst) const {
533
+ // memcpy is much faster when operating on a known size. On most supported
534
+ // platforms, the small std::string optimization is large enough that resizing
535
+ // to 15 bytes does not cause a memory allocation.
536
+ absl::strings_internal::STLStringResizeUninitialized(dst,
537
+ sizeof(data_) - 1);
538
+ memcpy(&(*dst)[0], data_, sizeof(data_) - 1);
539
+ // erase is faster than resize because the logic for memory allocation is
540
+ // not needed.
541
+ dst->erase(data_[kMaxInline]);
542
+ }
543
+
544
+ // Copies the inline contents into `dst`. Assumes the cord is not empty.
545
+ void CopyToArray(char* dst) const;
546
+
547
+ bool is_tree() const { return data_[kMaxInline] > kMaxInline; }
548
+
549
+ private:
550
+ friend class Cord;
551
+
552
+ void AssignSlow(const InlineRep& src);
553
+ // Unrefs the tree, stops profiling, and zeroes the contents
554
+ void ClearSlow();
555
+
556
+ // If the data has length <= kMaxInline, we store it in data_[0..len-1],
557
+ // and store the length in data_[kMaxInline]. Else we store it in a tree
558
+ // and store a pointer to that tree in data_[0..sizeof(CordRep*)-1].
559
+ alignas(absl::cord_internal::CordRep*) char data_[kMaxInline + 1];
560
+ };
561
+ InlineRep contents_;
562
+
563
+ // Helper for MemoryUsage()
564
+ static size_t MemoryUsageAux(const absl::cord_internal::CordRep* rep);
565
+
566
+ // Helper for GetFlat()
567
+ static bool GetFlatAux(absl::cord_internal::CordRep* rep,
568
+ absl::string_view* fragment);
569
+
570
+ // Helper for ForEachChunk()
571
+ static void ForEachChunkAux(
572
+ absl::cord_internal::CordRep* rep,
573
+ absl::FunctionRef<void(absl::string_view)> callback);
574
+
575
+ // The destructor for non-empty Cords.
576
+ void DestroyCordSlow();
577
+
578
+ // Out-of-line implementation of slower parts of logic.
579
+ void CopyToArraySlowPath(char* dst) const;
580
+ int CompareSlowPath(absl::string_view rhs, size_t compared_size,
581
+ size_t size_to_compare) const;
582
+ int CompareSlowPath(const Cord& rhs, size_t compared_size,
583
+ size_t size_to_compare) const;
584
+ bool EqualsImpl(absl::string_view rhs, size_t size_to_compare) const;
585
+ bool EqualsImpl(const Cord& rhs, size_t size_to_compare) const;
586
+ int CompareImpl(const Cord& rhs) const;
587
+
588
+ template <typename ResultType, typename RHS>
589
+ friend ResultType GenericCompare(const Cord& lhs, const RHS& rhs,
590
+ size_t size_to_compare);
591
+ static absl::string_view GetFirstChunk(const Cord& c);
592
+ static absl::string_view GetFirstChunk(absl::string_view sv);
593
+
594
+ // Returns a new reference to contents_.tree(), or steals an existing
595
+ // reference if called on an rvalue.
596
+ absl::cord_internal::CordRep* TakeRep() const&;
597
+ absl::cord_internal::CordRep* TakeRep() &&;
598
+
599
+ // Helper for Append()
600
+ template <typename C>
601
+ void AppendImpl(C&& src);
602
+ };
603
+
604
+ ABSL_NAMESPACE_END
605
+ } // namespace absl
606
+
607
+ namespace absl {
608
+ ABSL_NAMESPACE_BEGIN
609
+
610
+ // allow a Cord to be logged
611
+ extern std::ostream& operator<<(std::ostream& out, const Cord& cord);
612
+
613
+ // ------------------------------------------------------------------
614
+ // Internal details follow. Clients should ignore.
615
+
616
+ namespace cord_internal {
617
+
618
+ // Fast implementation of memmove for up to 15 bytes. This implementation is
619
+ // safe for overlapping regions. If nullify_tail is true, the destination is
620
+ // padded with '\0' up to 16 bytes.
621
+ inline void SmallMemmove(char* dst, const char* src, size_t n,
622
+ bool nullify_tail = false) {
623
+ if (n >= 8) {
624
+ assert(n <= 16);
625
+ uint64_t buf1;
626
+ uint64_t buf2;
627
+ memcpy(&buf1, src, 8);
628
+ memcpy(&buf2, src + n - 8, 8);
629
+ if (nullify_tail) {
630
+ memset(dst + 8, 0, 8);
631
+ }
632
+ memcpy(dst, &buf1, 8);
633
+ memcpy(dst + n - 8, &buf2, 8);
634
+ } else if (n >= 4) {
635
+ uint32_t buf1;
636
+ uint32_t buf2;
637
+ memcpy(&buf1, src, 4);
638
+ memcpy(&buf2, src + n - 4, 4);
639
+ if (nullify_tail) {
640
+ memset(dst + 4, 0, 4);
641
+ memset(dst + 8, 0, 8);
642
+ }
643
+ memcpy(dst, &buf1, 4);
644
+ memcpy(dst + n - 4, &buf2, 4);
645
+ } else {
646
+ if (n != 0) {
647
+ dst[0] = src[0];
648
+ dst[n / 2] = src[n / 2];
649
+ dst[n - 1] = src[n - 1];
650
+ }
651
+ if (nullify_tail) {
652
+ memset(dst + 8, 0, 8);
653
+ memset(dst + n, 0, 8);
654
+ }
655
+ }
656
+ }
657
+
658
+ struct ExternalRepReleaserPair {
659
+ CordRep* rep;
660
+ void* releaser_address;
661
+ };
662
+
663
+ // Allocates a new external `CordRep` and returns a pointer to it and a pointer
664
+ // to `releaser_size` bytes where the desired releaser can be constructed.
665
+ // Expects `data` to be non-empty.
666
+ ExternalRepReleaserPair NewExternalWithUninitializedReleaser(
667
+ absl::string_view data, ExternalReleaserInvoker invoker,
668
+ size_t releaser_size);
669
+
670
+ // Creates a new `CordRep` that owns `data` and `releaser` and returns a pointer
671
+ // to it, or `nullptr` if `data` was empty.
672
+ template <typename Releaser>
673
+ // NOLINTNEXTLINE - suppress clang-tidy raw pointer return.
674
+ CordRep* NewExternalRep(absl::string_view data, Releaser&& releaser) {
675
+ static_assert(
676
+ #if defined(__STDCPP_DEFAULT_NEW_ALIGNMENT__)
677
+ alignof(Releaser) <= __STDCPP_DEFAULT_NEW_ALIGNMENT__,
678
+ #else
679
+ alignof(Releaser) <= alignof(max_align_t),
680
+ #endif
681
+ "Releasers with alignment requirement greater than what is returned by "
682
+ "default `::operator new()` are not supported.");
683
+
684
+ using ReleaserType = absl::decay_t<Releaser>;
685
+ if (data.empty()) {
686
+ // Never create empty external nodes.
687
+ ::absl::base_internal::Invoke(
688
+ ReleaserType(std::forward<Releaser>(releaser)), data);
689
+ return nullptr;
690
+ }
691
+
692
+ auto releaser_invoker = [](void* type_erased_releaser, absl::string_view d) {
693
+ auto* my_releaser = static_cast<ReleaserType*>(type_erased_releaser);
694
+ ::absl::base_internal::Invoke(std::move(*my_releaser), d);
695
+ my_releaser->~ReleaserType();
696
+ return sizeof(Releaser);
697
+ };
698
+
699
+ ExternalRepReleaserPair external = NewExternalWithUninitializedReleaser(
700
+ data, releaser_invoker, sizeof(releaser));
701
+ ::new (external.releaser_address)
702
+ ReleaserType(std::forward<Releaser>(releaser));
703
+ return external.rep;
704
+ }
705
+
706
+ // Overload for function reference types that dispatches using a function
707
+ // pointer because there are no `alignof()` or `sizeof()` a function reference.
708
+ // NOLINTNEXTLINE - suppress clang-tidy raw pointer return.
709
+ inline CordRep* NewExternalRep(absl::string_view data,
710
+ void (&releaser)(absl::string_view)) {
711
+ return NewExternalRep(data, &releaser);
712
+ }
713
+
714
+ } // namespace cord_internal
715
+
716
+ template <typename Releaser>
717
+ Cord MakeCordFromExternal(absl::string_view data, Releaser&& releaser) {
718
+ Cord cord;
719
+ cord.contents_.set_tree(::absl::cord_internal::NewExternalRep(
720
+ data, std::forward<Releaser>(releaser)));
721
+ return cord;
722
+ }
723
+
724
+ inline Cord::InlineRep::InlineRep(const Cord::InlineRep& src) {
725
+ cord_internal::SmallMemmove(data_, src.data_, sizeof(data_));
726
+ }
727
+
728
+ inline Cord::InlineRep::InlineRep(Cord::InlineRep&& src) {
729
+ memcpy(data_, src.data_, sizeof(data_));
730
+ memset(src.data_, 0, sizeof(data_));
731
+ }
732
+
733
+ inline Cord::InlineRep& Cord::InlineRep::operator=(const Cord::InlineRep& src) {
734
+ if (this == &src) {
735
+ return *this;
736
+ }
737
+ if (!is_tree() && !src.is_tree()) {
738
+ cord_internal::SmallMemmove(data_, src.data_, sizeof(data_));
739
+ return *this;
740
+ }
741
+ AssignSlow(src);
742
+ return *this;
743
+ }
744
+
745
+ inline Cord::InlineRep& Cord::InlineRep::operator=(
746
+ Cord::InlineRep&& src) noexcept {
747
+ if (is_tree()) {
748
+ ClearSlow();
749
+ }
750
+ memcpy(data_, src.data_, sizeof(data_));
751
+ memset(src.data_, 0, sizeof(data_));
752
+ return *this;
753
+ }
754
+
755
+ inline void Cord::InlineRep::Swap(Cord::InlineRep* rhs) {
756
+ if (rhs == this) {
757
+ return;
758
+ }
759
+
760
+ Cord::InlineRep tmp;
761
+ cord_internal::SmallMemmove(tmp.data_, data_, sizeof(data_));
762
+ cord_internal::SmallMemmove(data_, rhs->data_, sizeof(data_));
763
+ cord_internal::SmallMemmove(rhs->data_, tmp.data_, sizeof(data_));
764
+ }
765
+
766
+ inline const char* Cord::InlineRep::data() const {
767
+ return is_tree() ? nullptr : data_;
768
+ }
769
+
770
+ inline absl::cord_internal::CordRep* Cord::InlineRep::tree() const {
771
+ if (is_tree()) {
772
+ absl::cord_internal::CordRep* rep;
773
+ memcpy(&rep, data_, sizeof(rep));
774
+ return rep;
775
+ } else {
776
+ return nullptr;
777
+ }
778
+ }
779
+
780
+ inline bool Cord::InlineRep::empty() const { return data_[kMaxInline] == 0; }
781
+
782
+ inline size_t Cord::InlineRep::size() const {
783
+ const char tag = data_[kMaxInline];
784
+ if (tag <= kMaxInline) return tag;
785
+ return static_cast<size_t>(tree()->length);
786
+ }
787
+
788
+ inline void Cord::InlineRep::set_tree(absl::cord_internal::CordRep* rep) {
789
+ if (rep == nullptr) {
790
+ memset(data_, 0, sizeof(data_));
791
+ } else {
792
+ bool was_tree = is_tree();
793
+ memcpy(data_, &rep, sizeof(rep));
794
+ memset(data_ + sizeof(rep), 0, sizeof(data_) - sizeof(rep) - 1);
795
+ if (!was_tree) {
796
+ data_[kMaxInline] = kTreeFlag;
797
+ }
798
+ }
799
+ }
800
+
801
+ inline void Cord::InlineRep::replace_tree(absl::cord_internal::CordRep* rep) {
802
+ ABSL_ASSERT(is_tree());
803
+ if (ABSL_PREDICT_FALSE(rep == nullptr)) {
804
+ set_tree(rep);
805
+ return;
806
+ }
807
+ memcpy(data_, &rep, sizeof(rep));
808
+ memset(data_ + sizeof(rep), 0, sizeof(data_) - sizeof(rep) - 1);
809
+ }
810
+
811
+ inline absl::cord_internal::CordRep* Cord::InlineRep::clear() {
812
+ const char tag = data_[kMaxInline];
813
+ absl::cord_internal::CordRep* result = nullptr;
814
+ if (tag > kMaxInline) {
815
+ memcpy(&result, data_, sizeof(result));
816
+ }
817
+ memset(data_, 0, sizeof(data_)); // Clear the cord
818
+ return result;
819
+ }
820
+
821
+ inline void Cord::InlineRep::CopyToArray(char* dst) const {
822
+ assert(!is_tree());
823
+ size_t n = data_[kMaxInline];
824
+ assert(n != 0);
825
+ cord_internal::SmallMemmove(dst, data_, n);
826
+ }
827
+
828
+ constexpr inline Cord::Cord() noexcept {}
829
+
830
+ inline Cord& Cord::operator=(const Cord& x) {
831
+ contents_ = x.contents_;
832
+ return *this;
833
+ }
834
+
835
+ inline Cord::Cord(Cord&& src) noexcept : contents_(std::move(src.contents_)) {}
836
+
837
+ inline Cord& Cord::operator=(Cord&& x) noexcept {
838
+ contents_ = std::move(x.contents_);
839
+ return *this;
840
+ }
841
+
842
+ template <typename T, Cord::EnableIfString<T>>
843
+ inline Cord& Cord::operator=(T&& src) {
844
+ *this = absl::string_view(src);
845
+ return *this;
846
+ }
847
+
848
+ inline size_t Cord::size() const {
849
+ // Length is 1st field in str.rep_
850
+ return contents_.size();
851
+ }
852
+
853
+ inline bool Cord::empty() const { return contents_.empty(); }
854
+
855
+ inline size_t Cord::EstimatedMemoryUsage() const {
856
+ size_t result = sizeof(Cord);
857
+ if (const absl::cord_internal::CordRep* rep = contents_.tree()) {
858
+ result += MemoryUsageAux(rep);
859
+ }
860
+ return result;
861
+ }
862
+
863
+ inline absl::string_view Cord::Flatten() {
864
+ absl::cord_internal::CordRep* rep = contents_.tree();
865
+ if (rep == nullptr) {
866
+ return absl::string_view(contents_.data(), contents_.size());
867
+ } else {
868
+ absl::string_view already_flat_contents;
869
+ if (GetFlatAux(rep, &already_flat_contents)) {
870
+ return already_flat_contents;
871
+ }
872
+ }
873
+ return FlattenSlowPath();
874
+ }
875
+
876
+ inline void Cord::Append(absl::string_view src) {
877
+ contents_.AppendArray(src.data(), src.size());
878
+ }
879
+
880
+ template <typename T, Cord::EnableIfString<T>>
881
+ inline void Cord::Append(T&& src) {
882
+ // Note that this function reserves the right to reuse the `string&&`'s
883
+ // memory and that it will do so in the future.
884
+ Append(absl::string_view(src));
885
+ }
886
+
887
+ template <typename T, Cord::EnableIfString<T>>
888
+ inline void Cord::Prepend(T&& src) {
889
+ // Note that this function reserves the right to reuse the `string&&`'s
890
+ // memory and that it will do so in the future.
891
+ Prepend(absl::string_view(src));
892
+ }
893
+
894
+ inline int Cord::Compare(const Cord& rhs) const {
895
+ if (!contents_.is_tree() && !rhs.contents_.is_tree()) {
896
+ return contents_.BitwiseCompare(rhs.contents_);
897
+ }
898
+
899
+ return CompareImpl(rhs);
900
+ }
901
+
902
+ // Does 'this' cord start/end with rhs
903
+ inline bool Cord::StartsWith(const Cord& rhs) const {
904
+ if (contents_.IsSame(rhs.contents_)) return true;
905
+ size_t rhs_size = rhs.size();
906
+ if (size() < rhs_size) return false;
907
+ return EqualsImpl(rhs, rhs_size);
908
+ }
909
+
910
+ inline bool Cord::StartsWith(absl::string_view rhs) const {
911
+ size_t rhs_size = rhs.size();
912
+ if (size() < rhs_size) return false;
913
+ return EqualsImpl(rhs, rhs_size);
914
+ }
915
+
916
+ inline Cord::ChunkIterator::ChunkIterator(const Cord* cord)
917
+ : bytes_remaining_(cord->size()) {
918
+ if (cord->empty()) return;
919
+ if (cord->contents_.is_tree()) {
920
+ stack_of_right_children_.push_back(cord->contents_.tree());
921
+ operator++();
922
+ } else {
923
+ current_chunk_ = absl::string_view(cord->contents_.data(), cord->size());
924
+ }
925
+ }
926
+
927
+ inline Cord::ChunkIterator Cord::ChunkIterator::operator++(int) {
928
+ ChunkIterator tmp(*this);
929
+ operator++();
930
+ return tmp;
931
+ }
932
+
933
+ inline bool Cord::ChunkIterator::operator==(const ChunkIterator& other) const {
934
+ return bytes_remaining_ == other.bytes_remaining_;
935
+ }
936
+
937
+ inline bool Cord::ChunkIterator::operator!=(const ChunkIterator& other) const {
938
+ return !(*this == other);
939
+ }
940
+
941
+ inline Cord::ChunkIterator::reference Cord::ChunkIterator::operator*() const {
942
+ assert(bytes_remaining_ != 0);
943
+ return current_chunk_;
944
+ }
945
+
946
+ inline Cord::ChunkIterator::pointer Cord::ChunkIterator::operator->() const {
947
+ assert(bytes_remaining_ != 0);
948
+ return &current_chunk_;
949
+ }
950
+
951
+ inline void Cord::ChunkIterator::RemoveChunkPrefix(size_t n) {
952
+ assert(n < current_chunk_.size());
953
+ current_chunk_.remove_prefix(n);
954
+ bytes_remaining_ -= n;
955
+ }
956
+
957
+ inline void Cord::ChunkIterator::AdvanceBytes(size_t n) {
958
+ if (ABSL_PREDICT_TRUE(n < current_chunk_.size())) {
959
+ RemoveChunkPrefix(n);
960
+ } else if (n != 0) {
961
+ AdvanceBytesSlowPath(n);
962
+ }
963
+ }
964
+
965
+ inline Cord::ChunkIterator Cord::chunk_begin() const {
966
+ return ChunkIterator(this);
967
+ }
968
+
969
+ inline Cord::ChunkIterator Cord::chunk_end() const { return ChunkIterator(); }
970
+
971
+ inline Cord::ChunkIterator Cord::ChunkRange::begin() const {
972
+ return cord_->chunk_begin();
973
+ }
974
+
975
+ inline Cord::ChunkIterator Cord::ChunkRange::end() const {
976
+ return cord_->chunk_end();
977
+ }
978
+
979
+ inline Cord::ChunkRange Cord::Chunks() const { return ChunkRange(this); }
980
+
981
+ inline Cord::CharIterator& Cord::CharIterator::operator++() {
982
+ if (ABSL_PREDICT_TRUE(chunk_iterator_->size() > 1)) {
983
+ chunk_iterator_.RemoveChunkPrefix(1);
984
+ } else {
985
+ ++chunk_iterator_;
986
+ }
987
+ return *this;
988
+ }
989
+
990
+ inline Cord::CharIterator Cord::CharIterator::operator++(int) {
991
+ CharIterator tmp(*this);
992
+ operator++();
993
+ return tmp;
994
+ }
995
+
996
+ inline bool Cord::CharIterator::operator==(const CharIterator& other) const {
997
+ return chunk_iterator_ == other.chunk_iterator_;
998
+ }
999
+
1000
+ inline bool Cord::CharIterator::operator!=(const CharIterator& other) const {
1001
+ return !(*this == other);
1002
+ }
1003
+
1004
+ inline Cord::CharIterator::reference Cord::CharIterator::operator*() const {
1005
+ return *chunk_iterator_->data();
1006
+ }
1007
+
1008
+ inline Cord::CharIterator::pointer Cord::CharIterator::operator->() const {
1009
+ return chunk_iterator_->data();
1010
+ }
1011
+
1012
+ inline Cord Cord::AdvanceAndRead(CharIterator* it, size_t n_bytes) {
1013
+ assert(it != nullptr);
1014
+ return it->chunk_iterator_.AdvanceAndReadBytes(n_bytes);
1015
+ }
1016
+
1017
+ inline void Cord::Advance(CharIterator* it, size_t n_bytes) {
1018
+ assert(it != nullptr);
1019
+ it->chunk_iterator_.AdvanceBytes(n_bytes);
1020
+ }
1021
+
1022
+ inline absl::string_view Cord::ChunkRemaining(const CharIterator& it) {
1023
+ return *it.chunk_iterator_;
1024
+ }
1025
+
1026
+ inline Cord::CharIterator Cord::char_begin() const {
1027
+ return CharIterator(this);
1028
+ }
1029
+
1030
+ inline Cord::CharIterator Cord::char_end() const { return CharIterator(); }
1031
+
1032
+ inline Cord::CharIterator Cord::CharRange::begin() const {
1033
+ return cord_->char_begin();
1034
+ }
1035
+
1036
+ inline Cord::CharIterator Cord::CharRange::end() const {
1037
+ return cord_->char_end();
1038
+ }
1039
+
1040
+ inline Cord::CharRange Cord::Chars() const { return CharRange(this); }
1041
+
1042
+ inline void Cord::ForEachChunk(
1043
+ absl::FunctionRef<void(absl::string_view)> callback) const {
1044
+ absl::cord_internal::CordRep* rep = contents_.tree();
1045
+ if (rep == nullptr) {
1046
+ callback(absl::string_view(contents_.data(), contents_.size()));
1047
+ } else {
1048
+ return ForEachChunkAux(rep, callback);
1049
+ }
1050
+ }
1051
+
1052
+ // Nonmember Cord-to-Cord relational operarators.
1053
+ inline bool operator==(const Cord& lhs, const Cord& rhs) {
1054
+ if (lhs.contents_.IsSame(rhs.contents_)) return true;
1055
+ size_t rhs_size = rhs.size();
1056
+ if (lhs.size() != rhs_size) return false;
1057
+ return lhs.EqualsImpl(rhs, rhs_size);
1058
+ }
1059
+
1060
+ inline bool operator!=(const Cord& x, const Cord& y) { return !(x == y); }
1061
+ inline bool operator<(const Cord& x, const Cord& y) {
1062
+ return x.Compare(y) < 0;
1063
+ }
1064
+ inline bool operator>(const Cord& x, const Cord& y) {
1065
+ return x.Compare(y) > 0;
1066
+ }
1067
+ inline bool operator<=(const Cord& x, const Cord& y) {
1068
+ return x.Compare(y) <= 0;
1069
+ }
1070
+ inline bool operator>=(const Cord& x, const Cord& y) {
1071
+ return x.Compare(y) >= 0;
1072
+ }
1073
+
1074
+ // Nonmember Cord-to-absl::string_view relational operators.
1075
+ //
1076
+ // Due to implicit conversions, these also enable comparisons of Cord with
1077
+ // with std::string, ::string, and const char*.
1078
+ inline bool operator==(const Cord& lhs, absl::string_view rhs) {
1079
+ size_t lhs_size = lhs.size();
1080
+ size_t rhs_size = rhs.size();
1081
+ if (lhs_size != rhs_size) return false;
1082
+ return lhs.EqualsImpl(rhs, rhs_size);
1083
+ }
1084
+
1085
+ inline bool operator==(absl::string_view x, const Cord& y) { return y == x; }
1086
+ inline bool operator!=(const Cord& x, absl::string_view y) { return !(x == y); }
1087
+ inline bool operator!=(absl::string_view x, const Cord& y) { return !(x == y); }
1088
+ inline bool operator<(const Cord& x, absl::string_view y) {
1089
+ return x.Compare(y) < 0;
1090
+ }
1091
+ inline bool operator<(absl::string_view x, const Cord& y) {
1092
+ return y.Compare(x) > 0;
1093
+ }
1094
+ inline bool operator>(const Cord& x, absl::string_view y) { return y < x; }
1095
+ inline bool operator>(absl::string_view x, const Cord& y) { return y < x; }
1096
+ inline bool operator<=(const Cord& x, absl::string_view y) { return !(y < x); }
1097
+ inline bool operator<=(absl::string_view x, const Cord& y) { return !(y < x); }
1098
+ inline bool operator>=(const Cord& x, absl::string_view y) { return !(x < y); }
1099
+ inline bool operator>=(absl::string_view x, const Cord& y) { return !(x < y); }
1100
+
1101
+ // Overload of swap for Cord. The use of non-const references is
1102
+ // required. :(
1103
+ inline void swap(Cord& x, Cord& y) noexcept { y.contents_.Swap(&x.contents_); }
1104
+
1105
+ // Some internals exposed to test code.
1106
+ namespace strings_internal {
1107
+ class CordTestAccess {
1108
+ public:
1109
+ static size_t FlatOverhead();
1110
+ static size_t MaxFlatLength();
1111
+ static size_t SizeofCordRepConcat();
1112
+ static size_t SizeofCordRepExternal();
1113
+ static size_t SizeofCordRepSubstring();
1114
+ static size_t FlatTagToLength(uint8_t tag);
1115
+ static uint8_t LengthToTag(size_t s);
1116
+ };
1117
+ } // namespace strings_internal
1118
+ ABSL_NAMESPACE_END
1119
+ } // namespace absl
1120
+
1121
+ #endif // ABSL_STRINGS_CORD_H_