catboost 1.25.1 → 1.27.0

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 (290) hide show
  1. package/DEPLOYMENT.md +22 -15
  2. package/README.md +43 -27
  3. package/binding.gyp +5 -7
  4. package/build_scripts/bootstrap.js +2 -1
  5. package/build_scripts/out/build.js +46 -68
  6. package/build_scripts/out/build_model.js +1 -1
  7. package/build_scripts/out/{build_ya.js → build_native.js} +1 -1
  8. package/build_scripts/out/ci.js +5 -5
  9. package/build_scripts/out/common.js +1 -1
  10. package/build_scripts/out/config.js +32 -18
  11. package/build_scripts/out/install.js +5 -3
  12. package/build_scripts/out/package_prepublish.js +1 -1
  13. package/build_scripts/out/packaging.js +1 -19
  14. package/build_scripts/out/run_tests.js +1 -1
  15. package/build_scripts/out/test.js +8 -3
  16. package/config.json +18 -11
  17. package/inc/catboost/libs/model_interface/c_api.h +367 -5
  18. package/lib/catboost.d.ts +65 -21
  19. package/package.json +4 -4
  20. package/src/api_helpers.cpp +100 -24
  21. package/src/api_helpers.h +8 -7
  22. package/src/api_module.cpp +1 -2
  23. package/src/model.cpp +483 -83
  24. package/src/model.h +24 -9
  25. package/inc/contrib/libs/cxxsupp/system_stl/include/stlfwd +0 -14
  26. package/inc/util/charset/recode_result.h +0 -9
  27. package/inc/util/charset/unicode_table.h +0 -123
  28. package/inc/util/charset/unidata.h +0 -421
  29. package/inc/util/charset/utf8.h +0 -384
  30. package/inc/util/charset/wide.h +0 -843
  31. package/inc/util/charset/wide_specific.h +0 -22
  32. package/inc/util/datetime/base.h +0 -669
  33. package/inc/util/datetime/constants.h +0 -7
  34. package/inc/util/datetime/cputimer.h +0 -124
  35. package/inc/util/datetime/parser.h +0 -292
  36. package/inc/util/datetime/systime.h +0 -47
  37. package/inc/util/datetime/uptime.h +0 -8
  38. package/inc/util/digest/city.h +0 -88
  39. package/inc/util/digest/fnv.h +0 -73
  40. package/inc/util/digest/multi.h +0 -14
  41. package/inc/util/digest/murmur.h +0 -57
  42. package/inc/util/digest/numeric.h +0 -86
  43. package/inc/util/digest/sequence.h +0 -48
  44. package/inc/util/draft/date.h +0 -129
  45. package/inc/util/draft/datetime.h +0 -184
  46. package/inc/util/draft/enum.h +0 -136
  47. package/inc/util/draft/holder_vector.h +0 -102
  48. package/inc/util/draft/ip.h +0 -131
  49. package/inc/util/draft/matrix.h +0 -108
  50. package/inc/util/draft/memory.h +0 -40
  51. package/inc/util/folder/dirent_win.h +0 -46
  52. package/inc/util/folder/dirut.h +0 -121
  53. package/inc/util/folder/filelist.h +0 -81
  54. package/inc/util/folder/fts.h +0 -108
  55. package/inc/util/folder/iterator.h +0 -109
  56. package/inc/util/folder/lstat_win.h +0 -20
  57. package/inc/util/folder/path.h +0 -225
  58. package/inc/util/folder/pathsplit.h +0 -113
  59. package/inc/util/folder/tempdir.h +0 -42
  60. package/inc/util/generic/adaptor.h +0 -134
  61. package/inc/util/generic/algorithm.h +0 -765
  62. package/inc/util/generic/array_ref.h +0 -282
  63. package/inc/util/generic/array_size.h +0 -24
  64. package/inc/util/generic/benchmark/vector_count_ctor/f.h +0 -9
  65. package/inc/util/generic/bitmap.h +0 -1115
  66. package/inc/util/generic/bitops.h +0 -459
  67. package/inc/util/generic/bt_exception.h +0 -24
  68. package/inc/util/generic/buffer.h +0 -232
  69. package/inc/util/generic/cast.h +0 -176
  70. package/inc/util/generic/deque.h +0 -24
  71. package/inc/util/generic/explicit_type.h +0 -42
  72. package/inc/util/generic/fastqueue.h +0 -55
  73. package/inc/util/generic/flags.h +0 -244
  74. package/inc/util/generic/function.h +0 -103
  75. package/inc/util/generic/fwd.h +0 -171
  76. package/inc/util/generic/guid.h +0 -61
  77. package/inc/util/generic/hash.h +0 -2032
  78. package/inc/util/generic/hash_primes.h +0 -140
  79. package/inc/util/generic/hash_set.h +0 -490
  80. package/inc/util/generic/hide_ptr.h +0 -3
  81. package/inc/util/generic/intrlist.h +0 -876
  82. package/inc/util/generic/is_in.h +0 -53
  83. package/inc/util/generic/iterator.h +0 -137
  84. package/inc/util/generic/iterator_range.h +0 -105
  85. package/inc/util/generic/lazy_value.h +0 -66
  86. package/inc/util/generic/list.h +0 -22
  87. package/inc/util/generic/map.h +0 -44
  88. package/inc/util/generic/mapfindptr.h +0 -60
  89. package/inc/util/generic/maybe.h +0 -713
  90. package/inc/util/generic/maybe_traits.h +0 -164
  91. package/inc/util/generic/mem_copy.h +0 -55
  92. package/inc/util/generic/noncopyable.h +0 -38
  93. package/inc/util/generic/object_counter.h +0 -53
  94. package/inc/util/generic/ptr.h +0 -1113
  95. package/inc/util/generic/queue.h +0 -57
  96. package/inc/util/generic/refcount.h +0 -162
  97. package/inc/util/generic/reserve.h +0 -11
  98. package/inc/util/generic/scope.h +0 -65
  99. package/inc/util/generic/serialized_enum.h +0 -406
  100. package/inc/util/generic/set.h +0 -42
  101. package/inc/util/generic/singleton.h +0 -136
  102. package/inc/util/generic/size_literals.h +0 -65
  103. package/inc/util/generic/stack.h +0 -18
  104. package/inc/util/generic/store_policy.h +0 -120
  105. package/inc/util/generic/strbase.h +0 -612
  106. package/inc/util/generic/strbuf.h +0 -552
  107. package/inc/util/generic/strfcpy.h +0 -17
  108. package/inc/util/generic/string.h +0 -1572
  109. package/inc/util/generic/string_hash.h +0 -21
  110. package/inc/util/generic/string_ut.h +0 -1175
  111. package/inc/util/generic/type_name.h +0 -34
  112. package/inc/util/generic/typelist.h +0 -114
  113. package/inc/util/generic/typetraits.h +0 -325
  114. package/inc/util/generic/utility.h +0 -132
  115. package/inc/util/generic/va_args.h +0 -400
  116. package/inc/util/generic/variant.h +0 -631
  117. package/inc/util/generic/variant_traits.h +0 -171
  118. package/inc/util/generic/vector.h +0 -119
  119. package/inc/util/generic/xrange.h +0 -258
  120. package/inc/util/generic/yexception.h +0 -212
  121. package/inc/util/generic/yexception_ut.h +0 -14
  122. package/inc/util/generic/ylimits.h +0 -92
  123. package/inc/util/generic/ymath.h +0 -206
  124. package/inc/util/memory/addstorage.h +0 -93
  125. package/inc/util/memory/alloc.h +0 -27
  126. package/inc/util/memory/blob.h +0 -296
  127. package/inc/util/memory/mmapalloc.h +0 -8
  128. package/inc/util/memory/pool.h +0 -432
  129. package/inc/util/memory/segmented_string_pool.h +0 -194
  130. package/inc/util/memory/segpool_alloc.h +0 -118
  131. package/inc/util/memory/smallobj.h +0 -141
  132. package/inc/util/memory/tempbuf.h +0 -111
  133. package/inc/util/network/address.h +0 -136
  134. package/inc/util/network/endpoint.h +0 -61
  135. package/inc/util/network/hostip.h +0 -16
  136. package/inc/util/network/init.h +0 -60
  137. package/inc/util/network/interface.h +0 -17
  138. package/inc/util/network/iovec.h +0 -65
  139. package/inc/util/network/ip.h +0 -116
  140. package/inc/util/network/nonblock.h +0 -8
  141. package/inc/util/network/pair.h +0 -9
  142. package/inc/util/network/poller.h +0 -58
  143. package/inc/util/network/pollerimpl.h +0 -707
  144. package/inc/util/network/sock.h +0 -608
  145. package/inc/util/network/socket.h +0 -421
  146. package/inc/util/random/common_ops.h +0 -130
  147. package/inc/util/random/easy.h +0 -47
  148. package/inc/util/random/entropy.h +0 -21
  149. package/inc/util/random/fast.h +0 -101
  150. package/inc/util/random/init_atfork.h +0 -3
  151. package/inc/util/random/lcg_engine.h +0 -66
  152. package/inc/util/random/mersenne.h +0 -46
  153. package/inc/util/random/mersenne32.h +0 -50
  154. package/inc/util/random/mersenne64.h +0 -50
  155. package/inc/util/random/normal.h +0 -38
  156. package/inc/util/random/random.h +0 -30
  157. package/inc/util/random/shuffle.h +0 -39
  158. package/inc/util/str_stl.h +0 -266
  159. package/inc/util/stream/aligned.h +0 -99
  160. package/inc/util/stream/buffer.h +0 -119
  161. package/inc/util/stream/buffered.h +0 -225
  162. package/inc/util/stream/debug.h +0 -53
  163. package/inc/util/stream/direct_io.h +0 -43
  164. package/inc/util/stream/file.h +0 -108
  165. package/inc/util/stream/format.h +0 -444
  166. package/inc/util/stream/fwd.h +0 -100
  167. package/inc/util/stream/hex.h +0 -8
  168. package/inc/util/stream/holder.h +0 -44
  169. package/inc/util/stream/input.h +0 -273
  170. package/inc/util/stream/labeled.h +0 -19
  171. package/inc/util/stream/length.h +0 -100
  172. package/inc/util/stream/mem.h +0 -255
  173. package/inc/util/stream/multi.h +0 -32
  174. package/inc/util/stream/null.h +0 -61
  175. package/inc/util/stream/output.h +0 -304
  176. package/inc/util/stream/pipe.h +0 -112
  177. package/inc/util/stream/printf.h +0 -25
  178. package/inc/util/stream/str.h +0 -207
  179. package/inc/util/stream/tee.h +0 -28
  180. package/inc/util/stream/tempbuf.h +0 -21
  181. package/inc/util/stream/tokenizer.h +0 -214
  182. package/inc/util/stream/trace.h +0 -60
  183. package/inc/util/stream/walk.h +0 -35
  184. package/inc/util/stream/zerocopy.h +0 -91
  185. package/inc/util/stream/zerocopy_output.h +0 -57
  186. package/inc/util/stream/zlib.h +0 -173
  187. package/inc/util/string/ascii.h +0 -236
  188. package/inc/util/string/builder.h +0 -39
  189. package/inc/util/string/cast.h +0 -347
  190. package/inc/util/string/cstriter.h +0 -14
  191. package/inc/util/string/escape.h +0 -70
  192. package/inc/util/string/hex.h +0 -59
  193. package/inc/util/string/join.h +0 -194
  194. package/inc/util/string/printf.h +0 -13
  195. package/inc/util/string/reverse.h +0 -16
  196. package/inc/util/string/split.h +0 -1080
  197. package/inc/util/string/strip.h +0 -257
  198. package/inc/util/string/strspn.h +0 -65
  199. package/inc/util/string/subst.h +0 -56
  200. package/inc/util/string/type.h +0 -50
  201. package/inc/util/string/util.h +0 -195
  202. package/inc/util/string/vector.h +0 -132
  203. package/inc/util/system/align.h +0 -50
  204. package/inc/util/system/atexit.h +0 -22
  205. package/inc/util/system/atomic.h +0 -51
  206. package/inc/util/system/atomic_gcc.h +0 -90
  207. package/inc/util/system/atomic_ops.h +0 -189
  208. package/inc/util/system/atomic_win.h +0 -114
  209. package/inc/util/system/backtrace.h +0 -39
  210. package/inc/util/system/byteorder.h +0 -186
  211. package/inc/util/system/compat.h +0 -84
  212. package/inc/util/system/compiler.h +0 -620
  213. package/inc/util/system/condvar.h +0 -71
  214. package/inc/util/system/context.h +0 -181
  215. package/inc/util/system/context_aarch64.h +0 -8
  216. package/inc/util/system/context_i686.h +0 -9
  217. package/inc/util/system/context_x86.h +0 -12
  218. package/inc/util/system/context_x86_64.h +0 -7
  219. package/inc/util/system/cpu_id.h +0 -159
  220. package/inc/util/system/daemon.h +0 -28
  221. package/inc/util/system/datetime.h +0 -98
  222. package/inc/util/system/defaults.h +0 -149
  223. package/inc/util/system/demangle.h +0 -5
  224. package/inc/util/system/demangle_impl.h +0 -23
  225. package/inc/util/system/direct_io.h +0 -71
  226. package/inc/util/system/dynlib.h +0 -119
  227. package/inc/util/system/env.h +0 -32
  228. package/inc/util/system/error.h +0 -95
  229. package/inc/util/system/event.h +0 -122
  230. package/inc/util/system/execpath.h +0 -17
  231. package/inc/util/system/fasttime.h +0 -6
  232. package/inc/util/system/fhandle.h +0 -27
  233. package/inc/util/system/file.h +0 -210
  234. package/inc/util/system/file_lock.h +0 -34
  235. package/inc/util/system/filemap.h +0 -383
  236. package/inc/util/system/flock.h +0 -35
  237. package/inc/util/system/fs.h +0 -156
  238. package/inc/util/system/fs_win.h +0 -29
  239. package/inc/util/system/fstat.h +0 -46
  240. package/inc/util/system/getpid.h +0 -12
  241. package/inc/util/system/guard.h +0 -179
  242. package/inc/util/system/hi_lo.h +0 -139
  243. package/inc/util/system/hostname.h +0 -10
  244. package/inc/util/system/hp_timer.h +0 -36
  245. package/inc/util/system/info.h +0 -12
  246. package/inc/util/system/interrupt_signals.h +0 -22
  247. package/inc/util/system/madvise.h +0 -30
  248. package/inc/util/system/maxlen.h +0 -32
  249. package/inc/util/system/mem_info.h +0 -18
  250. package/inc/util/system/mincore.h +0 -38
  251. package/inc/util/system/mktemp.h +0 -11
  252. package/inc/util/system/mlock.h +0 -43
  253. package/inc/util/system/mutex.h +0 -67
  254. package/inc/util/system/nice.h +0 -3
  255. package/inc/util/system/pipe.h +0 -90
  256. package/inc/util/system/platform.h +0 -246
  257. package/inc/util/system/progname.h +0 -13
  258. package/inc/util/system/protect.h +0 -25
  259. package/inc/util/system/rusage.h +0 -26
  260. package/inc/util/system/rwlock.h +0 -78
  261. package/inc/util/system/sanitizers.h +0 -122
  262. package/inc/util/system/sem.h +0 -41
  263. package/inc/util/system/shellcommand.h +0 -472
  264. package/inc/util/system/shmat.h +0 -32
  265. package/inc/util/system/sigset.h +0 -78
  266. package/inc/util/system/spin_wait.h +0 -10
  267. package/inc/util/system/spinlock.h +0 -121
  268. package/inc/util/system/src_location.h +0 -25
  269. package/inc/util/system/src_root.h +0 -68
  270. package/inc/util/system/sys_alloc.h +0 -43
  271. package/inc/util/system/sysstat.h +0 -52
  272. package/inc/util/system/tempfile.h +0 -34
  273. package/inc/util/system/thread.h +0 -167
  274. package/inc/util/system/tls.h +0 -307
  275. package/inc/util/system/types.h +0 -119
  276. package/inc/util/system/unaligned_mem.h +0 -67
  277. package/inc/util/system/user.h +0 -5
  278. package/inc/util/system/utime.h +0 -6
  279. package/inc/util/system/valgrind.h +0 -48
  280. package/inc/util/system/winint.h +0 -43
  281. package/inc/util/system/yassert.h +0 -121
  282. package/inc/util/system/yield.h +0 -4
  283. package/inc/util/thread/factory.h +0 -65
  284. package/inc/util/thread/fwd.h +0 -30
  285. package/inc/util/thread/lfqueue.h +0 -406
  286. package/inc/util/thread/lfstack.h +0 -188
  287. package/inc/util/thread/pool.h +0 -388
  288. package/inc/util/thread/singleton.h +0 -42
  289. package/inc/util/ysafeptr.h +0 -427
  290. package/inc/util/ysaveload.h +0 -700
