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.
- package/DEPLOYMENT.md +22 -15
- package/README.md +37 -27
- package/binding.gyp +5 -7
- package/build_scripts/bootstrap.js +2 -1
- package/build_scripts/out/build.js +46 -68
- package/build_scripts/out/build_model.js +1 -1
- package/build_scripts/out/{build_ya.js → build_native.js} +1 -1
- package/build_scripts/out/ci.js +5 -5
- package/build_scripts/out/config.js +32 -18
- package/build_scripts/out/install.js +5 -3
- package/build_scripts/out/package_prepublish.js +1 -1
- package/build_scripts/out/packaging.js +1 -19
- package/build_scripts/out/run_tests.js +1 -1
- package/build_scripts/out/test.js +8 -3
- package/config.json +18 -11
- package/inc/catboost/libs/model_interface/c_api.h +349 -3
- package/lib/catboost.d.ts +65 -21
- package/package.json +4 -4
- package/src/api_helpers.cpp +100 -24
- package/src/api_helpers.h +8 -7
- package/src/api_module.cpp +1 -2
- package/src/model.cpp +483 -83
- package/src/model.h +24 -9
- package/inc/contrib/libs/cxxsupp/system_stl/include/stlfwd +0 -14
- package/inc/util/charset/recode_result.h +0 -9
- package/inc/util/charset/unicode_table.h +0 -123
- package/inc/util/charset/unidata.h +0 -421
- package/inc/util/charset/utf8.h +0 -384
- package/inc/util/charset/wide.h +0 -843
- package/inc/util/charset/wide_specific.h +0 -22
- package/inc/util/datetime/base.h +0 -669
- package/inc/util/datetime/constants.h +0 -7
- package/inc/util/datetime/cputimer.h +0 -124
- package/inc/util/datetime/parser.h +0 -292
- package/inc/util/datetime/systime.h +0 -47
- package/inc/util/datetime/uptime.h +0 -8
- package/inc/util/digest/city.h +0 -88
- package/inc/util/digest/fnv.h +0 -73
- package/inc/util/digest/multi.h +0 -14
- package/inc/util/digest/murmur.h +0 -57
- package/inc/util/digest/numeric.h +0 -86
- package/inc/util/digest/sequence.h +0 -48
- package/inc/util/draft/date.h +0 -129
- package/inc/util/draft/datetime.h +0 -184
- package/inc/util/draft/enum.h +0 -136
- package/inc/util/draft/holder_vector.h +0 -102
- package/inc/util/draft/ip.h +0 -131
- package/inc/util/draft/matrix.h +0 -108
- package/inc/util/draft/memory.h +0 -40
- package/inc/util/folder/dirent_win.h +0 -46
- package/inc/util/folder/dirut.h +0 -121
- package/inc/util/folder/filelist.h +0 -81
- package/inc/util/folder/fts.h +0 -108
- package/inc/util/folder/iterator.h +0 -109
- package/inc/util/folder/lstat_win.h +0 -20
- package/inc/util/folder/path.h +0 -225
- package/inc/util/folder/pathsplit.h +0 -113
- package/inc/util/folder/tempdir.h +0 -42
- package/inc/util/generic/adaptor.h +0 -134
- package/inc/util/generic/algorithm.h +0 -765
- package/inc/util/generic/array_ref.h +0 -282
- package/inc/util/generic/array_size.h +0 -24
- package/inc/util/generic/benchmark/vector_count_ctor/f.h +0 -9
- package/inc/util/generic/bitmap.h +0 -1115
- package/inc/util/generic/bitops.h +0 -459
- package/inc/util/generic/bt_exception.h +0 -24
- package/inc/util/generic/buffer.h +0 -232
- package/inc/util/generic/cast.h +0 -176
- package/inc/util/generic/deque.h +0 -24
- package/inc/util/generic/explicit_type.h +0 -42
- package/inc/util/generic/fastqueue.h +0 -55
- package/inc/util/generic/flags.h +0 -244
- package/inc/util/generic/function.h +0 -103
- package/inc/util/generic/fwd.h +0 -171
- package/inc/util/generic/guid.h +0 -61
- package/inc/util/generic/hash.h +0 -2032
- package/inc/util/generic/hash_primes.h +0 -140
- package/inc/util/generic/hash_set.h +0 -490
- package/inc/util/generic/hide_ptr.h +0 -3
- package/inc/util/generic/intrlist.h +0 -876
- package/inc/util/generic/is_in.h +0 -53
- package/inc/util/generic/iterator.h +0 -137
- package/inc/util/generic/iterator_range.h +0 -105
- package/inc/util/generic/lazy_value.h +0 -66
- package/inc/util/generic/list.h +0 -22
- package/inc/util/generic/map.h +0 -44
- package/inc/util/generic/mapfindptr.h +0 -60
- package/inc/util/generic/maybe.h +0 -713
- package/inc/util/generic/maybe_traits.h +0 -164
- package/inc/util/generic/mem_copy.h +0 -55
- package/inc/util/generic/noncopyable.h +0 -38
- package/inc/util/generic/object_counter.h +0 -53
- package/inc/util/generic/ptr.h +0 -1113
- package/inc/util/generic/queue.h +0 -57
- package/inc/util/generic/refcount.h +0 -162
- package/inc/util/generic/reserve.h +0 -11
- package/inc/util/generic/scope.h +0 -65
- package/inc/util/generic/serialized_enum.h +0 -406
- package/inc/util/generic/set.h +0 -42
- package/inc/util/generic/singleton.h +0 -136
- package/inc/util/generic/size_literals.h +0 -65
- package/inc/util/generic/stack.h +0 -18
- package/inc/util/generic/store_policy.h +0 -120
- package/inc/util/generic/strbase.h +0 -612
- package/inc/util/generic/strbuf.h +0 -552
- package/inc/util/generic/strfcpy.h +0 -17
- package/inc/util/generic/string.h +0 -1572
- package/inc/util/generic/string_hash.h +0 -21
- package/inc/util/generic/string_ut.h +0 -1175
- package/inc/util/generic/type_name.h +0 -34
- package/inc/util/generic/typelist.h +0 -114
- package/inc/util/generic/typetraits.h +0 -325
- package/inc/util/generic/utility.h +0 -132
- package/inc/util/generic/va_args.h +0 -400
- package/inc/util/generic/variant.h +0 -631
- package/inc/util/generic/variant_traits.h +0 -171
- package/inc/util/generic/vector.h +0 -119
- package/inc/util/generic/xrange.h +0 -258
- package/inc/util/generic/yexception.h +0 -212
- package/inc/util/generic/yexception_ut.h +0 -14
- package/inc/util/generic/ylimits.h +0 -92
- package/inc/util/generic/ymath.h +0 -206
- package/inc/util/memory/addstorage.h +0 -93
- package/inc/util/memory/alloc.h +0 -27
- package/inc/util/memory/blob.h +0 -296
- package/inc/util/memory/mmapalloc.h +0 -8
- package/inc/util/memory/pool.h +0 -432
- package/inc/util/memory/segmented_string_pool.h +0 -194
- package/inc/util/memory/segpool_alloc.h +0 -118
- package/inc/util/memory/smallobj.h +0 -141
- package/inc/util/memory/tempbuf.h +0 -111
- package/inc/util/network/address.h +0 -136
- package/inc/util/network/endpoint.h +0 -61
- package/inc/util/network/hostip.h +0 -16
- package/inc/util/network/init.h +0 -60
- package/inc/util/network/interface.h +0 -17
- package/inc/util/network/iovec.h +0 -65
- package/inc/util/network/ip.h +0 -116
- package/inc/util/network/nonblock.h +0 -8
- package/inc/util/network/pair.h +0 -9
- package/inc/util/network/poller.h +0 -58
- package/inc/util/network/pollerimpl.h +0 -707
- package/inc/util/network/sock.h +0 -608
- package/inc/util/network/socket.h +0 -421
- package/inc/util/random/common_ops.h +0 -130
- package/inc/util/random/easy.h +0 -47
- package/inc/util/random/entropy.h +0 -21
- package/inc/util/random/fast.h +0 -101
- package/inc/util/random/init_atfork.h +0 -3
- package/inc/util/random/lcg_engine.h +0 -66
- package/inc/util/random/mersenne.h +0 -46
- package/inc/util/random/mersenne32.h +0 -50
- package/inc/util/random/mersenne64.h +0 -50
- package/inc/util/random/normal.h +0 -38
- package/inc/util/random/random.h +0 -30
- package/inc/util/random/shuffle.h +0 -39
- package/inc/util/str_stl.h +0 -266
- package/inc/util/stream/aligned.h +0 -99
- package/inc/util/stream/buffer.h +0 -119
- package/inc/util/stream/buffered.h +0 -225
- package/inc/util/stream/debug.h +0 -53
- package/inc/util/stream/direct_io.h +0 -43
- package/inc/util/stream/file.h +0 -108
- package/inc/util/stream/format.h +0 -444
- package/inc/util/stream/fwd.h +0 -100
- package/inc/util/stream/hex.h +0 -8
- package/inc/util/stream/holder.h +0 -44
- package/inc/util/stream/input.h +0 -273
- package/inc/util/stream/labeled.h +0 -19
- package/inc/util/stream/length.h +0 -100
- package/inc/util/stream/mem.h +0 -255
- package/inc/util/stream/multi.h +0 -32
- package/inc/util/stream/null.h +0 -61
- package/inc/util/stream/output.h +0 -304
- package/inc/util/stream/pipe.h +0 -112
- package/inc/util/stream/printf.h +0 -25
- package/inc/util/stream/str.h +0 -207
- package/inc/util/stream/tee.h +0 -28
- package/inc/util/stream/tempbuf.h +0 -21
- package/inc/util/stream/tokenizer.h +0 -214
- package/inc/util/stream/trace.h +0 -60
- package/inc/util/stream/walk.h +0 -35
- package/inc/util/stream/zerocopy.h +0 -91
- package/inc/util/stream/zerocopy_output.h +0 -57
- package/inc/util/stream/zlib.h +0 -173
- package/inc/util/string/ascii.h +0 -236
- package/inc/util/string/builder.h +0 -39
- package/inc/util/string/cast.h +0 -347
- package/inc/util/string/cstriter.h +0 -14
- package/inc/util/string/escape.h +0 -70
- package/inc/util/string/hex.h +0 -59
- package/inc/util/string/join.h +0 -194
- package/inc/util/string/printf.h +0 -13
- package/inc/util/string/reverse.h +0 -16
- package/inc/util/string/split.h +0 -1080
- package/inc/util/string/strip.h +0 -257
- package/inc/util/string/strspn.h +0 -65
- package/inc/util/string/subst.h +0 -56
- package/inc/util/string/type.h +0 -50
- package/inc/util/string/util.h +0 -195
- package/inc/util/string/vector.h +0 -132
- package/inc/util/system/align.h +0 -50
- package/inc/util/system/atexit.h +0 -22
- package/inc/util/system/atomic.h +0 -51
- package/inc/util/system/atomic_gcc.h +0 -90
- package/inc/util/system/atomic_ops.h +0 -189
- package/inc/util/system/atomic_win.h +0 -114
- package/inc/util/system/backtrace.h +0 -39
- package/inc/util/system/byteorder.h +0 -186
- package/inc/util/system/compat.h +0 -84
- package/inc/util/system/compiler.h +0 -620
- package/inc/util/system/condvar.h +0 -71
- package/inc/util/system/context.h +0 -181
- package/inc/util/system/context_aarch64.h +0 -8
- package/inc/util/system/context_i686.h +0 -9
- package/inc/util/system/context_x86.h +0 -12
- package/inc/util/system/context_x86_64.h +0 -7
- package/inc/util/system/cpu_id.h +0 -159
- package/inc/util/system/daemon.h +0 -28
- package/inc/util/system/datetime.h +0 -98
- package/inc/util/system/defaults.h +0 -149
- package/inc/util/system/demangle.h +0 -5
- package/inc/util/system/demangle_impl.h +0 -23
- package/inc/util/system/direct_io.h +0 -71
- package/inc/util/system/dynlib.h +0 -119
- package/inc/util/system/env.h +0 -32
- package/inc/util/system/error.h +0 -95
- package/inc/util/system/event.h +0 -122
- package/inc/util/system/execpath.h +0 -17
- package/inc/util/system/fasttime.h +0 -6
- package/inc/util/system/fhandle.h +0 -27
- package/inc/util/system/file.h +0 -210
- package/inc/util/system/file_lock.h +0 -34
- package/inc/util/system/filemap.h +0 -383
- package/inc/util/system/flock.h +0 -35
- package/inc/util/system/fs.h +0 -156
- package/inc/util/system/fs_win.h +0 -29
- package/inc/util/system/fstat.h +0 -46
- package/inc/util/system/getpid.h +0 -12
- package/inc/util/system/guard.h +0 -179
- package/inc/util/system/hi_lo.h +0 -139
- package/inc/util/system/hostname.h +0 -10
- package/inc/util/system/hp_timer.h +0 -36
- package/inc/util/system/info.h +0 -12
- package/inc/util/system/interrupt_signals.h +0 -22
- package/inc/util/system/madvise.h +0 -30
- package/inc/util/system/maxlen.h +0 -32
- package/inc/util/system/mem_info.h +0 -18
- package/inc/util/system/mincore.h +0 -38
- package/inc/util/system/mktemp.h +0 -11
- package/inc/util/system/mlock.h +0 -43
- package/inc/util/system/mutex.h +0 -67
- package/inc/util/system/nice.h +0 -3
- package/inc/util/system/pipe.h +0 -90
- package/inc/util/system/platform.h +0 -246
- package/inc/util/system/progname.h +0 -13
- package/inc/util/system/protect.h +0 -25
- package/inc/util/system/rusage.h +0 -26
- package/inc/util/system/rwlock.h +0 -78
- package/inc/util/system/sanitizers.h +0 -122
- package/inc/util/system/sem.h +0 -41
- package/inc/util/system/shellcommand.h +0 -472
- package/inc/util/system/shmat.h +0 -32
- package/inc/util/system/sigset.h +0 -78
- package/inc/util/system/spin_wait.h +0 -10
- package/inc/util/system/spinlock.h +0 -121
- package/inc/util/system/src_location.h +0 -25
- package/inc/util/system/src_root.h +0 -68
- package/inc/util/system/sys_alloc.h +0 -43
- package/inc/util/system/sysstat.h +0 -52
- package/inc/util/system/tempfile.h +0 -34
- package/inc/util/system/thread.h +0 -167
- package/inc/util/system/tls.h +0 -307
- package/inc/util/system/types.h +0 -119
- package/inc/util/system/unaligned_mem.h +0 -67
- package/inc/util/system/user.h +0 -5
- package/inc/util/system/utime.h +0 -6
- package/inc/util/system/valgrind.h +0 -48
- package/inc/util/system/winint.h +0 -43
- package/inc/util/system/yassert.h +0 -121
- package/inc/util/system/yield.h +0 -4
- package/inc/util/thread/factory.h +0 -65
- package/inc/util/thread/fwd.h +0 -30
- package/inc/util/thread/lfqueue.h +0 -406
- package/inc/util/thread/lfstack.h +0 -188
- package/inc/util/thread/pool.h +0 -388
- package/inc/util/thread/singleton.h +0 -42
- package/inc/util/ysafeptr.h +0 -427
- package/inc/util/ysaveload.h +0 -700
|
@@ -1,612 +0,0 @@
|
|
|
1
|
-
#pragma once
|
|
2
|
-
|
|
3
|
-
// Some of these includes are just a legacy from previous implementation.
|
|
4
|
-
// We don't need them here, but removing them is tricky because it breaks all
|
|
5
|
-
// kinds of builds downstream
|
|
6
|
-
#include "mem_copy.h"
|
|
7
|
-
#include "ptr.h"
|
|
8
|
-
#include "utility.h"
|
|
9
|
-
|
|
10
|
-
#include <util/charset/unidata.h>
|
|
11
|
-
#include <util/system/platform.h>
|
|
12
|
-
#include <util/system/yassert.h>
|
|
13
|
-
|
|
14
|
-
#include <contrib/libs/libc_compat/string.h>
|
|
15
|
-
|
|
16
|
-
#include <cctype>
|
|
17
|
-
#include <cstring>
|
|
18
|
-
#include <string>
|
|
19
|
-
#include <string_view>
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
namespace NStringPrivate {
|
|
23
|
-
template <class TCharType>
|
|
24
|
-
size_t GetStringLengthWithLimit(const TCharType* s, size_t maxlen) {
|
|
25
|
-
Y_ASSERT(s);
|
|
26
|
-
size_t i = 0;
|
|
27
|
-
for (; i != maxlen && s[i]; ++i)
|
|
28
|
-
;
|
|
29
|
-
return i;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
inline size_t GetStringLengthWithLimit(const char* s, size_t maxlen) {
|
|
33
|
-
Y_ASSERT(s);
|
|
34
|
-
return strnlen(s, maxlen);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
template <typename TDerived, typename TCharType, typename TTraitsType = std::char_traits<TCharType>>
|
|
39
|
-
class TStringBase {
|
|
40
|
-
using TStringView = std::basic_string_view<TCharType>;
|
|
41
|
-
using TStringViewWithTraits = std::basic_string_view<TCharType, TTraitsType>;
|
|
42
|
-
|
|
43
|
-
public:
|
|
44
|
-
using TChar = TCharType;
|
|
45
|
-
using TTraits = TTraitsType;
|
|
46
|
-
using TSelf = TStringBase<TDerived, TChar, TTraits>;
|
|
47
|
-
|
|
48
|
-
using size_type = size_t;
|
|
49
|
-
using difference_type = ptrdiff_t;
|
|
50
|
-
static constexpr size_t npos = size_t(-1);
|
|
51
|
-
|
|
52
|
-
using const_iterator = const TCharType*;
|
|
53
|
-
using const_reference = const TCharType&;
|
|
54
|
-
|
|
55
|
-
template <typename TBase>
|
|
56
|
-
struct TReverseIteratorBase {
|
|
57
|
-
constexpr TReverseIteratorBase() noexcept = default;
|
|
58
|
-
explicit constexpr TReverseIteratorBase(TBase p)
|
|
59
|
-
: P_(p)
|
|
60
|
-
{
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
TReverseIteratorBase operator++() noexcept {
|
|
64
|
-
--P_;
|
|
65
|
-
return *this;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
TReverseIteratorBase operator++(int) noexcept {
|
|
69
|
-
TReverseIteratorBase old(*this);
|
|
70
|
-
--P_;
|
|
71
|
-
return old;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
TReverseIteratorBase& operator--() noexcept {
|
|
75
|
-
++P_;
|
|
76
|
-
return *this;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
TReverseIteratorBase operator--(int) noexcept {
|
|
80
|
-
TReverseIteratorBase old(*this);
|
|
81
|
-
++P_;
|
|
82
|
-
return old;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
constexpr auto operator*() const noexcept -> std::remove_pointer_t<TBase>& {
|
|
86
|
-
return *TBase(*this);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
explicit constexpr operator TBase() const noexcept {
|
|
90
|
-
return TBase(P_ - 1);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
constexpr auto operator-(const TReverseIteratorBase o) const noexcept {
|
|
94
|
-
return o.P_ - P_;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
constexpr bool operator==(const TReverseIteratorBase o) const noexcept {
|
|
98
|
-
return P_ == o.P_;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
constexpr bool operator!=(const TReverseIteratorBase o) const noexcept {
|
|
102
|
-
return !(*this == o);
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
private:
|
|
106
|
-
TBase P_ = nullptr;
|
|
107
|
-
};
|
|
108
|
-
using const_reverse_iterator = TReverseIteratorBase<const_iterator>;
|
|
109
|
-
|
|
110
|
-
_LIBCPP_CONSTEXPR_AFTER_CXX14
|
|
111
|
-
static inline size_t StrLen(const TCharType* s) noexcept {
|
|
112
|
-
if (Y_LIKELY(s)) {
|
|
113
|
-
return TTraits::length(s);
|
|
114
|
-
}
|
|
115
|
-
return 0;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
template <class TCharTraits>
|
|
119
|
-
inline constexpr operator std::basic_string_view<TCharType, TCharTraits>() const {
|
|
120
|
-
return std::basic_string_view<TCharType, TCharTraits>(data(), size());
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
template <class TCharTraits, class Allocator>
|
|
124
|
-
inline explicit operator std::basic_string<TCharType, TCharTraits, Allocator>() const {
|
|
125
|
-
return std::basic_string<TCharType, TCharTraits, Allocator>(Ptr(), Len());
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
/**
|
|
129
|
-
* @param Pointer to character inside the string, or nullptr.
|
|
130
|
-
* @return Offset from string beginning (in chars), or npos on nullptr.
|
|
131
|
-
*/
|
|
132
|
-
inline size_t off(const TCharType* ret) const noexcept {
|
|
133
|
-
return ret ? (size_t)(ret - Ptr()) : npos;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
inline size_t IterOff(const_iterator it) const noexcept {
|
|
137
|
-
return begin() <= it && end() > it ? size_t(it - begin()) : npos;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
inline const_iterator begin() const noexcept {
|
|
141
|
-
return Ptr();
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
inline const_iterator end() const noexcept {
|
|
145
|
-
return Ptr() + size();
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
inline const_iterator cbegin() const noexcept {
|
|
149
|
-
return begin();
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
inline const_iterator cend() const noexcept {
|
|
153
|
-
return end();
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
inline const_reverse_iterator rbegin() const noexcept {
|
|
157
|
-
return const_reverse_iterator(Ptr() + size());
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
inline const_reverse_iterator rend() const noexcept {
|
|
161
|
-
return const_reverse_iterator(Ptr());
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
inline const_reverse_iterator crbegin() const noexcept {
|
|
165
|
-
return rbegin();
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
inline const_reverse_iterator crend() const noexcept {
|
|
169
|
-
return rend();
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
inline TCharType back() const noexcept {
|
|
173
|
-
Y_ASSERT(!this->empty());
|
|
174
|
-
return Ptr()[Len() - 1];
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
inline TCharType front() const noexcept {
|
|
178
|
-
Y_ASSERT(!empty());
|
|
179
|
-
return Ptr()[0];
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
constexpr const TCharType* data() const noexcept {
|
|
183
|
-
return Ptr();
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
constexpr inline size_t size() const noexcept {
|
|
187
|
-
return Len();
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
constexpr inline bool is_null() const noexcept {
|
|
191
|
-
return *Ptr() == 0;
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
Y_PURE_FUNCTION
|
|
195
|
-
constexpr inline bool empty() const noexcept {
|
|
196
|
-
return Len() == 0;
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
constexpr inline explicit operator bool() const noexcept {
|
|
200
|
-
return !empty();
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
public: // style-guide compliant methods
|
|
204
|
-
constexpr const TCharType* Data() const noexcept {
|
|
205
|
-
return Ptr();
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
constexpr size_t Size() const noexcept {
|
|
209
|
-
return Len();
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
Y_PURE_FUNCTION
|
|
213
|
-
constexpr bool Empty() const noexcept {
|
|
214
|
-
return 0 == Len();
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
private:
|
|
218
|
-
static inline TStringView LegacySubString(const TStringView view, size_t p, size_t n) noexcept {
|
|
219
|
-
p = Min(p, view.length());
|
|
220
|
-
return view.substr(p, n);
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
public:
|
|
224
|
-
// ~~~ Comparison ~~~ : FAMILY0(int, compare)
|
|
225
|
-
static int compare(const TSelf& s1, const TSelf& s2) noexcept {
|
|
226
|
-
return s1.AsStringView().compare(s2.AsStringView());
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
static int compare(const TCharType* p, const TSelf& s2) noexcept {
|
|
230
|
-
TCharType null{0};
|
|
231
|
-
return TStringViewWithTraits(p ? p : &null).compare(s2.AsStringView());
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
static int compare(const TSelf& s1, const TCharType* p) noexcept {
|
|
235
|
-
TCharType null{0};
|
|
236
|
-
return s1.AsStringView().compare(p ? p : &null);
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
static int compare(const TStringView s1, const TStringView s2) noexcept {
|
|
240
|
-
return TStringViewWithTraits(s1.data(), s1.size()).compare(
|
|
241
|
-
TStringViewWithTraits(s2.data(), s2.size()));
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
template <class T>
|
|
245
|
-
inline int compare(const T& t) const noexcept {
|
|
246
|
-
return compare(*this, t);
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
inline int compare(size_t p, size_t n, const TStringView t) const noexcept {
|
|
250
|
-
return compare(LegacySubString(*this, p, n), t);
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
inline int compare(size_t p, size_t n, const TStringView t, size_t p1, size_t n1) const noexcept {
|
|
254
|
-
return compare(LegacySubString(*this, p, n), LegacySubString(t, p1, n1));
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
inline int compare(size_t p, size_t n, const TStringView t, size_t n1) const noexcept {
|
|
258
|
-
return compare(LegacySubString(*this, p, n), LegacySubString(t, 0, n1));
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
inline int compare(const TCharType* p, size_t len) const noexcept {
|
|
262
|
-
return compare(*this, TStringView(p, len));
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
static bool equal(const TSelf& s1, const TSelf& s2) noexcept {
|
|
266
|
-
return s1.AsStringView() == s2.AsStringView();
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
static bool equal(const TSelf& s1, const TCharType* p) noexcept {
|
|
270
|
-
if (p == nullptr) {
|
|
271
|
-
return s1.Len() == 0;
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
return s1.AsStringView() == p;
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
static bool equal(const TCharType* p, const TSelf& s2) noexcept {
|
|
278
|
-
return equal(s2, p);
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
static bool equal(const TStringView s1, const TStringView s2) noexcept {
|
|
282
|
-
return TStringViewWithTraits{s1.data(), s1.size()} == TStringViewWithTraits{s2.data(), s2.size()};
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
template <class T>
|
|
286
|
-
inline bool equal(const T& t) const noexcept {
|
|
287
|
-
return equal(*this, t);
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
inline bool equal(size_t p, size_t n, const TStringView t) const noexcept {
|
|
291
|
-
return equal(LegacySubString(*this, p, n), t);
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
inline bool equal(size_t p, size_t n, const TStringView t, size_t p1, size_t n1) const noexcept {
|
|
295
|
-
return equal(LegacySubString(*this, p, n), LegacySubString(t, p1, n1));
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
inline bool equal(size_t p, size_t n, const TStringView t, size_t n1) const noexcept {
|
|
299
|
-
return equal(LegacySubString(*this, p, n), LegacySubString(t, 0, n1));
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
static inline bool StartsWith(const TCharType* what, size_t whatLen, const TCharType* with, size_t withLen) noexcept {
|
|
303
|
-
return withLen <= whatLen && TStringViewWithTraits(what, withLen) == TStringViewWithTraits(with, withLen);
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
static inline bool EndsWith(const TCharType* what, size_t whatLen, const TCharType* with, size_t withLen) noexcept {
|
|
307
|
-
return withLen <= whatLen && TStringViewWithTraits(what + whatLen - withLen, withLen) == TStringViewWithTraits(with, withLen);
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
inline bool StartsWith(const TCharType* s, size_t n) const noexcept {
|
|
311
|
-
return StartsWith(Ptr(), Len(), s, n);
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
inline bool StartsWith(const TStringView s) const noexcept {
|
|
315
|
-
return StartsWith(s.data(), s.length());
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
inline bool StartsWith(TCharType ch) const noexcept {
|
|
319
|
-
return !empty() && TTraits::eq(*Ptr(), ch);
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
inline bool EndsWith(const TCharType* s, size_t n) const noexcept {
|
|
323
|
-
return EndsWith(Ptr(), Len(), s, n);
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
inline bool EndsWith(const TStringView s) const noexcept {
|
|
327
|
-
return EndsWith(s.data(), s.length());
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
inline bool EndsWith(TCharType ch) const noexcept {
|
|
331
|
-
return !empty() && TTraits::eq(Ptr()[Len() - 1], ch);
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
template <typename TDerived2, typename TTraits2>
|
|
335
|
-
bool operator==(const TStringBase<TDerived2, TChar, TTraits2>& s2) const noexcept {
|
|
336
|
-
return equal(*this, s2);
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
bool operator==(TStringView s2) const noexcept {
|
|
340
|
-
return equal(*this, s2);
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
bool operator==(const TCharType* pc) const noexcept {
|
|
344
|
-
return equal(*this, pc);
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
#ifndef __cpp_impl_three_way_comparison
|
|
348
|
-
friend bool operator==(const TCharType* pc, const TSelf& s) noexcept {
|
|
349
|
-
return equal(pc, s);
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
template <typename TDerived2, typename TTraits2>
|
|
353
|
-
friend bool operator!=(const TSelf& s1, const TStringBase<TDerived2, TChar, TTraits2>& s2) noexcept {
|
|
354
|
-
return !(s1 == s2);
|
|
355
|
-
}
|
|
356
|
-
|
|
357
|
-
friend bool operator!=(const TSelf& s1, TStringView s2) noexcept {
|
|
358
|
-
return !(s1 == s2);
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
friend bool operator!=(const TSelf& s, const TCharType* pc) noexcept {
|
|
362
|
-
return !(s == pc);
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
friend bool operator!=(const TCharType* pc, const TSelf& s) noexcept {
|
|
366
|
-
return !(pc == s);
|
|
367
|
-
}
|
|
368
|
-
#endif
|
|
369
|
-
|
|
370
|
-
template <typename TDerived2, typename TTraits2>
|
|
371
|
-
friend bool operator<(const TSelf& s1, const TStringBase<TDerived2, TChar, TTraits2>& s2) noexcept {
|
|
372
|
-
return compare(s1, s2) < 0;
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
friend bool operator<(const TSelf& s1, TStringView s2) noexcept {
|
|
376
|
-
return compare(s1, s2) < 0;
|
|
377
|
-
}
|
|
378
|
-
|
|
379
|
-
friend bool operator<(const TSelf& s, const TCharType* pc) noexcept {
|
|
380
|
-
return compare(s, pc) < 0;
|
|
381
|
-
}
|
|
382
|
-
|
|
383
|
-
friend bool operator<(const TCharType* pc, const TSelf& s) noexcept {
|
|
384
|
-
return compare(pc, s) < 0;
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
template <typename TDerived2, typename TTraits2>
|
|
388
|
-
friend bool operator<=(const TSelf& s1, const TStringBase<TDerived2, TChar, TTraits2>& s2) noexcept {
|
|
389
|
-
return compare(s1, s2) <= 0;
|
|
390
|
-
}
|
|
391
|
-
|
|
392
|
-
friend bool operator<=(const TSelf& s1, TStringView s2) noexcept {
|
|
393
|
-
return compare(s1, s2) <= 0;
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
friend bool operator<=(const TSelf& s, const TCharType* pc) noexcept {
|
|
397
|
-
return compare(s, pc) <= 0;
|
|
398
|
-
}
|
|
399
|
-
|
|
400
|
-
friend bool operator<=(const TCharType* pc, const TSelf& s) noexcept {
|
|
401
|
-
return compare(pc, s) <= 0;
|
|
402
|
-
}
|
|
403
|
-
|
|
404
|
-
template <typename TDerived2, typename TTraits2>
|
|
405
|
-
friend bool operator>(const TSelf& s1, const TStringBase<TDerived2, TChar, TTraits2>& s2) noexcept {
|
|
406
|
-
return compare(s1, s2) > 0;
|
|
407
|
-
}
|
|
408
|
-
|
|
409
|
-
friend bool operator>(const TSelf& s1, TStringView s2) noexcept {
|
|
410
|
-
return compare(s1, s2) > 0;
|
|
411
|
-
}
|
|
412
|
-
|
|
413
|
-
friend bool operator>(const TSelf& s, const TCharType* pc) noexcept {
|
|
414
|
-
return compare(s, pc) > 0;
|
|
415
|
-
}
|
|
416
|
-
|
|
417
|
-
friend bool operator>(const TCharType* pc, const TSelf& s) noexcept {
|
|
418
|
-
return compare(pc, s) > 0;
|
|
419
|
-
}
|
|
420
|
-
|
|
421
|
-
template <typename TDerived2, typename TTraits2>
|
|
422
|
-
friend bool operator>=(const TSelf& s1, const TStringBase<TDerived2, TChar, TTraits2>& s2) noexcept {
|
|
423
|
-
return compare(s1, s2) >= 0;
|
|
424
|
-
}
|
|
425
|
-
|
|
426
|
-
friend bool operator>=(const TSelf& s1, TStringView s2) noexcept {
|
|
427
|
-
return compare(s1, s2) >= 0;
|
|
428
|
-
}
|
|
429
|
-
|
|
430
|
-
friend bool operator>=(const TSelf& s, const TCharType* pc) noexcept {
|
|
431
|
-
return compare(s, pc) >= 0;
|
|
432
|
-
}
|
|
433
|
-
|
|
434
|
-
friend bool operator>=(const TCharType* pc, const TSelf& s) noexcept {
|
|
435
|
-
return compare(pc, s) >= 0;
|
|
436
|
-
}
|
|
437
|
-
|
|
438
|
-
// ~~ Read access ~~
|
|
439
|
-
inline TCharType at(size_t pos) const noexcept {
|
|
440
|
-
if (Y_LIKELY(pos < Len())) {
|
|
441
|
-
return (Ptr())[pos];
|
|
442
|
-
}
|
|
443
|
-
return 0;
|
|
444
|
-
}
|
|
445
|
-
|
|
446
|
-
inline TCharType operator[](size_t pos) const noexcept {
|
|
447
|
-
Y_ASSERT(pos < this->size());
|
|
448
|
-
|
|
449
|
-
return Ptr()[pos];
|
|
450
|
-
}
|
|
451
|
-
|
|
452
|
-
//~~~~Search~~~~
|
|
453
|
-
/**
|
|
454
|
-
* @return Position of the substring inside this string, or `npos` if not found.
|
|
455
|
-
*/
|
|
456
|
-
inline size_t find(const TStringView s, size_t pos = 0) const noexcept {
|
|
457
|
-
return find(s.data(), pos, s.size());
|
|
458
|
-
}
|
|
459
|
-
|
|
460
|
-
inline size_t find(const TCharType* s, size_t pos, size_t count) const noexcept {
|
|
461
|
-
return AsStringView().find(s, pos, count);
|
|
462
|
-
}
|
|
463
|
-
|
|
464
|
-
inline size_t find(TCharType c, size_t pos = 0) const noexcept {
|
|
465
|
-
return AsStringView().find(c, pos);
|
|
466
|
-
}
|
|
467
|
-
|
|
468
|
-
inline size_t rfind(TCharType c) const noexcept {
|
|
469
|
-
return AsStringView().rfind(c);
|
|
470
|
-
}
|
|
471
|
-
|
|
472
|
-
inline size_t rfind(TCharType c, size_t pos) const noexcept {
|
|
473
|
-
if (pos == 0) {
|
|
474
|
-
return npos;
|
|
475
|
-
}
|
|
476
|
-
return AsStringView().rfind(c, pos - 1);
|
|
477
|
-
}
|
|
478
|
-
|
|
479
|
-
inline size_t rfind(const TStringView str, size_t pos = npos) const {
|
|
480
|
-
return AsStringView().rfind(str.data(), pos, str.size());
|
|
481
|
-
}
|
|
482
|
-
|
|
483
|
-
//~~~~Contains~~~~
|
|
484
|
-
/**
|
|
485
|
-
* @returns Whether this string contains the provided substring.
|
|
486
|
-
*/
|
|
487
|
-
inline bool Contains(const TStringView s, size_t pos = 0) const noexcept {
|
|
488
|
-
return !s.length() || find(s, pos) != npos;
|
|
489
|
-
}
|
|
490
|
-
|
|
491
|
-
inline bool Contains(TChar c, size_t pos = 0) const noexcept {
|
|
492
|
-
return find(c, pos) != npos;
|
|
493
|
-
}
|
|
494
|
-
|
|
495
|
-
inline void Contains(std::enable_if<std::is_unsigned<TCharType>::value, char> c, size_t pos = 0) const noexcept {
|
|
496
|
-
return find(ui8(c), pos) != npos;
|
|
497
|
-
}
|
|
498
|
-
|
|
499
|
-
//~~~~Character Set Search~~~
|
|
500
|
-
inline size_t find_first_of(TCharType c) const noexcept {
|
|
501
|
-
return find_first_of(c, 0);
|
|
502
|
-
}
|
|
503
|
-
|
|
504
|
-
inline size_t find_first_of(TCharType c, size_t pos) const noexcept {
|
|
505
|
-
return find(c, pos);
|
|
506
|
-
}
|
|
507
|
-
|
|
508
|
-
inline size_t find_first_of(const TStringView set) const noexcept {
|
|
509
|
-
return find_first_of(set, 0);
|
|
510
|
-
}
|
|
511
|
-
|
|
512
|
-
inline size_t find_first_of(const TStringView set, size_t pos) const noexcept {
|
|
513
|
-
return AsStringView().find_first_of(set.data(), pos, set.size());
|
|
514
|
-
}
|
|
515
|
-
|
|
516
|
-
inline size_t find_first_not_of(TCharType c) const noexcept {
|
|
517
|
-
return find_first_not_of(c, 0);
|
|
518
|
-
}
|
|
519
|
-
|
|
520
|
-
inline size_t find_first_not_of(TCharType c, size_t pos) const noexcept {
|
|
521
|
-
return find_first_not_of(TStringView(&c, 1), pos);
|
|
522
|
-
}
|
|
523
|
-
|
|
524
|
-
inline size_t find_first_not_of(const TStringView set) const noexcept {
|
|
525
|
-
return find_first_not_of(set, 0);
|
|
526
|
-
}
|
|
527
|
-
|
|
528
|
-
inline size_t find_first_not_of(const TStringView set, size_t pos) const noexcept {
|
|
529
|
-
return AsStringView().find_first_not_of(set.data(), pos, set.size());
|
|
530
|
-
}
|
|
531
|
-
|
|
532
|
-
inline size_t find_last_of(TCharType c, size_t pos = npos) const noexcept {
|
|
533
|
-
return find_last_of(&c, pos, 1);
|
|
534
|
-
}
|
|
535
|
-
|
|
536
|
-
inline size_t find_last_of(const TStringView set, size_t pos = npos) const noexcept {
|
|
537
|
-
return find_last_of(set.data(), pos, set.length());
|
|
538
|
-
}
|
|
539
|
-
|
|
540
|
-
inline size_t find_last_of(const TCharType* set, size_t pos, size_t n) const noexcept {
|
|
541
|
-
return AsStringView().find_last_of(set, pos, n);
|
|
542
|
-
}
|
|
543
|
-
|
|
544
|
-
inline size_t find_last_not_of(TCharType c, size_t pos = npos) const noexcept {
|
|
545
|
-
return AsStringView().find_last_not_of(c, pos);
|
|
546
|
-
}
|
|
547
|
-
|
|
548
|
-
inline size_t find_last_not_of(const TStringView set, size_t pos = npos) const noexcept {
|
|
549
|
-
return find_last_not_of(set.data(), pos, set.length());
|
|
550
|
-
}
|
|
551
|
-
|
|
552
|
-
inline size_t find_last_not_of(const TCharType* set, size_t pos, size_t n) const noexcept {
|
|
553
|
-
return AsStringView().find_last_not_of(set, pos, n);
|
|
554
|
-
}
|
|
555
|
-
|
|
556
|
-
inline size_t copy(TCharType* pc, size_t n, size_t pos) const {
|
|
557
|
-
if (pos > Len()) {
|
|
558
|
-
throw std::out_of_range("TStringBase::copy");
|
|
559
|
-
}
|
|
560
|
-
|
|
561
|
-
return CopyImpl(pc, n, pos);
|
|
562
|
-
}
|
|
563
|
-
|
|
564
|
-
inline size_t copy(TCharType* pc, size_t n) const noexcept {
|
|
565
|
-
return CopyImpl(pc, n, 0);
|
|
566
|
-
}
|
|
567
|
-
|
|
568
|
-
inline size_t strcpy(TCharType* pc, size_t n) const noexcept {
|
|
569
|
-
if (n) {
|
|
570
|
-
n = copy(pc, n - 1);
|
|
571
|
-
pc[n] = 0;
|
|
572
|
-
}
|
|
573
|
-
|
|
574
|
-
return n;
|
|
575
|
-
}
|
|
576
|
-
|
|
577
|
-
inline TDerived copy() const Y_WARN_UNUSED_RESULT {
|
|
578
|
-
return TDerived(Ptr(), Len());
|
|
579
|
-
}
|
|
580
|
-
|
|
581
|
-
// ~~~ Partial copy ~~~~
|
|
582
|
-
TDerived substr(size_t pos, size_t n = npos) const Y_WARN_UNUSED_RESULT {
|
|
583
|
-
return TDerived(*This(), pos, n);
|
|
584
|
-
}
|
|
585
|
-
|
|
586
|
-
private:
|
|
587
|
-
using GenericFinder = const TCharType* (*)(const TCharType*, size_t, const TCharType*, size_t);
|
|
588
|
-
|
|
589
|
-
TStringViewWithTraits AsStringView() const {
|
|
590
|
-
return static_cast<TStringViewWithTraits>(*this);
|
|
591
|
-
}
|
|
592
|
-
|
|
593
|
-
constexpr inline const TCharType* Ptr() const noexcept {
|
|
594
|
-
return This()->data();
|
|
595
|
-
}
|
|
596
|
-
|
|
597
|
-
constexpr inline size_t Len() const noexcept {
|
|
598
|
-
return This()->length();
|
|
599
|
-
}
|
|
600
|
-
|
|
601
|
-
constexpr inline const TDerived* This() const noexcept {
|
|
602
|
-
return static_cast<const TDerived*>(this);
|
|
603
|
-
}
|
|
604
|
-
|
|
605
|
-
inline size_t CopyImpl(TCharType* pc, size_t n, size_t pos) const noexcept {
|
|
606
|
-
const size_t toCopy = Min(Len() - pos, n);
|
|
607
|
-
|
|
608
|
-
TTraits::copy(pc, Ptr() + pos, toCopy);
|
|
609
|
-
|
|
610
|
-
return toCopy;
|
|
611
|
-
}
|
|
612
|
-
};
|