catboost 1.25.1 → 1.26.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 (289) hide show
  1. package/DEPLOYMENT.md +22 -15
  2. package/README.md +37 -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/config.js +32 -18
  10. package/build_scripts/out/install.js +5 -3
  11. package/build_scripts/out/package_prepublish.js +1 -1
  12. package/build_scripts/out/packaging.js +1 -19
  13. package/build_scripts/out/run_tests.js +1 -1
  14. package/build_scripts/out/test.js +8 -3
  15. package/config.json +18 -11
  16. package/inc/catboost/libs/model_interface/c_api.h +349 -3
  17. package/lib/catboost.d.ts +65 -21
  18. package/package.json +4 -4
  19. package/src/api_helpers.cpp +100 -24
  20. package/src/api_helpers.h +8 -7
  21. package/src/api_module.cpp +1 -2
  22. package/src/model.cpp +483 -83
  23. package/src/model.h +24 -9
  24. package/inc/contrib/libs/cxxsupp/system_stl/include/stlfwd +0 -14
  25. package/inc/util/charset/recode_result.h +0 -9
  26. package/inc/util/charset/unicode_table.h +0 -123
  27. package/inc/util/charset/unidata.h +0 -421
  28. package/inc/util/charset/utf8.h +0 -384
  29. package/inc/util/charset/wide.h +0 -843
  30. package/inc/util/charset/wide_specific.h +0 -22
  31. package/inc/util/datetime/base.h +0 -669
  32. package/inc/util/datetime/constants.h +0 -7
  33. package/inc/util/datetime/cputimer.h +0 -124
  34. package/inc/util/datetime/parser.h +0 -292
  35. package/inc/util/datetime/systime.h +0 -47
  36. package/inc/util/datetime/uptime.h +0 -8
  37. package/inc/util/digest/city.h +0 -88
  38. package/inc/util/digest/fnv.h +0 -73
  39. package/inc/util/digest/multi.h +0 -14
  40. package/inc/util/digest/murmur.h +0 -57
  41. package/inc/util/digest/numeric.h +0 -86
  42. package/inc/util/digest/sequence.h +0 -48
  43. package/inc/util/draft/date.h +0 -129
  44. package/inc/util/draft/datetime.h +0 -184
  45. package/inc/util/draft/enum.h +0 -136
  46. package/inc/util/draft/holder_vector.h +0 -102
  47. package/inc/util/draft/ip.h +0 -131
  48. package/inc/util/draft/matrix.h +0 -108
  49. package/inc/util/draft/memory.h +0 -40
  50. package/inc/util/folder/dirent_win.h +0 -46
  51. package/inc/util/folder/dirut.h +0 -121
  52. package/inc/util/folder/filelist.h +0 -81
  53. package/inc/util/folder/fts.h +0 -108
  54. package/inc/util/folder/iterator.h +0 -109
  55. package/inc/util/folder/lstat_win.h +0 -20
  56. package/inc/util/folder/path.h +0 -225
  57. package/inc/util/folder/pathsplit.h +0 -113
  58. package/inc/util/folder/tempdir.h +0 -42
  59. package/inc/util/generic/adaptor.h +0 -134
  60. package/inc/util/generic/algorithm.h +0 -765
  61. package/inc/util/generic/array_ref.h +0 -282
  62. package/inc/util/generic/array_size.h +0 -24
  63. package/inc/util/generic/benchmark/vector_count_ctor/f.h +0 -9
  64. package/inc/util/generic/bitmap.h +0 -1115
  65. package/inc/util/generic/bitops.h +0 -459
  66. package/inc/util/generic/bt_exception.h +0 -24
  67. package/inc/util/generic/buffer.h +0 -232
  68. package/inc/util/generic/cast.h +0 -176
  69. package/inc/util/generic/deque.h +0 -24
  70. package/inc/util/generic/explicit_type.h +0 -42
  71. package/inc/util/generic/fastqueue.h +0 -55
  72. package/inc/util/generic/flags.h +0 -244
  73. package/inc/util/generic/function.h +0 -103
  74. package/inc/util/generic/fwd.h +0 -171
  75. package/inc/util/generic/guid.h +0 -61
  76. package/inc/util/generic/hash.h +0 -2032
  77. package/inc/util/generic/hash_primes.h +0 -140
  78. package/inc/util/generic/hash_set.h +0 -490
  79. package/inc/util/generic/hide_ptr.h +0 -3
  80. package/inc/util/generic/intrlist.h +0 -876
  81. package/inc/util/generic/is_in.h +0 -53
  82. package/inc/util/generic/iterator.h +0 -137
  83. package/inc/util/generic/iterator_range.h +0 -105
  84. package/inc/util/generic/lazy_value.h +0 -66
  85. package/inc/util/generic/list.h +0 -22
  86. package/inc/util/generic/map.h +0 -44
  87. package/inc/util/generic/mapfindptr.h +0 -60
  88. package/inc/util/generic/maybe.h +0 -713
  89. package/inc/util/generic/maybe_traits.h +0 -164
  90. package/inc/util/generic/mem_copy.h +0 -55
  91. package/inc/util/generic/noncopyable.h +0 -38
  92. package/inc/util/generic/object_counter.h +0 -53
  93. package/inc/util/generic/ptr.h +0 -1113
  94. package/inc/util/generic/queue.h +0 -57
  95. package/inc/util/generic/refcount.h +0 -162
  96. package/inc/util/generic/reserve.h +0 -11
  97. package/inc/util/generic/scope.h +0 -65
  98. package/inc/util/generic/serialized_enum.h +0 -406
  99. package/inc/util/generic/set.h +0 -42
  100. package/inc/util/generic/singleton.h +0 -136
  101. package/inc/util/generic/size_literals.h +0 -65
  102. package/inc/util/generic/stack.h +0 -18
  103. package/inc/util/generic/store_policy.h +0 -120
  104. package/inc/util/generic/strbase.h +0 -612
  105. package/inc/util/generic/strbuf.h +0 -552
  106. package/inc/util/generic/strfcpy.h +0 -17
  107. package/inc/util/generic/string.h +0 -1572
  108. package/inc/util/generic/string_hash.h +0 -21
  109. package/inc/util/generic/string_ut.h +0 -1175
  110. package/inc/util/generic/type_name.h +0 -34
  111. package/inc/util/generic/typelist.h +0 -114
  112. package/inc/util/generic/typetraits.h +0 -325
  113. package/inc/util/generic/utility.h +0 -132
  114. package/inc/util/generic/va_args.h +0 -400
  115. package/inc/util/generic/variant.h +0 -631
  116. package/inc/util/generic/variant_traits.h +0 -171
  117. package/inc/util/generic/vector.h +0 -119
  118. package/inc/util/generic/xrange.h +0 -258
  119. package/inc/util/generic/yexception.h +0 -212
  120. package/inc/util/generic/yexception_ut.h +0 -14
  121. package/inc/util/generic/ylimits.h +0 -92
  122. package/inc/util/generic/ymath.h +0 -206
  123. package/inc/util/memory/addstorage.h +0 -93
  124. package/inc/util/memory/alloc.h +0 -27
  125. package/inc/util/memory/blob.h +0 -296
  126. package/inc/util/memory/mmapalloc.h +0 -8
  127. package/inc/util/memory/pool.h +0 -432
  128. package/inc/util/memory/segmented_string_pool.h +0 -194
  129. package/inc/util/memory/segpool_alloc.h +0 -118
  130. package/inc/util/memory/smallobj.h +0 -141
  131. package/inc/util/memory/tempbuf.h +0 -111
  132. package/inc/util/network/address.h +0 -136
  133. package/inc/util/network/endpoint.h +0 -61
  134. package/inc/util/network/hostip.h +0 -16
  135. package/inc/util/network/init.h +0 -60
  136. package/inc/util/network/interface.h +0 -17
  137. package/inc/util/network/iovec.h +0 -65
  138. package/inc/util/network/ip.h +0 -116
  139. package/inc/util/network/nonblock.h +0 -8
  140. package/inc/util/network/pair.h +0 -9
  141. package/inc/util/network/poller.h +0 -58
  142. package/inc/util/network/pollerimpl.h +0 -707
  143. package/inc/util/network/sock.h +0 -608
  144. package/inc/util/network/socket.h +0 -421
  145. package/inc/util/random/common_ops.h +0 -130
  146. package/inc/util/random/easy.h +0 -47
  147. package/inc/util/random/entropy.h +0 -21
  148. package/inc/util/random/fast.h +0 -101
  149. package/inc/util/random/init_atfork.h +0 -3
  150. package/inc/util/random/lcg_engine.h +0 -66
  151. package/inc/util/random/mersenne.h +0 -46
  152. package/inc/util/random/mersenne32.h +0 -50
  153. package/inc/util/random/mersenne64.h +0 -50
  154. package/inc/util/random/normal.h +0 -38
  155. package/inc/util/random/random.h +0 -30
  156. package/inc/util/random/shuffle.h +0 -39
  157. package/inc/util/str_stl.h +0 -266
  158. package/inc/util/stream/aligned.h +0 -99
  159. package/inc/util/stream/buffer.h +0 -119
  160. package/inc/util/stream/buffered.h +0 -225
  161. package/inc/util/stream/debug.h +0 -53
  162. package/inc/util/stream/direct_io.h +0 -43
  163. package/inc/util/stream/file.h +0 -108
  164. package/inc/util/stream/format.h +0 -444
  165. package/inc/util/stream/fwd.h +0 -100
  166. package/inc/util/stream/hex.h +0 -8
  167. package/inc/util/stream/holder.h +0 -44
  168. package/inc/util/stream/input.h +0 -273
  169. package/inc/util/stream/labeled.h +0 -19
  170. package/inc/util/stream/length.h +0 -100
  171. package/inc/util/stream/mem.h +0 -255
  172. package/inc/util/stream/multi.h +0 -32
  173. package/inc/util/stream/null.h +0 -61
  174. package/inc/util/stream/output.h +0 -304
  175. package/inc/util/stream/pipe.h +0 -112
  176. package/inc/util/stream/printf.h +0 -25
  177. package/inc/util/stream/str.h +0 -207
  178. package/inc/util/stream/tee.h +0 -28
  179. package/inc/util/stream/tempbuf.h +0 -21
  180. package/inc/util/stream/tokenizer.h +0 -214
  181. package/inc/util/stream/trace.h +0 -60
  182. package/inc/util/stream/walk.h +0 -35
  183. package/inc/util/stream/zerocopy.h +0 -91
  184. package/inc/util/stream/zerocopy_output.h +0 -57
  185. package/inc/util/stream/zlib.h +0 -173
  186. package/inc/util/string/ascii.h +0 -236
  187. package/inc/util/string/builder.h +0 -39
  188. package/inc/util/string/cast.h +0 -347
  189. package/inc/util/string/cstriter.h +0 -14
  190. package/inc/util/string/escape.h +0 -70
  191. package/inc/util/string/hex.h +0 -59
  192. package/inc/util/string/join.h +0 -194
  193. package/inc/util/string/printf.h +0 -13
  194. package/inc/util/string/reverse.h +0 -16
  195. package/inc/util/string/split.h +0 -1080
  196. package/inc/util/string/strip.h +0 -257
  197. package/inc/util/string/strspn.h +0 -65
  198. package/inc/util/string/subst.h +0 -56
  199. package/inc/util/string/type.h +0 -50
  200. package/inc/util/string/util.h +0 -195
  201. package/inc/util/string/vector.h +0 -132
  202. package/inc/util/system/align.h +0 -50
  203. package/inc/util/system/atexit.h +0 -22
  204. package/inc/util/system/atomic.h +0 -51
  205. package/inc/util/system/atomic_gcc.h +0 -90
  206. package/inc/util/system/atomic_ops.h +0 -189
  207. package/inc/util/system/atomic_win.h +0 -114
  208. package/inc/util/system/backtrace.h +0 -39
  209. package/inc/util/system/byteorder.h +0 -186
  210. package/inc/util/system/compat.h +0 -84
  211. package/inc/util/system/compiler.h +0 -620
  212. package/inc/util/system/condvar.h +0 -71
  213. package/inc/util/system/context.h +0 -181
  214. package/inc/util/system/context_aarch64.h +0 -8
  215. package/inc/util/system/context_i686.h +0 -9
  216. package/inc/util/system/context_x86.h +0 -12
  217. package/inc/util/system/context_x86_64.h +0 -7
  218. package/inc/util/system/cpu_id.h +0 -159
  219. package/inc/util/system/daemon.h +0 -28
  220. package/inc/util/system/datetime.h +0 -98
  221. package/inc/util/system/defaults.h +0 -149
  222. package/inc/util/system/demangle.h +0 -5
  223. package/inc/util/system/demangle_impl.h +0 -23
  224. package/inc/util/system/direct_io.h +0 -71
  225. package/inc/util/system/dynlib.h +0 -119
  226. package/inc/util/system/env.h +0 -32
  227. package/inc/util/system/error.h +0 -95
  228. package/inc/util/system/event.h +0 -122
  229. package/inc/util/system/execpath.h +0 -17
  230. package/inc/util/system/fasttime.h +0 -6
  231. package/inc/util/system/fhandle.h +0 -27
  232. package/inc/util/system/file.h +0 -210
  233. package/inc/util/system/file_lock.h +0 -34
  234. package/inc/util/system/filemap.h +0 -383
  235. package/inc/util/system/flock.h +0 -35
  236. package/inc/util/system/fs.h +0 -156
  237. package/inc/util/system/fs_win.h +0 -29
  238. package/inc/util/system/fstat.h +0 -46
  239. package/inc/util/system/getpid.h +0 -12
  240. package/inc/util/system/guard.h +0 -179
  241. package/inc/util/system/hi_lo.h +0 -139
  242. package/inc/util/system/hostname.h +0 -10
  243. package/inc/util/system/hp_timer.h +0 -36
  244. package/inc/util/system/info.h +0 -12
  245. package/inc/util/system/interrupt_signals.h +0 -22
  246. package/inc/util/system/madvise.h +0 -30
  247. package/inc/util/system/maxlen.h +0 -32
  248. package/inc/util/system/mem_info.h +0 -18
  249. package/inc/util/system/mincore.h +0 -38
  250. package/inc/util/system/mktemp.h +0 -11
  251. package/inc/util/system/mlock.h +0 -43
  252. package/inc/util/system/mutex.h +0 -67
  253. package/inc/util/system/nice.h +0 -3
  254. package/inc/util/system/pipe.h +0 -90
  255. package/inc/util/system/platform.h +0 -246
  256. package/inc/util/system/progname.h +0 -13
  257. package/inc/util/system/protect.h +0 -25
  258. package/inc/util/system/rusage.h +0 -26
  259. package/inc/util/system/rwlock.h +0 -78
  260. package/inc/util/system/sanitizers.h +0 -122
  261. package/inc/util/system/sem.h +0 -41
  262. package/inc/util/system/shellcommand.h +0 -472
  263. package/inc/util/system/shmat.h +0 -32
  264. package/inc/util/system/sigset.h +0 -78
  265. package/inc/util/system/spin_wait.h +0 -10
  266. package/inc/util/system/spinlock.h +0 -121
  267. package/inc/util/system/src_location.h +0 -25
  268. package/inc/util/system/src_root.h +0 -68
  269. package/inc/util/system/sys_alloc.h +0 -43
  270. package/inc/util/system/sysstat.h +0 -52
  271. package/inc/util/system/tempfile.h +0 -34
  272. package/inc/util/system/thread.h +0 -167
  273. package/inc/util/system/tls.h +0 -307
  274. package/inc/util/system/types.h +0 -119
  275. package/inc/util/system/unaligned_mem.h +0 -67
  276. package/inc/util/system/user.h +0 -5
  277. package/inc/util/system/utime.h +0 -6
  278. package/inc/util/system/valgrind.h +0 -48
  279. package/inc/util/system/winint.h +0 -43
  280. package/inc/util/system/yassert.h +0 -121
  281. package/inc/util/system/yield.h +0 -4
  282. package/inc/util/thread/factory.h +0 -65
  283. package/inc/util/thread/fwd.h +0 -30
  284. package/inc/util/thread/lfqueue.h +0 -406
  285. package/inc/util/thread/lfstack.h +0 -188
  286. package/inc/util/thread/pool.h +0 -388
  287. package/inc/util/thread/singleton.h +0 -42
  288. package/inc/util/ysafeptr.h +0 -427
  289. package/inc/util/ysaveload.h +0 -700