@@ -1,1080 +0,0 @@
1
- #pragma once
2
-
3
- #include "strspn.h"
4
- #include "cast.h"
5
-
6
- #include <util/generic/algorithm.h>
7
- #include <util/generic/fwd.h>
8
- #include <util/generic/iterator.h>
9
- #include <util/generic/iterator_range.h>
10
- #include <util/generic/store_policy.h>
11
- #include <util/generic/strbuf.h>
12
- #include <util/generic/string.h>
13
- #include <util/generic/typetraits.h>
14
- #include <util/generic/vector.h>
15
- #include <util/generic/ylimits.h>
16
- #include <util/system/compat.h>
17
- #include <util/system/defaults.h>
18
-
19
- #include <utility>
20
- #include <stlfwd>
21
-
22
- // NOTE: Check StringSplitter below to get more convenient split string interface.
23
-
24
- namespace NStringSplitPrivate {
25
-
26
- template <class T, class I, class = void>
27
- struct TIsConsumer : std::false_type {};
28
-
29
- template <class T, class I>
30
- struct TIsConsumer<
31
- T, I,
32
- TVoidT<decltype(std::declval<T>().Consume(
33
- std::declval<I>(), std::declval<I>(), std::declval<I>()))>>
34
- : std::true_type {};
35
-
36
- template <class T, class I>
37
- constexpr bool TIsConsumerV = TIsConsumer<T, I>::value;
38
-
39
- template <class T>
40
- T* Find(T* str, std::common_type_t<T> ch) {
41
- for (; *str; ++str) {
42
- if (*str == ch) {
43
- return str;
44
- }
45
- }
46
-
47
- return nullptr;
48
- }
49
-
50
- }
51
-
52
- template <class I, class TDelim, class TConsumer>
53
- std::enable_if_t<::NStringSplitPrivate::TIsConsumerV<TConsumer, I>>
54
- SplitString(I b, I e, const TDelim& d, TConsumer&& c) {
55
- I l, i;
56
-
57
- do {
58
- l = b;
59
- i = d.Find(b, e);
60
- } while (c.Consume(l, i, b) && (b != i));
61
- }
62
-
63
- template <class I, class TDelim, class TConsumer>
64
- std::enable_if_t<::NStringSplitPrivate::TIsConsumerV<TConsumer, I>>
65
- SplitString(I b, const TDelim& d, TConsumer&& c) {
66
- I l, i;
67
-
68
- do {
69
- l = b;
70
- i = d.Find(b);
71
- } while (c.Consume(l, i, b) && (b != i));
72
- }
73
-
74
- template <class I1, class I2>
75
- static inline I1* FastStrChr(I1* str, I2 f) noexcept {
76
- I1* ret = NStringSplitPrivate::Find(str, f);
77
-
78
- if (!ret) {
79
- ret = str + std::char_traits<I1>::length(str);
80
- }
81
-
82
- return ret;
83
- }
84
-
85
- template <class I>
86
- static inline I* FastStrStr(I* str, I* f, size_t l) noexcept {
87
- std::basic_string_view<I> strView(str);
88
- const auto ret = strView.find(*f);
89
-
90
- if (ret != std::string::npos) {
91
- std::basic_string_view<I> fView(f, l);
92
- strView = strView.substr(ret);
93
- for (; strView.size() >= l; strView = strView.substr(1)) {
94
- if (strView.substr(0, l) == fView) {
95
- break;
96
- }
97
- }
98
-
99
- return strView.size() >= l ? strView.data() : strView.data() + strView.size();
100
- } else {
101
- return strView.data() + strView.size();
102
- }
103
- }
104
-
105
- template <class Char>
106
- struct TStringDelimiter {
107
- inline TStringDelimiter(Char* delim) noexcept
108
- : Delim(delim)
109
- , Len(std::char_traits<Char>::length(delim))
110
- {
111
- }
112
-
113
- inline TStringDelimiter(Char* delim, size_t len) noexcept
114
- : Delim(delim)
115
- , Len(len)
116
- {
117
- }
118
-
119
- inline Char* Find(Char*& b, Char* e) const noexcept {
120
- const auto ret = std::basic_string_view<Char>(b, e - b).find(Delim, 0, Len);
121
-
122
- if (ret != std::string::npos) {
123
- const auto result = b + ret;
124
- b = result + Len;
125
- return result;
126
- }
127
-
128
- return (b = e);
129
- }
130
-
131
- inline Char* Find(Char*& b) const noexcept {
132
- Char* ret = FastStrStr(b, Delim, Len);
133
-
134
- b = *ret ? ret + Len : ret;
135
-
136
- return ret;
137
- }
138
-
139
- Char* Delim;
140
- const size_t Len;
141
- };
142
-
143
- template <class Char>
144
- struct TCharDelimiter {
145
- inline TCharDelimiter(Char ch) noexcept
146
- : Ch(ch)
147
- {
148
- }
149
-
150
- inline Char* Find(Char*& b, Char* e) const noexcept {
151
- const auto ret = std::basic_string_view<Char>(b, e - b).find(Ch);
152
-
153
- if (ret != std::string::npos) {
154
- const auto result = b + ret;
155
- b = result + 1;
156
- return result;
157
- }
158
-
159
- return (b = e);
160
- }
161
-
162
- inline Char* Find(Char*& b) const noexcept {
163
- Char* ret = FastStrChr(b, Ch);
164
-
165
- if (*ret) {
166
- b = ret + 1;
167
- } else {
168
- b = ret;
169
- }
170
-
171
- return ret;
172
- }
173
-
174
- Char Ch;
175
- };
176
-
177
- template <class Iterator, class Condition>
178
- struct TFuncDelimiter {
179
- public:
180
- template<class... Args>
181
- TFuncDelimiter(Args&&... args)
182
- : Fn(std::forward<Args>(args)...)
183
- {
184
- }
185
-
186
- inline Iterator Find(Iterator& b, Iterator e) const noexcept {
187
- if ((b = std::find_if(b, e, Fn)) != e) {
188
- return b++;
189
- }
190
-
191
- return b;
192
- }
193
-
194
- private:
195
- Condition Fn;
196
- };
197
-
198
- template <class Char>
199
- struct TFindFirstOf {
200
- inline TFindFirstOf(Char* set)
201
- : Set(set)
202
- {
203
- }
204
-
205
- inline Char* FindFirstOf(Char* b, Char* e) const noexcept {
206
- Char* ret = b;
207
- for (; ret != e; ++ret) {
208
- if (NStringSplitPrivate::Find(Set, *ret))
209
- break;
210
- }
211
- return ret;
212
- }
213
-
214
- inline Char* FindFirstOf(Char* b) const noexcept {
215
- const std::basic_string_view<Char> bView(b);
216
- const auto ret = bView.find_first_of(Set);
217
- return ret != std::string::npos ? b + ret : b + bView.size();
218
- }
219
-
220
- Char* Set;
221
- };
222
-
223
- template <>
224
- struct TFindFirstOf<const char>: public TCompactStrSpn {
225
- inline TFindFirstOf(const char* set, const char* e)
226
- : TCompactStrSpn(set, e)
227
- {
228
- }
229
-
230
- inline TFindFirstOf(const char* set)
231
- : TCompactStrSpn(set)
232
- {
233
- }
234
- };
235
-
236
- template <class Char>
237
- struct TSetDelimiter: private TFindFirstOf<const Char> {
238
- using TFindFirstOf<const Char>::TFindFirstOf;
239
-
240
- inline Char* Find(Char*& b, Char* e) const noexcept {
241
- Char* ret = const_cast<Char*>(this->FindFirstOf(b, e));
242
-
243
- if (ret != e) {
244
- b = ret + 1;
245
- return ret;
246
- }
247
-
248
- return (b = e);
249
- }
250
-
251
- inline Char* Find(Char*& b) const noexcept {
252
- Char* ret = const_cast<Char*>(this->FindFirstOf(b));
253
-
254
- if (*ret) {
255
- b = ret + 1;
256
- return ret;
257
- }
258
-
259
- return (b = ret);
260
- }
261
- };
262
-
263
- namespace NSplitTargetHasPushBack {
264
- Y_HAS_MEMBER(push_back, PushBack);
265
- }
266
-
267
- template <class T, class = void>
268
- struct TConsumerBackInserter;
269
-
270
- template <class T>
271
- struct TConsumerBackInserter<T, std::enable_if_t<NSplitTargetHasPushBack::TClassHasPushBack<T>::value>> {
272
- static void DoInsert(T* C, const typename T::value_type& i) {
273
- C->push_back(i);
274
- }
275
- };
276
-
277
- template <class T>
278
- struct TConsumerBackInserter<T, std::enable_if_t<!NSplitTargetHasPushBack::TClassHasPushBack<T>::value>> {
279
- static void DoInsert(T* C, const typename T::value_type& i) {
280
- C->insert(C->end(), i);
281
- }
282
- };
283
-
284
- template <class T>
285
- struct TContainerConsumer {
286
- inline TContainerConsumer(T* c) noexcept
287
- : C(c)
288
- {
289
- }
290
-
291
- template <class I>
292
- inline bool Consume(I* b, I* d, I* /*e*/) {
293
- TConsumerBackInserter<T>::DoInsert(C, typename T::value_type(b, d));
294
-
295
- return true;
296
- }
297
-
298
- T* C;
299
- };
300
-
301
- template <class T>
302
- struct TContainerConvertingConsumer {
303
- inline TContainerConvertingConsumer(T* c) noexcept
304
- : C(c)
305
- {
306
- }
307
-
308
- template <class I>
309
- inline bool Consume(I* b, I* d, I* /*e*/) {
310
- TConsumerBackInserter<T>::DoInsert(C, FromString<typename T::value_type>(TStringBuf(b, d)));
311
-
312
- return true;
313
- }
314
-
315
- T* C;
316
- };
317
-
318
- template <class S, class I>
319
- struct TLimitingConsumer {
320
- inline TLimitingConsumer(size_t cnt, S* slave) noexcept
321
- : Cnt(cnt ? cnt - 1 : Max<size_t>())
322
- , Slave(slave)
323
- , Last(nullptr)
324
- {
325
- }
326
-
327
- inline bool Consume(I* b, I* d, I* e) {
328
- if (!Cnt) {
329
- Last = b;
330
-
331
- return false;
332
- }
333
-
334
- --Cnt;
335
-
336
- return Slave->Consume(b, d, e);
337
- }
338
-
339
- size_t Cnt;
340
- S* Slave;
341
- I* Last;
342
- };
343
-
344
- template <class S>
345
- struct TSkipEmptyTokens {
346
- inline TSkipEmptyTokens(S* slave) noexcept
347
- : Slave(slave)
348
- {
349
- }
350
-
351
- template <class I>
352
- inline bool Consume(I* b, I* d, I* e) {
353
- if (b != d) {
354
- return Slave->Consume(b, d, e);
355
- }
356
-
357
- return true;
358
- }
359
-
360
- S* Slave;
361
- };
362
-
363
- template <class S>
364
- struct TKeepDelimiters {
365
- inline TKeepDelimiters(S* slave) noexcept
366
- : Slave(slave)
367
- {
368
- }
369
-
370
- template <class I>
371
- inline bool Consume(I* b, I* d, I* e) {
372
- if (Slave->Consume(b, d, d)) {
373
- if (d != e) {
374
- return Slave->Consume(d, e, e);
375
- }
376
-
377
- return true;
378
- }
379
-
380
- return false;
381
- }
382
-
383
- S* Slave;
384
- };
385
-
386
-
387
- template <class T>
388
- struct TSimplePusher {
389
- inline bool Consume(char* b, char* d, char*) {
390
- *d = 0;
391
- C->push_back(b);
392
-
393
- return true;
394
- }
395
-
396
- T* C;
397
- };
398
-
399
- template <class T>
400
- static inline void Split(char* buf, char ch, T* res) {
401
- res->resize(0);
402
- if (*buf == 0)
403
- return;
404
-
405
- TCharDelimiter<char> delim(ch);
406
- TSimplePusher<T> pusher = {res};
407
-
408
- SplitString(buf, delim, pusher);
409
- }
410
-
411
- /// Split string into res vector. Res vector is cleared before split.
412
- /// Old good slow split function.
413
- /// Field delimter is any number of symbols specified in delim (no empty strings in res vector)
414
- /// @return number of elements created
415
- size_t Split(const char* in, const char* delim, TVector<TString>& res);
416
- size_t Split(const TString& in, const TString& delim, TVector<TString>& res);
417
-
418
- /// Old split reimplemented for TStringBuf using the new code
419
- /// Note that delim can be constructed from char* automatically (it is not cheap though)
420
- inline size_t Split(const TStringBuf s, const TSetDelimiter<const char>& delim, TVector<TStringBuf>& res) {
421
- res.clear();
422
- TContainerConsumer<TVector<TStringBuf>> res1(&res);
423
- TSkipEmptyTokens<TContainerConsumer<TVector<TStringBuf>>> consumer(&res1);
424
- SplitString(s.data(), s.data() + s.size(), delim, consumer);
425
- return res.size();
426
- }
427
-
428
- template <class P, class D>
429
- void GetNext(TStringBuf& s, D delim, P& param) {
430
- TStringBuf next = s.NextTok(delim);
431
- Y_ENSURE(next.IsInited(), TStringBuf("Split: number of fields less than number of Split output arguments"));
432
- param = FromString<P>(next);
433
- }
434
-
435
- template <class P, class D>
436
- void GetNext(TStringBuf& s, D delim, TMaybe<P>& param) {
437
- TStringBuf next = s.NextTok(delim);
438
- if (next.IsInited()) {
439
- param = FromString<P>(next);
440
- } else {
441
- param.Clear();
442
- }
443
- }
444
-
445
- // example:
446
- // Split(TStringBuf("Sherlock,2014,36.6"), ',', name, year, temperature);
447
- template <class D, class P1, class P2>
448
- void Split(TStringBuf s, D delim, P1& p1, P2& p2) {
449
- GetNext(s, delim, p1);
450
- GetNext(s, delim, p2);
451
- Y_ENSURE(!s.IsInited(), TStringBuf("Split: number of fields more than number of Split output arguments"));
452
- }
453
-
454
- template <class D, class P1, class P2, class... Other>
455
- void Split(TStringBuf s, D delim, P1& p1, P2& p2, Other&... other) {
456
- GetNext(s, delim, p1);
457
- Split(s, delim, p2, other...);
458
- }
459
-
460
- /**
461
- * \fn auto StringSplitter(...)
462
- *
463
- * Creates a string splitter object. The only use for it is to call one of its
464
- * `Split*` methods, and then do something with the resulting proxy range.
465
- *
466
- * Some examples:
467
- * \code
468
- * TVector<TStringBuf> values = StringSplitter("1\t2\t3").Split('\t');
469
- *
470
- * for(TStringBuf part: StringSplitter("1::2::::3").SplitByString("::").SkipEmpty()) {
471
- * Cerr << part;
472
- * }
473
- *
474
- * TVector<TString> firstTwoValues = StringSplitter("1\t2\t3").Split('\t').Take(2);
475
- * \endcode
476
- *
477
- * Use `Collect` or `AddTo` to store split results into an existing container:
478
- * \code
479
- * TVector<TStringBuf> values = {"0"};
480
- * StringSplitter("1\t2\t3").Split('\t').AddTo(&values);
481
- * \endcode
482
- * Note that `Collect` clears target container, while `AddTo` just inserts values.
483
- * You can use these methods with any container that has `emplace` / `emplace_back`.
484
- *
485
- * Use `ParseInto` to also perform string conversions before inserting values
486
- * into target container:
487
- * \code
488
- * TSet<int> values;
489
- * StringSplitter("1\t2\t3").Split('\t').ParseInto(&values);
490
- * \endcode
491
- */
492
-
493
- namespace NStringSplitPrivate {
494
- Y_HAS_MEMBER(push_back, PushBack);
495
- Y_HAS_MEMBER(insert, Insert);
496
- Y_HAS_MEMBER(data, Data);
497
-
498
- /**
499
- * This one is needed here so that `std::string_view -> std::string_view`
500
- * conversion works.
501
- */
502
- template<class Src, class Dst>
503
- inline void DoFromString(const Src& src, Dst* dst) {
504
- *dst = ::FromString<Dst>(src);
505
- }
506
-
507
- template<class T>
508
- inline void DoFromString(const T& src, T* dst) noexcept {
509
- *dst = src;
510
- }
511
-
512
- template<class Src, class Dst>
513
- inline Y_WARN_UNUSED_RESULT bool TryDoFromString(const Src& src, Dst* dst) noexcept {
514
- return ::TryFromString(src, *dst);
515
- }
516
-
517
- template<class T>
518
- inline Y_WARN_UNUSED_RESULT bool TryDoFromString(const T& src, T* dst) noexcept {
519
- *dst = src;
520
- return true;
521
- }
522
-
523
- /**
524
- * Consumer that places provided elements into a container. Not using
525
- * `emplace(iterator)` for efficiency.
526
- */
527
- template <class Container>
528
- struct TContainerConsumer {
529
- using value_type = typename Container::value_type;
530
-
531
- TContainerConsumer(Container* c)
532
- : C_(c)
533
- {
534
- }
535
-
536
- // TODO: return bool (continue)
537
- template<class StringBuf>
538
- void operator()(StringBuf e) const {
539
- this->operator()(C_, e);
540
- }
541
-
542
- private:
543
- template<class OtherContainer, class StringBuf>
544
- auto operator()(OtherContainer* c, StringBuf e) const -> decltype(c->emplace_back()) {
545
- return c->emplace_back(value_type(e));
546
- }
547
-
548
- template<class OtherContainer, class StringBuf>
549
- auto operator()(OtherContainer* c, StringBuf e) const -> decltype(c->emplace()) {
550
- return c->emplace(value_type(e));
551
- }
552
-
553
- Container* C_;
554
- };
555
-
556
- /**
557
- * Consumer that converts provided elements via `FromString` and places them
558
- * into a container.
559
- */
560
- template <class Container>
561
- struct TContainerConvertingConsumer {
562
- using value_type = typename Container::value_type;
563
-
564
- TContainerConvertingConsumer(Container* c)
565
- : C_(c)
566
- {
567
- }
568
-
569
- template <class StringBuf>
570
- void operator()(StringBuf e) const {
571
- this->operator()(C_, e);
572
- }
573
-
574
- private:
575
- template<class OtherContainer, class StringBuf>
576
- auto operator()(OtherContainer* c, StringBuf e) const -> decltype(c->emplace_back()) {
577
- value_type v;
578
- DoFromString(e, &v);
579
- return c->emplace_back(std::move(v));
580
- }
581
-
582
- template<class OtherContainer, class StringBuf>
583
- auto operator()(OtherContainer* c, StringBuf e) const -> decltype(c->emplace()) {
584
- value_type v;
585
- DoFromString(e, &v);
586
- return c->emplace(std::move(v));
587
- }
588
-
589
- Container* C_;
590
- };
591
-
592
- template <class String>
593
- struct TStringBufOfImpl {
594
- using type = std::conditional_t<
595
- THasData<String>::value,
596
- TBasicStringBuf<typename String::value_type>,
597
- TIteratorRange<typename String::const_iterator>
598
- >;
599
- };
600
-
601
- template <class Char, class Traits, class Allocator>
602
- struct TStringBufOfImpl<std::basic_string<Char, Traits, Allocator>> {
603
- using type = std::basic_string_view<Char, Traits>;
604
- };
605
-
606
- template <class Char, class Traits>
607
- struct TStringBufOfImpl<std::basic_string_view<Char, Traits>> {
608
- using type = std::basic_string_view<Char, Traits>;
609
- };
610
-
611
- /**
612
- * Metafunction that returns a string buffer for the given type. This is to
613
- * make sure that splitting `std::string` returns `std::string_view`.
614
- */
615
- template<class String>
616
- using TStringBufOf = typename TStringBufOfImpl<String>::type;
617
-
618
- template<class StringBuf, class Iterator>
619
- StringBuf DoMakeStringBuf(Iterator b, Iterator e, StringBuf*) {
620
- return StringBuf(b, e);
621
- }
622
-
623
- template<class Char, class Traits, class Iterator>
624
- std::basic_string_view<Char, Traits> DoMakeStringBuf(Iterator b, Iterator e, std::basic_string_view<Char, Traits>*) {
625
- return std::basic_string_view<Char, Traits>(b, e - b);
626
- }
627
-
628
- template<class StringBuf, class Iterator>
629
- StringBuf MakeStringBuf(Iterator b, Iterator e) {
630
- return DoMakeStringBuf(b, e, static_cast<StringBuf*>(nullptr));
631
- }
632
-
633
- template<class String>
634
- struct TIteratorOfImpl {
635
- using type = std::conditional_t<
636
- THasData<String>::value,
637
- const typename String::value_type*,
638
- typename String::const_iterator
639
- >;
640
- };
641
-
642
- template<class String>
643
- using TIteratorOf = typename TIteratorOfImpl<String>::type;
644
-
645
- template<class String>
646
- struct TIterState {
647
- using TStringBufType = TStringBufOf<String>;
648
- using TIterator = TIteratorOf<String>;
649
-
650
- TIterState(const String& string) noexcept
651
- : TokS()
652
- , TokD()
653
- {
654
- Init(string, THasData<String>());
655
- }
656
-
657
- operator TStringBufType() const noexcept {
658
- return Token();
659
- }
660
-
661
- template<
662
- typename Other,
663
- class = typename std::enable_if<
664
- std::is_convertible<Other, TStringBufType>::value,
665
- void
666
- >::type
667
- >
668
- bool operator==(const Other& toCompare) const {
669
- return TStringBufType(*this) == TStringBufType(toCompare);
670
- }
671
-
672
- explicit operator bool() const {
673
- return !Empty();
674
- }
675
-
676
- TIterator TokenStart() const noexcept {
677
- return TokS;
678
- }
679
-
680
- TIterator TokenDelim() const noexcept {
681
- return TokD;
682
- }
683
-
684
- TIterator TokenEnd() const noexcept {
685
- return B;
686
- }
687
-
688
- Y_PURE_FUNCTION
689
- bool Empty() const noexcept {
690
- return TokenStart() == TokenDelim();
691
- }
692
-
693
- TStringBufType Token() const noexcept {
694
- return MakeStringBuf<TStringBufType>(TokenStart(), TokenDelim());
695
- }
696
-
697
- TStringBufType Delim() const noexcept {
698
- return MakeStringBuf<TStringBufType>(TokenDelim(), TokenEnd());
699
- }
700
-
701
- TIterator B;
702
- TIterator E;
703
-
704
- TIterator TokS;
705
- TIterator TokD;
706
-
707
- private:
708
- void Init(const String& string, std::true_type) {
709
- B = string.data();
710
- E = string.data() + string.size();
711
- }
712
-
713
- void Init(const String& string, std::false_type) {
714
- B = string.begin();
715
- E = string.end();
716
- }
717
- };
718
-
719
- template <class Base>
720
- class TSplitRange : public Base, public TInputRangeAdaptor<TSplitRange<Base>> {
721
- using TStringBufType = decltype(std::declval<Base>().Next()->Token());
722
-
723
- public:
724
- template <typename... Args>
725
- inline TSplitRange(Args&&... args)
726
- : Base(std::forward<Args>(args)...)
727
- {
728
- }
729
-
730
- template <class Consumer, std::enable_if_t<std::is_same<decltype(std::declval<Consumer>()(std::declval<TStringBufType>())), void>::value, int>* = nullptr>
731
- inline void Consume(Consumer&& f) {
732
- for (auto&& it : *this) {
733
- f(it.Token());
734
- }
735
- }
736
-
737
- template <class Consumer, std::enable_if_t<std::is_same<decltype(std::declval<Consumer>()(std::declval<TStringBufType>())), bool>::value, int>* = nullptr>
738
- inline bool Consume(Consumer&& f) {
739
- for (auto&& it : *this) {
740
- if (!f(it.Token())) {
741
- return false;
742
- }
743
- }
744
- return true;
745
- }
746
-
747
- template<class Container, class = std::enable_if_t<THasInsert<Container>::value || THasPushBack<Container>::value>>
748
- operator Container() {
749
- Container result;
750
- AddTo(&result);
751
- return result;
752
- }
753
-
754
- template <class S>
755
- inline TVector<S> ToList() {
756
- TVector<S> result;
757
- for (auto&& it : *this) {
758
- result.push_back(S(it.Token()));
759
- }
760
- return result;
761
- }
762
-
763
- template <class Container>
764
- inline void Collect(Container* c) {
765
- Y_ASSERT(c);
766
- c->clear();
767
- AddTo(c);
768
- }
769
-
770
- template <class Container>
771
- inline void AddTo(Container* c) {
772
- Y_ASSERT(c);
773
- TContainerConsumer<Container> consumer(c);
774
- Consume(consumer);
775
- }
776
-
777
- template <class Container>
778
- inline void ParseInto(Container* c) {
779
- Y_ASSERT(c);
780
- TContainerConvertingConsumer<Container> consumer(c);
781
- Consume(consumer);
782
- }
783
-
784
- // TODO: this is actually TryParseInto
785
- /**
786
- * Same as `CollectInto`, just doesn't throw.
787
- *
788
- * \param[out] args Output arguments.
789
- * \returns Whether parsing was successful.
790
- */
791
- template <typename... Args>
792
- inline bool TryCollectInto(Args*... args) noexcept {
793
- size_t successfullyFilled = 0;
794
- auto it = this->begin();
795
-
796
- //FIXME: actually, some kind of TryApplyToMany is needed in order to stop iteration upon first failure
797
- ApplyToMany([&](auto&& arg) {
798
- if (it != this->end()) {
799
- if (TryDoFromString(it->Token(), arg)) {
800
- ++successfullyFilled;
801
- }
802
- ++it;
803
- }
804
- }, args...);
805
-
806
- return successfullyFilled == sizeof...(args) && it == this->end();
807
- }
808
-
809
- // TODO: this is actually ParseInto
810
- /**
811
- * Splits and parses everything that's in this splitter into `args`.
812
- *
813
- * Example usage:
814
- * \code
815
- * int l, r;
816
- * StringSplitter("100*200").Split('*').CollectInto(&l, &r);
817
- * \endcode
818
- *
819
- * \param[out] args Output arguments.
820
- * \throws If not all items were parsed, or
821
- * if there were too many items in the split.
822
- */
823
- template <typename... Args>
824
- inline void CollectInto(Args*... args) {
825
- Y_ENSURE(TryCollectInto<Args...>(args...));
826
- }
827
-
828
- inline size_t Count() const {
829
- size_t cnt = 0;
830
- for (auto&& it : *this) {
831
- Y_UNUSED(it);
832
- ++cnt;
833
- }
834
- return cnt;
835
- }
836
- };
837
-
838
- template <class String>
839
- class TStringSplitter {
840
- using TStringType = String;
841
- using TStringBufType = TStringBufOf<TStringType>;
842
- using TChar = typename TStringType::value_type;
843
- using TIterator = TIteratorOf<TStringType>;
844
- using TIteratorState = TIterState<TStringType>;
845
-
846
- /**
847
- * Base class for all split ranges that actually does the splitting.
848
- */
849
- template <class DelimStorage>
850
- struct TSplitRangeBase {
851
- template <class OtherString, class... Args>
852
- inline TSplitRangeBase(OtherString&& s, Args&&... args)
853
- : String_(std::forward<OtherString>(s))
854
- , State_(String_)
855
- , Delim_(std::forward<Args>(args)...)
856
- {
857
- }
858
-
859
- inline TIteratorState* Next() {
860
- if (State_.TokD == State_.B) {
861
- return nullptr;
862
- }
863
-
864
- State_.TokS = State_.B;
865
- State_.TokD = Delim_.Ptr()->Find(State_.B, State_.E);
866
-
867
- return &State_;
868
- }
869
-
870
- private:
871
- TStringType String_;
872
- TIteratorState State_;
873
- DelimStorage Delim_;
874
- };
875
-
876
- template <class Base, class Filter>
877
- struct TFilterRange : public Base {
878
- template <class... Args>
879
- inline TFilterRange(const Base& base, Args&&... args)
880
- : Base(base)
881
- , Filter_(std::forward<Args>(args)...)
882
- {
883
- }
884
-
885
- inline TIteratorState* Next() {
886
- TIteratorState* ret;
887
-
888
- do {
889
- ret = Base::Next();
890
- } while (ret && !Filter_.Accept(ret));
891
-
892
- return ret;
893
- }
894
-
895
- Filter Filter_;
896
- };
897
-
898
- struct TNonEmptyFilter {
899
- template <class TToken>
900
- inline bool Accept(const TToken* token) noexcept {
901
- return !token->Empty();
902
- }
903
- };
904
-
905
- template <class TIter>
906
- struct TStopIteration;
907
-
908
- template <class Base>
909
- struct TFilters : public Base {
910
- template <class TFilter>
911
- using TIt = TSplitRange<TStopIteration<TFilters<TFilterRange<Base, TFilter>>>>;
912
-
913
- template <typename... Args>
914
- inline TFilters(Args&&... args)
915
- : Base(std::forward<Args>(args)...)
916
- {
917
- }
918
-
919
- inline TIt<TNonEmptyFilter> SkipEmpty() const {
920
- return { *this };
921
- }
922
- };
923
-
924
- template <class Base, class Stopper>
925
- struct TStopRange : public Base {
926
- template <typename... Args>
927
- inline TStopRange(const Base& base, Args&&... args)
928
- : Base(base)
929
- , Stopper_(std::forward<Args>(args)...)
930
- {
931
- }
932
-
933
- inline TIteratorState* Next() {
934
- TIteratorState* ret = Base::Next();
935
- if (!ret || Stopper_.Stop(ret)) {
936
- return nullptr;
937
- }
938
- return ret;
939
- }
940
-
941
- Stopper Stopper_;
942
- };
943
-
944
- struct TTake {
945
- TTake() = default;
946
-
947
- TTake(size_t count)
948
- : Count(count)
949
- {
950
- }
951
-
952
- template <class TToken>
953
- inline bool Stop(TToken*) noexcept {
954
- if (Count > 0) {
955
- --Count;
956
- return false;
957
- } else {
958
- return true;
959
- }
960
- }
961
-
962
- size_t Count = 0;
963
- };
964
-
965
- struct TLimit {
966
- TLimit() = default;
967
-
968
- TLimit(size_t count)
969
- : Count(count)
970
- {
971
- Y_ASSERT(Count > 0);
972
- }
973
-
974
- template <class TToken>
975
- inline bool Stop(TToken* token) noexcept {
976
- if (Count > 1) {
977
- --Count;
978
- return false;
979
- } else if (Count == 1) {
980
- token->TokD = token->B = token->E;
981
- return false;
982
- }
983
- return true;
984
- }
985
-
986
- size_t Count = 0;
987
- };
988
-
989
- template <class Base>
990
- struct TStopIteration : public Base {
991
- template <class TStopper>
992
- using TIt = TSplitRange<TStopIteration<TFilters<TStopRange<Base, TStopper>>>>;
993
-
994
- template <typename... Args>
995
- inline TStopIteration(Args&&... args)
996
- : Base(std::forward<Args>(args)...)
997
- {
998
- }
999
-
1000
- inline TIt<TTake> Take(size_t count) {
1001
- return { *this, count };
1002
- }
1003
-
1004
- inline TIt<TLimit> Limit(size_t count) {
1005
- return { *this, count };
1006
- }
1007
- };
1008
-
1009
- template <class TPolicy>
1010
- using TIt = TSplitRange<TStopIteration<TFilters<TSplitRangeBase<TPolicy>>>>;
1011
-
1012
- public:
1013
- template<class OtherString>
1014
- explicit TStringSplitter(OtherString&& s)
1015
- : String_(std::forward<OtherString>(s))
1016
- {
1017
- }
1018
-
1019
- //does not own TDelim
1020
- template <class TDelim>
1021
- inline TIt<TPtrPolicy<const TDelim>> Split(const TDelim& d) const noexcept {
1022
- return { String_, &d };
1023
- }
1024
-
1025
- inline TIt<TEmbedPolicy<TCharDelimiter<const TChar>>> Split(TChar ch) const noexcept {
1026
- return { String_, ch };
1027
- }
1028
-
1029
- inline TIt<TSimpleRefPolicy<TSetDelimiter<const TChar>>> SplitBySet(const TChar* set) const noexcept {
1030
- return { String_, set };
1031
- }
1032
-
1033
- inline TIt<TEmbedPolicy<TStringDelimiter<const TChar>>> SplitByString(const TStringBufType& str) const noexcept {
1034
- return { String_, str.data(), str.size() };
1035
- }
1036
-
1037
- template <class TFunc>
1038
- inline TIt<TEmbedPolicy<TFuncDelimiter<TIterator, TFunc>>> SplitByFunc(TFunc f) const noexcept {
1039
- return { String_, f };
1040
- }
1041
-
1042
- private:
1043
- TStringType String_;
1044
- };
1045
-
1046
- template<class String>
1047
- auto MakeStringSplitter(String&& s) {
1048
- return TStringSplitter<std::remove_reference_t<String>>(std::forward<String>(s));
1049
- }
1050
- }
1051
-
1052
- template <class Iterator>
1053
- auto StringSplitter(Iterator begin, Iterator end) {
1054
- return ::NStringSplitPrivate::MakeStringSplitter(TIteratorRange<Iterator>(begin, end));
1055
- }
1056
-
1057
- template <class Char>
1058
- auto StringSplitter(const Char* begin, const Char* end) {
1059
- return ::NStringSplitPrivate::MakeStringSplitter(TBasicStringBuf<Char>(begin, end));
1060
- }
1061
-
1062
- template <class Char>
1063
- auto StringSplitter(const Char* begin, size_t len) {
1064
- return ::NStringSplitPrivate::MakeStringSplitter(TBasicStringBuf<Char>(begin, len));
1065
- }
1066
-
1067
- template <class Char>
1068
- auto StringSplitter(const Char* str) {
1069
- return ::NStringSplitPrivate::MakeStringSplitter(TBasicStringBuf<Char>(str));
1070
- }
1071
-
1072
- template <class String, std::enable_if_t<!std::is_pointer<std::remove_reference_t<String>>::value, int> = 0>
1073
- auto StringSplitter(String& s) {
1074
- return ::NStringSplitPrivate::MakeStringSplitter(::NStringSplitPrivate::TStringBufOf<String>(s.data(), s.size()));
1075
- }
1076
-
1077
- template <class String, std::enable_if_t<!std::is_pointer<std::remove_reference_t<String>>::value, int> = 0>
1078
- auto StringSplitter(String&& s) {
1079
- return ::NStringSplitPrivate::MakeStringSplitter(std::move(s));
1080
- }