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,273 +0,0 @@
1
- #pragma once
2
-
3
- #include <util/generic/fwd.h>
4
- #include <util/generic/noncopyable.h>
5
- #include <util/system/defaults.h>
6
-
7
- class IOutputStream;
8
-
9
- /**
10
- * @addtogroup Streams_Base
11
- * @{
12
- */
13
-
14
- /**
15
- * Abstract input stream.
16
- */
17
- class IInputStream: public TNonCopyable {
18
- public:
19
- IInputStream() noexcept;
20
- virtual ~IInputStream();
21
-
22
- IInputStream(IInputStream&&) noexcept {
23
- }
24
-
25
- IInputStream& operator=(IInputStream&&) noexcept {
26
- return *this;
27
- }
28
-
29
- /**
30
- * Reads some data from the stream. Note that this function might read less
31
- * data than what was requested. Use `Load` function if you want to read as
32
- * much data as possible.
33
- *
34
- * @param buf Buffer to read into.
35
- * @param len Number of bytes to read.
36
- * @returns Number of bytes that were actually read.
37
- * A return value of zero signals end of stream.
38
- */
39
- inline size_t Read(void* buf, size_t len) {
40
- if (len == 0) {
41
- return 0;
42
- }
43
-
44
- return DoRead(buf, len);
45
- }
46
-
47
- /**
48
- * Reads one character from the stream.
49
- *
50
- * @param[out] c Character to read.
51
- * @returns Whether the character was read.
52
- * A return value of false signals the end
53
- * of stream.
54
- */
55
- inline bool ReadChar(char& c) {
56
- return DoRead(&c, 1) > 0;
57
- }
58
-
59
- /**
60
- * Reads all characters from the stream until the given character is
61
- * encountered, and stores them into the given string. The character itself
62
- * is read from the stream, but not stored in the string.
63
- *
64
- * @param[out] st String to read into.
65
- * @param ch Character to stop at.
66
- * @returns Total number of characters read from the stream.
67
- * A return value of zero signals end of stream.
68
- */
69
- inline size_t ReadTo(TString& st, char ch) {
70
- return DoReadTo(st, ch);
71
- }
72
-
73
- /**
74
- * Reads the requested amount of data from the stream. Unlike `Read`, this
75
- * function stops only when the requested amount of data is read, or when
76
- * end of stream is reached.
77
- *
78
- * @param buf Buffer to read into.
79
- * @param len Number of bytes to read.
80
- * @returns Number of bytes that were actually read.
81
- * A return value different from `len`
82
- * signals end of stream.
83
- */
84
- size_t Load(void* buf, size_t len);
85
-
86
- /**
87
- * Reads the requested amount of data from the stream, or fails with an
88
- * exception if unable to do so.
89
- *
90
- * @param buf Buffer to read into.
91
- * @param len Number of bytes to read.
92
- * @see Load
93
- */
94
- void LoadOrFail(void* buf, size_t len);
95
-
96
- /**
97
- * Reads all data from this stream and returns it as a string.
98
- *
99
- * @returns Contents of this stream as a string.
100
- */
101
- TString ReadAll();
102
-
103
- /**
104
- * Reads all data from this stream and writes it into a provided output
105
- * stream.
106
- *
107
- * @param out Output stream to use.
108
- * @returns Total number of characters read from the stream.
109
- */
110
- ui64 ReadAll(IOutputStream& out);
111
-
112
- /**
113
- * Reads all data from the stream until the first occurrence of '\n'. Also
114
- * handles Windows line breaks correctly.
115
- *
116
- * @returns Next line read from this stream,
117
- * excluding the line terminator.
118
- * @throws yexception If no data could be read from a stream
119
- * because end of stream has already been
120
- * reached.
121
- */
122
- TString ReadLine();
123
-
124
- /**
125
- * Reads all characters from the stream until the given character is
126
- * encountered and returns them as a string. The character itself is read
127
- * from the stream, but not stored in the string.
128
- *
129
- * @param ch Character to stop at.
130
- * @returns String containing all the characters read.
131
- * @throws yexception If no data could be read from a stream
132
- * because end of stream has already been
133
- * reached.
134
- */
135
- TString ReadTo(char ch);
136
-
137
- /**
138
- * Reads all data from the stream until the first occurrence of '\n' and
139
- * stores it into provided string. Also handles Windows line breaks correctly.
140
- *
141
- * @param[out] st String to store read characters into,
142
- * excluding the line terminator.
143
- * @returns Total number of characters read from the stream.
144
- * A return value of zero signals end of stream.
145
- */
146
- size_t ReadLine(TString& st);
147
-
148
- /**
149
- * Reads UTF8 encoded characters from the stream the first occurrence of '\n',
150
- * converts them into wide ones, and stores into provided string. Also handles
151
- * Windows line breaks correctly.
152
- *
153
- * @param[out] w Wide string to store read characters into,
154
- * excluding the line terminator.
155
- * @returns Total number of characters read from the stream.
156
- * A return value of zero signals end of stream.
157
- */
158
- size_t ReadLine(TUtf16String& w);
159
-
160
- /**
161
- * Skips some data from the stream without reading / copying it. Note that
162
- * this function might skip less data than what was requested.
163
- *
164
- * @param len Number of bytes to skip.
165
- * @returns Number of bytes that were actually skipped.
166
- * A return value of zero signals end of stream.
167
- */
168
- size_t Skip(size_t len);
169
-
170
- protected:
171
- /**
172
- * Reads some data from the stream. Might read less data than what was
173
- * requested.
174
- *
175
- * @param buf Buffer to read into.
176
- * @param len Number of bytes to read.
177
- * @returns Number of bytes that were actually read.
178
- * A return value of zero signals end of stream.
179
- * @throws yexception If IO error occurs.
180
- */
181
- virtual size_t DoRead(void* buf, size_t len) = 0;
182
-
183
- /**
184
- * Skips some data from the stream. Might skip less data than what was
185
- * requested.
186
- *
187
- * @param len Number of bytes to skip.
188
- * @returns Number of bytes that were actually skipped.
189
- * A return value of zero signals end of stream.
190
- * @throws yexception If IO error occurs.
191
- */
192
- virtual size_t DoSkip(size_t len);
193
-
194
- /**
195
- * Reads all characters from the stream until the given character is
196
- * encountered, and stores them into the given string. The character itself
197
- * is read from the stream, but not stored in the string.
198
- *
199
- * Provided string is cleared only if there is data in the stream.
200
- *
201
- * @param[out] st String to read into.
202
- * @param ch Character to stop at.
203
- * @returns Total number of characters read from the stream.
204
- * A return value of zero signals end of stream.
205
- * @throws yexception If IO error occurs.
206
- */
207
- virtual size_t DoReadTo(TString& st, char ch);
208
-
209
- /**
210
- * Reads all data from this stream and writes it into a provided output
211
- * stream.
212
- *
213
- * @param out Output stream to use.
214
- * @returns Total number of characters read from
215
- * this stream.
216
- * @throws yexception If IO error occurs.
217
- */
218
- virtual ui64 DoReadAll(IOutputStream& out);
219
- };
220
-
221
- /**
222
- * Transfers all data from the given input stream into the given output stream.
223
- *
224
- * @param in Input stream.
225
- * @param out Output stream.
226
- */
227
- ui64 TransferData(IInputStream* in, IOutputStream* out);
228
-
229
- /**
230
- * `operator>>` for `IInputStream` by default delegates to this function.
231
- *
232
- * Note that while `operator>>` uses overloading (and thus argument-dependent
233
- * lookup), `In` uses template specializations. This makes it possible to
234
- * have a single `In` declaration, and then just provide specializations in
235
- * cpp files, letting the linker figure everything else out. This approach
236
- * reduces compilation times.
237
- *
238
- * However, if the flexibility of overload resolution is needed, then one should
239
- * just overload `operator>>`.
240
- *
241
- * @param in Input stream to read from.
242
- * @param[out] value Value to read.
243
- * @throws `yexception` on invalid input or end of stream.
244
- * @see Out(IOutputStream&, T&)
245
- */
246
- template <typename T>
247
- void In(IInputStream& in, T& value);
248
-
249
- /**
250
- * Reads a value from the stream.
251
- *
252
- * @param in Input stream to read from.
253
- * @param[out] value Value to read.
254
- * @returns Input stream.
255
- * @throws `yexception` on invalid input or end of stream.
256
- * @see operator<<(IOutputStream&, T&)
257
- */
258
- template <typename T>
259
- inline IInputStream& operator>>(IInputStream& in, T& value) {
260
- In<T>(in, value);
261
- return in;
262
- }
263
-
264
- namespace NPrivate {
265
- IInputStream& StdInStream() noexcept;
266
- }
267
-
268
- /**
269
- * Standard input stream.
270
- */
271
- #define Cin (::NPrivate::StdInStream())
272
-
273
- /** @} */
@@ -1,19 +0,0 @@
1
- #pragma once
2
-
3
- #include <util/generic/va_args.h>
4
-
5
- /**
6
- * Generates an output sequence for the provided expressions that is formatted
7
- * as a labeled comma-separated list.
8
- *
9
- * Example usage:
10
- * @code
11
- * int a = 1, b = 2, c = 3;
12
- * stream << LabeledOutput(a, b, c, a + b + c);
13
- * // Outputs "a = 1, b = 2, c = 3, a + b + c = 6"
14
- * @endcode
15
- */
16
- #define LabeledOutput(...) "" Y_PASS_VA_ARGS(Y_MAP_ARGS_WITH_LAST(__LABELED_OUTPUT_NONLAST__, __LABELED_OUTPUT_IMPL__, __VA_ARGS__))
17
-
18
- #define __LABELED_OUTPUT_IMPL__(x) << #x " = " << (x)
19
- #define __LABELED_OUTPUT_NONLAST__(x) __LABELED_OUTPUT_IMPL__(x) << ", "
@@ -1,100 +0,0 @@
1
- #pragma once
2
-
3
- #include "input.h"
4
- #include "output.h"
5
-
6
- #include <util/generic/utility.h>
7
-
8
- /**
9
- * Proxy input stream that can read a limited number of characters from a slave
10
- * stream.
11
- *
12
- * This can be useful for breaking up the slave stream into small chunks and
13
- * treat these as separate streams.
14
- */
15
- class TLengthLimitedInput: public IInputStream {
16
- public:
17
- inline TLengthLimitedInput(IInputStream* slave, ui64 length) noexcept
18
- : Slave_(slave)
19
- , Length_(length)
20
- {
21
- }
22
-
23
- ~TLengthLimitedInput() override = default;
24
-
25
- inline ui64 Left() const noexcept {
26
- return Length_;
27
- }
28
-
29
- private:
30
- size_t DoRead(void* buf, size_t len) override;
31
- size_t DoSkip(size_t len) override;
32
-
33
- private:
34
- IInputStream* Slave_;
35
- ui64 Length_;
36
- };
37
-
38
- /**
39
- * Proxy input stream that counts the number of characters read.
40
- */
41
- class TCountingInput: public IInputStream {
42
- public:
43
- inline TCountingInput(IInputStream* slave) noexcept
44
- : Slave_(slave)
45
- , Count_()
46
- {
47
- }
48
-
49
- ~TCountingInput() override = default;
50
-
51
- /**
52
- * \returns The total number of characters read from
53
- * this stream.
54
- */
55
- inline ui64 Counter() const noexcept {
56
- return Count_;
57
- }
58
-
59
- private:
60
- size_t DoRead(void* buf, size_t len) override;
61
- size_t DoSkip(size_t len) override;
62
- size_t DoReadTo(TString& st, char ch) override;
63
- ui64 DoReadAll(IOutputStream& out) override;
64
-
65
- private:
66
- IInputStream* Slave_;
67
- ui64 Count_;
68
- };
69
-
70
- /**
71
- * Proxy output stream that counts the number of characters written.
72
- */
73
- class TCountingOutput: public IOutputStream {
74
- public:
75
- inline TCountingOutput(IOutputStream* slave) noexcept
76
- : Slave_(slave)
77
- , Count_()
78
- {
79
- }
80
-
81
- ~TCountingOutput() override = default;
82
-
83
- TCountingOutput(TCountingOutput&&) noexcept = default;
84
- TCountingOutput& operator=(TCountingOutput&&) noexcept = default;
85
-
86
- /**
87
- * \returns The total number of characters written
88
- * into this stream.
89
- */
90
- inline ui64 Counter() const noexcept {
91
- return Count_;
92
- }
93
-
94
- private:
95
- void DoWrite(const void* buf, size_t len) override;
96
-
97
- private:
98
- IOutputStream* Slave_;
99
- ui64 Count_;
100
- };
@@ -1,255 +0,0 @@
1
- #pragma once
2
-
3
- #include "zerocopy.h"
4
- #include "zerocopy_output.h"
5
-
6
- #include <util/generic/strbuf.h>
7
-
8
- /**
9
- * @addtogroup Streams_Memory
10
- * @{
11
- */
12
-
13
- /**
14
- * Input stream that reads data from a memory block.
15
- */
16
- class TMemoryInput: public IZeroCopyInputFastReadTo {
17
- public:
18
- TMemoryInput() noexcept;
19
-
20
- /**
21
- * Constructs a stream that reads from the provided memory block. It's up
22
- * to the user to make sure that the memory block doesn't get freed while
23
- * this stream is in use.
24
- *
25
- * @param buf Memory block to use.
26
- * @param len Size of the memory block.
27
- */
28
- TMemoryInput(const void* buf, size_t len) noexcept;
29
- explicit TMemoryInput(const TStringBuf buf) noexcept;
30
- ~TMemoryInput() override;
31
-
32
- TMemoryInput(const TMemoryInput& other) noexcept
33
- : IZeroCopyInputFastReadTo()
34
- , Buf_(other.Buf_)
35
- , Len_(other.Len_)
36
- {
37
- }
38
-
39
- TMemoryInput& operator=(const TMemoryInput& other) noexcept {
40
- if (this != &other) {
41
- Buf_ = other.Buf_;
42
- Len_ = other.Len_;
43
- }
44
-
45
- return *this;
46
- }
47
-
48
- TMemoryInput(TMemoryInput&&) noexcept = default;
49
- TMemoryInput& operator=(TMemoryInput&&) noexcept = default;
50
-
51
- /**
52
- * Initializes this stream with a new memory block. It's up to the
53
- * user to make sure that the memory block doesn't get freed while this
54
- * stream is in use.
55
- *
56
- * @param buf New memory block to use.
57
- * @param len Size of the new memory block.
58
- */
59
- void Reset(const void* buf, size_t len) noexcept {
60
- Buf_ = (const char*)buf;
61
- Len_ = len;
62
- }
63
-
64
- /**
65
- * @returns Whether there is more data in the stream.
66
- */
67
- bool Exhausted() const noexcept {
68
- return !Avail();
69
- }
70
-
71
- /**
72
- * @returns Number of bytes available in the stream.
73
- */
74
- size_t Avail() const noexcept {
75
- return Len_;
76
- }
77
-
78
- /**
79
- * @returns Current read position in the memory block
80
- * used by this stream.
81
- */
82
- const char* Buf() const noexcept {
83
- return Buf_;
84
- }
85
-
86
- /**
87
- * Initializes this stream with a next chunk extracted from the given zero
88
- * copy stream.
89
- *
90
- * @param stream Zero copy stream to initialize from.
91
- */
92
- void Fill(IZeroCopyInput* stream) {
93
- Len_ = stream->Next(&Buf_);
94
- if (!Len_) {
95
- Reset(nullptr, 0);
96
- }
97
- }
98
-
99
- private:
100
- size_t DoNext(const void** ptr, size_t len) override;
101
- void DoUndo(size_t len) override;
102
-
103
- private:
104
- const char* Buf_;
105
- size_t Len_;
106
- };
107
-
108
- /**
109
- * Output stream that writes data to a memory block.
110
- */
111
- class TMemoryOutput: public IZeroCopyOutput {
112
- public:
113
- /**
114
- * Constructs a stream that writes to the provided memory block. It's up
115
- * to the user to make sure that the memory block doesn't get freed while
116
- * this stream is in use.
117
- *
118
- * @param buf Memory block to use.
119
- * @param len Size of the memory block.
120
- */
121
- TMemoryOutput(void* buf, size_t len) noexcept
122
- : Buf_(static_cast<char*>(buf))
123
- , End_(Buf_ + len)
124
- {
125
- }
126
- ~TMemoryOutput() override;
127
-
128
- TMemoryOutput(TMemoryOutput&&) noexcept = default;
129
- TMemoryOutput& operator=(TMemoryOutput&&) noexcept = default;
130
-
131
- /**
132
- * Initializes this stream with a new memory block. It's up to the
133
- * user to make sure that the memory block doesn't get freed while this
134
- * stream is in use.
135
- *
136
- * @param buf New memory block to use.
137
- * @param len Size of the new memory block.
138
- */
139
- inline void Reset(void* buf, size_t len) noexcept {
140
- Buf_ = static_cast<char*>(buf);
141
- End_ = Buf_ + len;
142
- }
143
-
144
- /**
145
- * @returns Whether there is more space in the
146
- * stream for writing.
147
- */
148
- inline bool Exhausted() const noexcept {
149
- return !Avail();
150
- }
151
-
152
- /**
153
- * @returns Number of bytes available for writing
154
- * in the stream.
155
- */
156
- inline size_t Avail() const noexcept {
157
- return End_ - Buf_;
158
- }
159
-
160
- /**
161
- * @returns Current write position in the memory block
162
- * used by this stream.
163
- */
164
- inline char* Buf() const noexcept {
165
- return Buf_;
166
- }
167
-
168
- /**
169
- * @returns Pointer to the end of the memory block
170
- * used by this stream.
171
- */
172
- char* End() const {
173
- return End_;
174
- }
175
-
176
- private:
177
- size_t DoNext(void** ptr) override;
178
- void DoUndo(size_t len) override;
179
- void DoWrite(const void* buf, size_t len) override;
180
- void DoWriteC(char c) override;
181
-
182
- protected:
183
- char* Buf_;
184
- char* End_;
185
- };
186
-
187
- /**
188
- * Memory output stream that supports changing the position of the
189
- * write pointer.
190
- *
191
- * @see TMemoryOutput
192
- */
193
- class TMemoryWriteBuffer: public TMemoryOutput {
194
- public:
195
- TMemoryWriteBuffer(void* buf, size_t len)
196
- : TMemoryOutput(buf, len)
197
- , Beg_(Buf_)
198
- {
199
- }
200
-
201
- void Reset(void* buf, size_t len) {
202
- TMemoryOutput::Reset(buf, len);
203
- Beg_ = Buf_;
204
- }
205
-
206
- size_t Len() const {
207
- return Buf() - Beg();
208
- }
209
-
210
- size_t Empty() const {
211
- return Buf() == Beg();
212
- }
213
-
214
- /**
215
- * @returns Data that has been written into this
216
- * stream as a string.
217
- */
218
- TStringBuf Str() const {
219
- return TStringBuf(Beg(), Buf());
220
- }
221
-
222
- char* Beg() const {
223
- return Beg_;
224
- }
225
-
226
- /**
227
- * @param ptr New write position for this stream.
228
- * Must be inside the memory block that
229
- * this stream uses.
230
- */
231
- void SetPos(char* ptr) {
232
- Y_ASSERT(Beg_ <= ptr);
233
- SetPosImpl(ptr);
234
- }
235
-
236
- /**
237
- * @param pos New write position for this stream,
238
- * relative to the beginning of the memory
239
- * block that this stream uses.
240
- */
241
- void SetPos(size_t pos) {
242
- SetPosImpl(Beg_ + pos);
243
- }
244
-
245
- protected:
246
- void SetPosImpl(char* ptr) {
247
- Y_ASSERT(End_ >= ptr);
248
- Buf_ = ptr;
249
- }
250
-
251
- protected:
252
- char* Beg_;
253
- };
254
-
255
- /** @} */
@@ -1,32 +0,0 @@
1
- #pragma once
2
-
3
- #include "input.h"
4
-
5
- /**
6
- * @addtogroup Streams_Multi
7
- * @{
8
- */
9
-
10
- /**
11
- * A proxy input stream that concatenates two slave streams into one.
12
- */
13
- class TMultiInput: public IInputStream {
14
- public:
15
- TMultiInput(IInputStream* f, IInputStream* s) noexcept;
16
- ~TMultiInput() override;
17
-
18
- private:
19
- size_t DoRead(void* buf, size_t len) override;
20
- size_t DoSkip(size_t len) override;
21
- size_t DoReadTo(TString& st, char ch) override;
22
-
23
- private:
24
- IInputStream* C_;
25
- IInputStream* N_;
26
- };
27
-
28
- /**
29
- * See also "util/stream/tee.h" for multi output.
30
- */
31
-
32
- /** @} */