clickhouse-native 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (260) hide show
  1. checksums.yaml +7 -0
  2. data/ext/clickhouse_native/client.cpp +847 -0
  3. data/ext/clickhouse_native/extconf.rb +101 -0
  4. data/ext/clickhouse_native/vendor/clickhouse-cpp/.clang-format +11 -0
  5. data/ext/clickhouse_native/vendor/clickhouse-cpp/.git +1 -0
  6. data/ext/clickhouse_native/vendor/clickhouse-cpp/.gitattributes +63 -0
  7. data/ext/clickhouse_native/vendor/clickhouse-cpp/.github/CODEOWNERS +1 -0
  8. data/ext/clickhouse_native/vendor/clickhouse-cpp/.github/workflows/linux.yml +139 -0
  9. data/ext/clickhouse_native/vendor/clickhouse-cpp/.github/workflows/macos.yml +87 -0
  10. data/ext/clickhouse_native/vendor/clickhouse-cpp/.github/workflows/windows_mingw.yml +102 -0
  11. data/ext/clickhouse_native/vendor/clickhouse-cpp/.github/workflows/windows_msvc.yml +74 -0
  12. data/ext/clickhouse_native/vendor/clickhouse-cpp/.gitignore +280 -0
  13. data/ext/clickhouse_native/vendor/clickhouse-cpp/.travis.yml +62 -0
  14. data/ext/clickhouse_native/vendor/clickhouse-cpp/CMakeLists.txt +157 -0
  15. data/ext/clickhouse_native/vendor/clickhouse-cpp/LICENSE +206 -0
  16. data/ext/clickhouse_native/vendor/clickhouse-cpp/README.md +260 -0
  17. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/CMakeLists.txt +246 -0
  18. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/base/buffer.h +10 -0
  19. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/base/compressed.cpp +258 -0
  20. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/base/compressed.h +48 -0
  21. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/base/endpoints_iterator.cpp +20 -0
  22. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/base/endpoints_iterator.h +34 -0
  23. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/base/input.cpp +96 -0
  24. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/base/input.h +103 -0
  25. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/base/open_telemetry.h +23 -0
  26. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/base/output.cpp +119 -0
  27. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/base/output.h +142 -0
  28. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/base/platform.cpp +1 -0
  29. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/base/platform.h +33 -0
  30. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/base/projected_iterator.h +55 -0
  31. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/base/singleton.h +11 -0
  32. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/base/socket.cpp +489 -0
  33. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/base/socket.h +177 -0
  34. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/base/sslsocket.cpp +307 -0
  35. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/base/sslsocket.h +111 -0
  36. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/base/string_utils.h +28 -0
  37. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/base/string_view.h +142 -0
  38. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/base/uuid.h +10 -0
  39. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/base/wire_format.cpp +177 -0
  40. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/base/wire_format.h +79 -0
  41. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/block.cpp +134 -0
  42. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/block.h +114 -0
  43. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/client.cpp +1269 -0
  44. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/client.h +320 -0
  45. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/array.cpp +175 -0
  46. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/array.h +321 -0
  47. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/column.cpp +24 -0
  48. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/column.h +107 -0
  49. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/date.cpp +365 -0
  50. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/date.h +245 -0
  51. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/decimal.cpp +255 -0
  52. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/decimal.h +50 -0
  53. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/enum.cpp +123 -0
  54. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/enum.h +65 -0
  55. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/factory.cpp +285 -0
  56. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/factory.h +14 -0
  57. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/geo.cpp +108 -0
  58. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/geo.h +79 -0
  59. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/ip4.cpp +117 -0
  60. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/ip4.h +71 -0
  61. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/ip6.cpp +108 -0
  62. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/ip6.h +66 -0
  63. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/itemview.cpp +101 -0
  64. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/itemview.h +86 -0
  65. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/lowcardinality.cpp +527 -0
  66. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/lowcardinality.h +221 -0
  67. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/lowcardinalityadaptor.h +63 -0
  68. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/map.cpp +87 -0
  69. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/map.h +257 -0
  70. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/nothing.h +87 -0
  71. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/nullable.cpp +109 -0
  72. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/nullable.h +153 -0
  73. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/numeric.cpp +126 -0
  74. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/numeric.h +88 -0
  75. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/string.cpp +333 -0
  76. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/string.h +145 -0
  77. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/time.cpp +155 -0
  78. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/time.h +118 -0
  79. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/tuple.cpp +106 -0
  80. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/tuple.h +178 -0
  81. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/utils.h +41 -0
  82. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/uuid.cpp +80 -0
  83. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/uuid.h +58 -0
  84. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/error_codes.h +595 -0
  85. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/exceptions.h +66 -0
  86. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/protocol.h +54 -0
  87. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/query.cpp +25 -0
  88. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/query.h +246 -0
  89. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/server_exception.h +16 -0
  90. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/types/type_parser.cpp +314 -0
  91. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/types/type_parser.h +89 -0
  92. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/types/types.cpp +484 -0
  93. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/types/types.h +397 -0
  94. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/version.h +14 -0
  95. data/ext/clickhouse_native/vendor/clickhouse-cpp/cmake/Findcityhash.cmake +26 -0
  96. data/ext/clickhouse_native/vendor/clickhouse-cpp/cmake/Findlz4.cmake +39 -0
  97. data/ext/clickhouse_native/vendor/clickhouse-cpp/cmake/Findzstd.cmake +39 -0
  98. data/ext/clickhouse_native/vendor/clickhouse-cpp/cmake/cpp17.cmake +8 -0
  99. data/ext/clickhouse_native/vendor/clickhouse-cpp/cmake/openssl.cmake +8 -0
  100. data/ext/clickhouse_native/vendor/clickhouse-cpp/cmake/subdirs.cmake +5 -0
  101. data/ext/clickhouse_native/vendor/clickhouse-cpp/cmake/version.cmake +87 -0
  102. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/absl/absl/CMakeLists.txt +9 -0
  103. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/absl/absl/base/attributes.h +682 -0
  104. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/absl/absl/base/config.h +714 -0
  105. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/absl/absl/base/internal/bits.h +219 -0
  106. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/absl/absl/base/macros.h +147 -0
  107. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/absl/absl/base/optimization.h +241 -0
  108. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/absl/absl/base/options.h +238 -0
  109. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/absl/absl/base/policy_checks.h +111 -0
  110. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/absl/absl/base/port.h +26 -0
  111. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/absl/absl/numeric/int128.cc +390 -0
  112. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/absl/absl/numeric/int128.h +1092 -0
  113. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/absl/absl/numeric/int128_have_intrinsic.inc +302 -0
  114. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/absl/absl/numeric/int128_no_intrinsic.inc +308 -0
  115. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/cityhash/cityhash/BUCK +13 -0
  116. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/cityhash/cityhash/CMakeLists.txt +7 -0
  117. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/cityhash/cityhash/COPYING +19 -0
  118. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/cityhash/cityhash/city.cc +469 -0
  119. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/cityhash/cityhash/city.h +90 -0
  120. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/cityhash/cityhash/citycrc.h +43 -0
  121. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/cityhash/cityhash/config.h +118 -0
  122. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/BUCK +14 -0
  123. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/CMakeLists.txt +4 -0
  124. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/LICENSE +28 -0
  125. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/README.md +1 -0
  126. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/include/gtest/gtest-death-test.h +346 -0
  127. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/include/gtest/gtest-matchers.h +930 -0
  128. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/include/gtest/gtest-message.h +219 -0
  129. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/include/gtest/gtest-param-test.h +507 -0
  130. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/include/gtest/gtest-printers.h +1029 -0
  131. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/include/gtest/gtest-spi.h +238 -0
  132. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/include/gtest/gtest-test-part.h +184 -0
  133. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/include/gtest/gtest-typed-test.h +329 -0
  134. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/include/gtest/gtest.h +2495 -0
  135. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/include/gtest/gtest_pred_impl.h +359 -0
  136. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/include/gtest/gtest_prod.h +61 -0
  137. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/include/gtest/internal/custom/README.md +56 -0
  138. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/include/gtest/internal/custom/gtest-port.h +37 -0
  139. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/include/gtest/internal/custom/gtest-printers.h +42 -0
  140. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/include/gtest/internal/custom/gtest.h +37 -0
  141. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/include/gtest/internal/gtest-death-test-internal.h +304 -0
  142. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/include/gtest/internal/gtest-filepath.h +211 -0
  143. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/include/gtest/internal/gtest-internal.h +1560 -0
  144. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/include/gtest/internal/gtest-param-util.h +947 -0
  145. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/include/gtest/internal/gtest-port-arch.h +114 -0
  146. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/include/gtest/internal/gtest-port.h +2389 -0
  147. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/include/gtest/internal/gtest-string.h +175 -0
  148. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/include/gtest/internal/gtest-type-util.h +183 -0
  149. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/src/gtest-all.cc +48 -0
  150. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/src/gtest-death-test.cc +1644 -0
  151. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/src/gtest-filepath.cc +369 -0
  152. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/src/gtest-internal-inl.h +1221 -0
  153. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/src/gtest-matchers.cc +97 -0
  154. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/src/gtest-port.cc +1433 -0
  155. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/src/gtest-printers.cc +533 -0
  156. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/src/gtest-test-part.cc +108 -0
  157. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/src/gtest-typed-test.cc +107 -0
  158. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/src/gtest.cc +6746 -0
  159. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/src/gtest_main.cc +54 -0
  160. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/lz4/lz4/BUCK +13 -0
  161. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/lz4/lz4/CMakeLists.txt +8 -0
  162. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/lz4/lz4/LICENSE +24 -0
  163. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/lz4/lz4/lz4.c +2402 -0
  164. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/lz4/lz4/lz4.h +764 -0
  165. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/lz4/lz4/lz4hc.c +1554 -0
  166. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/lz4/lz4/lz4hc.h +438 -0
  167. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/BUCK +232 -0
  168. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/CMakeLists.txt +115 -0
  169. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/LICENSE +30 -0
  170. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/common/allocations.h +55 -0
  171. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/common/bits.h +200 -0
  172. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/common/bitstream.h +437 -0
  173. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/common/compiler.h +358 -0
  174. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/common/cpu.h +213 -0
  175. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/common/debug.c +24 -0
  176. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/common/debug.h +107 -0
  177. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/common/entropy_common.c +340 -0
  178. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/common/error_private.c +63 -0
  179. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/common/error_private.h +159 -0
  180. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/common/fse.h +639 -0
  181. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/common/fse_decompress.c +311 -0
  182. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/common/huf.h +273 -0
  183. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/common/mem.h +435 -0
  184. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/common/pool.c +371 -0
  185. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/common/pool.h +90 -0
  186. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/common/portability_macros.h +156 -0
  187. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/common/threading.c +176 -0
  188. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/common/threading.h +150 -0
  189. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/common/xxhash.c +24 -0
  190. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/common/xxhash.h +5686 -0
  191. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/common/zstd_common.c +48 -0
  192. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/common/zstd_deps.h +111 -0
  193. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/common/zstd_internal.h +392 -0
  194. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/common/zstd_trace.h +163 -0
  195. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/compress/clevels.h +134 -0
  196. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/compress/fse_compress.c +624 -0
  197. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/compress/hist.c +181 -0
  198. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/compress/hist.h +75 -0
  199. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/compress/huf_compress.c +1435 -0
  200. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/compress/zstd_compress.c +7032 -0
  201. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/compress/zstd_compress_internal.h +1532 -0
  202. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/compress/zstd_compress_literals.c +235 -0
  203. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/compress/zstd_compress_literals.h +39 -0
  204. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/compress/zstd_compress_sequences.c +442 -0
  205. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/compress/zstd_compress_sequences.h +54 -0
  206. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/compress/zstd_compress_superblock.c +577 -0
  207. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/compress/zstd_compress_superblock.h +32 -0
  208. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/compress/zstd_cwksp.h +742 -0
  209. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/compress/zstd_double_fast.c +758 -0
  210. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/compress/zstd_double_fast.h +39 -0
  211. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/compress/zstd_fast.c +960 -0
  212. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/compress/zstd_fast.h +38 -0
  213. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/compress/zstd_lazy.c +2157 -0
  214. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/compress/zstd_lazy.h +127 -0
  215. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/compress/zstd_ldm.c +724 -0
  216. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/compress/zstd_ldm.h +117 -0
  217. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/compress/zstd_ldm_geartab.h +106 -0
  218. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/compress/zstd_opt.c +1472 -0
  219. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/compress/zstd_opt.h +56 -0
  220. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/compress/zstdmt_compress.c +1867 -0
  221. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/compress/zstdmt_compress.h +113 -0
  222. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/decompress/huf_decompress.c +1882 -0
  223. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/decompress/huf_decompress_amd64.S +576 -0
  224. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/decompress/zstd_ddict.c +244 -0
  225. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/decompress/zstd_ddict.h +44 -0
  226. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/decompress/zstd_decompress.c +2355 -0
  227. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/decompress/zstd_decompress_block.c +2192 -0
  228. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/decompress/zstd_decompress_block.h +73 -0
  229. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/decompress/zstd_decompress_internal.h +238 -0
  230. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/dictBuilder/cover.c +1257 -0
  231. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/dictBuilder/cover.h +158 -0
  232. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/dictBuilder/divsufsort.c +1913 -0
  233. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/dictBuilder/divsufsort.h +67 -0
  234. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/dictBuilder/fastcover.c +766 -0
  235. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/dictBuilder/zdict.c +1127 -0
  236. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/legacy/zstd_legacy.h +422 -0
  237. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/legacy/zstd_v01.c +2125 -0
  238. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/legacy/zstd_v01.h +94 -0
  239. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/legacy/zstd_v02.c +3477 -0
  240. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/legacy/zstd_v02.h +93 -0
  241. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/legacy/zstd_v03.c +3117 -0
  242. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/legacy/zstd_v03.h +93 -0
  243. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/legacy/zstd_v04.c +3605 -0
  244. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/legacy/zstd_v04.h +142 -0
  245. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/legacy/zstd_v05.c +4004 -0
  246. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/legacy/zstd_v05.h +162 -0
  247. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/legacy/zstd_v06.c +4113 -0
  248. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/legacy/zstd_v06.h +172 -0
  249. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/legacy/zstd_v07.c +4498 -0
  250. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/legacy/zstd_v07.h +187 -0
  251. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/zdict.h +474 -0
  252. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/zstd.h +3020 -0
  253. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/zstd_errors.h +114 -0
  254. data/lib/clickhouse_native/clickhouse_native.bundle +0 -0
  255. data/lib/clickhouse_native/client.rb +50 -0
  256. data/lib/clickhouse_native/errors.rb +23 -0
  257. data/lib/clickhouse_native/pool.rb +49 -0
  258. data/lib/clickhouse_native/version.rb +3 -0
  259. data/lib/clickhouse_native.rb +8 -0
  260. metadata +369 -0