@@ -1,236 +0,0 @@
1
- #pragma once
2
-
3
- #include <util/system/defaults.h>
4
- #include <util/system/compat.h>
5
- #include <util/generic/string.h>
6
-
7
- // ctype.h-like functions, locale-independent:
8
- // IsAscii{Upper,Lower,Digit,Alpha,Alnum,Space} and
9
- // AsciiTo{Upper,Lower}
10
- //
11
- // standard functions from <ctype.h> are locale dependent,
12
- // and cause undefined behavior when called on chars outside [0..127] range
13
-
14
- namespace NPrivate {
15
- enum ECharClass {
16
- CC_SPACE = 1,
17
- CC_UPPER = 2,
18
- CC_LOWER = 4,
19
- CC_DIGIT = 8,
20
- CC_ALPHA = 16,
21
- CC_ALNUM = 32,
22
- CC_ISHEX = 64,
23
- CC_PUNCT = 128,
24
- };
25
-
26
- extern const unsigned char ASCII_CLASS[256];
27
- extern const unsigned char ASCII_LOWER[256];
28
-
29
- template <class T>
30
- struct TDereference {
31
- using type = T;
32
- };
33
-
34
- #ifndef TSTRING_IS_STD_STRING
35
- template <class String>
36
- struct TDereference<TBasicCharRef<String>> {
37
- using type = typename String::value_type;
38
- };
39
- #endif
40
-
41
- template <class T>
42
- using TDereferenced = typename TDereference<T>::type;
43
-
44
- template <class T>
45
- bool RangeOk(T c) noexcept {
46
- static_assert(std::is_integral<T>::value, "Integral type character expected");
47
-
48
- if (sizeof(T) == 1) {
49
- return true;
50
- }
51
-
52
- return c >= static_cast<T>(0) && c <= static_cast<T>(127);
53
- }
54
-
55
- #ifndef TSTRING_IS_STD_STRING
56
- template <class String>
57
- bool RangeOk(const TBasicCharRef<String>& c) {
58
- return RangeOk(static_cast<typename String::value_type>(c));
59
- }
60
- #endif
61
- }
62
-
63
- constexpr bool IsAscii(const int c) noexcept {
64
- return !(c & ~0x7f);
65
- }
66
-
67
- inline bool IsAsciiSpace(unsigned char c) {
68
- return ::NPrivate::ASCII_CLASS[c] & ::NPrivate::CC_SPACE;
69
- }
70
-
71
- inline bool IsAsciiUpper(unsigned char c) {
72
- return ::NPrivate::ASCII_CLASS[c] & ::NPrivate::CC_UPPER;
73
- }
74
-
75
- inline bool IsAsciiLower(unsigned char c) {
76
- return ::NPrivate::ASCII_CLASS[c] & ::NPrivate::CC_LOWER;
77
- }
78
-
79
- inline bool IsAsciiDigit(unsigned char c) {
80
- return ::NPrivate::ASCII_CLASS[c] & ::NPrivate::CC_DIGIT;
81
- }
82
-
83
- inline bool IsAsciiAlpha(unsigned char c) {
84
- return ::NPrivate::ASCII_CLASS[c] & ::NPrivate::CC_ALPHA;
85
- }
86
-
87
- inline bool IsAsciiAlnum(unsigned char c) {
88
- return ::NPrivate::ASCII_CLASS[c] & ::NPrivate::CC_ALNUM;
89
- }
90
-
91
- inline bool IsAsciiHex(unsigned char c) {
92
- return ::NPrivate::ASCII_CLASS[c] & ::NPrivate::CC_ISHEX;
93
- }
94
-
95
- inline bool IsAsciiPunct(unsigned char c) {
96
- return ::NPrivate::ASCII_CLASS[c] & ::NPrivate::CC_PUNCT;
97
- }
98
-
99
- // some overloads
100
-
101
- template <class T>
102
- inline bool IsAsciiSpace(T c) {
103
- return ::NPrivate::RangeOk(c) && IsAsciiSpace(static_cast<unsigned char>(c));
104
- }
105
-
106
- template <class T>
107
- inline bool IsAsciiUpper(T c) {
108
- return ::NPrivate::RangeOk(c) && IsAsciiUpper(static_cast<unsigned char>(c));
109
- }
110
-
111
- template <class T>
112
- inline bool IsAsciiLower(T c) {
113
- return ::NPrivate::RangeOk(c) && IsAsciiLower(static_cast<unsigned char>(c));
114
- }
115
-
116
- template <class T>
117
- inline bool IsAsciiDigit(T c) {
118
- return ::NPrivate::RangeOk(c) && IsAsciiDigit(static_cast<unsigned char>(c));
119
- }
120
-
121
- template <class T>
122
- inline bool IsAsciiAlpha(T c) {
123
- return ::NPrivate::RangeOk(c) && IsAsciiAlpha(static_cast<unsigned char>(c));
124
- }
125
-
126
- template <class T>
127
- inline bool IsAsciiAlnum(T c) {
128
- return ::NPrivate::RangeOk(c) && IsAsciiAlnum(static_cast<unsigned char>(c));
129
- }
130
-
131
- template <class T>
132
- inline bool IsAsciiHex(T c) {
133
- return ::NPrivate::RangeOk(c) && IsAsciiHex(static_cast<unsigned char>(c));
134
- }
135
-
136
- template <class T>
137
- inline bool IsAsciiPunct(T c) {
138
- return ::NPrivate::RangeOk(c) && IsAsciiPunct(static_cast<unsigned char>(c));
139
- }
140
-
141
- // some extra helpers
142
- inline ui8 AsciiToLower(ui8 c) noexcept {
143
- return ::NPrivate::ASCII_LOWER[c];
144
- }
145
-
146
- inline char AsciiToLower(char c) noexcept {
147
- return (char)AsciiToLower((ui8)c);
148
- }
149
-
150
- template <class T>
151
- inline ::NPrivate::TDereferenced<T> AsciiToLower(T c) noexcept {
152
- return (c >= 0 && c <= 127) ? (::NPrivate::TDereferenced<T>)AsciiToLower((ui8)c) : c;
153
- }
154
-
155
- template <class T>
156
- inline ::NPrivate::TDereferenced<T> AsciiToUpper(T c) noexcept {
157
- return IsAsciiLower(c) ? (c + ('A' - 'a')) : c;
158
- }
159
-
160
- /**
161
- * ASCII case-insensitive string comparison (for proper UTF8 strings
162
- * case-insensitive comparison consider using @c library/cpp/charset).
163
- *
164
- * @return true iff @c s1 ans @c s2 are case-insensitively equal.
165
- */
166
- static inline bool AsciiEqualsIgnoreCase(const char* s1, const char* s2) noexcept {
167
- return stricmp(s1, s2) == 0;
168
- }
169
-
170
- /**
171
- * ASCII case-insensitive string comparison (for proper UTF8 strings
172
- * case-insensitive comparison consider using @c library/cpp/charset).
173
- *
174
- * @return true iff @c s1 ans @c s2 are case-insensitively equal.
175
- */
176
- static inline bool AsciiEqualsIgnoreCase(const TStringBuf s1, const TStringBuf s2) noexcept {
177
- return (s1.size() == s2.size()) && strnicmp(s1.data(), s2.data(), s1.size()) == 0;
178
- }
179
-
180
- /**
181
- * ASCII case-insensitive string comparison (for proper UTF8 strings
182
- * case-insensitive comparison consider using @c library/cpp/charset).
183
- *
184
- * @return 0 if strings are equal, negative if @c s1 < @c s2
185
- * and positive otherwise.
186
- * (same value as @c stricmp does).
187
- */
188
- static inline int AsciiCompareIgnoreCase(const char* s1, const char* s2) noexcept {
189
- return stricmp(s1, s2);
190
- }
191
-
192
- /**
193
- * ASCII case-insensitive string comparison (for proper UTF8 strings
194
- * case-insensitive comparison consider using @c library/cpp/charset).
195
- *
196
- * @return
197
- * - zero if strings are equal
198
- * - negative if @c s1 < @c s2
199
- * - positive otherwise,
200
- * similar to stricmp.
201
- *
202
- * BUGS: Currently will NOT work properly with strings that contain
203
- * 0-terminator character inside.
204
- */
205
- Y_PURE_FUNCTION
206
- int AsciiCompareIgnoreCase(const TStringBuf s1, const TStringBuf s2) noexcept;
207
-
208
- /**
209
- * ASCII case-sensitive string comparison (for proper UTF8 strings
210
- * case-sensitive comparison consider using @c library/cpp/charset).
211
- *
212
- * @return true iff @c s2 are case-sensitively prefix of @c s1.
213
- */
214
- static inline bool AsciiHasPrefix(const TStringBuf s1, const TStringBuf s2) noexcept {
215
- return (s1.size() >= s2.size()) && memcmp(s1.data(), s2.data(), s2.size()) == 0;
216
- }
217
-
218
- /**
219
- * ASCII case-insensitive string comparison (for proper UTF8 strings
220
- * case-insensitive comparison consider using @c library/cpp/charset).
221
- *
222
- * @return true iff @c s2 are case-insensitively prefix of @c s1.
223
- */
224
- static inline bool AsciiHasPrefixIgnoreCase(const TStringBuf s1, const TStringBuf s2) noexcept {
225
- return (s1.size() >= s2.size()) && strnicmp(s1.data(), s2.data(), s2.size()) == 0;
226
- }
227
-
228
- /**
229
- * ASCII case-insensitive string comparison (for proper UTF8 strings
230
- * case-insensitive comparison consider using @c library/cpp/charset).
231
- *
232
- * @return true iff @c s2 are case-insensitively suffix of @c s1.
233
- */
234
- static inline bool AsciiHasSuffixIgnoreCase(const TStringBuf s1, const TStringBuf s2) noexcept {
235
- return (s1.size() >= s2.size()) && strnicmp((s1.data() + (s1.size() - s2.size())), s2.data(), s2.size()) == 0;
236
- }
@@ -1,39 +0,0 @@
1
- #pragma once
2
-
3
- #include <util/stream/str.h>
4
- #include <utility>
5
- #include <util/generic/string.h>
6
-
7
- namespace NPrivateStringBuilder {
8
- class TStringBuilder: public TString {
9
- public:
10
- inline TStringBuilder()
11
- : Out(*this)
12
- {
13
- }
14
-
15
- TStringBuilder(TStringBuilder&& rhs)
16
- : TString(std::move(rhs))
17
- , Out(*this)
18
- {
19
- }
20
-
21
- TStringOutput Out;
22
- };
23
-
24
- template <class T>
25
- static inline TStringBuilder& operator<<(TStringBuilder& builder, const T& t) {
26
- builder.Out << t;
27
-
28
- return builder;
29
- }
30
-
31
- template <class T>
32
- static inline TStringBuilder&& operator<<(TStringBuilder&& builder, const T& t) {
33
- builder.Out << t;
34
-
35
- return std::move(builder);
36
- }
37
- }
38
-
39
- using TStringBuilder = NPrivateStringBuilder::TStringBuilder;
@@ -1,347 +0,0 @@
1
- #pragma once
2
-
3
- #include <util/system/defaults.h>
4
- #include <util/stream/str.h>
5
- #include <util/generic/string.h>
6
- #include <util/generic/strbuf.h>
7
- #include <util/generic/typetraits.h>
8
- #include <util/generic/yexception.h>
9
-
10
- /*
11
- * specialized for all arithmetic types
12
- */
13
-
14
- template <class T>
15
- size_t ToStringImpl(T t, char* buf, size_t len);
16
-
17
- /**
18
- * Converts @c t to string writing not more than @c len bytes to output buffer @c buf.
19
- * No NULL terminator appended! Throws exception on buffer overflow.
20
- * @return number of bytes written
21
- */
22
- template <class T>
23
- inline size_t ToString(const T& t, char* buf, size_t len) {
24
- using TParam = typename TTypeTraits<T>::TFuncParam;
25
-
26
- return ToStringImpl<TParam>(t, buf, len);
27
- }
28
-
29
- /**
30
- * Floating point to string conversion mode, values are enforced by `dtoa_impl.cpp`.
31
- */
32
- enum EFloatToStringMode {
33
- /** 0.1f -> "0.1", 0.12345678f -> "0.12345678", ignores ndigits. */
34
- PREC_AUTO = 0,
35
-
36
- /** "%g" mode, writes up to the given number of significant digits:
37
- * 0.1f -> "0.1", 0.12345678f -> "0.123457" for ndigits=6, 1.2e-06f -> "1.2e-06" */
38
- PREC_NDIGITS = 2,
39
-
40
- /** "%f" mode, writes the given number of digits after decimal point:
41
- * 0.1f -> "0.100000", 1.2e-06f -> "0.000001" for ndigits=6 */
42
- PREC_POINT_DIGITS = 3,
43
-
44
- /** same as PREC_POINT_DIGITS, but stripping trailing zeroes:
45
- * 0.1f for ndgigits=6 -> "0.1" */
46
- PREC_POINT_DIGITS_STRIP_ZEROES = 4
47
- };
48
-
49
- size_t FloatToString(float t, char* buf, size_t len, EFloatToStringMode mode = PREC_AUTO, int ndigits = 0);
50
- size_t FloatToString(double t, char* buf, size_t len, EFloatToStringMode mode = PREC_AUTO, int ndigits = 0);
51
-
52
- template <typename T>
53
- inline TString FloatToString(const T& t, EFloatToStringMode mode = PREC_AUTO, int ndigits = 0) {
54
- char buf[512]; // Max<double>() with mode = PREC_POINT_DIGITS has 309 digits before the decimal point
55
- size_t count = FloatToString(t, buf, sizeof(buf), mode, ndigits);
56
- return TString(buf, count);
57
- }
58
-
59
- namespace NPrivate {
60
- template <class T, bool isSimple>
61
- struct TToString {
62
- static inline TString Cvt(const T& t) {
63
- char buf[512];
64
-
65
- return TString(buf, ToString<T>(t, buf, sizeof(buf)));
66
- }
67
- };
68
-
69
- template <class T>
70
- struct TToString<T, false> {
71
- static inline TString Cvt(const T& t) {
72
- TString s;
73
- TStringOutput o(s);
74
- o << t;
75
- return s;
76
- }
77
- };
78
- }
79
-
80
- /*
81
- * some clever implementations...
82
- */
83
- template <class T>
84
- inline TString ToString(const T& t) {
85
- using TR = std::remove_cv_t<T>;
86
-
87
- return ::NPrivate::TToString<TR, std::is_arithmetic<TR>::value>::Cvt((const TR&)t);
88
- }
89
-
90
- inline const TString& ToString(const TString& s) noexcept {
91
- return s;
92
- }
93
-
94
- inline const TString& ToString(TString& s) noexcept {
95
- return s;
96
- }
97
-
98
- inline TString ToString(const char* s) {
99
- return s;
100
- }
101
-
102
- inline TString ToString(char* s) {
103
- return s;
104
- }
105
-
106
- /*
107
- * Wrapper for wide strings.
108
- */
109
- template <class T>
110
- inline TUtf16String ToWtring(const T& t) {
111
- return TUtf16String::FromAscii(ToString(t));
112
- }
113
-
114
- inline const TUtf16String& ToWtring(const TUtf16String& w) {
115
- return w;
116
- }
117
-
118
- inline const TUtf16String& ToWtring(TUtf16String& w) {
119
- return w;
120
- }
121
-
122
- struct TFromStringException: public TBadCastException {
123
- };
124
-
125
- /*
126
- * specialized for:
127
- * bool
128
- * short
129
- * unsigned short
130
- * int
131
- * unsigned int
132
- * long
133
- * unsigned long
134
- * long long
135
- * unsigned long long
136
- * float
137
- * double
138
- * long double
139
- */
140
- template <typename T, typename TChar>
141
- T FromStringImpl(const TChar* data, size_t len);
142
-
143
- template <typename T, typename TChar>
144
- inline T FromString(const TChar* data, size_t len) {
145
- return ::FromStringImpl<T>(data, len);
146
- }
147
-
148
- template <typename T, typename TChar>
149
- inline T FromString(const TChar* data) {
150
- return ::FromString<T>(data, std::char_traits<TChar>::length(data));
151
- }
152
-
153
- template <class T>
154
- inline T FromString(const TStringBuf& s) {
155
- return ::FromString<T>(s.data(), s.size());
156
- }
157
-
158
- template <class T>
159
- inline T FromString(const TString& s) {
160
- return ::FromString<T>(s.data(), s.size());
161
- }
162
-
163
- template <>
164
- inline TString FromString<TString>(const TString& s) {
165
- return s;
166
- }
167
-
168
- template <class T>
169
- inline T FromString(const TWtringBuf& s) {
170
- return ::FromString<T, typename TWtringBuf::char_type>(s.data(), s.size());
171
- }
172
-
173
- template <class T>
174
- inline T FromString(const TUtf16String& s) {
175
- return ::FromString<T, wchar16>(s.data(), s.size());
176
- }
177
-
178
- namespace NPrivate {
179
- template <typename TChar>
180
- class TFromString {
181
- const TChar* const Data;
182
- const size_t Len;
183
-
184
- public:
185
- inline TFromString(const TChar* data, size_t len)
186
- : Data(data)
187
- , Len(len)
188
- {
189
- }
190
-
191
- template <typename T>
192
- inline operator T() const {
193
- return FromString<T, TChar>(Data, Len);
194
- }
195
- };
196
- }
197
-
198
- template <typename TChar>
199
- inline ::NPrivate::TFromString<TChar> FromString(const TChar* data, size_t len) {
200
- return ::NPrivate::TFromString<TChar>(data, len);
201
- }
202
-
203
- template <typename TChar>
204
- inline ::NPrivate::TFromString<TChar> FromString(const TChar* data) {
205
- return ::NPrivate::TFromString<TChar>(data, std::char_traits<TChar>::length(data));
206
- }
207
-
208
- template <typename T>
209
- inline ::NPrivate::TFromString<typename T::TChar> FromString(const T& s) {
210
- return ::NPrivate::TFromString<typename T::TChar>(s.data(), s.size());
211
- }
212
-
213
- // Conversion exception free versions
214
- template <typename T, typename TChar>
215
- bool TryFromStringImpl(const TChar* data, size_t len, T& result);
216
-
217
- /**
218
- * @param data Source string buffer pointer
219
- * @param len Source string length, in characters
220
- * @param result Place to store conversion result value.
221
- * If conversion error occurs, no value stored in @c result
222
- * @return @c true in case of successful conversion, @c false otherwise
223
- **/
224
- template <typename T, typename TChar>
225
- inline bool TryFromString(const TChar* data, size_t len, T& result) {
226
- return TryFromStringImpl<T>(data, len, result);
227
- }
228
-
229
- template <typename T, typename TChar>
230
- inline bool TryFromString(const TChar* data, T& result) {
231
- return TryFromString<T>(data, std::char_traits<TChar>::length(data), result);
232
- }
233
-
234
- template <class T, class TChar>
235
- inline bool TryFromString(const TChar* data, const size_t len, T& result, const T& def) {
236
- if (TryFromString<T>(data, len, result)) {
237
- return true;
238
- }
239
- result = def;
240
- return false;
241
- }
242
-
243
- template <class T>
244
- inline bool TryFromString(const TStringBuf& s, T& result) {
245
- return TryFromString<T>(s.data(), s.size(), result);
246
- }
247
-
248
- template <class T>
249
- inline bool TryFromString(const TString& s, T& result) {
250
- return TryFromString<T>(s.data(), s.size(), result);
251
- }
252
-
253
- template <class T>
254
- inline bool TryFromString(const TWtringBuf& s, T& result) {
255
- return TryFromString<T>(s.data(), s.size(), result);
256
- }
257
-
258
- template <class T>
259
- inline bool TryFromString(const TUtf16String& s, T& result) {
260
- return TryFromString<T>(s.data(), s.size(), result);
261
- }
262
-
263
- template <class T, class TStringType>
264
- inline bool TryFromStringWithDefault(const TStringType& s, T& result, const T& def) {
265
- return TryFromString<T>(s.data(), s.size(), result, def);
266
- }
267
-
268
- template <class T>
269
- inline bool TryFromStringWithDefault(const char* s, T& result, const T& def) {
270
- return TryFromStringWithDefault<T>(TStringBuf(s), result, def);
271
- }
272
-
273
- template <class T, class TStringType>
274
- inline bool TryFromStringWithDefault(const TStringType& s, T& result) {
275
- return TryFromStringWithDefault<T>(s, result, T());
276
- }
277
-
278
- // FromString methods with default value if data is invalid
279
- template <class T, class TChar>
280
- inline T FromString(const TChar* data, const size_t len, const T& def) {
281
- T result;
282
- TryFromString<T>(data, len, result, def);
283
- return result;
284
- }
285
-
286
- template <class T, class TStringType>
287
- inline T FromStringWithDefault(const TStringType& s, const T& def) {
288
- return FromString<T>(s.data(), s.size(), def);
289
- }
290
-
291
- template <class T>
292
- inline T FromStringWithDefault(const char* s, const T& def) {
293
- return FromStringWithDefault<T>(TStringBuf(s), def);
294
- }
295
-
296
- template <class T, class TStringType>
297
- inline T FromStringWithDefault(const TStringType& s) {
298
- return FromStringWithDefault<T>(s, T());
299
- }
300
-
301
- double StrToD(const char* b, char** se);
302
- double StrToD(const char* b, const char* e, char** se);
303
-
304
- template <int base, class T>
305
- size_t IntToString(T t, char* buf, size_t len);
306
-
307
- template <int base, class T>
308
- inline TString IntToString(T t) {
309
- static_assert(std::is_arithmetic<std::remove_cv_t<T>>::value, "expect std::is_arithmetic<std::remove_cv_t<T>>::value");
310
-
311
- char buf[256];
312
-
313
- return TString(buf, IntToString<base>(t, buf, sizeof(buf)));
314
- }
315
-
316
- template <int base, class TInt, class TChar>
317
- bool TryIntFromString(const TChar* data, size_t len, TInt& result);
318
-
319
- template <int base, class TInt, class TStringType>
320
- inline bool TryIntFromString(const TStringType& s, TInt& result) {
321
- return TryIntFromString<base>(s.data(), s.size(), result);
322
- }
323
-
324
- template <class TInt, int base, class TChar>
325
- TInt IntFromString(const TChar* str, size_t len);
326
-
327
- template <class TInt, int base, class TChar>
328
- inline TInt IntFromString(const TChar* str) {
329
- return IntFromString<TInt, base>(str, std::char_traits<TChar>::length(str));
330
- }
331
-
332
- template <class TInt, int base, class TStringType>
333
- inline TInt IntFromString(const TStringType& str) {
334
- return IntFromString<TInt, base>(str.data(), str.size());
335
- }
336
-
337
- static inline TString ToString(const TStringBuf str) {
338
- return TString(str);
339
- }
340
-
341
- static inline TUtf16String ToWtring(const TWtringBuf wtr) {
342
- return TUtf16String(wtr);
343
- }
344
-
345
- static inline TUtf32String ToUtf32String(const TUtf32StringBuf wtr) {
346
- return TUtf32String(wtr);
347
- }
@@ -1,14 +0,0 @@
1
- #pragma once
2
-
3
- struct TCStringEndIterator {
4
- };
5
-
6
- template <class It>
7
- static inline bool operator==(It b, TCStringEndIterator) {
8
- return !*b;
9
- }
10
-
11
- template <class It>
12
- static inline bool operator!=(It b, TCStringEndIterator) {
13
- return !!*b;
14
- }
@@ -1,70 +0,0 @@
1
- #pragma once
2
-
3
- #include <util/generic/string.h>
4
- #include <util/generic/strbuf.h>
5
-
6
- template <class TChar>
7
- TBasicString<TChar>& EscapeCImpl(const TChar* str, size_t len, TBasicString<TChar>&);
8
-
9
- template <class TChar>
10
- TBasicString<TChar>& UnescapeCImpl(const TChar* str, size_t len, TBasicString<TChar>&);
11
-
12
- template <class TChar>
13
- TChar* UnescapeC(const TChar* str, size_t len, TChar* buf);
14
-
15
- template <typename TChar>
16
- static inline TBasicString<TChar>& EscapeC(const TChar* str, size_t len, TBasicString<TChar>& s) {
17
- return EscapeCImpl(str, len, s);
18
- }
19
-
20
- template <typename TChar>
21
- static inline TBasicString<TChar> EscapeC(const TChar* str, size_t len) {
22
- TBasicString<TChar> s;
23
- return EscapeC(str, len, s);
24
- }
25
-
26
- template <typename TChar>
27
- static inline TBasicString<TChar> EscapeC(const TBasicStringBuf<TChar>& str) {
28
- return EscapeC(str.data(), str.size());
29
- }
30
-
31
- template <typename TChar>
32
- static inline TBasicString<TChar>& UnescapeC(const TChar* str, size_t len, TBasicString<TChar>& s) {
33
- return UnescapeCImpl(str, len, s);
34
- }
35
-
36
- template <typename TChar>
37
- static inline TBasicString<TChar> UnescapeC(const TChar* str, size_t len) {
38
- TBasicString<TChar> s;
39
- return UnescapeCImpl(str, len, s);
40
- }
41
-
42
- template <typename TChar>
43
- static inline TBasicString<TChar> EscapeC(TChar ch) {
44
- return EscapeC(&ch, 1);
45
- }
46
-
47
- template <typename TChar>
48
- static inline TBasicString<TChar> EscapeC(const TChar* str) {
49
- return EscapeC(str, std::char_traits<TChar>::length(str));
50
- }
51
-
52
- TString& EscapeC(const TStringBuf str, TString& res);
53
- TUtf16String& EscapeC(const TWtringBuf str, TUtf16String& res);
54
-
55
- // these two need to be methods, because of TBasicString::Quote implementation
56
- TString EscapeC(const TString& str);
57
- TUtf16String EscapeC(const TUtf16String& str);
58
-
59
- TString& UnescapeC(const TStringBuf str, TString& res);
60
- TUtf16String& UnescapeC(const TWtringBuf str, TUtf16String& res);
61
-
62
- TString UnescapeC(const TStringBuf str);
63
- TUtf16String UnescapeC(const TWtringBuf wtr);
64
-
65
- /// Returns number of chars in escape sequence.
66
- /// - 0, if begin >= end
67
- /// - 1, if [begin, end) starts with an unescaped char
68
- /// - at least 2 (including '\'), if [begin, end) starts with an escaped symbol
69
- template <class TChar>
70
- size_t UnescapeCCharLen(const TChar* begin, const TChar* end);