@@ -0,0 +1,1029 @@
1
+ // Copyright 2007, Google Inc.
2
+ // All rights reserved.
3
+ //
4
+ // Redistribution and use in source and binary forms, with or without
5
+ // modification, are permitted provided that the following conditions are
6
+ // met:
7
+ //
8
+ // * Redistributions of source code must retain the above copyright
9
+ // notice, this list of conditions and the following disclaimer.
10
+ // * Redistributions in binary form must reproduce the above
11
+ // copyright notice, this list of conditions and the following disclaimer
12
+ // in the documentation and/or other materials provided with the
13
+ // distribution.
14
+ // * Neither the name of Google Inc. nor the names of its
15
+ // contributors may be used to endorse or promote products derived from
16
+ // this software without specific prior written permission.
17
+ //
18
+ // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19
+ // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20
+ // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21
+ // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22
+ // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23
+ // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24
+ // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25
+ // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26
+ // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27
+ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28
+ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
+
30
+
31
+ // Google Test - The Google C++ Testing and Mocking Framework
32
+ //
33
+ // This file implements a universal value printer that can print a
34
+ // value of any type T:
35
+ //
36
+ // void ::testing::internal::UniversalPrinter<T>::Print(value, ostream_ptr);
37
+ //
38
+ // A user can teach this function how to print a class type T by
39
+ // defining either operator<<() or PrintTo() in the namespace that
40
+ // defines T. More specifically, the FIRST defined function in the
41
+ // following list will be used (assuming T is defined in namespace
42
+ // foo):
43
+ //
44
+ // 1. foo::PrintTo(const T&, ostream*)
45
+ // 2. operator<<(ostream&, const T&) defined in either foo or the
46
+ // global namespace.
47
+ //
48
+ // However if T is an STL-style container then it is printed element-wise
49
+ // unless foo::PrintTo(const T&, ostream*) is defined. Note that
50
+ // operator<<() is ignored for container types.
51
+ //
52
+ // If none of the above is defined, it will print the debug string of
53
+ // the value if it is a protocol buffer, or print the raw bytes in the
54
+ // value otherwise.
55
+ //
56
+ // To aid debugging: when T is a reference type, the address of the
57
+ // value is also printed; when T is a (const) char pointer, both the
58
+ // pointer value and the NUL-terminated string it points to are
59
+ // printed.
60
+ //
61
+ // We also provide some convenient wrappers:
62
+ //
63
+ // // Prints a value to a string. For a (const or not) char
64
+ // // pointer, the NUL-terminated string (but not the pointer) is
65
+ // // printed.
66
+ // std::string ::testing::PrintToString(const T& value);
67
+ //
68
+ // // Prints a value tersely: for a reference type, the referenced
69
+ // // value (but not the address) is printed; for a (const or not) char
70
+ // // pointer, the NUL-terminated string (but not the pointer) is
71
+ // // printed.
72
+ // void ::testing::internal::UniversalTersePrint(const T& value, ostream*);
73
+ //
74
+ // // Prints value using the type inferred by the compiler. The difference
75
+ // // from UniversalTersePrint() is that this function prints both the
76
+ // // pointer and the NUL-terminated string for a (const or not) char pointer.
77
+ // void ::testing::internal::UniversalPrint(const T& value, ostream*);
78
+ //
79
+ // // Prints the fields of a tuple tersely to a string vector, one
80
+ // // element for each field. Tuple support must be enabled in
81
+ // // gtest-port.h.
82
+ // std::vector<string> UniversalTersePrintTupleFieldsToStrings(
83
+ // const Tuple& value);
84
+ //
85
+ // Known limitation:
86
+ //
87
+ // The print primitives print the elements of an STL-style container
88
+ // using the compiler-inferred type of *iter where iter is a
89
+ // const_iterator of the container. When const_iterator is an input
90
+ // iterator but not a forward iterator, this inferred type may not
91
+ // match value_type, and the print output may be incorrect. In
92
+ // practice, this is rarely a problem as for most containers
93
+ // const_iterator is a forward iterator. We'll fix this if there's an
94
+ // actual need for it. Note that this fix cannot rely on value_type
95
+ // being defined as many user-defined container types don't have
96
+ // value_type.
97
+
98
+ // GOOGLETEST_CM0001 DO NOT DELETE
99
+
100
+ #ifndef GOOGLETEST_INCLUDE_GTEST_GTEST_PRINTERS_H_
101
+ #define GOOGLETEST_INCLUDE_GTEST_GTEST_PRINTERS_H_
102
+
103
+ #include <functional>
104
+ #include <memory>
105
+ #include <ostream> // NOLINT
106
+ #include <sstream>
107
+ #include <string>
108
+ #include <tuple>
109
+ #include <type_traits>
110
+ #include <utility>
111
+ #include <vector>
112
+
113
+ #include "gtest/internal/gtest-internal.h"
114
+ #include "gtest/internal/gtest-port.h"
115
+
116
+ namespace testing {
117
+
118
+ // Definitions in the internal* namespaces are subject to change without notice.
119
+ // DO NOT USE THEM IN USER CODE!
120
+ namespace internal {
121
+
122
+ template <typename T>
123
+ void UniversalPrint(const T& value, ::std::ostream* os);
124
+
125
+ // Used to print an STL-style container when the user doesn't define
126
+ // a PrintTo() for it.
127
+ struct ContainerPrinter {
128
+ template <typename T,
129
+ typename = typename std::enable_if<
130
+ (sizeof(IsContainerTest<T>(0)) == sizeof(IsContainer)) &&
131
+ !IsRecursiveContainer<T>::value>::type>
132
+ static void PrintValue(const T& container, std::ostream* os) {
133
+ const size_t kMaxCount = 32; // The maximum number of elements to print.
134
+ *os << '{';
135
+ size_t count = 0;
136
+ for (auto&& elem : container) {
137
+ if (count > 0) {
138
+ *os << ',';
139
+ if (count == kMaxCount) { // Enough has been printed.
140
+ *os << " ...";
141
+ break;
142
+ }
143
+ }
144
+ *os << ' ';
145
+ // We cannot call PrintTo(elem, os) here as PrintTo() doesn't
146
+ // handle `elem` being a native array.
147
+ internal::UniversalPrint(elem, os);
148
+ ++count;
149
+ }
150
+
151
+ if (count > 0) {
152
+ *os << ' ';
153
+ }
154
+ *os << '}';
155
+ }
156
+ };
157
+
158
+ // Used to print a pointer that is neither a char pointer nor a member
159
+ // pointer, when the user doesn't define PrintTo() for it. (A member
160
+ // variable pointer or member function pointer doesn't really point to
161
+ // a location in the address space. Their representation is
162
+ // implementation-defined. Therefore they will be printed as raw
163
+ // bytes.)
164
+ struct FunctionPointerPrinter {
165
+ template <typename T, typename = typename std::enable_if<
166
+ std::is_function<T>::value>::type>
167
+ static void PrintValue(T* p, ::std::ostream* os) {
168
+ if (p == nullptr) {
169
+ *os << "NULL";
170
+ } else {
171
+ // T is a function type, so '*os << p' doesn't do what we want
172
+ // (it just prints p as bool). We want to print p as a const
173
+ // void*.
174
+ *os << reinterpret_cast<const void*>(p);
175
+ }
176
+ }
177
+ };
178
+
179
+ struct PointerPrinter {
180
+ template <typename T>
181
+ static void PrintValue(T* p, ::std::ostream* os) {
182
+ if (p == nullptr) {
183
+ *os << "NULL";
184
+ } else {
185
+ // T is not a function type. We just call << to print p,
186
+ // relying on ADL to pick up user-defined << for their pointer
187
+ // types, if any.
188
+ *os << p;
189
+ }
190
+ }
191
+ };
192
+
193
+ namespace internal_stream_operator_without_lexical_name_lookup {
194
+
195
+ // The presence of an operator<< here will terminate lexical scope lookup
196
+ // straight away (even though it cannot be a match because of its argument
197
+ // types). Thus, the two operator<< calls in StreamPrinter will find only ADL
198
+ // candidates.
199
+ struct LookupBlocker {};
200
+ void operator<<(LookupBlocker, LookupBlocker);
201
+
202
+ struct StreamPrinter {
203
+ template <typename T,
204
+ // Don't accept member pointers here. We'd print them via implicit
205
+ // conversion to bool, which isn't useful.
206
+ typename = typename std::enable_if<
207
+ !std::is_member_pointer<T>::value>::type,
208
+ // Only accept types for which we can find a streaming operator via
209
+ // ADL (possibly involving implicit conversions).
210
+ typename = decltype(std::declval<std::ostream&>()
211
+ << std::declval<const T&>())>
212
+ static void PrintValue(const T& value, ::std::ostream* os) {
213
+ // Call streaming operator found by ADL, possibly with implicit conversions
214
+ // of the arguments.
215
+ *os << value;
216
+ }
217
+ };
218
+
219
+ } // namespace internal_stream_operator_without_lexical_name_lookup
220
+
221
+ struct ProtobufPrinter {
222
+ // We print a protobuf using its ShortDebugString() when the string
223
+ // doesn't exceed this many characters; otherwise we print it using
224
+ // DebugString() for better readability.
225
+ static const size_t kProtobufOneLinerMaxLength = 50;
226
+
227
+ template <typename T,
228
+ typename = typename std::enable_if<
229
+ internal::HasDebugStringAndShortDebugString<T>::value>::type>
230
+ static void PrintValue(const T& value, ::std::ostream* os) {
231
+ std::string pretty_str = value.ShortDebugString();
232
+ if (pretty_str.length() > kProtobufOneLinerMaxLength) {
233
+ pretty_str = "\n" + value.DebugString();
234
+ }
235
+ *os << ("<" + pretty_str + ">");
236
+ }
237
+ };
238
+
239
+ struct ConvertibleToIntegerPrinter {
240
+ // Since T has no << operator or PrintTo() but can be implicitly
241
+ // converted to BiggestInt, we print it as a BiggestInt.
242
+ //
243
+ // Most likely T is an enum type (either named or unnamed), in which
244
+ // case printing it as an integer is the desired behavior. In case
245
+ // T is not an enum, printing it as an integer is the best we can do
246
+ // given that it has no user-defined printer.
247
+ static void PrintValue(internal::BiggestInt value, ::std::ostream* os) {
248
+ *os << value;
249
+ }
250
+ };
251
+
252
+ struct ConvertibleToStringViewPrinter {
253
+ #if GTEST_INTERNAL_HAS_STRING_VIEW
254
+ static void PrintValue(internal::StringView value, ::std::ostream* os) {
255
+ internal::UniversalPrint(value, os);
256
+ }
257
+ #endif
258
+ };
259
+
260
+
261
+ // Prints the given number of bytes in the given object to the given
262
+ // ostream.
263
+ GTEST_API_ void PrintBytesInObjectTo(const unsigned char* obj_bytes,
264
+ size_t count,
265
+ ::std::ostream* os);
266
+ struct RawBytesPrinter {
267
+ // SFINAE on `sizeof` to make sure we have a complete type.
268
+ template <typename T, size_t = sizeof(T)>
269
+ static void PrintValue(const T& value, ::std::ostream* os) {
270
+ PrintBytesInObjectTo(
271
+ static_cast<const unsigned char*>(
272
+ // Load bearing cast to void* to support iOS
273
+ reinterpret_cast<const void*>(std::addressof(value))),
274
+ sizeof(value), os);
275
+ }
276
+ };
277
+
278
+ struct FallbackPrinter {
279
+ template <typename T>
280
+ static void PrintValue(const T&, ::std::ostream* os) {
281
+ *os << "(incomplete type)";
282
+ }
283
+ };
284
+
285
+ // Try every printer in order and return the first one that works.
286
+ template <typename T, typename E, typename Printer, typename... Printers>
287
+ struct FindFirstPrinter : FindFirstPrinter<T, E, Printers...> {};
288
+
289
+ template <typename T, typename Printer, typename... Printers>
290
+ struct FindFirstPrinter<
291
+ T, decltype(Printer::PrintValue(std::declval<const T&>(), nullptr)),
292
+ Printer, Printers...> {
293
+ using type = Printer;
294
+ };
295
+
296
+ // Select the best printer in the following order:
297
+ // - Print containers (they have begin/end/etc).
298
+ // - Print function pointers.
299
+ // - Print object pointers.
300
+ // - Use the stream operator, if available.
301
+ // - Print protocol buffers.
302
+ // - Print types convertible to BiggestInt.
303
+ // - Print types convertible to StringView, if available.
304
+ // - Fallback to printing the raw bytes of the object.
305
+ template <typename T>
306
+ void PrintWithFallback(const T& value, ::std::ostream* os) {
307
+ using Printer = typename FindFirstPrinter<
308
+ T, void, ContainerPrinter, FunctionPointerPrinter, PointerPrinter,
309
+ internal_stream_operator_without_lexical_name_lookup::StreamPrinter,
310
+ ProtobufPrinter, ConvertibleToIntegerPrinter,
311
+ ConvertibleToStringViewPrinter, RawBytesPrinter, FallbackPrinter>::type;
312
+ Printer::PrintValue(value, os);
313
+ }
314
+
315
+ // FormatForComparison<ToPrint, OtherOperand>::Format(value) formats a
316
+ // value of type ToPrint that is an operand of a comparison assertion
317
+ // (e.g. ASSERT_EQ). OtherOperand is the type of the other operand in
318
+ // the comparison, and is used to help determine the best way to
319
+ // format the value. In particular, when the value is a C string
320
+ // (char pointer) and the other operand is an STL string object, we
321
+ // want to format the C string as a string, since we know it is
322
+ // compared by value with the string object. If the value is a char
323
+ // pointer but the other operand is not an STL string object, we don't
324
+ // know whether the pointer is supposed to point to a NUL-terminated
325
+ // string, and thus want to print it as a pointer to be safe.
326
+ //
327
+ // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
328
+
329
+ // The default case.
330
+ template <typename ToPrint, typename OtherOperand>
331
+ class FormatForComparison {
332
+ public:
333
+ static ::std::string Format(const ToPrint& value) {
334
+ return ::testing::PrintToString(value);
335
+ }
336
+ };
337
+
338
+ // Array.
339
+ template <typename ToPrint, size_t N, typename OtherOperand>
340
+ class FormatForComparison<ToPrint[N], OtherOperand> {
341
+ public:
342
+ static ::std::string Format(const ToPrint* value) {
343
+ return FormatForComparison<const ToPrint*, OtherOperand>::Format(value);
344
+ }
345
+ };
346
+
347
+ // By default, print C string as pointers to be safe, as we don't know
348
+ // whether they actually point to a NUL-terminated string.
349
+
350
+ #define GTEST_IMPL_FORMAT_C_STRING_AS_POINTER_(CharType) \
351
+ template <typename OtherOperand> \
352
+ class FormatForComparison<CharType*, OtherOperand> { \
353
+ public: \
354
+ static ::std::string Format(CharType* value) { \
355
+ return ::testing::PrintToString(static_cast<const void*>(value)); \
356
+ } \
357
+ }
358
+
359
+ GTEST_IMPL_FORMAT_C_STRING_AS_POINTER_(char);
360
+ GTEST_IMPL_FORMAT_C_STRING_AS_POINTER_(const char);
361
+ GTEST_IMPL_FORMAT_C_STRING_AS_POINTER_(wchar_t);
362
+ GTEST_IMPL_FORMAT_C_STRING_AS_POINTER_(const wchar_t);
363
+ #ifdef __cpp_char8_t
364
+ GTEST_IMPL_FORMAT_C_STRING_AS_POINTER_(char8_t);
365
+ GTEST_IMPL_FORMAT_C_STRING_AS_POINTER_(const char8_t);
366
+ #endif
367
+ GTEST_IMPL_FORMAT_C_STRING_AS_POINTER_(char16_t);
368
+ GTEST_IMPL_FORMAT_C_STRING_AS_POINTER_(const char16_t);
369
+ GTEST_IMPL_FORMAT_C_STRING_AS_POINTER_(char32_t);
370
+ GTEST_IMPL_FORMAT_C_STRING_AS_POINTER_(const char32_t);
371
+
372
+ #undef GTEST_IMPL_FORMAT_C_STRING_AS_POINTER_
373
+
374
+ // If a C string is compared with an STL string object, we know it's meant
375
+ // to point to a NUL-terminated string, and thus can print it as a string.
376
+
377
+ #define GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(CharType, OtherStringType) \
378
+ template <> \
379
+ class FormatForComparison<CharType*, OtherStringType> { \
380
+ public: \
381
+ static ::std::string Format(CharType* value) { \
382
+ return ::testing::PrintToString(value); \
383
+ } \
384
+ }
385
+
386
+ GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(char, ::std::string);
387
+ GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(const char, ::std::string);
388
+ #ifdef __cpp_char8_t
389
+ GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(char8_t, ::std::u8string);
390
+ GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(const char8_t, ::std::u8string);
391
+ #endif
392
+ GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(char16_t, ::std::u16string);
393
+ GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(const char16_t, ::std::u16string);
394
+ GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(char32_t, ::std::u32string);
395
+ GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(const char32_t, ::std::u32string);
396
+
397
+ #if GTEST_HAS_STD_WSTRING
398
+ GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(wchar_t, ::std::wstring);
399
+ GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(const wchar_t, ::std::wstring);
400
+ #endif
401
+
402
+ #undef GTEST_IMPL_FORMAT_C_STRING_AS_STRING_
403
+
404
+ // Formats a comparison assertion (e.g. ASSERT_EQ, EXPECT_LT, and etc)
405
+ // operand to be used in a failure message. The type (but not value)
406
+ // of the other operand may affect the format. This allows us to
407
+ // print a char* as a raw pointer when it is compared against another
408
+ // char* or void*, and print it as a C string when it is compared
409
+ // against an std::string object, for example.
410
+ //
411
+ // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
412
+ template <typename T1, typename T2>
413
+ std::string FormatForComparisonFailureMessage(
414
+ const T1& value, const T2& /* other_operand */) {
415
+ return FormatForComparison<T1, T2>::Format(value);
416
+ }
417
+
418
+ // UniversalPrinter<T>::Print(value, ostream_ptr) prints the given
419
+ // value to the given ostream. The caller must ensure that
420
+ // 'ostream_ptr' is not NULL, or the behavior is undefined.
421
+ //
422
+ // We define UniversalPrinter as a class template (as opposed to a
423
+ // function template), as we need to partially specialize it for
424
+ // reference types, which cannot be done with function templates.
425
+ template <typename T>
426
+ class UniversalPrinter;
427
+
428
+ // Prints the given value using the << operator if it has one;
429
+ // otherwise prints the bytes in it. This is what
430
+ // UniversalPrinter<T>::Print() does when PrintTo() is not specialized
431
+ // or overloaded for type T.
432
+ //
433
+ // A user can override this behavior for a class type Foo by defining
434
+ // an overload of PrintTo() in the namespace where Foo is defined. We
435
+ // give the user this option as sometimes defining a << operator for
436
+ // Foo is not desirable (e.g. the coding style may prevent doing it,
437
+ // or there is already a << operator but it doesn't do what the user
438
+ // wants).
439
+ template <typename T>
440
+ void PrintTo(const T& value, ::std::ostream* os) {
441
+ internal::PrintWithFallback(value, os);
442
+ }
443
+
444
+ // The following list of PrintTo() overloads tells
445
+ // UniversalPrinter<T>::Print() how to print standard types (built-in
446
+ // types, strings, plain arrays, and pointers).
447
+
448
+ // Overloads for various char types.
449
+ GTEST_API_ void PrintTo(unsigned char c, ::std::ostream* os);
450
+ GTEST_API_ void PrintTo(signed char c, ::std::ostream* os);
451
+ inline void PrintTo(char c, ::std::ostream* os) {
452
+ // When printing a plain char, we always treat it as unsigned. This
453
+ // way, the output won't be affected by whether the compiler thinks
454
+ // char is signed or not.
455
+ PrintTo(static_cast<unsigned char>(c), os);
456
+ }
457
+
458
+ // Overloads for other simple built-in types.
459
+ inline void PrintTo(bool x, ::std::ostream* os) {
460
+ *os << (x ? "true" : "false");
461
+ }
462
+
463
+ // Overload for wchar_t type.
464
+ // Prints a wchar_t as a symbol if it is printable or as its internal
465
+ // code otherwise and also as its decimal code (except for L'\0').
466
+ // The L'\0' char is printed as "L'\\0'". The decimal code is printed
467
+ // as signed integer when wchar_t is implemented by the compiler
468
+ // as a signed type and is printed as an unsigned integer when wchar_t
469
+ // is implemented as an unsigned type.
470
+ GTEST_API_ void PrintTo(wchar_t wc, ::std::ostream* os);
471
+
472
+ GTEST_API_ void PrintTo(char32_t c, ::std::ostream* os);
473
+ inline void PrintTo(char16_t c, ::std::ostream* os) {
474
+ PrintTo(ImplicitCast_<char32_t>(c), os);
475
+ }
476
+ #ifdef __cpp_char8_t
477
+ inline void PrintTo(char8_t c, ::std::ostream* os) {
478
+ PrintTo(ImplicitCast_<char32_t>(c), os);
479
+ }
480
+ #endif
481
+
482
+ // Overloads for C strings.
483
+ GTEST_API_ void PrintTo(const char* s, ::std::ostream* os);
484
+ inline void PrintTo(char* s, ::std::ostream* os) {
485
+ PrintTo(ImplicitCast_<const char*>(s), os);
486
+ }
487
+
488
+ // signed/unsigned char is often used for representing binary data, so
489
+ // we print pointers to it as void* to be safe.
490
+ inline void PrintTo(const signed char* s, ::std::ostream* os) {
491
+ PrintTo(ImplicitCast_<const void*>(s), os);
492
+ }
493
+ inline void PrintTo(signed char* s, ::std::ostream* os) {
494
+ PrintTo(ImplicitCast_<const void*>(s), os);
495
+ }
496
+ inline void PrintTo(const unsigned char* s, ::std::ostream* os) {
497
+ PrintTo(ImplicitCast_<const void*>(s), os);
498
+ }
499
+ inline void PrintTo(unsigned char* s, ::std::ostream* os) {
500
+ PrintTo(ImplicitCast_<const void*>(s), os);
501
+ }
502
+ #ifdef __cpp_char8_t
503
+ // Overloads for u8 strings.
504
+ GTEST_API_ void PrintTo(const char8_t* s, ::std::ostream* os);
505
+ inline void PrintTo(char8_t* s, ::std::ostream* os) {
506
+ PrintTo(ImplicitCast_<const char8_t*>(s), os);
507
+ }
508
+ #endif
509
+ // Overloads for u16 strings.
510
+ GTEST_API_ void PrintTo(const char16_t* s, ::std::ostream* os);
511
+ inline void PrintTo(char16_t* s, ::std::ostream* os) {
512
+ PrintTo(ImplicitCast_<const char16_t*>(s), os);
513
+ }
514
+ // Overloads for u32 strings.
515
+ GTEST_API_ void PrintTo(const char32_t* s, ::std::ostream* os);
516
+ inline void PrintTo(char32_t* s, ::std::ostream* os) {
517
+ PrintTo(ImplicitCast_<const char32_t*>(s), os);
518
+ }
519
+
520
+ // MSVC can be configured to define wchar_t as a typedef of unsigned
521
+ // short. It defines _NATIVE_WCHAR_T_DEFINED when wchar_t is a native
522
+ // type. When wchar_t is a typedef, defining an overload for const
523
+ // wchar_t* would cause unsigned short* be printed as a wide string,
524
+ // possibly causing invalid memory accesses.
525
+ #if !defined(_MSC_VER) || defined(_NATIVE_WCHAR_T_DEFINED)
526
+ // Overloads for wide C strings
527
+ GTEST_API_ void PrintTo(const wchar_t* s, ::std::ostream* os);
528
+ inline void PrintTo(wchar_t* s, ::std::ostream* os) {
529
+ PrintTo(ImplicitCast_<const wchar_t*>(s), os);
530
+ }
531
+ #endif
532
+
533
+ // Overload for C arrays. Multi-dimensional arrays are printed
534
+ // properly.
535
+
536
+ // Prints the given number of elements in an array, without printing
537
+ // the curly braces.
538
+ template <typename T>
539
+ void PrintRawArrayTo(const T a[], size_t count, ::std::ostream* os) {
540
+ UniversalPrint(a[0], os);
541
+ for (size_t i = 1; i != count; i++) {
542
+ *os << ", ";
543
+ UniversalPrint(a[i], os);
544
+ }
545
+ }
546
+
547
+ // Overloads for ::std::string.
548
+ GTEST_API_ void PrintStringTo(const ::std::string&s, ::std::ostream* os);
549
+ inline void PrintTo(const ::std::string& s, ::std::ostream* os) {
550
+ PrintStringTo(s, os);
551
+ }
552
+
553
+ // Overloads for ::std::u8string
554
+ #ifdef __cpp_char8_t
555
+ GTEST_API_ void PrintU8StringTo(const ::std::u8string& s, ::std::ostream* os);
556
+ inline void PrintTo(const ::std::u8string& s, ::std::ostream* os) {
557
+ PrintU8StringTo(s, os);
558
+ }
559
+ #endif
560
+
561
+ // Overloads for ::std::u16string
562
+ GTEST_API_ void PrintU16StringTo(const ::std::u16string& s, ::std::ostream* os);
563
+ inline void PrintTo(const ::std::u16string& s, ::std::ostream* os) {
564
+ PrintU16StringTo(s, os);
565
+ }
566
+
567
+ // Overloads for ::std::u32string
568
+ GTEST_API_ void PrintU32StringTo(const ::std::u32string& s, ::std::ostream* os);
569
+ inline void PrintTo(const ::std::u32string& s, ::std::ostream* os) {
570
+ PrintU32StringTo(s, os);
571
+ }
572
+
573
+ // Overloads for ::std::wstring.
574
+ #if GTEST_HAS_STD_WSTRING
575
+ GTEST_API_ void PrintWideStringTo(const ::std::wstring&s, ::std::ostream* os);
576
+ inline void PrintTo(const ::std::wstring& s, ::std::ostream* os) {
577
+ PrintWideStringTo(s, os);
578
+ }
579
+ #endif // GTEST_HAS_STD_WSTRING
580
+
581
+ #if GTEST_INTERNAL_HAS_STRING_VIEW
582
+ // Overload for internal::StringView.
583
+ inline void PrintTo(internal::StringView sp, ::std::ostream* os) {
584
+ PrintTo(::std::string(sp), os);
585
+ }
586
+ #endif // GTEST_INTERNAL_HAS_STRING_VIEW
587
+
588
+ inline void PrintTo(std::nullptr_t, ::std::ostream* os) { *os << "(nullptr)"; }
589
+
590
+ template <typename T>
591
+ void PrintTo(std::reference_wrapper<T> ref, ::std::ostream* os) {
592
+ UniversalPrinter<T&>::Print(ref.get(), os);
593
+ }
594
+
595
+ inline const void* VoidifyPointer(const void* p) { return p; }
596
+ inline const void* VoidifyPointer(volatile const void* p) {
597
+ return const_cast<const void*>(p);
598
+ }
599
+
600
+ template <typename T, typename Ptr>
601
+ void PrintSmartPointer(const Ptr& ptr, std::ostream* os, char) {
602
+ if (ptr == nullptr) {
603
+ *os << "(nullptr)";
604
+ } else {
605
+ // We can't print the value. Just print the pointer..
606
+ *os << "(" << (VoidifyPointer)(ptr.get()) << ")";
607
+ }
608
+ }
609
+ template <typename T, typename Ptr,
610
+ typename = typename std::enable_if<!std::is_void<T>::value &&
611
+ !std::is_array<T>::value>::type>
612
+ void PrintSmartPointer(const Ptr& ptr, std::ostream* os, int) {
613
+ if (ptr == nullptr) {
614
+ *os << "(nullptr)";
615
+ } else {
616
+ *os << "(ptr = " << (VoidifyPointer)(ptr.get()) << ", value = ";
617
+ UniversalPrinter<T>::Print(*ptr, os);
618
+ *os << ")";
619
+ }
620
+ }
621
+
622
+ template <typename T, typename D>
623
+ void PrintTo(const std::unique_ptr<T, D>& ptr, std::ostream* os) {
624
+ (PrintSmartPointer<T>)(ptr, os, 0);
625
+ }
626
+
627
+ template <typename T>
628
+ void PrintTo(const std::shared_ptr<T>& ptr, std::ostream* os) {
629
+ (PrintSmartPointer<T>)(ptr, os, 0);
630
+ }
631
+
632
+ // Helper function for printing a tuple. T must be instantiated with
633
+ // a tuple type.
634
+ template <typename T>
635
+ void PrintTupleTo(const T&, std::integral_constant<size_t, 0>,
636
+ ::std::ostream*) {}
637
+
638
+ template <typename T, size_t I>
639
+ void PrintTupleTo(const T& t, std::integral_constant<size_t, I>,
640
+ ::std::ostream* os) {
641
+ PrintTupleTo(t, std::integral_constant<size_t, I - 1>(), os);
642
+ GTEST_INTENTIONAL_CONST_COND_PUSH_()
643
+ if (I > 1) {
644
+ GTEST_INTENTIONAL_CONST_COND_POP_()
645
+ *os << ", ";
646
+ }
647
+ UniversalPrinter<typename std::tuple_element<I - 1, T>::type>::Print(
648
+ std::get<I - 1>(t), os);
649
+ }
650
+
651
+ template <typename... Types>
652
+ void PrintTo(const ::std::tuple<Types...>& t, ::std::ostream* os) {
653
+ *os << "(";
654
+ PrintTupleTo(t, std::integral_constant<size_t, sizeof...(Types)>(), os);
655
+ *os << ")";
656
+ }
657
+
658
+ // Overload for std::pair.
659
+ template <typename T1, typename T2>
660
+ void PrintTo(const ::std::pair<T1, T2>& value, ::std::ostream* os) {
661
+ *os << '(';
662
+ // We cannot use UniversalPrint(value.first, os) here, as T1 may be
663
+ // a reference type. The same for printing value.second.
664
+ UniversalPrinter<T1>::Print(value.first, os);
665
+ *os << ", ";
666
+ UniversalPrinter<T2>::Print(value.second, os);
667
+ *os << ')';
668
+ }
669
+
670
+ // Implements printing a non-reference type T by letting the compiler
671
+ // pick the right overload of PrintTo() for T.
672
+ template <typename T>
673
+ class UniversalPrinter {
674
+ public:
675
+ // MSVC warns about adding const to a function type, so we want to
676
+ // disable the warning.
677
+ GTEST_DISABLE_MSC_WARNINGS_PUSH_(4180)
678
+
679
+ // Note: we deliberately don't call this PrintTo(), as that name
680
+ // conflicts with ::testing::internal::PrintTo in the body of the
681
+ // function.
682
+ static void Print(const T& value, ::std::ostream* os) {
683
+ // By default, ::testing::internal::PrintTo() is used for printing
684
+ // the value.
685
+ //
686
+ // Thanks to Koenig look-up, if T is a class and has its own
687
+ // PrintTo() function defined in its namespace, that function will
688
+ // be visible here. Since it is more specific than the generic ones
689
+ // in ::testing::internal, it will be picked by the compiler in the
690
+ // following statement - exactly what we want.
691
+ PrintTo(value, os);
692
+ }
693
+
694
+ GTEST_DISABLE_MSC_WARNINGS_POP_()
695
+ };
696
+
697
+ // Remove any const-qualifiers before passing a type to UniversalPrinter.
698
+ template <typename T>
699
+ class UniversalPrinter<const T> : public UniversalPrinter<T> {};
700
+
701
+ #if GTEST_INTERNAL_HAS_ANY
702
+
703
+ // Printer for std::any / absl::any
704
+
705
+ template <>
706
+ class UniversalPrinter<Any> {
707
+ public:
708
+ static void Print(const Any& value, ::std::ostream* os) {
709
+ if (value.has_value()) {
710
+ *os << "value of type " << GetTypeName(value);
711
+ } else {
712
+ *os << "no value";
713
+ }
714
+ }
715
+
716
+ private:
717
+ static std::string GetTypeName(const Any& value) {
718
+ #if GTEST_HAS_RTTI
719
+ return internal::GetTypeName(value.type());
720
+ #else
721
+ static_cast<void>(value); // possibly unused
722
+ return "<unknown_type>";
723
+ #endif // GTEST_HAS_RTTI
724
+ }
725
+ };
726
+
727
+ #endif // GTEST_INTERNAL_HAS_ANY
728
+
729
+ #if GTEST_INTERNAL_HAS_OPTIONAL
730
+
731
+ // Printer for std::optional / absl::optional
732
+
733
+ template <typename T>
734
+ class UniversalPrinter<Optional<T>> {
735
+ public:
736
+ static void Print(const Optional<T>& value, ::std::ostream* os) {
737
+ *os << '(';
738
+ if (!value) {
739
+ *os << "nullopt";
740
+ } else {
741
+ UniversalPrint(*value, os);
742
+ }
743
+ *os << ')';
744
+ }
745
+ };
746
+
747
+ #endif // GTEST_INTERNAL_HAS_OPTIONAL
748
+
749
+ #if GTEST_INTERNAL_HAS_VARIANT
750
+
751
+ // Printer for std::variant / absl::variant
752
+
753
+ template <typename... T>
754
+ class UniversalPrinter<Variant<T...>> {
755
+ public:
756
+ static void Print(const Variant<T...>& value, ::std::ostream* os) {
757
+ *os << '(';
758
+ #if GTEST_HAS_ABSL
759
+ absl::visit(Visitor{os, value.index()}, value);
760
+ #else
761
+ std::visit(Visitor{os, value.index()}, value);
762
+ #endif // GTEST_HAS_ABSL
763
+ *os << ')';
764
+ }
765
+
766
+ private:
767
+ struct Visitor {
768
+ template <typename U>
769
+ void operator()(const U& u) const {
770
+ *os << "'" << GetTypeName<U>() << "(index = " << index
771
+ << ")' with value ";
772
+ UniversalPrint(u, os);
773
+ }
774
+ ::std::ostream* os;
775
+ std::size_t index;
776
+ };
777
+ };
778
+
779
+ #endif // GTEST_INTERNAL_HAS_VARIANT
780
+
781
+ // UniversalPrintArray(begin, len, os) prints an array of 'len'
782
+ // elements, starting at address 'begin'.
783
+ template <typename T>
784
+ void UniversalPrintArray(const T* begin, size_t len, ::std::ostream* os) {
785
+ if (len == 0) {
786
+ *os << "{}";
787
+ } else {
788
+ *os << "{ ";
789
+ const size_t kThreshold = 18;
790
+ const size_t kChunkSize = 8;
791
+ // If the array has more than kThreshold elements, we'll have to
792
+ // omit some details by printing only the first and the last
793
+ // kChunkSize elements.
794
+ if (len <= kThreshold) {
795
+ PrintRawArrayTo(begin, len, os);
796
+ } else {
797
+ PrintRawArrayTo(begin, kChunkSize, os);
798
+ *os << ", ..., ";
799
+ PrintRawArrayTo(begin + len - kChunkSize, kChunkSize, os);
800
+ }
801
+ *os << " }";
802
+ }
803
+ }
804
+ // This overload prints a (const) char array compactly.
805
+ GTEST_API_ void UniversalPrintArray(
806
+ const char* begin, size_t len, ::std::ostream* os);
807
+
808
+ #ifdef __cpp_char8_t
809
+ // This overload prints a (const) char8_t array compactly.
810
+ GTEST_API_ void UniversalPrintArray(const char8_t* begin, size_t len,
811
+ ::std::ostream* os);
812
+ #endif
813
+
814
+ // This overload prints a (const) char16_t array compactly.
815
+ GTEST_API_ void UniversalPrintArray(const char16_t* begin, size_t len,
816
+ ::std::ostream* os);
817
+
818
+ // This overload prints a (const) char32_t array compactly.
819
+ GTEST_API_ void UniversalPrintArray(const char32_t* begin, size_t len,
820
+ ::std::ostream* os);
821
+
822
+ // This overload prints a (const) wchar_t array compactly.
823
+ GTEST_API_ void UniversalPrintArray(
824
+ const wchar_t* begin, size_t len, ::std::ostream* os);
825
+
826
+ // Implements printing an array type T[N].
827
+ template <typename T, size_t N>
828
+ class UniversalPrinter<T[N]> {
829
+ public:
830
+ // Prints the given array, omitting some elements when there are too
831
+ // many.
832
+ static void Print(const T (&a)[N], ::std::ostream* os) {
833
+ UniversalPrintArray(a, N, os);
834
+ }
835
+ };
836
+
837
+ // Implements printing a reference type T&.
838
+ template <typename T>
839
+ class UniversalPrinter<T&> {
840
+ public:
841
+ // MSVC warns about adding const to a function type, so we want to
842
+ // disable the warning.
843
+ GTEST_DISABLE_MSC_WARNINGS_PUSH_(4180)
844
+
845
+ static void Print(const T& value, ::std::ostream* os) {
846
+ // Prints the address of the value. We use reinterpret_cast here
847
+ // as static_cast doesn't compile when T is a function type.
848
+ *os << "@" << reinterpret_cast<const void*>(&value) << " ";
849
+
850
+ // Then prints the value itself.
851
+ UniversalPrint(value, os);
852
+ }
853
+
854
+ GTEST_DISABLE_MSC_WARNINGS_POP_()
855
+ };
856
+
857
+ // Prints a value tersely: for a reference type, the referenced value
858
+ // (but not the address) is printed; for a (const) char pointer, the
859
+ // NUL-terminated string (but not the pointer) is printed.
860
+
861
+ template <typename T>
862
+ class UniversalTersePrinter {
863
+ public:
864
+ static void Print(const T& value, ::std::ostream* os) {
865
+ UniversalPrint(value, os);
866
+ }
867
+ };
868
+ template <typename T>
869
+ class UniversalTersePrinter<T&> {
870
+ public:
871
+ static void Print(const T& value, ::std::ostream* os) {
872
+ UniversalPrint(value, os);
873
+ }
874
+ };
875
+ template <typename T, size_t N>
876
+ class UniversalTersePrinter<T[N]> {
877
+ public:
878
+ static void Print(const T (&value)[N], ::std::ostream* os) {
879
+ UniversalPrinter<T[N]>::Print(value, os);
880
+ }
881
+ };
882
+ template <>
883
+ class UniversalTersePrinter<const char*> {
884
+ public:
885
+ static void Print(const char* str, ::std::ostream* os) {
886
+ if (str == nullptr) {
887
+ *os << "NULL";
888
+ } else {
889
+ UniversalPrint(std::string(str), os);
890
+ }
891
+ }
892
+ };
893
+ template <>
894
+ class UniversalTersePrinter<char*> : public UniversalTersePrinter<const char*> {
895
+ };
896
+
897
+ #ifdef __cpp_char8_t
898
+ template <>
899
+ class UniversalTersePrinter<const char8_t*> {
900
+ public:
901
+ static void Print(const char8_t* str, ::std::ostream* os) {
902
+ if (str == nullptr) {
903
+ *os << "NULL";
904
+ } else {
905
+ UniversalPrint(::std::u8string(str), os);
906
+ }
907
+ }
908
+ };
909
+ template <>
910
+ class UniversalTersePrinter<char8_t*>
911
+ : public UniversalTersePrinter<const char8_t*> {};
912
+ #endif
913
+
914
+ template <>
915
+ class UniversalTersePrinter<const char16_t*> {
916
+ public:
917
+ static void Print(const char16_t* str, ::std::ostream* os) {
918
+ if (str == nullptr) {
919
+ *os << "NULL";
920
+ } else {
921
+ UniversalPrint(::std::u16string(str), os);
922
+ }
923
+ }
924
+ };
925
+ template <>
926
+ class UniversalTersePrinter<char16_t*>
927
+ : public UniversalTersePrinter<const char16_t*> {};
928
+
929
+ template <>
930
+ class UniversalTersePrinter<const char32_t*> {
931
+ public:
932
+ static void Print(const char32_t* str, ::std::ostream* os) {
933
+ if (str == nullptr) {
934
+ *os << "NULL";
935
+ } else {
936
+ UniversalPrint(::std::u32string(str), os);
937
+ }
938
+ }
939
+ };
940
+ template <>
941
+ class UniversalTersePrinter<char32_t*>
942
+ : public UniversalTersePrinter<const char32_t*> {};
943
+
944
+ #if GTEST_HAS_STD_WSTRING
945
+ template <>
946
+ class UniversalTersePrinter<const wchar_t*> {
947
+ public:
948
+ static void Print(const wchar_t* str, ::std::ostream* os) {
949
+ if (str == nullptr) {
950
+ *os << "NULL";
951
+ } else {
952
+ UniversalPrint(::std::wstring(str), os);
953
+ }
954
+ }
955
+ };
956
+ #endif
957
+
958
+ template <>
959
+ class UniversalTersePrinter<wchar_t*> {
960
+ public:
961
+ static void Print(wchar_t* str, ::std::ostream* os) {
962
+ UniversalTersePrinter<const wchar_t*>::Print(str, os);
963
+ }
964
+ };
965
+
966
+ template <typename T>
967
+ void UniversalTersePrint(const T& value, ::std::ostream* os) {
968
+ UniversalTersePrinter<T>::Print(value, os);
969
+ }
970
+
971
+ // Prints a value using the type inferred by the compiler. The
972
+ // difference between this and UniversalTersePrint() is that for a
973
+ // (const) char pointer, this prints both the pointer and the
974
+ // NUL-terminated string.
975
+ template <typename T>
976
+ void UniversalPrint(const T& value, ::std::ostream* os) {
977
+ // A workarond for the bug in VC++ 7.1 that prevents us from instantiating
978
+ // UniversalPrinter with T directly.
979
+ typedef T T1;
980
+ UniversalPrinter<T1>::Print(value, os);
981
+ }
982
+
983
+ typedef ::std::vector< ::std::string> Strings;
984
+
985
+ // Tersely prints the first N fields of a tuple to a string vector,
986
+ // one element for each field.
987
+ template <typename Tuple>
988
+ void TersePrintPrefixToStrings(const Tuple&, std::integral_constant<size_t, 0>,
989
+ Strings*) {}
990
+ template <typename Tuple, size_t I>
991
+ void TersePrintPrefixToStrings(const Tuple& t,
992
+ std::integral_constant<size_t, I>,
993
+ Strings* strings) {
994
+ TersePrintPrefixToStrings(t, std::integral_constant<size_t, I - 1>(),
995
+ strings);
996
+ ::std::stringstream ss;
997
+ UniversalTersePrint(std::get<I - 1>(t), &ss);
998
+ strings->push_back(ss.str());
999
+ }
1000
+
1001
+ // Prints the fields of a tuple tersely to a string vector, one
1002
+ // element for each field. See the comment before
1003
+ // UniversalTersePrint() for how we define "tersely".
1004
+ template <typename Tuple>
1005
+ Strings UniversalTersePrintTupleFieldsToStrings(const Tuple& value) {
1006
+ Strings result;
1007
+ TersePrintPrefixToStrings(
1008
+ value, std::integral_constant<size_t, std::tuple_size<Tuple>::value>(),
1009
+ &result);
1010
+ return result;
1011
+ }
1012
+
1013
+ } // namespace internal
1014
+
1015
+ template <typename T>
1016
+ ::std::string PrintToString(const T& value) {
1017
+ ::std::stringstream ss;
1018
+ internal::UniversalTersePrinter<T>::Print(value, &ss);
1019
+ return ss.str();
1020
+ }
1021
+
1022
+ } // namespace testing
1023
+
1024
+ // Include any custom printer added by the local installation.
1025
+ // We must include this header at the end to make sure it can use the
1026
+ // declarations from this file.
1027
+ #include "gtest/internal/custom/gtest-printers.h"
1028
+
1029
+ #endif // GOOGLETEST_INCLUDE_GTEST_GTEST_PRINTERS_H_