aboutsummaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorVlad Yaroslavlev <vladon@vladon.com>2022-02-10 16:46:25 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:46:25 +0300
commit344ea37b4a345701ab0e67de2266a1c1bd7baf2d (patch)
tree1a2c5ffcf89eb53ecd79dbc9bc0a195c27404d0c /util
parent706b83ed7de5a473436620367af31fc0ceecde07 (diff)
downloadydb-344ea37b4a345701ab0e67de2266a1c1bd7baf2d.tar.gz
Restoring authorship annotation for Vlad Yaroslavlev <vladon@vladon.com>. Commit 2 of 2.
Diffstat (limited to 'util')
-rw-r--r--util/charset/benchmark/utf8_to_wide/main.cpp6
-rw-r--r--util/charset/utf8.cpp12
-rw-r--r--util/charset/utf8.h12
-rw-r--r--util/charset/utf8_ut.cpp68
-rw-r--r--util/charset/wide.cpp36
-rw-r--r--util/charset/wide.h56
-rw-r--r--util/charset/wide_ut.cpp70
-rw-r--r--util/datetime/base.cpp18
-rw-r--r--util/datetime/base.h206
-rw-r--r--util/datetime/base_ut.cpp42
-rw-r--r--util/datetime/cputimer.cpp8
-rw-r--r--util/datetime/cputimer.h12
-rw-r--r--util/datetime/parser.h2
-rw-r--r--util/datetime/systime.cpp2
-rw-r--r--util/datetime/systime.h4
-rw-r--r--util/datetime/uptime.cpp104
-rw-r--r--util/datetime/uptime.h16
-rw-r--r--util/datetime/uptime_ut.cpp22
-rw-r--r--util/datetime/ut/ya.make2
-rw-r--r--util/digest/city.h20
-rw-r--r--util/digest/multi_ut.pyx2
-rw-r--r--util/digest/sequence_ut.cpp10
-rw-r--r--util/draft/date.cpp6
-rw-r--r--util/draft/date.h10
-rw-r--r--util/draft/datetime.cpp2
-rw-r--r--util/draft/datetime.h10
-rw-r--r--util/draft/datetime_ut.cpp12
-rw-r--r--util/draft/enum.h8
-rw-r--r--util/draft/holder_vector.h4
-rw-r--r--util/draft/holder_vector_ut.cpp4
-rw-r--r--util/draft/ip.h6
-rw-r--r--util/folder/dirut.cpp44
-rw-r--r--util/folder/dirut.h36
-rw-r--r--util/folder/dirut_ut.cpp2
-rw-r--r--util/folder/filelist.cpp2
-rw-r--r--util/folder/filelist.h8
-rw-r--r--util/folder/filelist_ut.cpp12
-rw-r--r--util/folder/fts_ut.cpp2
-rw-r--r--util/folder/iterator.cpp2
-rw-r--r--util/folder/iterator.h14
-rw-r--r--util/folder/iterator_ut.cpp42
-rw-r--r--util/folder/path.cpp36
-rw-r--r--util/folder/path.h34
-rw-r--r--util/folder/path_ut.cpp56
-rw-r--r--util/folder/pathsplit.cpp6
-rw-r--r--util/folder/pathsplit.h12
-rw-r--r--util/folder/tempdir.cpp2
-rw-r--r--util/folder/tempdir.h8
-rw-r--r--util/generic/adaptor_ut.cpp10
-rw-r--r--util/generic/algorithm.h8
-rw-r--r--util/generic/algorithm_ut.cpp122
-rw-r--r--util/generic/array_ref_ut.cpp38
-rw-r--r--util/generic/benchmark/fastclp2/main.cpp2
-rw-r--r--util/generic/benchmark/log2/main.cpp2
-rw-r--r--util/generic/benchmark/rotate_bits/main.cpp2
-rw-r--r--util/generic/benchmark/sort/main.cpp16
-rw-r--r--util/generic/benchmark/vector_count_ctor/f.cpp2
-rw-r--r--util/generic/bitmap.h2
-rw-r--r--util/generic/bitops.h26
-rw-r--r--util/generic/bt_exception.h2
-rw-r--r--util/generic/buffer.cpp4
-rw-r--r--util/generic/buffer.h36
-rw-r--r--util/generic/buffer_ut.cpp16
-rw-r--r--util/generic/cast.h2
-rw-r--r--util/generic/deque.h2
-rw-r--r--util/generic/deque_ut.cpp24
-rw-r--r--util/generic/explicit_type_ut.cpp2
-rw-r--r--util/generic/fastqueue.h4
-rw-r--r--util/generic/flags_ut.cpp2
-rw-r--r--util/generic/fuzz/vector/main.cpp2
-rw-r--r--util/generic/fwd.h34
-rw-r--r--util/generic/guid.cpp6
-rw-r--r--util/generic/guid.h4
-rw-r--r--util/generic/guid_ut.cpp2
-rw-r--r--util/generic/hash.cpp20
-rw-r--r--util/generic/hash.h310
-rw-r--r--util/generic/hash.pxd22
-rw-r--r--util/generic/hash_set.h72
-rw-r--r--util/generic/hash_ut.cpp166
-rw-r--r--util/generic/hash_ut.pyx22
-rw-r--r--util/generic/intrlist.h248
-rw-r--r--util/generic/intrlist_ut.cpp34
-rw-r--r--util/generic/is_in_ut.cpp30
-rw-r--r--util/generic/iterator_range_ut.cpp4
-rw-r--r--util/generic/iterator_ut.cpp2
-rw-r--r--util/generic/lazy_value_ut.cpp2
-rw-r--r--util/generic/list.h2
-rw-r--r--util/generic/list_ut.cpp4
-rw-r--r--util/generic/map.h4
-rw-r--r--util/generic/map_ut.cpp44
-rw-r--r--util/generic/mapfindptr.h2
-rw-r--r--util/generic/mapfindptr_ut.cpp12
-rw-r--r--util/generic/maybe.h380
-rw-r--r--util/generic/maybe_ut.cpp1038
-rw-r--r--util/generic/mem_copy.h4
-rw-r--r--util/generic/noncopyable.h8
-rw-r--r--util/generic/object_counter.h6
-rw-r--r--util/generic/objects_counter_ut.cpp2
-rw-r--r--util/generic/ptr.cpp4
-rw-r--r--util/generic/ptr.h236
-rw-r--r--util/generic/ptr_ut.cpp10
-rw-r--r--util/generic/queue.h4
-rw-r--r--util/generic/queue_ut.cpp26
-rw-r--r--util/generic/refcount.h24
-rw-r--r--util/generic/serialized_enum.h42
-rw-r--r--util/generic/set.h4
-rw-r--r--util/generic/set_ut.cpp56
-rw-r--r--util/generic/singleton.cpp10
-rw-r--r--util/generic/singleton.h8
-rw-r--r--util/generic/stack.h2
-rw-r--r--util/generic/stack_ut.cpp2
-rw-r--r--util/generic/strbase.h100
-rw-r--r--util/generic/strbuf.h40
-rw-r--r--util/generic/strbuf_ut.cpp2
-rw-r--r--util/generic/string.cpp2
-rw-r--r--util/generic/string.h26
-rw-r--r--util/generic/string.pxd50
-rw-r--r--util/generic/string_transparent_hash_ut.cpp2
-rw-r--r--util/generic/string_ut.cpp148
-rw-r--r--util/generic/string_ut.h178
-rw-r--r--util/generic/string_ut.pyx30
-rw-r--r--util/generic/typelist_ut.cpp18
-rw-r--r--util/generic/typetraits.h20
-rw-r--r--util/generic/typetraits_ut.cpp24
-rw-r--r--util/generic/ut/ya.make4
-rw-r--r--util/generic/utility.cpp36
-rw-r--r--util/generic/utility.h62
-rw-r--r--util/generic/utility_ut.cpp38
-rw-r--r--util/generic/vector.h28
-rw-r--r--util/generic/vector.pxd24
-rw-r--r--util/generic/vector_ut.cpp74
-rw-r--r--util/generic/vector_ut.pyx48
-rw-r--r--util/generic/xrange.h2
-rw-r--r--util/generic/xrange_ut.cpp14
-rw-r--r--util/generic/yexception.cpp40
-rw-r--r--util/generic/yexception.h10
-rw-r--r--util/generic/yexception_ut.cpp16
-rw-r--r--util/generic/ylimits.h8
-rw-r--r--util/generic/ymath_ut.cpp2
-rw-r--r--util/memory/addstorage.h14
-rw-r--r--util/memory/alloc.cpp2
-rw-r--r--util/memory/alloc.h2
-rw-r--r--util/memory/blob.cpp42
-rw-r--r--util/memory/blob.h50
-rw-r--r--util/memory/pool.cpp4
-rw-r--r--util/memory/pool.h56
-rw-r--r--util/memory/pool_ut.cpp6
-rw-r--r--util/memory/segmented_string_pool.h2
-rw-r--r--util/memory/segpool_alloc.h4
-rw-r--r--util/memory/smallobj.h18
-rw-r--r--util/memory/smallobj_ut.cpp2
-rw-r--r--util/memory/tempbuf.cpp72
-rw-r--r--util/memory/tempbuf.h28
-rw-r--r--util/memory/tempbuf_ut.cpp2
-rw-r--r--util/network/address.cpp4
-rw-r--r--util/network/address.h22
-rw-r--r--util/network/address_ut.cpp8
-rw-r--r--util/network/endpoint.cpp2
-rw-r--r--util/network/endpoint.h6
-rw-r--r--util/network/endpoint_ut.cpp8
-rw-r--r--util/network/interface.cpp2
-rw-r--r--util/network/interface.h4
-rw-r--r--util/network/iovec.h12
-rw-r--r--util/network/ip.h28
-rw-r--r--util/network/nonblock.cpp2
-rw-r--r--util/network/poller.h2
-rw-r--r--util/network/pollerimpl.h86
-rw-r--r--util/network/sock.h46
-rw-r--r--util/network/socket.cpp40
-rw-r--r--util/network/socket.h76
-rw-r--r--util/network/socket_ut.cpp14
-rw-r--r--util/random/common_ops.h20
-rw-r--r--util/random/common_ops_ut.cpp2
-rw-r--r--util/random/easy.h2
-rw-r--r--util/random/fast.cpp6
-rw-r--r--util/random/fast.h12
-rw-r--r--util/random/lcg_engine.cpp6
-rw-r--r--util/random/lcg_engine.h18
-rw-r--r--util/random/mersenne.h6
-rw-r--r--util/random/mersenne32.cpp6
-rw-r--r--util/random/mersenne32.h12
-rw-r--r--util/random/mersenne64.cpp6
-rw-r--r--util/random/mersenne64.h10
-rw-r--r--util/random/normal_ut.cpp2
-rw-r--r--util/random/shuffle_ut.cpp4
-rw-r--r--util/str_stl.h24
-rw-r--r--util/stream/aligned.cpp2
-rw-r--r--util/stream/aligned.h8
-rw-r--r--util/stream/buffer.cpp8
-rw-r--r--util/stream/buffer.h12
-rw-r--r--util/stream/buffer_ut.cpp2
-rw-r--r--util/stream/buffered.cpp36
-rw-r--r--util/stream/buffered.h40
-rw-r--r--util/stream/buffered_ut.cpp20
-rw-r--r--util/stream/debug.cpp2
-rw-r--r--util/stream/debug.h10
-rw-r--r--util/stream/direct_io.cpp2
-rw-r--r--util/stream/direct_io.h8
-rw-r--r--util/stream/direct_io_ut.cpp4
-rw-r--r--util/stream/file.cpp20
-rw-r--r--util/stream/file.h44
-rw-r--r--util/stream/file_ut.cpp22
-rw-r--r--util/stream/format.h2
-rw-r--r--util/stream/format_ut.cpp2
-rw-r--r--util/stream/hex_ut.cpp8
-rw-r--r--util/stream/input.cpp16
-rw-r--r--util/stream/input.h22
-rw-r--r--util/stream/input_ut.cpp12
-rw-r--r--util/stream/ios_ut.cpp62
-rw-r--r--util/stream/length.cpp2
-rw-r--r--util/stream/length.h14
-rw-r--r--util/stream/length_ut.cpp8
-rw-r--r--util/stream/mem.cpp4
-rw-r--r--util/stream/mem.h68
-rw-r--r--util/stream/mem_ut.cpp4
-rw-r--r--util/stream/multi.cpp4
-rw-r--r--util/stream/multi.h4
-rw-r--r--util/stream/multi_ut.cpp8
-rw-r--r--util/stream/null.cpp8
-rw-r--r--util/stream/null.h20
-rw-r--r--util/stream/output.cpp12
-rw-r--r--util/stream/output.h18
-rw-r--r--util/stream/pipe.cpp12
-rw-r--r--util/stream/pipe.h16
-rw-r--r--util/stream/printf_ut.cpp4
-rw-r--r--util/stream/str.h32
-rw-r--r--util/stream/str_ut.cpp30
-rw-r--r--util/stream/tee.h2
-rw-r--r--util/stream/tempbuf.cpp2
-rw-r--r--util/stream/tempbuf.h6
-rw-r--r--util/stream/tokenizer.h22
-rw-r--r--util/stream/tokenizer_ut.cpp8
-rw-r--r--util/stream/walk.cpp2
-rw-r--r--util/stream/walk_ut.cpp14
-rw-r--r--util/stream/zerocopy.h4
-rw-r--r--util/stream/zlib.cpp16
-rw-r--r--util/stream/zlib.h12
-rw-r--r--util/stream/zlib_ut.cpp12
-rw-r--r--util/string/ascii.h2
-rw-r--r--util/string/ascii_ut.cpp14
-rw-r--r--util/string/benchmark/float_to_string/main.cpp4
-rw-r--r--util/string/benchmark/join/main.cpp2
-rw-r--r--util/string/benchmark/subst_global/main.cpp16
-rw-r--r--util/string/builder.cpp2
-rw-r--r--util/string/builder.h4
-rw-r--r--util/string/builder_ut.cpp12
-rw-r--r--util/string/cast.cpp18
-rw-r--r--util/string/cast.h72
-rw-r--r--util/string/cast_ut.cpp20
-rw-r--r--util/string/escape.cpp26
-rw-r--r--util/string/escape.h18
-rw-r--r--util/string/escape_ut.cpp52
-rw-r--r--util/string/fuzzing/collapse/main.cpp4
-rw-r--r--util/string/hex.cpp8
-rw-r--r--util/string/hex.h10
-rw-r--r--util/string/join.h8
-rw-r--r--util/string/join_ut.cpp14
-rw-r--r--util/string/printf.cpp10
-rw-r--r--util/string/printf.h8
-rw-r--r--util/string/printf_ut.cpp10
-rw-r--r--util/string/split.cpp8
-rw-r--r--util/string/split.h26
-rw-r--r--util/string/split_ut.cpp96
-rw-r--r--util/string/strip.cpp6
-rw-r--r--util/string/strip.h46
-rw-r--r--util/string/strip_ut.cpp28
-rw-r--r--util/string/strspn.h16
-rw-r--r--util/string/subst.h30
-rw-r--r--util/string/subst_ut.cpp156
-rw-r--r--util/string/type.cpp2
-rw-r--r--util/string/type_ut.cpp4
-rw-r--r--util/string/util.cpp10
-rw-r--r--util/string/util.h16
-rw-r--r--util/string/util_ut.cpp2
-rw-r--r--util/string/vector.cpp10
-rw-r--r--util/string/vector.h42
-rw-r--r--util/string/vector_ut.cpp16
-rw-r--r--util/system/align.h16
-rw-r--r--util/system/atexit.cpp6
-rw-r--r--util/system/atomic_ut.cpp4
-rw-r--r--util/system/backtrace.cpp4
-rw-r--r--util/system/backtrace.h2
-rw-r--r--util/system/backtrace_ut.cpp2
-rw-r--r--util/system/byteorder.h24
-rw-r--r--util/system/compiler.h336
-rw-r--r--util/system/compiler_ut.cpp102
-rw-r--r--util/system/condvar.cpp22
-rw-r--r--util/system/condvar.h10
-rw-r--r--util/system/context.cpp38
-rw-r--r--util/system/context.h16
-rw-r--r--util/system/context_ut.cpp2
-rw-r--r--util/system/direct_io.cpp2
-rw-r--r--util/system/direct_io.h2
-rw-r--r--util/system/direct_io_ut.cpp2
-rw-r--r--util/system/dynlib.cpp18
-rw-r--r--util/system/dynlib.h36
-rw-r--r--util/system/env.cpp44
-rw-r--r--util/system/env.h6
-rw-r--r--util/system/env_ut.cpp32
-rw-r--r--util/system/error.cpp2
-rw-r--r--util/system/event.cpp14
-rw-r--r--util/system/event.h14
-rw-r--r--util/system/execpath.cpp30
-rw-r--r--util/system/execpath.h2
-rw-r--r--util/system/execpath_ut.cpp2
-rw-r--r--util/system/fasttime.cpp14
-rw-r--r--util/system/file.cpp70
-rw-r--r--util/system/file.h78
-rw-r--r--util/system/file_ut.cpp10
-rw-r--r--util/system/filemap.cpp60
-rw-r--r--util/system/filemap.h64
-rw-r--r--util/system/filemap_ut.cpp6
-rw-r--r--util/system/fs.cpp38
-rw-r--r--util/system/fs.h38
-rw-r--r--util/system/fs_ut.cpp12
-rw-r--r--util/system/fs_win.cpp52
-rw-r--r--util/system/fs_win.h20
-rw-r--r--util/system/fstat.cpp4
-rw-r--r--util/system/fstat.h4
-rw-r--r--util/system/fstat_ut.cpp2
-rw-r--r--util/system/guard.h32
-rw-r--r--util/system/hostname.cpp12
-rw-r--r--util/system/hostname.h6
-rw-r--r--util/system/info.cpp2
-rw-r--r--util/system/info.h2
-rw-r--r--util/system/madvise.cpp2
-rw-r--r--util/system/mem_info.cpp6
-rw-r--r--util/system/mutex.cpp12
-rw-r--r--util/system/mutex.h14
-rw-r--r--util/system/pipe.cpp12
-rw-r--r--util/system/pipe.h26
-rw-r--r--util/system/progname.cpp4
-rw-r--r--util/system/progname.h4
-rw-r--r--util/system/progname_ut.cpp4
-rw-r--r--util/system/protect.cpp4
-rw-r--r--util/system/rwlock.cpp78
-rw-r--r--util/system/rwlock.h28
-rw-r--r--util/system/sem.cpp36
-rw-r--r--util/system/sem.h16
-rw-r--r--util/system/shellcommand.cpp88
-rw-r--r--util/system/shellcommand.h30
-rw-r--r--util/system/shellcommand_ut.cpp22
-rw-r--r--util/system/spin_wait.cpp2
-rw-r--r--util/system/spinlock.h16
-rw-r--r--util/system/src_location.cpp2
-rw-r--r--util/system/src_location_ut.cpp2
-rw-r--r--util/system/src_root_ut.cpp2
-rw-r--r--util/system/tempfile.cpp2
-rw-r--r--util/system/tempfile.h12
-rw-r--r--util/system/tempfile_ut.cpp4
-rw-r--r--util/system/thread.cpp22
-rw-r--r--util/system/thread.h18
-rw-r--r--util/system/thread.i6
-rw-r--r--util/system/tls.cpp20
-rw-r--r--util/system/tls.h12
-rw-r--r--util/system/tls_ut.cpp2
-rw-r--r--util/system/type_name.h2
-rw-r--r--util/system/user.cpp6
-rw-r--r--util/system/user.h2
-rw-r--r--util/system/ut/ya.make4
-rw-r--r--util/system/yassert.cpp8
-rw-r--r--util/system/yield.cpp4
-rw-r--r--util/system/yield.h4
-rw-r--r--util/tests/cython/test_generic.py2
-rw-r--r--util/tests/cython/ya.make6
-rw-r--r--util/thread/factory.cpp4
-rw-r--r--util/thread/factory.h4
-rw-r--r--util/thread/lfqueue.h2
-rw-r--r--util/thread/lfqueue_ut.cpp2
-rw-r--r--util/thread/lfstack.h2
-rw-r--r--util/thread/lfstack_ut.cpp16
-rw-r--r--util/thread/pool.cpp42
-rw-r--r--util/thread/pool.h26
-rw-r--r--util/thread/pool_ut.cpp4
-rw-r--r--util/ya.make6
-rw-r--r--util/ysafeptr.h6
-rw-r--r--util/ysaveload.h90
-rw-r--r--util/ysaveload_ut.cpp50
378 files changed, 4946 insertions, 4946 deletions
diff --git a/util/charset/benchmark/utf8_to_wide/main.cpp b/util/charset/benchmark/utf8_to_wide/main.cpp
index da4782c3bd..09fa567fe5 100644
--- a/util/charset/benchmark/utf8_to_wide/main.cpp
+++ b/util/charset/benchmark/utf8_to_wide/main.cpp
@@ -10,7 +10,7 @@
namespace {
template <size_t N>
- struct TRandomAsciiString: public TVector<char> {
+ struct TRandomAsciiString: public TVector<char> {
inline TRandomAsciiString() {
reserve(N);
for (size_t i = 0; i < N; ++i) {
@@ -20,9 +20,9 @@ namespace {
};
template <size_t N>
- struct TRandomRuString: public TVector<char> {
+ struct TRandomRuString: public TVector<char> {
inline TRandomRuString() {
- TVector<unsigned char> data(N * 2);
+ TVector<unsigned char> data(N * 2);
unsigned char* textEnd = data.begin();
for (size_t i = 0; i < N; ++i) {
size_t runeLen;
diff --git a/util/charset/utf8.cpp b/util/charset/utf8.cpp
index 33eb298185..efe3a52f61 100644
--- a/util/charset/utf8.cpp
+++ b/util/charset/utf8.cpp
@@ -129,23 +129,23 @@ EUTF8Detect UTF8Detect(const char* s, size_t len) {
return res;
}
-bool ToLowerUTF8Impl(const char* beg, size_t n, TString& newString) {
+bool ToLowerUTF8Impl(const char* beg, size_t n, TString& newString) {
return ConvertCaseUTF8Impl(ECaseConversion::ToLower, beg, n, newString);
}
-TString ToLowerUTF8(const TString& s) {
- TString newString;
+TString ToLowerUTF8(const TString& s) {
+ TString newString;
bool changed = ToLowerUTF8Impl(s.data(), s.size(), newString);
return changed ? newString : s;
}
-TString ToLowerUTF8(TStringBuf s) {
- TString newString;
+TString ToLowerUTF8(TStringBuf s) {
+ TString newString;
bool changed = ToLowerUTF8Impl(s.data(), s.size(), newString);
return changed ? newString : TString(s.data(), s.size());
}
-TString ToLowerUTF8(const char* s) {
+TString ToLowerUTF8(const char* s) {
return ToLowerUTF8(TStringBuf(s));
}
diff --git a/util/charset/utf8.h b/util/charset/utf8.h
index 1997f73771..5039b46ae9 100644
--- a/util/charset/utf8.h
+++ b/util/charset/utf8.h
@@ -3,7 +3,7 @@
#include "recode_result.h"
#include <util/generic/strbuf.h>
-#include <util/generic/string.h>
+#include <util/generic/string.h>
#include <util/generic/yexception.h>
#include <util/system/defaults.h>
#include <util/system/yassert.h>
@@ -134,7 +134,7 @@ inline bool GetNumberOfUTF8Chars(const char* text, size_t len, size_t& number) {
inline size_t GetNumberOfUTF8Chars(TStringBuf text) {
size_t number;
if (!GetNumberOfUTF8Chars(text.data(), text.size(), number)) {
- ythrow yexception() << "GetNumberOfUTF8Chars failed on invalid utf-8 " << TString(text.substr(0, 50)).Quote();
+ ythrow yexception() << "GetNumberOfUTF8Chars failed on invalid utf-8 " << TString(text.substr(0, 50)).Quote();
}
return number;
}
@@ -369,11 +369,11 @@ inline bool IsUtf(const TStringBuf input) {
//! returns true, if result is not the same as input, and put it in newString
//! returns false, if result is unmodified
-bool ToLowerUTF8Impl(const char* beg, size_t n, TString& newString);
+bool ToLowerUTF8Impl(const char* beg, size_t n, TString& newString);
-TString ToLowerUTF8(const TString& s);
-TString ToLowerUTF8(TStringBuf s);
-TString ToLowerUTF8(const char* s);
+TString ToLowerUTF8(const TString& s);
+TString ToLowerUTF8(TStringBuf s);
+TString ToLowerUTF8(const char* s);
inline TString ToLowerUTF8(const std::string& s) {
return ToLowerUTF8(TStringBuf(s));
diff --git a/util/charset/utf8_ut.cpp b/util/charset/utf8_ut.cpp
index fc379ff694..9e68881cca 100644
--- a/util/charset/utf8_ut.cpp
+++ b/util/charset/utf8_ut.cpp
@@ -17,37 +17,37 @@ Y_UNIT_TEST_SUITE(TUtfUtilTest) {
UNIT_ASSERT_VALUES_EQUAL(ToLowerUTF8(TStringBuf("xyz")), "xyz");
- {
- TString s = "привет!";
- TString q = "ПРИВЕТ!";
- TString tmp;
+ {
+ TString s = "привет!";
+ TString q = "ПРИВЕТ!";
+ TString tmp;
UNIT_ASSERT(ToLowerUTF8Impl(s.data(), s.size(), tmp) == false);
UNIT_ASSERT(ToLowerUTF8Impl(q.data(), q.size(), tmp) == true);
- }
-
- {
- const char* weird = "\xC8\xBE"; // 'Ⱦ', U+023E. strlen(weird)==2, strlen(tolower_utf8(weird)) is 3
- const char* turkI = "İ"; //strlen("İ") == 2, strlen(tolower_utf8("İ") == 1
- TStringBuf chars[] = {"f", "F", "Б", "б", weird, turkI};
- const int N = Y_ARRAY_SIZE(chars);
- //try all combinations of these letters.
- int numberOfVariants = 1;
- for (int len = 0; len <= 4; ++len) {
- for (int i = 0; i < numberOfVariants; ++i) {
- TString s;
- int k = i;
- for (int j = 0; j < len; ++j) {
- //Treat 'i' like number in base-N system with digits from 'chars'-array
- s += chars[k % N];
- k /= N;
- }
-
- TUtf16String tmp = UTF8ToWide(s);
- tmp.to_lower();
-
- UNIT_ASSERT_VALUES_EQUAL(ToLowerUTF8(s), WideToUTF8(tmp));
- }
- numberOfVariants *= N;
+ }
+
+ {
+ const char* weird = "\xC8\xBE"; // 'Ⱦ', U+023E. strlen(weird)==2, strlen(tolower_utf8(weird)) is 3
+ const char* turkI = "İ"; //strlen("İ") == 2, strlen(tolower_utf8("İ") == 1
+ TStringBuf chars[] = {"f", "F", "Б", "б", weird, turkI};
+ const int N = Y_ARRAY_SIZE(chars);
+ //try all combinations of these letters.
+ int numberOfVariants = 1;
+ for (int len = 0; len <= 4; ++len) {
+ for (int i = 0; i < numberOfVariants; ++i) {
+ TString s;
+ int k = i;
+ for (int j = 0; j < len; ++j) {
+ //Treat 'i' like number in base-N system with digits from 'chars'-array
+ s += chars[k % N];
+ k /= N;
+ }
+
+ TUtf16String tmp = UTF8ToWide(s);
+ tmp.to_lower();
+
+ UNIT_ASSERT_VALUES_EQUAL(ToLowerUTF8(s), WideToUTF8(tmp));
+ }
+ numberOfVariants *= N;
}
}
}
@@ -95,12 +95,12 @@ Y_UNIT_TEST_SUITE(TUtfUtilTest) {
Y_UNIT_TEST(TestUTF8ToWide) {
TFileInput in(ArcadiaSourceRoot() + TStringBuf("/util/charset/ut/utf8/test1.txt"));
- TString text = in.ReadAll();
+ TString text = in.ReadAll();
UNIT_ASSERT(WideToUTF8(UTF8ToWide(text)) == text);
}
Y_UNIT_TEST(TestInvalidUTF8) {
- TVector<TString> testData;
+ TVector<TString> testData;
TFileInput input(ArcadiaSourceRoot() + TStringBuf("/util/charset/ut/utf8/invalid_UTF8.bin"));
Load(&input, testData);
@@ -112,9 +112,9 @@ Y_UNIT_TEST_SUITE(TUtfUtilTest) {
Y_UNIT_TEST(TestUTF8ToWideScalar) {
TFileInput in(ArcadiaSourceRoot() + TStringBuf("/util/charset/ut/utf8/test1.txt"));
- TString text = in.ReadAll();
- TUtf16String wtextSSE = UTF8ToWide(text);
- TUtf16String wtextScalar = TUtf16String::Uninitialized(text.size());
+ TString text = in.ReadAll();
+ TUtf16String wtextSSE = UTF8ToWide(text);
+ TUtf16String wtextScalar = TUtf16String::Uninitialized(text.size());
const unsigned char* textBegin = reinterpret_cast<const unsigned char*>(text.c_str());
wchar16* wtextBegin = wtextScalar.begin();
::NDetail::UTF8ToWideImplScalar<false>(textBegin, textBegin + text.size(), wtextBegin);
diff --git a/util/charset/wide.cpp b/util/charset/wide.cpp
index 49badb7f14..a287438ddd 100644
--- a/util/charset/wide.cpp
+++ b/util/charset/wide.cpp
@@ -31,7 +31,7 @@ namespace {
}
}
-void Collapse(TUtf16String& w) {
+void Collapse(TUtf16String& w) {
CollapseImpl(w, w, 0, IsWhitespace);
}
@@ -532,20 +532,20 @@ static TUtf32String ToSmthRet(const TUtf32StringBuf text, size_t pos, size_t cou
}
TUtf16String ToLowerRet(const TWtringBuf text, size_t pos, size_t count) {
- return ToSmthRet(text, pos, count, [](const wchar16* theText, size_t length, wchar16* out) {
- ToLower(theText, length, out);
+ return ToSmthRet(text, pos, count, [](const wchar16* theText, size_t length, wchar16* out) {
+ ToLower(theText, length, out);
});
}
TUtf16String ToUpperRet(const TWtringBuf text, size_t pos, size_t count) {
- return ToSmthRet(text, pos, count, [](const wchar16* theText, size_t length, wchar16* out) {
- ToUpper(theText, length, out);
+ return ToSmthRet(text, pos, count, [](const wchar16* theText, size_t length, wchar16* out) {
+ ToUpper(theText, length, out);
});
}
TUtf16String ToTitleRet(const TWtringBuf text, size_t pos, size_t count) {
- return ToSmthRet(text, pos, count, [](const wchar16* theText, size_t length, wchar16* out) {
- ToTitle(theText, length, out);
+ return ToSmthRet(text, pos, count, [](const wchar16* theText, size_t length, wchar16* out) {
+ ToTitle(theText, length, out);
});
}
@@ -568,16 +568,16 @@ TUtf32String ToTitleRet(const TUtf32StringBuf text, size_t pos, size_t count) {
}
template <bool insertBr>
-void EscapeHtmlChars(TUtf16String& str) {
- static const TUtf16String lt(LT, Y_ARRAY_SIZE(LT));
- static const TUtf16String gt(GT, Y_ARRAY_SIZE(GT));
- static const TUtf16String amp(AMP, Y_ARRAY_SIZE(AMP));
- static const TUtf16String br(BR, Y_ARRAY_SIZE(BR));
- static const TUtf16String quot(QUOT, Y_ARRAY_SIZE(QUOT));
+void EscapeHtmlChars(TUtf16String& str) {
+ static const TUtf16String lt(LT, Y_ARRAY_SIZE(LT));
+ static const TUtf16String gt(GT, Y_ARRAY_SIZE(GT));
+ static const TUtf16String amp(AMP, Y_ARRAY_SIZE(AMP));
+ static const TUtf16String br(BR, Y_ARRAY_SIZE(BR));
+ static const TUtf16String quot(QUOT, Y_ARRAY_SIZE(QUOT));
size_t escapedLen = 0;
- const TUtf16String& cs = str;
+ const TUtf16String& cs = str;
for (size_t i = 0; i < cs.size(); ++i)
escapedLen += EscapedLen<insertBr>(cs[i]);
@@ -585,13 +585,13 @@ void EscapeHtmlChars(TUtf16String& str) {
if (escapedLen == cs.size())
return;
- TUtf16String res;
+ TUtf16String res;
res.reserve(escapedLen);
size_t start = 0;
for (size_t i = 0; i < cs.size(); ++i) {
- const TUtf16String* ent = nullptr;
+ const TUtf16String* ent = nullptr;
switch (cs[i]) {
case '<':
ent = &lt;
@@ -622,5 +622,5 @@ void EscapeHtmlChars(TUtf16String& str) {
res.swap(str);
}
-template void EscapeHtmlChars<false>(TUtf16String& str);
-template void EscapeHtmlChars<true>(TUtf16String& str);
+template void EscapeHtmlChars<false>(TUtf16String& str);
+template void EscapeHtmlChars<true>(TUtf16String& str);
diff --git a/util/charset/wide.h b/util/charset/wide.h
index 22f922df5a..04e6928aab 100644
--- a/util/charset/wide.h
+++ b/util/charset/wide.h
@@ -6,7 +6,7 @@
#include "wide_specific.h"
#include <util/generic/algorithm.h>
-#include <util/generic/string.h>
+#include <util/generic/string.h>
#include <util/generic/yexception.h>
#include <util/memory/tempbuf.h>
#include <util/system/compiler.h>
@@ -24,8 +24,8 @@ class TTempArray;
using TCharTemp = TTempArray<wchar16>;
namespace NDetail {
- inline TString InStringMsg(const char* s, size_t len) {
- return (len <= 50) ? " in string " + TString(s, len).Quote() : TString();
+ inline TString InStringMsg(const char* s, size_t len) {
+ return (len <= 50) ? " in string " + TString(s, len).Quote() : TString();
}
template <bool isPointer>
@@ -321,8 +321,8 @@ inline size_t UTF8ToWideImpl(const char* text, size_t len, TCharType* dest, size
}
template <bool robust>
-inline TUtf16String UTF8ToWide(const char* text, size_t len) {
- TUtf16String w = TUtf16String::Uninitialized(len);
+inline TUtf16String UTF8ToWide(const char* text, size_t len) {
+ TUtf16String w = TUtf16String::Uninitialized(len);
size_t written;
size_t pos = UTF8ToWideImpl<robust>(text, len, w.begin(), written);
if (pos != len)
@@ -347,7 +347,7 @@ inline bool UTF8ToWide(const char* text, size_t len, TCharType* dest, size_t& wr
}
template <bool robust>
-inline TWtringBuf UTF8ToWide(const TStringBuf src, TUtf16String& dst) {
+inline TWtringBuf UTF8ToWide(const TStringBuf src, TUtf16String& dst) {
dst.ReserveAndResize(src.size());
size_t written = 0;
UTF8ToWideImpl<robust>(src.data(), src.size(), dst.begin(), written);
@@ -365,16 +365,16 @@ inline TUtf32StringBuf UTF8ToUTF32(const TStringBuf src, TUtf32String& dst) {
return dst;
}
-inline TWtringBuf UTF8ToWide(const TStringBuf src, TUtf16String& dst) {
+inline TWtringBuf UTF8ToWide(const TStringBuf src, TUtf16String& dst) {
return UTF8ToWide<false>(src, dst);
}
-inline TUtf16String UTF8ToWide(const char* text, size_t len) {
+inline TUtf16String UTF8ToWide(const char* text, size_t len) {
return UTF8ToWide<false>(text, len);
}
template <bool robust>
-inline TUtf16String UTF8ToWide(const TStringBuf s) {
+inline TUtf16String UTF8ToWide(const TStringBuf s) {
return UTF8ToWide<robust>(s.data(), s.size());
}
@@ -385,7 +385,7 @@ inline TUtf32String UTF8ToUTF32(const TStringBuf s) {
return r;
}
-inline TUtf16String UTF8ToWide(const TStringBuf s) {
+inline TUtf16String UTF8ToWide(const TStringBuf s) {
return UTF8ToWide<false>(s.data(), s.size());
}
@@ -410,7 +410,7 @@ constexpr size_t WideToUTF8BufferSize(const size_t inputStringSize) noexcept {
return inputStringSize * 4; // * 4 because the conversion functions can convert unicode character into maximum 4 bytes of UTF8
}
-inline TStringBuf WideToUTF8(const TWtringBuf src, TString& dst) {
+inline TStringBuf WideToUTF8(const TWtringBuf src, TString& dst) {
dst.ReserveAndResize(WideToUTF8BufferSize(src.size()));
size_t written = 0;
WideToUTF8(src.data(), src.size(), dst.begin(), written);
@@ -419,8 +419,8 @@ inline TStringBuf WideToUTF8(const TWtringBuf src, TString& dst) {
return dst;
}
-inline TString WideToUTF8(const wchar16* text, size_t len) {
- TString s = TString::Uninitialized(WideToUTF8BufferSize(len));
+inline TString WideToUTF8(const wchar16* text, size_t len) {
+ TString s = TString::Uninitialized(WideToUTF8BufferSize(len));
size_t written = 0;
WideToUTF8(text, len, s.begin(), written);
Y_ASSERT(s.size() >= written);
@@ -437,7 +437,7 @@ inline TString WideToUTF8(const wchar32* text, size_t len) {
return s;
}
-inline TString WideToUTF8(const TWtringBuf w) {
+inline TString WideToUTF8(const TWtringBuf w) {
return WideToUTF8(w.data(), w.size());
}
@@ -445,8 +445,8 @@ inline TString WideToUTF8(const TUtf32StringBuf w) {
return WideToUTF8(w.data(), w.size());
}
-inline TUtf16String UTF32ToWide(const wchar32* begin, size_t len) {
- TUtf16String res;
+inline TUtf16String UTF32ToWide(const wchar32* begin, size_t len) {
+ TUtf16String res;
res.reserve(len);
const wchar32* end = begin + len;
@@ -628,29 +628,29 @@ inline void Copy(const TChar1* first, size_t len, TChar2* result) {
//! template <typename InputIterator>
//! basic_string(InputIterator begin, InputIterator end, const Allocator& a = Allocator());
//! and the family of template member functions: append, assign, insert, replace.
-template <typename TStringType, typename TChar>
-inline TStringType CopyTo(const TChar* first, const TChar* last) {
+template <typename TStringType, typename TChar>
+inline TStringType CopyTo(const TChar* first, const TChar* last) {
Y_ASSERT(first <= last);
- TStringType str = TStringType::Uninitialized(last - first);
+ TStringType str = TStringType::Uninitialized(last - first);
Copy(first, last, str.begin());
return str;
}
-template <typename TStringType, typename TChar>
-inline TStringType CopyTo(const TChar* s, size_t n) {
- TStringType str = TStringType::Uninitialized(n);
+template <typename TStringType, typename TChar>
+inline TStringType CopyTo(const TChar* s, size_t n) {
+ TStringType str = TStringType::Uninitialized(n);
Copy(s, n, str.begin());
return str;
}
-inline TString WideToASCII(const TWtringBuf w) {
+inline TString WideToASCII(const TWtringBuf w) {
Y_ASSERT(IsStringASCII(w.begin(), w.end()));
- return CopyTo<TString>(w.begin(), w.end());
+ return CopyTo<TString>(w.begin(), w.end());
}
-inline TUtf16String ASCIIToWide(const TStringBuf s) {
+inline TUtf16String ASCIIToWide(const TStringBuf s) {
Y_ASSERT(IsStringASCII(s.begin(), s.end()));
- return CopyTo<TUtf16String>(s.begin(), s.end());
+ return CopyTo<TUtf16String>(s.begin(), s.end());
}
inline TUtf32String ASCIIToUTF32(const TStringBuf s) {
@@ -679,7 +679,7 @@ inline bool IsSpace(const TWtringBuf s) {
}
//! replaces multiple sequential whitespace characters with a single space character
-void Collapse(TUtf16String& w);
+void Collapse(TUtf16String& w);
//! @return new length
size_t Collapse(wchar16* s, size_t n);
@@ -810,7 +810,7 @@ TUtf32String ToTitleRet(const TUtf32StringBuf text, size_t pos = 0, size_t count
//! replaces the '<', '>' and '&' characters in string with '&lt;', '&gt;' and '&amp;' respectively
// insertBr=true - replace '\r' and '\n' with "<BR>"
template <bool insertBr>
-void EscapeHtmlChars(TUtf16String& str);
+void EscapeHtmlChars(TUtf16String& str);
//! returns number of characters in range. Handle surrogate pairs as one character.
inline size_t CountWideChars(const wchar16* b, const wchar16* e) {
diff --git a/util/charset/wide_ut.cpp b/util/charset/wide_ut.cpp
index 9eecf20ae0..d8f3233e73 100644
--- a/util/charset/wide_ut.cpp
+++ b/util/charset/wide_ut.cpp
@@ -53,7 +53,7 @@ namespace {
{0x01C5, 0x10428, 0x10429, 0x10447, 0x10441, 0x1C03, 0x00A0, 0x10428, 0x1043D, 0x10437}, // title
};
- TUtf16String CreateUnicodeText() {
+ TUtf16String CreateUnicodeText() {
const int len = 256;
wchar16 text[len] = {
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x00 - 0x0F
@@ -77,10 +77,10 @@ namespace {
text[i] = static_cast<wchar16>(i + 0x0350); // 0x0410 - 0x044F
}
}
- return TUtf16String(text, len);
+ return TUtf16String(text, len);
}
- TString CreateUTF8Text() {
+ TString CreateUTF8Text() {
char text[] = {
'\x00', '\x01', '\x02', '\x03', '\x04', '\x05', '\x06', '\x07', '\x08', '\x09', '\x0a', '\x0b', '\x0c', '\x0d', '\x0e', '\x0f',
'\x10', '\x11', '\x12', '\x13', '\x14', '\x15', '\x16', '\x17', '\x18', '\x19', '\x1a', '\x1b', '\x1c', '\x1d', '\x1e', '\x1f',
@@ -107,12 +107,12 @@ namespace {
'\xd0', '\xbf', '\xd1', '\x80', '\xd1', '\x81', '\xd1', '\x82', '\xd1', '\x83', '\xd1', '\x84', '\xd1', '\x85', '\xd1', '\x86',
'\xd1', '\x87', '\xd1', '\x88', '\xd1', '\x89', '\xd1', '\x8a', '\xd1', '\x8b', '\xd1', '\x8c', '\xd1', '\x8d', '\xd1', '\x8e',
'\xd1', '\x8f'};
- return TString(text, Y_ARRAY_SIZE(text));
+ return TString(text, Y_ARRAY_SIZE(text));
}
//! use this function to dump UTF8 text into a file in case of any changes
// void DumpUTF8Text() {
- // TString s = WideToUTF8(UnicodeText);
+ // TString s = WideToUTF8(UnicodeText);
// std::ofstream f("utf8.txt");
// f << std::hex;
// for (int i = 0; i < (int)s.size(); ++i) {
@@ -455,12 +455,12 @@ void TConversionTest::TestWriteUTF8Char() {
}
static void TestSurrogates(const char* str, const wchar16* wide, size_t wideSize) {
- TUtf16String w = UTF8ToWide(str);
+ TUtf16String w = UTF8ToWide(str);
UNIT_ASSERT(w.size() == wideSize);
UNIT_ASSERT(!memcmp(w.c_str(), wide, wideSize));
- TString s = WideToUTF8(w);
+ TString s = WideToUTF8(w);
UNIT_ASSERT(s == str);
}
@@ -511,7 +511,7 @@ void TConversionTest::TestUTF8ToWide() {
UNIT_ASSERT_VALUES_EQUAL(WideToUTF8(UTF8ToWide(WideToUTF8(UTF8ToWide<true>(
"m\xFB\xB2\xA5\xAA\xAFyeuse.sexwebcamz.com")))),
- TString(
+ TString(
"m\xEF\xBF\xBD\xEF\xBF\xBD\xEF\xBF\xBD\xEF\xBF\xBD\xEF\xBF\xBDyeuse.sexwebcamz.com"));
}
@@ -571,7 +571,7 @@ void TConversionTest::TestUnicodeCase() {
}
void TConversionTest::TestUnicodeDetails() {
- TUtf16String temp;
+ TUtf16String temp;
for (wchar32 i = 0; i != NUnicode::UnicodeInstancesLimit(); ++i) {
temp.clear();
WriteSymbol(i, temp);
@@ -604,12 +604,12 @@ class TWideUtilTest: public TTestBase {
public:
void TestCollapse() {
- TUtf16String s;
+ TUtf16String s;
s.append(ws, Y_ARRAY_SIZE(ws)).append(3, 'a').append(ws, Y_ARRAY_SIZE(ws)).append(3, 'b').append(ws, Y_ARRAY_SIZE(ws));
Collapse(s);
UNIT_ASSERT(s == ASCIIToWide(" aaa bbb "));
{
- const TUtf16String w(ASCIIToWide(" a b c "));
+ const TUtf16String w(ASCIIToWide(" a b c "));
s = w;
Collapse(s);
UNIT_ASSERT(s == w);
@@ -637,7 +637,7 @@ public:
Collapse(s);
UNIT_ASSERT(s == ASCIIToWide("1 23 "));
{
- const TUtf16String w = ASCIIToWide(" ");
+ const TUtf16String w = ASCIIToWide(" ");
s = w;
Collapse(s);
UNIT_ASSERT(s == w);
@@ -659,11 +659,11 @@ public:
s.clear();
Collapse(s);
- UNIT_ASSERT(s == TUtf16String());
+ UNIT_ASSERT(s == TUtf16String());
}
void TestCollapseBuffer() {
- TUtf16String s;
+ TUtf16String s;
s.append(ws, Y_ARRAY_SIZE(ws)).append(3, 'a').append(ws, Y_ARRAY_SIZE(ws)).append(3, 'b').append(ws, Y_ARRAY_SIZE(ws));
size_t n = Collapse(s.begin(), s.size());
s.resize(n);
@@ -727,14 +727,14 @@ public:
s.clear();
n = Collapse(s.begin(), s.size());
UNIT_ASSERT(n == 0);
- UNIT_ASSERT(s == TUtf16String());
+ UNIT_ASSERT(s == TUtf16String());
}
void TestStrip() {
- TUtf16String s;
+ TUtf16String s;
Strip(s);
- UNIT_ASSERT(s == TUtf16String());
+ UNIT_ASSERT(s == TUtf16String());
StripLeft(s);
UNIT_ASSERT(s == TUtf16String());
StripRight(s);
@@ -742,7 +742,7 @@ public:
s = ASCIIToWide(" \t\r\n");
Strip(s);
- UNIT_ASSERT(s == TUtf16String());
+ UNIT_ASSERT(s == TUtf16String());
s = ASCIIToWide(" \t\r\n");
StripLeft(s);
UNIT_ASSERT(s == TUtf16String());
@@ -770,7 +770,7 @@ public:
StripRight(s);
UNIT_ASSERT(s == ASCIIToWide("\r\na\r\nb\t\tc"));
- const TUtf16String w(ASCIIToWide("a b"));
+ const TUtf16String w(ASCIIToWide("a b"));
s = w;
Strip(s);
UNIT_ASSERT(s == w);
@@ -792,25 +792,25 @@ public:
}
void TestIsSpace() {
- UNIT_ASSERT(!IsSpace(TUtf16String()));
+ UNIT_ASSERT(!IsSpace(TUtf16String()));
UNIT_ASSERT(IsSpace(ws, Y_ARRAY_SIZE(ws)));
- TUtf16String w;
- w.assign(ws, Y_ARRAY_SIZE(ws)).append(TUtf16String(1, '!'));
+ TUtf16String w;
+ w.assign(ws, Y_ARRAY_SIZE(ws)).append(TUtf16String(1, '!'));
UNIT_ASSERT(!IsSpace(w.c_str(), w.size()));
- w.assign(TUtf16String(1, '_')).append(ws, Y_ARRAY_SIZE(ws));
+ w.assign(TUtf16String(1, '_')).append(ws, Y_ARRAY_SIZE(ws));
UNIT_ASSERT(!IsSpace(w.c_str(), w.size()));
- w.assign(ws, Y_ARRAY_SIZE(ws)).append(TUtf16String(1, '$')).append(ws, Y_ARRAY_SIZE(ws));
+ w.assign(ws, Y_ARRAY_SIZE(ws)).append(TUtf16String(1, '$')).append(ws, Y_ARRAY_SIZE(ws));
UNIT_ASSERT(!IsSpace(w.c_str(), w.size()));
}
void TestEscapeHtmlChars() {
// characters from the first half of the ASCII table
for (wchar16 c = 1; c < 0x7F; ++c) {
- TUtf16String w(1, c);
+ TUtf16String w(1, c);
EscapeHtmlChars<false>(w);
switch (c) {
@@ -827,13 +827,13 @@ public:
UNIT_ASSERT(w == ASCIIToWide("&quot;"));
break;
default:
- UNIT_ASSERT(w == TUtf16String(1, c));
+ UNIT_ASSERT(w == TUtf16String(1, c));
break;
}
}
for (wchar16 c = 1; c < 0x7F; ++c) {
- TUtf16String w(1, c);
+ TUtf16String w(1, c);
EscapeHtmlChars<true>(w);
switch (c) {
@@ -854,7 +854,7 @@ public:
UNIT_ASSERT(w == ASCIIToWide("<BR>"));
break;
default:
- UNIT_ASSERT(w == TUtf16String(1, c));
+ UNIT_ASSERT(w == TUtf16String(1, c));
break;
}
}
@@ -877,11 +877,11 @@ public:
}
void TestWideString() {
- const TUtf16String original = UTF32ToWide(WideStringTestData[0], CaseTestDataSize);
- const TUtf16String lower = UTF32ToWide(WideStringTestData[1], CaseTestDataSize);
- const TUtf16String upper = UTF32ToWide(WideStringTestData[2], CaseTestDataSize);
- const TUtf16String title = UTF32ToWide(WideStringTestData[3], CaseTestDataSize);
- TUtf16String temp;
+ const TUtf16String original = UTF32ToWide(WideStringTestData[0], CaseTestDataSize);
+ const TUtf16String lower = UTF32ToWide(WideStringTestData[1], CaseTestDataSize);
+ const TUtf16String upper = UTF32ToWide(WideStringTestData[2], CaseTestDataSize);
+ const TUtf16String title = UTF32ToWide(WideStringTestData[3], CaseTestDataSize);
+ TUtf16String temp;
temp = original;
temp.to_lower();
@@ -907,7 +907,7 @@ public:
ToTitle(temp.begin(), temp.size());
UNIT_ASSERT(temp == title);
- TVector<wchar32> buffer(WideStringTestData[0], WideStringTestData[0] + CaseTestDataSize);
+ TVector<wchar32> buffer(WideStringTestData[0], WideStringTestData[0] + CaseTestDataSize);
std::reverse(buffer.begin(), buffer.end());
const TUtf16String reversed = UTF32ToWide(buffer.data(), buffer.size());
@@ -918,7 +918,7 @@ public:
void TestCountWideChars() {
UNIT_ASSERT_EQUAL(CountWideChars(UTF8ToWide("привет!")), 7);
- TUtf16String wideStr = UTF8ToWide("\xf0\x9f\x92\xb8привет!");
+ TUtf16String wideStr = UTF8ToWide("\xf0\x9f\x92\xb8привет!");
UNIT_ASSERT_EQUAL(wideStr.size(), 9);
UNIT_ASSERT_EQUAL(CountWideChars(wideStr), 8);
}
diff --git a/util/datetime/base.cpp b/util/datetime/base.cpp
index f0df9b1b40..38ecc3ab96 100644
--- a/util/datetime/base.cpp
+++ b/util/datetime/base.cpp
@@ -5,17 +5,17 @@
#include <util/stream/mem.h>
#include <util/system/compat.h>
#include <util/memory/tempbuf.h>
-#include <util/generic/string.h>
+#include <util/generic/string.h>
#include <util/generic/strbuf.h>
#include <util/generic/yexception.h>
-TString Strftime(const char* format, const struct tm* tm) {
+TString Strftime(const char* format, const struct tm* tm) {
size_t size = Max<size_t>(strlen(format) * 2 + 1, 107);
for (;;) {
TTempBuf buf(size);
int r = strftime(buf.Data(), buf.Size(), format, tm);
if (r != 0) {
- return TString(buf.Data(), r);
+ return TString(buf.Data(), r);
}
size *= 2;
}
@@ -173,11 +173,11 @@ void Out<::NPrivate::TPrintableLocalTime<true, true>>(IOutputStream& os, TTypeTr
WritePrintableLocalTimeToStream(os, localTime);
}
-TString TDuration::ToString() const {
+TString TDuration::ToString() const {
return ::ToString(*this);
}
-TString TInstant::ToString() const {
+TString TInstant::ToString() const {
return ::ToString(*this);
}
@@ -185,20 +185,20 @@ TString TInstant::ToRfc822String() const {
return FormatGmTime("%a, %d %b %Y %H:%M:%S GMT");
}
-TString TInstant::ToStringUpToSeconds() const {
+TString TInstant::ToStringUpToSeconds() const {
char buf[64];
auto len = FormatDate8601(buf, sizeof(buf), TimeT());
if (!len) {
ythrow yexception() << "TInstant::ToStringUpToSeconds: year does not fit into an integer";
}
- return TString(buf, len);
+ return TString(buf, len);
}
TString TInstant::ToIsoStringLocal() const {
return ::ToString(FormatIsoLocal(*this));
}
-TString TInstant::ToStringLocal() const {
+TString TInstant::ToStringLocal() const {
return ::ToString(FormatLocal(*this));
}
@@ -210,7 +210,7 @@ TString TInstant::ToIsoStringLocalUpToSeconds() const {
return ::ToString(FormatIsoLocalUpToSeconds(*this));
}
-TString TInstant::ToStringLocalUpToSeconds() const {
+TString TInstant::ToStringLocalUpToSeconds() const {
return ::ToString(FormatLocalUpToSeconds(*this));
}
diff --git a/util/datetime/base.h b/util/datetime/base.h
index b64b9de711..5e902b8f63 100644
--- a/util/datetime/base.h
+++ b/util/datetime/base.h
@@ -5,7 +5,7 @@
#include <util/str_stl.h>
#include <util/system/platform.h>
#include <util/system/datetime.h>
-#include <util/generic/string.h>
+#include <util/generic/string.h>
#include <util/generic/strbuf.h>
#include <util/generic/ylimits.h>
#include <util/generic/utility.h>
@@ -36,7 +36,7 @@ class TInstant;
class TDuration;
/// Current time
-static inline TInstant Now() noexcept;
+static inline TInstant Now() noexcept;
/// Use Now() method to obtain current time instead of *Seconds() unless you understand what are you doing.
@@ -82,7 +82,7 @@ constexpr long TVdiff(timeval r1, timeval r2) {
return (1000000 * (r2.tv_sec - r1.tv_sec) + (r2.tv_usec - r1.tv_usec));
}
-TString Strftime(const char* format, const struct tm* tm);
+TString Strftime(const char* format, const struct tm* tm);
// Use functions below instead of sprint_date (check IGNIETFERRO-892 for details)
void DateToString(char* buf, const struct tm& theTm);
@@ -98,28 +98,28 @@ class TTimeBase {
public:
using TValue = ui64;
-protected:
- constexpr TTimeBase(const TValue& value) noexcept
+protected:
+ constexpr TTimeBase(const TValue& value) noexcept
: Value_(value)
{
}
-public:
- constexpr TTimeBase() noexcept
- : Value_(0)
- {
- }
-
- constexpr TTimeBase(const struct timeval& tv) noexcept
+public:
+ constexpr TTimeBase() noexcept
+ : Value_(0)
+ {
+ }
+
+ constexpr TTimeBase(const struct timeval& tv) noexcept
: Value_(tv.tv_sec * (ui64)1000000 + tv.tv_usec)
{
}
- constexpr TValue GetValue() const noexcept {
+ constexpr TValue GetValue() const noexcept {
return Value_;
}
- constexpr double SecondsFloat() const noexcept {
+ constexpr double SecondsFloat() const noexcept {
return Value_ * (1 / 1000000.0);
}
@@ -127,43 +127,43 @@ public:
return Value_ * (1 / 1000.0);
}
- constexpr TValue MicroSeconds() const noexcept {
+ constexpr TValue MicroSeconds() const noexcept {
return Value_;
}
- constexpr TValue MilliSeconds() const noexcept {
+ constexpr TValue MilliSeconds() const noexcept {
return MicroSeconds() / 1000;
}
- constexpr TValue Seconds() const noexcept {
+ constexpr TValue Seconds() const noexcept {
return MilliSeconds() / 1000;
}
- constexpr TValue Minutes() const noexcept {
+ constexpr TValue Minutes() const noexcept {
return Seconds() / 60;
}
- constexpr TValue Hours() const noexcept {
+ constexpr TValue Hours() const noexcept {
return Minutes() / 60;
}
- constexpr TValue Days() const noexcept {
+ constexpr TValue Days() const noexcept {
return Hours() / 24;
}
- constexpr TValue NanoSeconds() const noexcept {
+ constexpr TValue NanoSeconds() const noexcept {
return MicroSeconds() >= (Max<TValue>() / (TValue)1000) ? Max<TValue>() : MicroSeconds() * (TValue)1000;
}
- constexpr ui32 MicroSecondsOfSecond() const noexcept {
+ constexpr ui32 MicroSecondsOfSecond() const noexcept {
return MicroSeconds() % (TValue)1000000;
}
- constexpr ui32 MilliSecondsOfSecond() const noexcept {
+ constexpr ui32 MilliSecondsOfSecond() const noexcept {
return MicroSecondsOfSecond() / (TValue)1000;
}
- constexpr ui32 NanoSecondsOfSecond() const noexcept {
+ constexpr ui32 NanoSecondsOfSecond() const noexcept {
return MicroSecondsOfSecond() * (TValue)1000;
}
@@ -195,20 +195,20 @@ namespace NDateTimeHelpers {
class TDuration: public TTimeBase<TDuration> {
using TBase = TTimeBase<TDuration>;
-private:
- /**
- * private construct from microseconds
- */
- constexpr explicit TDuration(TValue value) noexcept
+private:
+ /**
+ * private construct from microseconds
+ */
+ constexpr explicit TDuration(TValue value) noexcept
: TBase(value)
{
}
-public:
- constexpr TDuration() noexcept {
- }
-
- constexpr TDuration(const struct timeval& tv) noexcept
+public:
+ constexpr TDuration() noexcept {
+ }
+
+ constexpr TDuration(const struct timeval& tv) noexcept
: TBase(tv)
{
}
@@ -256,11 +256,11 @@ public:
}
}
- static constexpr TDuration FromValue(TValue value) noexcept {
- return TDuration(value);
- }
-
- static constexpr TDuration MicroSeconds(ui64 us) noexcept {
+ static constexpr TDuration FromValue(TValue value) noexcept {
+ return TDuration(value);
+ }
+
+ static constexpr TDuration MicroSeconds(ui64 us) noexcept {
return TDuration(us);
}
@@ -281,11 +281,11 @@ public:
inline TInstant ToDeadLine() const;
constexpr TInstant ToDeadLine(TInstant now) const;
- static constexpr TDuration Max() noexcept {
+ static constexpr TDuration Max() noexcept {
return TDuration(::Max<TValue>());
}
- static constexpr TDuration Zero() noexcept {
+ static constexpr TDuration Zero() noexcept {
return TDuration();
}
@@ -295,15 +295,15 @@ public:
return MilliSeconds(typename NDateTimeHelpers::TPrecisionHelper<T>::THighPrecision(s) * 1000);
}
- static constexpr TDuration Minutes(ui64 m) noexcept {
+ static constexpr TDuration Minutes(ui64 m) noexcept {
return Seconds(m * 60);
}
- static constexpr TDuration Hours(ui64 h) noexcept {
+ static constexpr TDuration Hours(ui64 h) noexcept {
return Minutes(h * 60);
}
- static constexpr TDuration Days(ui64 d) noexcept {
+ static constexpr TDuration Days(ui64 d) noexcept {
return Hours(d * 24);
}
@@ -315,26 +315,26 @@ public:
// note global Out method is defined for TDuration, so it could be written to IOutputStream as text
template <class T>
- inline TDuration& operator+=(const T& t) noexcept {
+ inline TDuration& operator+=(const T& t) noexcept {
return (*this = (*this + t));
}
template <class T>
- inline TDuration& operator-=(const T& t) noexcept {
+ inline TDuration& operator-=(const T& t) noexcept {
return (*this = (*this - t));
}
template <class T>
- inline TDuration& operator*=(const T& t) noexcept {
+ inline TDuration& operator*=(const T& t) noexcept {
return (*this = (*this * t));
}
template <class T>
- inline TDuration& operator/=(const T& t) noexcept {
+ inline TDuration& operator/=(const T& t) noexcept {
return (*this = (*this / t));
}
- TString ToString() const;
+ TString ToString() const;
};
Y_DECLARE_PODTYPE(TDuration);
@@ -350,28 +350,28 @@ struct THash<TDuration> {
class TInstant: public TTimeBase<TInstant> {
using TBase = TTimeBase<TInstant>;
-private:
- /**
- * private construct from microseconds since epoch
- */
+private:
+ /**
+ * private construct from microseconds since epoch
+ */
constexpr explicit TInstant(TValue value) noexcept
: TBase(value)
{
}
-public:
- constexpr TInstant() noexcept {
- }
-
+public:
+ constexpr TInstant() noexcept {
+ }
+
constexpr TInstant(const struct timeval& tv) noexcept
: TBase(tv)
{
}
- static constexpr TInstant FromValue(TValue value) noexcept {
- return TInstant(value);
- }
-
+ static constexpr TInstant FromValue(TValue value) noexcept {
+ return TInstant(value);
+ }
+
static inline TInstant Now() {
return TInstant::MicroSeconds(::MicroSeconds());
}
@@ -383,49 +383,49 @@ public:
using TBase::Minutes;
using TBase::Seconds;
- static constexpr TInstant Max() noexcept {
+ static constexpr TInstant Max() noexcept {
return TInstant(::Max<TValue>());
}
- static constexpr TInstant Zero() noexcept {
+ static constexpr TInstant Zero() noexcept {
return TInstant();
}
/// us since epoch
- static constexpr TInstant MicroSeconds(ui64 us) noexcept {
+ static constexpr TInstant MicroSeconds(ui64 us) noexcept {
return TInstant(us);
}
/// ms since epoch
- static constexpr TInstant MilliSeconds(ui64 ms) noexcept {
+ static constexpr TInstant MilliSeconds(ui64 ms) noexcept {
return MicroSeconds(ms * 1000);
}
/// seconds since epoch
- static constexpr TInstant Seconds(ui64 s) noexcept {
+ static constexpr TInstant Seconds(ui64 s) noexcept {
return MilliSeconds(s * 1000);
}
/// minutes since epoch
- static constexpr TInstant Minutes(ui64 m) noexcept {
+ static constexpr TInstant Minutes(ui64 m) noexcept {
return Seconds(m * 60);
}
/// hours since epoch
- static constexpr TInstant Hours(ui64 h) noexcept {
+ static constexpr TInstant Hours(ui64 h) noexcept {
return Minutes(h * 60);
}
/// days since epoch
- static constexpr TInstant Days(ui64 d) noexcept {
+ static constexpr TInstant Days(ui64 d) noexcept {
return Hours(d * 24);
}
- constexpr time_t TimeT() const noexcept {
+ constexpr time_t TimeT() const noexcept {
return (time_t)Seconds();
}
- inline struct timeval TimeVal() const noexcept {
+ inline struct timeval TimeVal() const noexcept {
struct timeval tv;
::Zero(tv);
tv.tv_sec = TimeT();
@@ -433,12 +433,12 @@ public:
return tv;
}
- inline struct tm* LocalTime(struct tm* tm) const noexcept {
+ inline struct tm* LocalTime(struct tm* tm) const noexcept {
time_t clock = Seconds();
return localtime_r(&clock, tm);
}
- inline struct tm* GmTime(struct tm* tm) const noexcept {
+ inline struct tm* GmTime(struct tm* tm) const noexcept {
time_t clock = Seconds();
return GmTimeR(&clock, tm);
}
@@ -449,7 +449,7 @@ public:
* @returns An ISO 8601 formatted string, e.g. '2015-11-21T23:30:27.991669Z'.
* @note Global Out method is defined to TInstant, so it can be written as text to IOutputStream.
*/
- TString ToString() const;
+ TString ToString() const;
/**
* Formats the instant using the UTC time zone.
@@ -463,7 +463,7 @@ public:
*
* @returns An ISO 8601 formatted string, e.g. '2015-11-21T23:30:27Z'.
*/
- TString ToStringUpToSeconds() const;
+ TString ToStringUpToSeconds() const;
/**
* Formats the instant using the system time zone, with microsecond precision.
@@ -479,7 +479,7 @@ public:
* @returns A semi-ISO 8601 formatted string with timezone without colon,
* e.g. '2015-11-22T04:30:27.991669+0500'.
*/
- TString ToStringLocal() const;
+ TString ToStringLocal() const;
/**
* Formats the instant using the system time zone.
@@ -502,7 +502,7 @@ public:
* @returns A semi-ISO 8601 formatted string with timezone without colon,
* e.g. '2015-11-22T04:30:27+0500'.
*/
- TString ToStringLocalUpToSeconds() const;
+ TString ToStringLocalUpToSeconds() const;
TString FormatLocalTime(const char* format) const noexcept;
TString FormatGmTime(const char* format) const noexcept;
@@ -547,12 +547,12 @@ public:
static bool TryParseX509Deprecated(TStringBuf input, TInstant& instant);
template <class T>
- inline TInstant& operator+=(const T& t) noexcept {
+ inline TInstant& operator+=(const T& t) noexcept {
return (*this = (*this + t));
}
template <class T>
- inline TInstant& operator-=(const T& t) noexcept {
+ inline TInstant& operator-=(const T& t) noexcept {
return (*this = (*this - t));
}
};
@@ -602,32 +602,32 @@ namespace NPrivate {
///@}
template <class S>
-static constexpr bool operator<(const TTimeBase<S>& l, const TTimeBase<S>& r) noexcept {
+static constexpr bool operator<(const TTimeBase<S>& l, const TTimeBase<S>& r) noexcept {
return l.GetValue() < r.GetValue();
}
template <class S>
-static constexpr bool operator<=(const TTimeBase<S>& l, const TTimeBase<S>& r) noexcept {
+static constexpr bool operator<=(const TTimeBase<S>& l, const TTimeBase<S>& r) noexcept {
return l.GetValue() <= r.GetValue();
}
template <class S>
-static constexpr bool operator==(const TTimeBase<S>& l, const TTimeBase<S>& r) noexcept {
+static constexpr bool operator==(const TTimeBase<S>& l, const TTimeBase<S>& r) noexcept {
return l.GetValue() == r.GetValue();
}
template <class S>
-static constexpr bool operator!=(const TTimeBase<S>& l, const TTimeBase<S>& r) noexcept {
+static constexpr bool operator!=(const TTimeBase<S>& l, const TTimeBase<S>& r) noexcept {
return l.GetValue() != r.GetValue();
}
template <class S>
-static constexpr bool operator>(const TTimeBase<S>& l, const TTimeBase<S>& r) noexcept {
+static constexpr bool operator>(const TTimeBase<S>& l, const TTimeBase<S>& r) noexcept {
return l.GetValue() > r.GetValue();
}
template <class S>
-static constexpr bool operator>=(const TTimeBase<S>& l, const TTimeBase<S>& r) noexcept {
+static constexpr bool operator>=(const TTimeBase<S>& l, const TTimeBase<S>& r) noexcept {
return l.GetValue() >= r.GetValue();
}
@@ -647,24 +647,24 @@ namespace NDateTimeHelpers {
}
}
-constexpr TDuration operator-(const TInstant& l, const TInstant& r) noexcept {
- return TDuration::FromValue(::NDateTimeHelpers::DiffWithSaturation(l.GetValue(), r.GetValue()));
+constexpr TDuration operator-(const TInstant& l, const TInstant& r) noexcept {
+ return TDuration::FromValue(::NDateTimeHelpers::DiffWithSaturation(l.GetValue(), r.GetValue()));
}
-constexpr TInstant operator+(const TInstant& i, const TDuration& d) noexcept {
- return TInstant::FromValue(::NDateTimeHelpers::SumWithSaturation(i.GetValue(), d.GetValue()));
+constexpr TInstant operator+(const TInstant& i, const TDuration& d) noexcept {
+ return TInstant::FromValue(::NDateTimeHelpers::SumWithSaturation(i.GetValue(), d.GetValue()));
}
-constexpr TInstant operator-(const TInstant& i, const TDuration& d) noexcept {
- return TInstant::FromValue(::NDateTimeHelpers::DiffWithSaturation(i.GetValue(), d.GetValue()));
+constexpr TInstant operator-(const TInstant& i, const TDuration& d) noexcept {
+ return TInstant::FromValue(::NDateTimeHelpers::DiffWithSaturation(i.GetValue(), d.GetValue()));
}
-constexpr TDuration operator-(const TDuration& l, const TDuration& r) noexcept {
- return TDuration::FromValue(::NDateTimeHelpers::DiffWithSaturation(l.GetValue(), r.GetValue()));
+constexpr TDuration operator-(const TDuration& l, const TDuration& r) noexcept {
+ return TDuration::FromValue(::NDateTimeHelpers::DiffWithSaturation(l.GetValue(), r.GetValue()));
}
-constexpr TDuration operator+(const TDuration& l, const TDuration& r) noexcept {
- return TDuration::FromValue(::NDateTimeHelpers::SumWithSaturation(l.GetValue(), r.GetValue()));
+constexpr TDuration operator+(const TDuration& l, const TDuration& r) noexcept {
+ return TDuration::FromValue(::NDateTimeHelpers::SumWithSaturation(l.GetValue(), r.GetValue()));
}
template <typename T, typename TRatio>
@@ -775,7 +775,7 @@ template <class T>
inline TDuration operator*(TDuration d, T t) noexcept {
Y_ASSERT(t >= T());
Y_ASSERT(t == T() || Max<TDuration::TValue>() / t >= d.GetValue());
- return TDuration::FromValue(d.GetValue() * t);
+ return TDuration::FromValue(d.GetValue() * t);
}
template <>
@@ -795,14 +795,14 @@ inline TDuration operator*(T t, TDuration d) noexcept {
}
template <class T, std::enable_if_t<!std::is_same<TDuration, T>::value, int> = 0>
-constexpr TDuration operator/(const TDuration& d, const T& t) noexcept {
- return TDuration::FromValue(d.GetValue() / t);
+constexpr TDuration operator/(const TDuration& d, const T& t) noexcept {
+ return TDuration::FromValue(d.GetValue() / t);
+}
+
+constexpr double operator/(const TDuration& x, const TDuration& y) noexcept {
+ return static_cast<double>(x.GetValue()) / static_cast<double>(y.GetValue());
}
-constexpr double operator/(const TDuration& x, const TDuration& y) noexcept {
- return static_cast<double>(x.GetValue()) / static_cast<double>(y.GetValue());
-}
-
inline TInstant TDuration::ToDeadLine() const {
return ToDeadLine(TInstant::Now());
}
@@ -814,7 +814,7 @@ constexpr TInstant TDuration::ToDeadLine(TInstant now) const {
void Sleep(TDuration duration);
void SleepUntil(TInstant instant);
-static inline TInstant Now() noexcept {
+static inline TInstant Now() noexcept {
return TInstant::Now();
}
diff --git a/util/datetime/base_ut.cpp b/util/datetime/base_ut.cpp
index 6699076949..afc3f802eb 100644
--- a/util/datetime/base_ut.cpp
+++ b/util/datetime/base_ut.cpp
@@ -411,9 +411,9 @@ Y_UNIT_TEST_SUITE(DateTimeTest) {
}
Y_UNIT_TEST(TestInstantToString) {
- UNIT_ASSERT_VALUES_EQUAL(TString("2009-08-06T15:19:06.023455Z"), ToString(TInstant::Seconds(1249571946) + TDuration::MicroSeconds(23455)));
- UNIT_ASSERT_VALUES_EQUAL(TString("2009-08-06T15:19:06.023455Z"), (TInstant::Seconds(1249571946) + TDuration::MicroSeconds(23455)).ToString());
- UNIT_ASSERT_VALUES_EQUAL(TString("2009-08-06T15:19:06Z"), (TInstant::Seconds(1249571946) + TDuration::MicroSeconds(23455)).ToStringUpToSeconds());
+ UNIT_ASSERT_VALUES_EQUAL(TString("2009-08-06T15:19:06.023455Z"), ToString(TInstant::Seconds(1249571946) + TDuration::MicroSeconds(23455)));
+ UNIT_ASSERT_VALUES_EQUAL(TString("2009-08-06T15:19:06.023455Z"), (TInstant::Seconds(1249571946) + TDuration::MicroSeconds(23455)).ToString());
+ UNIT_ASSERT_VALUES_EQUAL(TString("2009-08-06T15:19:06Z"), (TInstant::Seconds(1249571946) + TDuration::MicroSeconds(23455)).ToStringUpToSeconds());
}
Y_UNIT_TEST(TestInstantToRfc822String) {
@@ -461,10 +461,10 @@ Y_UNIT_TEST_SUITE(DateTimeTest) {
template <class T>
void TestTimeUnits() {
- T withTime = T::MicroSeconds(1249571946000000L);
- T onlyMinutes = T::MicroSeconds(1249571940000000L);
- T onlyHours = T::MicroSeconds(1249570800000000L);
- T onlyDays = T::MicroSeconds(1249516800000000L);
+ T withTime = T::MicroSeconds(1249571946000000L);
+ T onlyMinutes = T::MicroSeconds(1249571940000000L);
+ T onlyHours = T::MicroSeconds(1249570800000000L);
+ T onlyDays = T::MicroSeconds(1249516800000000L);
ui64 minutes = 20826199;
ui64 hours = 347103;
ui64 days = 14462;
@@ -496,22 +496,22 @@ Y_UNIT_TEST_SUITE(DateTimeTest) {
UNIT_ASSERT_EXCEPTION(TDuration::MilliSeconds(FromString(TStringBuf("not a number"))), yexception);
UNIT_ASSERT_EXCEPTION(TDuration::Seconds(FromString(TStringBuf("not a number"))), yexception);
}
-
+
Y_UNIT_TEST(TestFromValueForTDuration) {
- // check that FromValue creates the same TDuration
- TDuration d1 = TDuration::MicroSeconds(12345);
- TDuration d2 = TDuration::FromValue(d1.GetValue());
-
- UNIT_ASSERT_VALUES_EQUAL(d1, d2);
- }
-
+ // check that FromValue creates the same TDuration
+ TDuration d1 = TDuration::MicroSeconds(12345);
+ TDuration d2 = TDuration::FromValue(d1.GetValue());
+
+ UNIT_ASSERT_VALUES_EQUAL(d1, d2);
+ }
+
Y_UNIT_TEST(TestFromValueForTInstant) {
- // check that FromValue creates the same TInstant
- TInstant i1 = TInstant::MicroSeconds(12345);
- TInstant i2 = TInstant::FromValue(i1.GetValue());
-
- UNIT_ASSERT_VALUES_EQUAL(i1, i2);
- }
+ // check that FromValue creates the same TInstant
+ TInstant i1 = TInstant::MicroSeconds(12345);
+ TInstant i2 = TInstant::FromValue(i1.GetValue());
+
+ UNIT_ASSERT_VALUES_EQUAL(i1, i2);
+ }
Y_UNIT_TEST(TestTimeGmDateConversion) {
tm time{};
diff --git a/util/datetime/cputimer.cpp b/util/datetime/cputimer.cpp
index 08f97a2c7a..516d372c37 100644
--- a/util/datetime/cputimer.cpp
+++ b/util/datetime/cputimer.cpp
@@ -65,14 +65,14 @@ ui64 TPrecisionTimer::GetCycleCount() const {
return ::GetCycleCount() - Start;
}
-TString FormatCycles(ui64 cycles) {
+TString FormatCycles(ui64 cycles) {
ui64 milliseconds = cycles / GetCyclesPerMillisecond();
ui32 ms = ui32(milliseconds % 1000);
milliseconds /= 1000;
ui32 secs = ui32(milliseconds % 60);
milliseconds /= 60;
ui32 mins = ui32(milliseconds);
- TString result;
+ TString result;
sprintf(result, "%" PRIu32 " m %.2" PRIu32 " s %.3" PRIu32 " ms", mins, secs, ms);
return result;
}
@@ -98,11 +98,11 @@ TFuncTimer::TFuncTimer(const char* func)
Cerr << "enter " << Func_ << Endl;
}
-TFuncTimer::~TFuncTimer() {
+TFuncTimer::~TFuncTimer() {
Cerr << "leave " << Func_ << " -> " << (TInstant::Now() - Start_) << Endl;
}
-TTimeLogger::TTimeLogger(const TString& message, bool verbose)
+TTimeLogger::TTimeLogger(const TString& message, bool verbose)
: Message(message)
, Verbose(verbose)
, OK(false)
diff --git a/util/datetime/cputimer.h b/util/datetime/cputimer.h
index eae2f535ad..7d38d5bdb3 100644
--- a/util/datetime/cputimer.h
+++ b/util/datetime/cputimer.h
@@ -3,7 +3,7 @@
#include "base.h"
#include <util/system/rusage.h>
-#include <util/generic/string.h>
+#include <util/generic/string.h>
#include <util/stream/str.h>
class TTimer {
@@ -72,7 +72,7 @@ public:
ui64 GetCycleCount() const;
};
-TString FormatCycles(ui64 cycles);
+TString FormatCycles(ui64 cycles);
class TFormattedPrecisionTimer {
private:
@@ -88,7 +88,7 @@ public:
class TFuncTimer {
public:
TFuncTimer(const char* func);
- ~TFuncTimer();
+ ~TFuncTimer();
private:
const TInstant Start_;
@@ -97,7 +97,7 @@ private:
class TFakeTimer {
public:
- inline TFakeTimer(const char* = nullptr) noexcept {
+ inline TFakeTimer(const char* = nullptr) noexcept {
}
};
@@ -109,14 +109,14 @@ public:
class TTimeLogger {
private:
- TString Message;
+ TString Message;
bool Verbose;
bool OK;
time_t Begin;
ui64 BeginCycles;
public:
- TTimeLogger(const TString& message, bool verbose = true);
+ TTimeLogger(const TString& message, bool verbose = true);
~TTimeLogger();
void SetOK();
diff --git a/util/datetime/parser.h b/util/datetime/parser.h
index 007c5a4615..f0c1b4a0c7 100644
--- a/util/datetime/parser.h
+++ b/util/datetime/parser.h
@@ -28,7 +28,7 @@ struct TDateTimeFields {
Year = year;
}
- bool IsOk() const noexcept {
+ bool IsOk() const noexcept {
if (Year < 1970)
return false;
if (Month < 1 || Month > 12)
diff --git a/util/datetime/systime.cpp b/util/datetime/systime.cpp
index d7e5a69b03..6ee7e8fc6e 100644
--- a/util/datetime/systime.cpp
+++ b/util/datetime/systime.cpp
@@ -132,7 +132,7 @@ struct tm* GmTimeR(const time_t* timer, struct tm* tmbuf) {
return tmbuf;
}
-TString CTimeR(const time_t* timer) {
+TString CTimeR(const time_t* timer) {
char sTime[32];
sTime[0] = 0;
ctime_r(timer, &sTime[0]);
diff --git a/util/datetime/systime.h b/util/datetime/systime.h
index e64744977c..491d36e802 100644
--- a/util/datetime/systime.h
+++ b/util/datetime/systime.h
@@ -1,7 +1,7 @@
#pragma once
#include <util/system/platform.h>
-#include <util/generic/string.h>
+#include <util/generic/string.h>
#include <ctime>
@@ -9,7 +9,7 @@
time_t TimeGM(const struct tm* t);
struct tm* GmTimeR(const time_t* timer, struct tm* tmbuf);
// safe version of ctime, convinient version of ctime_r
-TString CTimeR(const time_t* timer);
+TString CTimeR(const time_t* timer);
#ifdef _win_
#include <util/system/winint.h>
diff --git a/util/datetime/uptime.cpp b/util/datetime/uptime.cpp
index 322a229000..12476a94bf 100644
--- a/util/datetime/uptime.cpp
+++ b/util/datetime/uptime.cpp
@@ -1,56 +1,56 @@
-#include "uptime.h"
-
-#if defined(_win_)
+#include "uptime.h"
+
+#if defined(_win_)
#include <util/system/winint.h>
-#elif defined(_linux_)
+#elif defined(_linux_)
#include <util/stream/file.h>
#include <util/string/cast.h>
-#elif defined(_darwin_)
+#elif defined(_darwin_)
#include <sys/sysctl.h>
-#endif
-
-#if defined(_darwin_)
-namespace {
- TInstant GetBootTime() {
- struct timeval timeSinceBoot;
- size_t len = sizeof(timeSinceBoot);
- int request[2] = {CTL_KERN, KERN_BOOTTIME};
- if (sysctl(request, 2, &timeSinceBoot, &len, nullptr, 0) < 0) {
- ythrow yexception() << "cannot get kern.boottime from sysctl";
- }
- return TInstant::MicroSeconds(timeSinceBoot.tv_sec * 1'000'000 + timeSinceBoot.tv_usec);
- }
-
- TDuration GetDarwinUptime() {
- TInstant beforeNow;
- TInstant afterNow;
- TInstant now;
-
- // avoid race when NTP changes machine time between getting Now() and uptime
- afterNow = GetBootTime();
- do {
- beforeNow = afterNow;
- now = Now();
- afterNow = GetBootTime();
- } while (afterNow != beforeNow);
-
- return now - beforeNow;
- }
-}
-#endif // _darwin_
-
-TDuration Uptime() {
-#if defined(_win_)
- return TDuration::MilliSeconds(GetTickCount64());
-#elif defined(_linux_)
- TUnbufferedFileInput in("/proc/uptime");
- TString uptimeStr = in.ReadLine();
- double up, idle;
- if (sscanf(uptimeStr.data(), "%lf %lf", &up, &idle) < 2) {
- ythrow yexception() << "cannot read values from /proc/uptime";
- }
- return TDuration::MilliSeconds(up * 1000.0);
-#elif defined(_darwin_)
- return GetDarwinUptime();
-#endif
-}
+#endif
+
+#if defined(_darwin_)
+namespace {
+ TInstant GetBootTime() {
+ struct timeval timeSinceBoot;
+ size_t len = sizeof(timeSinceBoot);
+ int request[2] = {CTL_KERN, KERN_BOOTTIME};
+ if (sysctl(request, 2, &timeSinceBoot, &len, nullptr, 0) < 0) {
+ ythrow yexception() << "cannot get kern.boottime from sysctl";
+ }
+ return TInstant::MicroSeconds(timeSinceBoot.tv_sec * 1'000'000 + timeSinceBoot.tv_usec);
+ }
+
+ TDuration GetDarwinUptime() {
+ TInstant beforeNow;
+ TInstant afterNow;
+ TInstant now;
+
+ // avoid race when NTP changes machine time between getting Now() and uptime
+ afterNow = GetBootTime();
+ do {
+ beforeNow = afterNow;
+ now = Now();
+ afterNow = GetBootTime();
+ } while (afterNow != beforeNow);
+
+ return now - beforeNow;
+ }
+}
+#endif // _darwin_
+
+TDuration Uptime() {
+#if defined(_win_)
+ return TDuration::MilliSeconds(GetTickCount64());
+#elif defined(_linux_)
+ TUnbufferedFileInput in("/proc/uptime");
+ TString uptimeStr = in.ReadLine();
+ double up, idle;
+ if (sscanf(uptimeStr.data(), "%lf %lf", &up, &idle) < 2) {
+ ythrow yexception() << "cannot read values from /proc/uptime";
+ }
+ return TDuration::MilliSeconds(up * 1000.0);
+#elif defined(_darwin_)
+ return GetDarwinUptime();
+#endif
+}
diff --git a/util/datetime/uptime.h b/util/datetime/uptime.h
index fabf141734..88f0de63da 100644
--- a/util/datetime/uptime.h
+++ b/util/datetime/uptime.h
@@ -1,8 +1,8 @@
-#pragma once
-
-#include "base.h"
-
-/**
- * Returns system uptime
- */
-TDuration Uptime();
+#pragma once
+
+#include "base.h"
+
+/**
+ * Returns system uptime
+ */
+TDuration Uptime();
diff --git a/util/datetime/uptime_ut.cpp b/util/datetime/uptime_ut.cpp
index 5ffc372784..7f5ecc482c 100644
--- a/util/datetime/uptime_ut.cpp
+++ b/util/datetime/uptime_ut.cpp
@@ -1,12 +1,12 @@
#include <library/cpp/testing/unittest/registar.h>
-
-#include "uptime.h"
-
-Y_UNIT_TEST_SUITE(TestUptimeSuite) {
- Y_UNIT_TEST(TestUptime) {
- auto t1 = Uptime();
- Sleep(TDuration::MilliSeconds(50)); // typical uptime resolution is 10-16 ms
- auto t2 = Uptime();
- UNIT_ASSERT(t2 > t1);
- }
-}
+
+#include "uptime.h"
+
+Y_UNIT_TEST_SUITE(TestUptimeSuite) {
+ Y_UNIT_TEST(TestUptime) {
+ auto t1 = Uptime();
+ Sleep(TDuration::MilliSeconds(50)); // typical uptime resolution is 10-16 ms
+ auto t2 = Uptime();
+ UNIT_ASSERT(t2 > t1);
+ }
+}
diff --git a/util/datetime/ut/ya.make b/util/datetime/ut/ya.make
index 9f5b65aeee..c2bc714059 100644
--- a/util/datetime/ut/ya.make
+++ b/util/datetime/ut/ya.make
@@ -7,7 +7,7 @@ SRCS(
datetime/base_ut.cpp
datetime/parser_deprecated_ut.cpp
datetime/parser_ut.cpp
- datetime/uptime_ut.cpp
+ datetime/uptime_ut.cpp
)
INCLUDE(${ARCADIA_ROOT}/util/tests/ya_util_tests.inc)
diff --git a/util/digest/city.h b/util/digest/city.h
index ce37768d7f..675a798074 100644
--- a/util/digest/city.h
+++ b/util/digest/city.h
@@ -52,32 +52,32 @@ namespace NPrivateCityHash {
}
}
-template <class TStringType>
-inline ui64 CityHash64(const TStringType& str) {
+template <class TStringType>
+inline ui64 CityHash64(const TStringType& str) {
TStringBuf buf = NPrivateCityHash::GetBufFromStr(str);
return CityHash64(buf.data(), buf.size());
}
-template <class TStringType>
-inline ui64 CityHash64WithSeeds(const TStringType& str, ui64 seed0, ui64 seed1) {
+template <class TStringType>
+inline ui64 CityHash64WithSeeds(const TStringType& str, ui64 seed0, ui64 seed1) {
TStringBuf buf = NPrivateCityHash::GetBufFromStr(str);
return CityHash64WithSeeds(buf.data(), buf.size(), seed0, seed1);
}
-template <class TStringType>
-inline ui64 CityHash64WithSeed(const TStringType& str, ui64 seed) {
+template <class TStringType>
+inline ui64 CityHash64WithSeed(const TStringType& str, ui64 seed) {
TStringBuf buf = NPrivateCityHash::GetBufFromStr(str);
return CityHash64WithSeed(buf.data(), buf.size(), seed);
}
-template <class TStringType>
-inline uint128 CityHash128(const TStringType& str) {
+template <class TStringType>
+inline uint128 CityHash128(const TStringType& str) {
TStringBuf buf = NPrivateCityHash::GetBufFromStr(str);
return CityHash128(buf.data(), buf.size());
}
-template <class TStringType>
-inline uint128 CityHash128WithSeed(const TStringType& str, uint128 seed) {
+template <class TStringType>
+inline uint128 CityHash128WithSeed(const TStringType& str, uint128 seed) {
TStringBuf buf = NPrivateCityHash::GetBufFromStr(str);
return CityHash128WithSeed(buf.data(), buf.size(), seed);
}
diff --git a/util/digest/multi_ut.pyx b/util/digest/multi_ut.pyx
index 6dbdb32d8f..26faa0069b 100644
--- a/util/digest/multi_ut.pyx
+++ b/util/digest/multi_ut.pyx
@@ -1,5 +1,5 @@
from util.digest.multi cimport MultiHash
-from util.generic.string cimport TString
+from util.generic.string cimport TString
import pytest
import unittest
diff --git a/util/digest/sequence_ut.cpp b/util/digest/sequence_ut.cpp
index d915d7ad06..87d6102ee5 100644
--- a/util/digest/sequence_ut.cpp
+++ b/util/digest/sequence_ut.cpp
@@ -16,18 +16,18 @@ class TRangeHashTest: public TTestBase {
private:
inline void TestStrokaInt() {
const size_t canonicalHash = static_cast<size_t>(ULL(12727184940294366172));
- UNIT_ASSERT_EQUAL(canonicalHash, TRangeHash<>()(TString("12345")));
+ UNIT_ASSERT_EQUAL(canonicalHash, TRangeHash<>()(TString("12345")));
}
inline void TestIntVector() {
const size_t canonicalHash = static_cast<size_t>(ULL(1351128487744230578));
- TVector<int> testVec = {1, 2, 4, 3};
+ TVector<int> testVec = {1, 2, 4, 3};
UNIT_ASSERT_EQUAL(canonicalHash, TRangeHash<>()(testVec));
}
inline void TestOneElement() {
const int testVal = 42;
- TVector<int> testVec = {testVal};
+ TVector<int> testVec = {testVal};
UNIT_ASSERT_UNEQUAL(THash<int>()(testVal), TRangeHash<>()(testVec));
}
@@ -38,8 +38,8 @@ private:
}
inline void TestCollectionIndependancy() {
- TVector<char> testVec = {'a', 'b', 'c'};
- TString testStroka = "abc";
+ TVector<char> testVec = {'a', 'b', 'c'};
+ TString testStroka = "abc";
UNIT_ASSERT_EQUAL(TRangeHash<>()(testVec), TRangeHash<>()(testStroka));
}
};
diff --git a/util/draft/date.cpp b/util/draft/date.cpp
index 645edad013..a290c46050 100644
--- a/util/draft/date.cpp
+++ b/util/draft/date.cpp
@@ -44,7 +44,7 @@ TDate::TDate(const char* yyyymmdd)
{
}
-TDate::TDate(const TString& yyyymmdd)
+TDate::TDate(const TString& yyyymmdd)
: Timestamp(GetDateStart(ParseDate(yyyymmdd.c_str())))
{
}
@@ -54,7 +54,7 @@ TDate::TDate(time_t ts)
{
}
-TDate::TDate(const TString& date, const TString& format)
+TDate::TDate(const TString& date, const TString& format)
: Timestamp(GetDateStart(ParseDate(date.data(), format.data())))
{
}
@@ -82,7 +82,7 @@ time_t TDate::GetStartUTC() const {
return TimeGM(&dateTm);
}
-TString TDate::ToStroka(const char* format) const {
+TString TDate::ToStroka(const char* format) const {
tm dateTm;
localtime_r(&Timestamp, &dateTm);
return Strftime(format, &dateTm);
diff --git a/util/draft/date.h b/util/draft/date.h
index b973a8d197..e3eb616fe5 100644
--- a/util/draft/date.h
+++ b/util/draft/date.h
@@ -2,7 +2,7 @@
#include <util/stream/output.h>
#include <util/stream/input.h>
-#include <util/generic/string.h>
+#include <util/generic/string.h>
#include <util/datetime/constants.h>
#include <ctime>
@@ -28,9 +28,9 @@ public:
}
TDate(const char* yyyymmdd);
- TDate(const TString& yyyymmdd);
+ TDate(const TString& yyyymmdd);
TDate(unsigned year, unsigned month, unsigned monthDay); // month from 01, monthDay from 01
- TDate(const TString& date, const TString& format);
+ TDate(const TString& date, const TString& format);
explicit TDate(time_t t);
@@ -40,7 +40,7 @@ public:
time_t GetStartUTC() const;
- TString ToStroka(const char* format = "%Y%m%d") const;
+ TString ToStroka(const char* format = "%Y%m%d") const;
TDate& operator++() {
Timestamp = GetDateStart(Timestamp + 3 * (SECONDS_IN_DAY / 2));
@@ -117,7 +117,7 @@ inline int operator-(const TDate& left, const TDate& right) {
}
inline IInputStream& operator>>(IInputStream& left, TDate& right) {
- TString stroka;
+ TString stroka;
left >> stroka;
TDate date(stroka.c_str());
right = date;
diff --git a/util/draft/datetime.cpp b/util/draft/datetime.cpp
index 5365dd737a..5cbe7d8847 100644
--- a/util/draft/datetime.cpp
+++ b/util/draft/datetime.cpp
@@ -178,7 +178,7 @@ namespace NDatetime {
}
}
- TString TSimpleTM::ToString(const char* fmt) const {
+ TString TSimpleTM::ToString(const char* fmt) const {
struct tm t = *this;
return Strftime(fmt, &t);
}
diff --git a/util/draft/datetime.h b/util/draft/datetime.h
index 5bf0ee7156..8a387ea6f1 100644
--- a/util/draft/datetime.h
+++ b/util/draft/datetime.h
@@ -1,7 +1,7 @@
#pragma once
#include <util/generic/algorithm.h>
-#include <util/generic/string.h>
+#include <util/generic/string.h>
#include <util/generic/yexception.h>
#include <util/generic/ymath.h>
#include <util/datetime/base.h>
@@ -70,7 +70,7 @@ namespace NDatetime {
// keeps the object consistent
TSimpleTM& Add(EField f, i32 amount = 1);
- TString ToString(const char* fmt = "%a, %d %b %Y %H:%M:%S %z") const;
+ TString ToString(const char* fmt = "%a, %d %b %Y %H:%M:%S %z") const;
TSimpleTM& ToUTC() {
return *this = New(AsTimeT());
@@ -133,16 +133,16 @@ namespace NDatetime {
};
}
-inline TString date2str(const time_t date) {
+inline TString date2str(const time_t date) {
struct tm dateTm;
memset(&dateTm, 0, sizeof(dateTm));
localtime_r(&date, &dateTm);
char buf[9];
strftime(buf, sizeof(buf), "%Y%m%d", &dateTm);
- return TString(buf);
+ return TString(buf);
}
-inline time_t str2date(const TString& dateStr) {
+inline time_t str2date(const TString& dateStr) {
struct tm dateTm;
memset(&dateTm, 0, sizeof(tm));
strptime(dateStr.data(), "%Y%m%d", &dateTm);
diff --git a/util/draft/datetime_ut.cpp b/util/draft/datetime_ut.cpp
index 2af8430977..a5e065ef6e 100644
--- a/util/draft/datetime_ut.cpp
+++ b/util/draft/datetime_ut.cpp
@@ -5,19 +5,19 @@
#include <util/string/builder.h>
Y_UNIT_TEST_SUITE(TSimpleTMTest) {
- TString PrintMarker(const TString& test, int line) {
+ TString PrintMarker(const TString& test, int line) {
return TStringBuilder() << "test " << test << " at line " << line;
}
- TString JoinMarker(const TString& marker, time_t t) {
+ TString JoinMarker(const TString& marker, time_t t) {
return TStringBuilder() << marker << " (tstamp=" << t << ")";
}
- TString PrintMarker(const TString& test, int line, time_t t) {
+ TString PrintMarker(const TString& test, int line, time_t t) {
return JoinMarker(PrintMarker(test, line), t);
}
- void AssertStructTmEqual(const TString& marker, const struct tm& tmt, const NDatetime::TSimpleTM& tms) {
+ void AssertStructTmEqual(const TString& marker, const struct tm& tmt, const NDatetime::TSimpleTM& tms) {
UNIT_ASSERT_VALUES_EQUAL_C((int)tms.Sec, tmt.tm_sec, marker);
UNIT_ASSERT_VALUES_EQUAL_C((int)tms.Min, tmt.tm_min, marker);
UNIT_ASSERT_VALUES_EQUAL_C((int)tms.Hour, tmt.tm_hour, marker);
@@ -32,10 +32,10 @@ Y_UNIT_TEST_SUITE(TSimpleTMTest) {
#endif
}
- void AssertSimpleTM(const TString& mark,
+ void AssertSimpleTM(const TString& mark,
const NDatetime::TSimpleTM& tms,
time_t tstamp, ui32 year, ui32 mon, ui32 mday, ui32 hour, ui32 minu, ui32 sec) {
- TString marker = JoinMarker(mark, tstamp);
+ TString marker = JoinMarker(mark, tstamp);
struct tm tmt;
Zero(tmt);
GmTimeR(&tstamp, &tmt);
diff --git a/util/draft/enum.h b/util/draft/enum.h
index a7adc49c32..18002b7df2 100644
--- a/util/draft/enum.h
+++ b/util/draft/enum.h
@@ -37,8 +37,8 @@ const V* FindEnumFromStringImpl(const char* key, const std::pair<const char*, V>
}
template <class K, class V>
-TString PrintEnumItemsImpl(const std::pair<K, V>* entries, size_t arraySize) {
- TString result;
+TString PrintEnumItemsImpl(const std::pair<K, V>* entries, size_t arraySize) {
+ TString result;
TStringOutput out(result);
for (size_t i = 0; i < arraySize; i++)
out << (i ? ", " : "") << "'" << entries[i].first << "'";
@@ -47,8 +47,8 @@ TString PrintEnumItemsImpl(const std::pair<K, V>* entries, size_t arraySize) {
// special version for const char*
template <class V>
-TString PrintEnumItemsImpl(const std::pair<const char*, V>* entries, size_t arraySize) {
- TString result;
+TString PrintEnumItemsImpl(const std::pair<const char*, V>* entries, size_t arraySize) {
+ TString result;
TStringOutput out(result);
for (size_t i = 0; i < arraySize; i++)
out << (i ? ", " : "") << "'" << (entries[i].first ? entries[i].first : "<null>") << "'";
diff --git a/util/draft/holder_vector.h b/util/draft/holder_vector.h
index b1d9b695d8..1c62055bd9 100644
--- a/util/draft/holder_vector.h
+++ b/util/draft/holder_vector.h
@@ -6,7 +6,7 @@
template <class T, class D = TDelete>
class THolderVector: public TVector<T*>, public TNonCopyable {
- using TBase = TVector<T*>;
+ using TBase = TVector<T*>;
public:
explicit THolderVector(size_t n = 0)
@@ -30,7 +30,7 @@ public:
return TBase::size();
}
- // TVector takes ownership of T
+ // TVector takes ownership of T
void PushBack(T* t) {
try {
TBase::push_back(t);
diff --git a/util/draft/holder_vector_ut.cpp b/util/draft/holder_vector_ut.cpp
index 3acb823941..f64393860a 100644
--- a/util/draft/holder_vector_ut.cpp
+++ b/util/draft/holder_vector_ut.cpp
@@ -60,8 +60,8 @@ Y_UNIT_TEST_SUITE(THolderVectorTest) {
}
Y_UNIT_TEST(TestUniquePtr) {
- THolderVector<TString> v;
- std::unique_ptr<TString> str(new TString("hello"));
+ THolderVector<TString> v;
+ std::unique_ptr<TString> str(new TString("hello"));
v.PushBack(std::move(str));
UNIT_ASSERT(v.Size() == 1);
UNIT_ASSERT(str.get() == nullptr);
diff --git a/util/draft/ip.h b/util/draft/ip.h
index 550bdbf8e5..eb947cd2cd 100644
--- a/util/draft/ip.h
+++ b/util/draft/ip.h
@@ -80,10 +80,10 @@ static inline char* Ip6ToString(const TIp6& ip, char* buf, size_t len) {
return buf;
}
-static inline TString Ip6ToString(const TIp6& ip) {
+static inline TString Ip6ToString(const TIp6& ip) {
char buf[INET6_ADDRSTRLEN];
- return TString(Ip6ToString(ip, buf, sizeof(buf)));
+ return TString(Ip6ToString(ip, buf, sizeof(buf)));
}
template <>
@@ -106,7 +106,7 @@ static inline TIp4Or6 Ip4Or6FromString(const char* ipStr) {
ythrow TSystemError() << "Failed to convert (" << ipStr << ") to ipv4 or ipv6 address";
}
-static inline TString Ip4Or6ToString(const TIp4Or6& ip) {
+static inline TString Ip4Or6ToString(const TIp4Or6& ip) {
if (std::holds_alternative<TIp6>(ip)) {
return Ip6ToString(std::get<TIp6>(ip));
} else {
diff --git a/util/folder/dirut.cpp b/util/folder/dirut.cpp
index 84d0093241..ffc9b09f96 100644
--- a/util/folder/dirut.cpp
+++ b/util/folder/dirut.cpp
@@ -11,12 +11,12 @@
#include <util/system/maxlen.h>
#include <util/system/yassert.h>
-void SlashFolderLocal(TString& folder) {
+void SlashFolderLocal(TString& folder) {
if (!folder)
return;
#ifdef _win32_
size_t pos;
- while ((pos = folder.find('/')) != TString::npos)
+ while ((pos = folder.find('/')) != TString::npos)
folder.replace(pos, 1, LOCSLASH_S);
#endif
if (folder[folder.size() - 1] != LOCSLASH_C)
@@ -25,11 +25,11 @@ void SlashFolderLocal(TString& folder) {
#ifndef _win32_
-bool correctpath(TString& folder) {
+bool correctpath(TString& folder) {
return resolvepath(folder, "/");
}
-bool resolvepath(TString& folder, const TString& home) {
+bool resolvepath(TString& folder, const TString& home) {
Y_ASSERT(home && home.at(0) == '/');
if (!folder) {
return false;
@@ -348,7 +348,7 @@ int resolvepath(char* apath, const char* rpath, const char* cpath) {
return correctpath(apath, tpath);
}
-bool correctpath(TString& filename) {
+bool correctpath(TString& filename) {
char* ptr = (char*)alloca(filename.size() + 2);
if (correctpath(ptr, filename.data())) {
filename = ptr;
@@ -357,7 +357,7 @@ bool correctpath(TString& filename) {
return false;
}
-bool resolvepath(TString& folder, const TString& home) {
+bool resolvepath(TString& folder, const TString& home) {
char* ptr = (char*)alloca(folder.size() + 3 + home.size());
if (resolvepath(ptr, folder.data(), home.data())) {
folder = ptr;
@@ -376,7 +376,7 @@ const char* GetDirectorySeparatorS() {
return LOCSLASH_S;
}
-void RemoveDirWithContents(TString dirName) {
+void RemoveDirWithContents(TString dirName) {
SlashFolderLocal(dirName);
TDirIterator dir(dirName, TDirIterator::TOptions(FTS_NOSTAT));
@@ -402,7 +402,7 @@ int mkpath(char* path, int mode) {
// Implementation of realpath in FreeBSD (version 9.0 and less) and GetFullPathName in Windows
// did not require last component of the file name to exist (other implementations will fail
// if it does not). Use RealLocation if that behaviour is required.
-TString RealPath(const TString& path) {
+TString RealPath(const TString& path) {
TTempBuf result;
Y_ASSERT(result.Size() > MAX_PATH); //TMP_BUF_LEN > MAX_PATH
#ifdef _win_
@@ -414,10 +414,10 @@ TString RealPath(const TString& path) {
return result.Data();
}
-TString RealLocation(const TString& path) {
+TString RealLocation(const TString& path) {
if (NFs::Exists(path))
return RealPath(path);
- TString dirpath = GetDirName(path);
+ TString dirpath = GetDirName(path);
if (NFs::Exists(dirpath))
return RealPath(dirpath) + GetDirectorySeparatorS() + GetFileNameComponent(path.data());
ythrow TFileError() << "RealLocation failed \"" << path << "\"";
@@ -426,7 +426,7 @@ TString RealLocation(const TString& path) {
int MakeTempDir(char path[/*FILENAME_MAX*/], const char* prefix) {
int ret;
- TString sysTmp;
+ TString sysTmp;
#ifdef _win32_
if (!prefix || *prefix == '/') {
@@ -449,12 +449,12 @@ int MakeTempDir(char path[/*FILENAME_MAX*/], const char* prefix) {
return 0;
}
-bool IsDir(const TString& path) {
+bool IsDir(const TString& path) {
return TFileStat(path).IsDir();
}
-TString GetHomeDir() {
- TString s(getenv("HOME"));
+TString GetHomeDir() {
+ TString s(getenv("HOME"));
if (!s) {
#ifndef _win32_
passwd* pw = nullptr;
@@ -505,14 +505,14 @@ const char* GetFileNameComponent(const char* f) {
return f;
}
-TString GetSystemTempDir() {
+TString GetSystemTempDir() {
#ifdef _win_
char buffer[1024];
DWORD size = GetTempPath(1024, buffer);
if (!size) {
ythrow TSystemError() << "failed to get system temporary directory";
}
- return TString(buffer, size);
+ return TString(buffer, size);
#else
const char* var = "TMPDIR";
const char* def = "/tmp";
@@ -522,11 +522,11 @@ TString GetSystemTempDir() {
#endif
}
-TString ResolveDir(const char* path) {
+TString ResolveDir(const char* path) {
return ResolvePath(path, true);
}
-bool SafeResolveDir(const char* path, TString& result) {
+bool SafeResolveDir(const char* path, TString& result) {
try {
result = ResolvePath(path, true);
return true;
@@ -535,7 +535,7 @@ bool SafeResolveDir(const char* path, TString& result) {
}
}
-TString GetDirName(const TString& path) {
+TString GetDirName(const TString& path) {
return TFsPath(path).Dirname();
}
@@ -548,7 +548,7 @@ char* realpath(const char* pathname, char resolved_path[MAXPATHLEN]) {
#endif
-TString GetBaseName(const TString& path) {
+TString GetBaseName(const TString& path) {
return TFsPath(path).Basename();
}
@@ -612,8 +612,8 @@ TString ResolvePath(const char* path, bool isDir) {
return ResolvePath(path, nullptr, isDir);
}
-TString StripFileComponent(const TString& fileName) {
- TString dir = IsDir(fileName) ? fileName : GetDirName(fileName);
+TString StripFileComponent(const TString& fileName) {
+ TString dir = IsDir(fileName) ? fileName : GetDirName(fileName);
if (!dir.empty() && dir.back() != GetDirectorySeparator()) {
dir.append(GetDirectorySeparator());
}
diff --git a/util/folder/dirut.h b/util/folder/dirut.h
index f523aa085e..2537027b12 100644
--- a/util/folder/dirut.h
+++ b/util/folder/dirut.h
@@ -3,7 +3,7 @@
#include <util/system/defaults.h>
#include <util/system/sysstat.h>
#include <util/system/fs.h>
-#include <util/generic/string.h>
+#include <util/generic/string.h>
#include <util/generic/yexception.h>
#include <sys/types.h>
@@ -37,57 +37,57 @@ char* mkdtemp(char* path);
#endif
#endif
-bool IsDir(const TString& path);
+bool IsDir(const TString& path);
int mkpath(char* path, int mode = 0777);
-TString GetHomeDir();
+TString GetHomeDir();
void MakeDirIfNotExist(const char* path, int mode = 0777);
-inline void MakeDirIfNotExist(const TString& path, int mode = 0777) {
+inline void MakeDirIfNotExist(const TString& path, int mode = 0777) {
MakeDirIfNotExist(path.data(), mode);
}
/// Create path making parent directories as needed
void MakePathIfNotExist(const char* path, int mode = 0777);
-void SlashFolderLocal(TString& folder);
-bool correctpath(TString& filename);
-bool resolvepath(TString& folder, const TString& home);
+void SlashFolderLocal(TString& folder);
+bool correctpath(TString& filename);
+bool resolvepath(TString& folder, const TString& home);
char GetDirectorySeparator();
const char* GetDirectorySeparatorS();
-void RemoveDirWithContents(TString dirName);
+void RemoveDirWithContents(TString dirName);
const char* GetFileNameComponent(const char* f);
-inline TString GetFileNameComponent(const TString& f) {
+inline TString GetFileNameComponent(const TString& f) {
return GetFileNameComponent(f.data());
}
/// RealPath doesn't guarantee trailing separator to be stripped or left in place for directories.
-TString RealPath(const TString& path); // throws
-TString RealLocation(const TString& path); /// throws; last file name component doesn't need to exist
+TString RealPath(const TString& path); // throws
+TString RealLocation(const TString& path); /// throws; last file name component doesn't need to exist
-TString GetSystemTempDir();
+TString GetSystemTempDir();
int MakeTempDir(char path[/*FILENAME_MAX*/], const char* prefix);
int ResolvePath(const char* rel, const char* abs, char res[/*FILENAME_MAX*/], bool isdir = false);
TString ResolvePath(const char* rel, const char* abs, bool isdir = false);
-TString ResolvePath(const char* path, bool isDir = false);
+TString ResolvePath(const char* path, bool isDir = false);
-TString ResolveDir(const char* path);
+TString ResolveDir(const char* path);
-bool SafeResolveDir(const char* path, TString& result);
+bool SafeResolveDir(const char* path, TString& result);
-TString GetDirName(const TString& path);
+TString GetDirName(const TString& path);
-TString GetBaseName(const TString& path);
+TString GetBaseName(const TString& path);
-TString StripFileComponent(const TString& fileName);
+TString StripFileComponent(const TString& fileName);
class TExistenceChecker {
public:
diff --git a/util/folder/dirut_ut.cpp b/util/folder/dirut_ut.cpp
index 9afcf03621..45ebfc842c 100644
--- a/util/folder/dirut_ut.cpp
+++ b/util/folder/dirut_ut.cpp
@@ -3,7 +3,7 @@
#include <library/cpp/testing/unittest/registar.h>
-#include <util/generic/string.h>
+#include <util/generic/string.h>
#include <util/memory/tempbuf.h>
#include <util/stream/file.h>
#include <util/system/platform.h>
diff --git a/util/folder/filelist.cpp b/util/folder/filelist.cpp
index beb543734c..b21fcdbf20 100644
--- a/util/folder/filelist.cpp
+++ b/util/folder/filelist.cpp
@@ -4,7 +4,7 @@
#include <util/system/defaults.h>
-void TFileEntitiesList::Fill(const TString& dirname, TStringBuf prefix, TStringBuf suffix, int depth, bool sort) {
+void TFileEntitiesList::Fill(const TString& dirname, TStringBuf prefix, TStringBuf suffix, int depth, bool sort) {
TDirIterator::TOptions opts;
opts.SetMaxLevel(depth);
if (sort) {
diff --git a/util/folder/filelist.h b/util/folder/filelist.h
index 1228a08613..3f615fa4c2 100644
--- a/util/folder/filelist.h
+++ b/util/folder/filelist.h
@@ -1,7 +1,7 @@
#pragma once
#include <util/generic/buffer.h>
-#include <util/generic/string.h>
+#include <util/generic/string.h>
#include <util/generic/strbuf.h>
#include <util/generic/flags.h>
@@ -40,15 +40,15 @@ public:
return FileNamesSize;
}
- inline void Fill(const TString& dirname, bool sort = false) {
+ inline void Fill(const TString& dirname, bool sort = false) {
Fill(dirname, TStringBuf(), sort);
}
- inline void Fill(const TString& dirname, TStringBuf prefix, bool sort = false) {
+ inline void Fill(const TString& dirname, TStringBuf prefix, bool sort = false) {
Fill(dirname, prefix, TStringBuf(), 1, sort);
}
- void Fill(const TString& dirname, TStringBuf prefix, TStringBuf suffix, int depth, bool sort = false);
+ void Fill(const TString& dirname, TStringBuf prefix, TStringBuf suffix, int depth, bool sort = false);
void Restart() {
Cur = FileNames.Data();
diff --git a/util/folder/filelist_ut.cpp b/util/folder/filelist_ut.cpp
index 60db164e56..0cdcdf3d00 100644
--- a/util/folder/filelist_ut.cpp
+++ b/util/folder/filelist_ut.cpp
@@ -5,7 +5,7 @@
#include <library/cpp/testing/unittest/registar.h>
#include <util/system/file.h>
-#include <util/generic/string.h>
+#include <util/generic/string.h>
class TFileListTest: public TTestBase {
UNIT_TEST_SUITE(TFileListTest);
@@ -25,7 +25,7 @@ void TFileListTest::TestSimple() {
TFileList fileList;
fileList.Fill(tempDir().data(), "", "", 1000);
- TString fileName(fileList.Next());
+ TString fileName(fileList.Next());
UNIT_ASSERT_EQUAL(fileName, "subdir" LOCSLASH_S "file");
UNIT_ASSERT_EQUAL(fileList.Next(), nullptr);
}
@@ -41,14 +41,14 @@ void TFileListTest::TestPrefix() {
TFileList fileList;
{
fileList.Fill(tempDir().data(), "good_file", SORT);
- UNIT_ASSERT_EQUAL(TString(fileList.Next()), "good_file1");
- UNIT_ASSERT_EQUAL(TString(fileList.Next()), "good_file2");
+ UNIT_ASSERT_EQUAL(TString(fileList.Next()), "good_file1");
+ UNIT_ASSERT_EQUAL(TString(fileList.Next()), "good_file2");
UNIT_ASSERT_EQUAL(fileList.Next(), nullptr);
}
{
fileList.Fill(tempDir().data(), "bad_file", SORT);
- UNIT_ASSERT_EQUAL(TString(fileList.Next()), "bad_file1");
- UNIT_ASSERT_EQUAL(TString(fileList.Next()), "bad_file2");
+ UNIT_ASSERT_EQUAL(TString(fileList.Next()), "bad_file1");
+ UNIT_ASSERT_EQUAL(TString(fileList.Next()), "bad_file2");
UNIT_ASSERT_EQUAL(fileList.Next(), nullptr);
}
}
diff --git a/util/folder/fts_ut.cpp b/util/folder/fts_ut.cpp
index a628efd90e..c5d59e35f4 100644
--- a/util/folder/fts_ut.cpp
+++ b/util/folder/fts_ut.cpp
@@ -7,7 +7,7 @@
#include <util/system/file.h>
#include <util/system/tempfile.h>
-#include <util/generic/string.h>
+#include <util/generic/string.h>
class TFtsTest: public TTestBase {
UNIT_TEST_SUITE(TFtsTest);
diff --git a/util/folder/iterator.cpp b/util/folder/iterator.cpp
index 722238c67b..73703d31f9 100644
--- a/util/folder/iterator.cpp
+++ b/util/folder/iterator.cpp
@@ -6,6 +6,6 @@ static int SortFTSENTByName(const FTSENT** a, const FTSENT** b) {
return strcmp((*a)->fts_name, (*b)->fts_name);
}
-TDirIterator::TOptions& TDirIterator::TOptions::SetSortByName() noexcept {
+TDirIterator::TOptions& TDirIterator::TOptions::SetSortByName() noexcept {
return SetSortFunctor(SortFTSENTByName);
}
diff --git a/util/folder/iterator.h b/util/folder/iterator.h
index cce6aee8d4..69e025b9c4 100644
--- a/util/folder/iterator.h
+++ b/util/folder/iterator.h
@@ -11,7 +11,7 @@
class TDirIterator: public TInputRangeAdaptor<TDirIterator> {
struct TFtsDestroy {
- static inline void Destroy(FTS* f) noexcept {
+ static inline void Destroy(FTS* f) noexcept {
yfts_close(f);
}
};
@@ -36,33 +36,33 @@ public:
Init(opts);
}
- inline TOptions& SetMaxLevel(size_t level) noexcept {
+ inline TOptions& SetMaxLevel(size_t level) noexcept {
MaxLevel = level;
return *this;
}
- inline TOptions& SetSortFunctor(TCompare cmp) noexcept {
+ inline TOptions& SetSortFunctor(TCompare cmp) noexcept {
Cmp = cmp;
return *this;
}
- TOptions& SetSortByName() noexcept;
+ TOptions& SetSortByName() noexcept;
int FtsOptions;
size_t MaxLevel;
TCompare Cmp;
private:
- inline void Init(int opts) noexcept {
+ inline void Init(int opts) noexcept {
FtsOptions = opts | FTS_NOCHDIR;
MaxLevel = Max<size_t>();
Cmp = nullptr;
}
};
- inline TDirIterator(const TString& path, const TOptions& options = TOptions())
+ inline TDirIterator(const TString& path, const TOptions& options = TOptions())
: Options_(options)
, Path_(path)
{
@@ -103,7 +103,7 @@ public:
private:
TOptions Options_;
- TString Path_;
+ TString Path_;
char* Trees_[2];
THolder<FTS, TFtsDestroy> FileTree_;
};
diff --git a/util/folder/iterator_ut.cpp b/util/folder/iterator_ut.cpp
index 0cae693ef6..936becd139 100644
--- a/util/folder/iterator_ut.cpp
+++ b/util/folder/iterator_ut.cpp
@@ -9,7 +9,7 @@
#include <util/generic/algorithm.h>
#include <util/random/mersenne.h>
-static TString JoinWithNewline(const TVector<TString>& strings) {
+static TString JoinWithNewline(const TVector<TString>& strings) {
TStringStream ss;
for (const auto& string : strings) {
ss << string << "\n";
@@ -30,19 +30,19 @@ private:
class TDirHier {
public:
struct TPath {
- TString Path;
+ TString Path;
int Type;
};
- inline void AddFile(const TString& path) {
+ inline void AddFile(const TString& path) {
Add(path, 0);
}
- inline void AddDir(const TString& path) {
+ inline void AddDir(const TString& path) {
Add(path, 1);
}
- inline void Add(const TString& path, int type) {
+ inline void Add(const TString& path, int type) {
const TPath p = {
path, type};
@@ -67,15 +67,15 @@ private:
Srch_[path.Path] = path;
}
- inline int Type(const TString& path) {
- THashMap<TString, TPath>::const_iterator it = Srch_.find(path);
+ inline int Type(const TString& path) {
+ THashMap<TString, TPath>::const_iterator it = Srch_.find(path);
UNIT_ASSERT(it != Srch_.end());
return it->second.Type;
}
- inline bool Have(const TString& path, int type) {
+ inline bool Have(const TString& path, int type) {
return Type(path) == type;
}
@@ -86,12 +86,12 @@ private:
}
private:
- TVector<TPath> Paths_;
- THashMap<TString, TPath> Srch_;
+ TVector<TPath> Paths_;
+ THashMap<TString, TPath> Srch_;
};
inline void TestLocal() {
- TString dirname("." LOCSLASH_S);
+ TString dirname("." LOCSLASH_S);
TDirIterator d(dirname, FTS_NOCHDIR);
for (auto it = d.begin(); it != d.end(); ++it) {
}
@@ -100,26 +100,26 @@ private:
inline void TestIt() {
TDirHier hier;
- const TString dir = "tmpdir";
+ const TString dir = "tmpdir";
const TDirHier::TPath path = {dir, 1};
hier.Add(path);
for (size_t i = 0; i < 10; ++i) {
- const TString dir1 = dir + LOCSLASH_C + ToString(i);
+ const TString dir1 = dir + LOCSLASH_C + ToString(i);
const TDirHier::TPath path1 = {dir1, 1};
hier.Add(path1);
for (size_t j = 0; j < 10; ++j) {
- const TString subdir2 = ToString(j);
- const TString dir2 = dir1 + LOCSLASH_C + subdir2;
+ const TString subdir2 = ToString(j);
+ const TString dir2 = dir1 + LOCSLASH_C + subdir2;
const TDirHier::TPath path2 = {dir2, 1};
hier.Add(path2);
for (size_t k = 0; k < 3; ++k) {
- const TString file = dir2 + LOCSLASH_C + "file" + ToString(k);
+ const TString file = dir2 + LOCSLASH_C + "file" + ToString(k);
const TDirHier::TPath fpath = {file, 0};
hier.Add(fpath);
@@ -175,24 +175,24 @@ private:
inline void TestSort() {
TDirHier dh;
- const TString dir("tmpdir");
+ const TString dir("tmpdir");
//prepare fs
{
TMersenne<ui32> rnd;
- const TString prefixes[] = {
+ const TString prefixes[] = {
"a", "b", "xxx", "111", ""};
dh.AddDir(dir);
for (size_t i = 0; i < 100; ++i) {
- const TString fname = dir + LOCSLASH_C + prefixes[i % Y_ARRAY_SIZE(prefixes)] + ToString(rnd.GenRand());
+ const TString fname = dir + LOCSLASH_C + prefixes[i % Y_ARRAY_SIZE(prefixes)] + ToString(rnd.GenRand());
dh.AddFile(fname);
}
}
- TVector<TString> fnames;
+ TVector<TString> fnames;
{
TDirIterator d(dir, TDirIterator::TOptions().SetSortByName());
@@ -204,7 +204,7 @@ private:
}
}
- TVector<TString> sorted(fnames);
+ TVector<TString> sorted(fnames);
Sort(sorted.begin(), sorted.end());
UNIT_ASSERT_VALUES_EQUAL(JoinWithNewline(fnames), JoinWithNewline(sorted));
diff --git a/util/folder/path.cpp b/util/folder/path.cpp
index e239276067..bfe0c67d68 100644
--- a/util/folder/path.cpp
+++ b/util/folder/path.cpp
@@ -89,7 +89,7 @@ TFsPath TFsPath::RelativePath(const TFsPath& root) const {
if (cnt == 0 && !absboth) {
ythrow TIoException() << "No common parts in " << *this << " and " << root;
}
- TString r;
+ TString r;
for (size_t i = 0; i < rsplit.size() - cnt; i++) {
r += i == 0 ? ".." : "/..";
}
@@ -139,16 +139,16 @@ TFsPath& TFsPath::Fix() {
return *this;
}
-TString TFsPath::GetName() const {
+TString TFsPath::GetName() const {
if (!IsDefined()) {
- return TString();
+ return TString();
}
const TSplit& split = GetSplit();
if (split.size() > 0) {
if (split.back() != "..") {
- return TString(split.back());
+ return TString(split.back());
} else {
// cannot just drop last component, because path itself may be a symlink
return RealPath().GetName();
@@ -162,8 +162,8 @@ TString TFsPath::GetName() const {
}
}
-TString TFsPath::GetExtension() const {
- return TString(GetSplit().Extension());
+TString TFsPath::GetExtension() const {
+ return TString(GetSplit().Extension());
}
bool TFsPath::IsAbsolute() const {
@@ -193,7 +193,7 @@ static Y_FORCE_INLINE void VerifyPath(const TStringBuf path) {
TFsPath::TFsPath() {
}
-TFsPath::TFsPath(const TString& path)
+TFsPath::TFsPath(const TString& path)
: Path_(path)
{
VerifyPath(Path_);
@@ -210,7 +210,7 @@ TFsPath::TFsPath(const char* path)
{
}
-TFsPath TFsPath::Child(const TString& name) const {
+TFsPath TFsPath::Child(const TString& name) const {
if (!name) {
ythrow TIoException() << "child name must not be empty";
}
@@ -228,7 +228,7 @@ struct TClosedir {
}
};
-void TFsPath::ListNames(TVector<TString>& children) const {
+void TFsPath::ListNames(TVector<TString>& children) const {
CheckDefined();
THolder<DIR, TClosedir> dir(opendir(this->c_str()));
if (!dir) {
@@ -250,7 +250,7 @@ void TFsPath::ListNames(TVector<TString>& children) const {
if (ok == nullptr) {
return;
}
- TString name(de.d_name);
+ TString name(de.d_name);
if (name == "." || name == "..") {
continue;
}
@@ -275,15 +275,15 @@ bool TFsPath::Contains(const TString& component) const {
return false;
}
-void TFsPath::List(TVector<TFsPath>& files) const {
- TVector<TString> names;
+void TFsPath::List(TVector<TFsPath>& files) const {
+ TVector<TString> names;
ListNames(names);
for (auto& name : names) {
files.push_back(Child(name));
}
}
-void TFsPath::RenameTo(const TString& newPath) const {
+void TFsPath::RenameTo(const TString& newPath) const {
CheckDefined();
if (!newPath) {
ythrow TIoException() << "bad new file name";
@@ -294,7 +294,7 @@ void TFsPath::RenameTo(const TString& newPath) const {
}
void TFsPath::RenameTo(const char* newPath) const {
- RenameTo(TString(newPath));
+ RenameTo(TString(newPath));
}
void TFsPath::RenameTo(const TFsPath& newPath) const {
@@ -407,7 +407,7 @@ void TFsPath::ForceDelete() const {
ClearLastSystemError();
if (stat.IsDir()) {
- TVector<TFsPath> children;
+ TVector<TFsPath> children;
List(children);
for (auto& i : children) {
i.ForceDelete();
@@ -422,14 +422,14 @@ void TFsPath::ForceDelete() const {
}
}
-void TFsPath::CopyTo(const TString& newPath, bool force) const {
+void TFsPath::CopyTo(const TString& newPath, bool force) const {
if (IsDirectory()) {
if (force) {
TFsPath(newPath).MkDirs();
} else if (!TFsPath(newPath).IsDirectory()) {
ythrow TIoException() << "Target path is not a directory " << newPath;
}
- TVector<TFsPath> children;
+ TVector<TFsPath> children;
List(children);
for (auto&& i : children) {
i.CopyTo(newPath + "/" + i.GetName(), force);
@@ -449,7 +449,7 @@ void TFsPath::CopyTo(const TString& newPath, bool force) const {
}
}
-void TFsPath::ForceRenameTo(const TString& newPath) const {
+void TFsPath::ForceRenameTo(const TString& newPath) const {
try {
RenameTo(newPath);
} catch (const TIoSystemError& /* error */) {
diff --git a/util/folder/path.h b/util/folder/path.h
index 1c98714492..2fb4d6b4ef 100644
--- a/util/folder/path.h
+++ b/util/folder/path.h
@@ -5,7 +5,7 @@
#include <util/generic/ptr.h>
#include <util/generic/strbuf.h>
-#include <util/generic/string.h>
+#include <util/generic/string.h>
#include <util/generic/vector.h>
#include <util/string/cast.h>
#include <util/system/fstat.h>
@@ -25,7 +25,7 @@ private:
public:
TFsPath();
- TFsPath(const TString& path);
+ TFsPath(const TString& path);
TFsPath(const TStringBuf path);
TFsPath(const char* path);
@@ -48,7 +48,7 @@ public:
return Path_.c_str();
}
- inline operator const TString&() const {
+ inline operator const TString&() const {
return Path_;
}
@@ -71,19 +71,19 @@ public:
TFsPath& Fix();
- inline const TString& GetPath() const {
+ inline const TString& GetPath() const {
return Path_;
}
/// last component of path, or "/" if root
- TString GetName() const;
+ TString GetName() const;
/**
* "a.b.tmp" -> "tmp"
* "a.tmp" -> "tmp"
* ".tmp" -> ""
*/
- TString GetExtension() const;
+ TString GetExtension() const;
bool IsAbsolute() const;
bool IsRelative() const;
@@ -126,14 +126,14 @@ public:
*/
TFsPath Parent() const;
- TString Basename() const {
+ TString Basename() const {
return GetName();
}
- TString Dirname() const {
+ TString Dirname() const {
return Parent();
}
- TFsPath Child(const TString& name) const;
+ TFsPath Child(const TString& name) const;
/**
* @brief create this directory
@@ -152,8 +152,8 @@ public:
void MkDirs(const int mode = MODE0777) const;
// XXX: rewrite to return iterator
- void List(TVector<TFsPath>& children) const;
- void ListNames(TVector<TString>& children) const;
+ void List(TVector<TFsPath>& children) const;
+ void ListNames(TVector<TString>& children) const;
// Check, if path contains at least one component with a specific name.
bool Contains(const TString& component) const;
@@ -181,12 +181,12 @@ public:
/// throw TIoException if not exists
void CheckExists() const;
- void RenameTo(const TString& newPath) const;
+ void RenameTo(const TString& newPath) const;
void RenameTo(const char* newPath) const;
void RenameTo(const TFsPath& newFile) const;
- void ForceRenameTo(const TString& newPath) const;
+ void ForceRenameTo(const TString& newPath) const;
- void CopyTo(const TString& newPath, bool force) const;
+ void CopyTo(const TString& newPath, bool force) const;
void Touch() const;
@@ -197,7 +197,7 @@ public:
/// always absolute
static TFsPath Cwd();
- inline void Swap(TFsPath& p) noexcept {
+ inline void Swap(TFsPath& p) noexcept {
DoSwap(Path_, p.Path_);
Split_.Swap(p.Split_);
}
@@ -207,7 +207,7 @@ private:
TSplit& GetSplit() const;
private:
- TString Path_;
+ TString Path_;
/// cache
mutable TSimpleIntrusivePtr<TSplit> Split_;
};
@@ -224,7 +224,7 @@ namespace NPrivate {
}
template <class... Ts>
-TString JoinFsPaths(Ts&&... args) {
+TString JoinFsPaths(Ts&&... args) {
TFsPath fsPath;
::NPrivate::AppendToFsPath(fsPath, std::forward<Ts>(args)...);
return fsPath.GetPath();
diff --git a/util/folder/path_ut.cpp b/util/folder/path_ut.cpp
index 595e727f2c..e6a3451016 100644
--- a/util/folder/path_ut.cpp
+++ b/util/folder/path_ut.cpp
@@ -26,23 +26,23 @@ namespace {
TFsPath Path_;
public:
- TTestDirectory(const TString& name);
+ TTestDirectory(const TString& name);
~TTestDirectory();
TFsPath GetFsPath() const {
return Path_;
}
- TFsPath Child(const TString& name) const {
+ TFsPath Child(const TString& name) const {
return Path_.Child(name);
}
};
- TTestDirectory::TTestDirectory(const TString& name) {
+ TTestDirectory::TTestDirectory(const TString& name) {
Y_VERIFY(name.length() > 0, "have to specify name");
- Y_VERIFY(name.find('.') == TString::npos, "must be simple name");
- Y_VERIFY(name.find('/') == TString::npos, "must be simple name");
- Y_VERIFY(name.find('\\') == TString::npos, "must be simple name");
+ Y_VERIFY(name.find('.') == TString::npos, "must be simple name");
+ Y_VERIFY(name.find('/') == TString::npos, "must be simple name");
+ Y_VERIFY(name.find('\\') == TString::npos, "must be simple name");
Path_ = TFsPath(name);
Path_.ForceDelete();
@@ -119,13 +119,13 @@ Y_UNIT_TEST_SUITE(TFsPathTests) {
Y_UNIT_TEST(GetName) {
TTestDirectory d("GetName");
- UNIT_ASSERT_VALUES_EQUAL(TString("dfgh"), d.Child("dfgh").GetName());
+ UNIT_ASSERT_VALUES_EQUAL(TString("dfgh"), d.Child("dfgh").GetName());
// check does not fail
TFsPath(".").GetName();
#ifdef _unix_
- UNIT_ASSERT_VALUES_EQUAL(TString("/"), TFsPath("/").GetName());
+ UNIT_ASSERT_VALUES_EQUAL(TString("/"), TFsPath("/").GetName());
#endif
}
@@ -235,11 +235,11 @@ Y_UNIT_TEST_SUITE(TFsPathTests) {
dir.Child("c").MkDir();
dir.Child("d").Touch();
- TVector<TString> children;
+ TVector<TString> children;
dir.ListNames(children);
std::sort(children.begin(), children.end());
- TVector<TString> expected;
+ TVector<TString> expected;
expected.push_back("a");
expected.push_back("b");
expected.push_back("c");
@@ -430,16 +430,16 @@ Y_UNIT_TEST_SUITE(TFsPathTests) {
TTempDir tempDir;
TFsPath tempDirPath(tempDir());
- const TString originDir = tempDirPath.Child("origin");
+ const TString originDir = tempDirPath.Child("origin");
MakePathIfNotExist(originDir.c_str());
- const TString originFile = TFsPath(originDir).Child("data");
+ const TString originFile = TFsPath(originDir).Child("data");
{
- TFixedBufferFileOutput out(originFile);
+ TFixedBufferFileOutput out(originFile);
out << "data111!!!";
}
- const TString link = tempDirPath.Child("origin_symlink");
+ const TString link = tempDirPath.Child("origin_symlink");
NFs::SymLink(originDir, link);
TFsPath(link).ForceDelete();
@@ -453,16 +453,16 @@ Y_UNIT_TEST_SUITE(TFsPathTests) {
TTempDir tempDir;
TFsPath tempDirPath(tempDir());
- const TString originDir = tempDirPath.Child("origin");
+ const TString originDir = tempDirPath.Child("origin");
MakePathIfNotExist(originDir.c_str());
- const TString originFile = TFsPath(originDir).Child("data");
+ const TString originFile = TFsPath(originDir).Child("data");
{
- TFixedBufferFileOutput out(originFile);
+ TFixedBufferFileOutput out(originFile);
out << "data111!!!";
}
- const TString link = tempDirPath.Child("origin_symlink");
+ const TString link = tempDirPath.Child("origin_symlink");
NFs::SymLink(originFile, link);
TFsPath(link).ForceDelete();
@@ -476,19 +476,19 @@ Y_UNIT_TEST_SUITE(TFsPathTests) {
TTempDir tempDir;
TFsPath tempDirPath(tempDir());
- const TString symlinkedDir = tempDirPath.Child("to_remove");
+ const TString symlinkedDir = tempDirPath.Child("to_remove");
MakePathIfNotExist(symlinkedDir.c_str());
- const TString originDir = tempDirPath.Child("origin");
+ const TString originDir = tempDirPath.Child("origin");
MakePathIfNotExist(originDir.c_str());
- const TString originFile = TFsPath(originDir).Child("data");
+ const TString originFile = TFsPath(originDir).Child("data");
{
- TFixedBufferFileOutput out(originFile);
+ TFixedBufferFileOutput out(originFile);
out << "data111!!!";
}
- const TString symlinkedFile = TFsPath(symlinkedDir).Child("origin_symlink");
+ const TString symlinkedFile = TFsPath(symlinkedDir).Child("origin_symlink");
NFs::SymLink(originDir, symlinkedFile);
TFsPath(symlinkedDir).ForceDelete();
@@ -503,19 +503,19 @@ Y_UNIT_TEST_SUITE(TFsPathTests) {
TTempDir tempDir;
TFsPath tempDirPath(tempDir());
- const TString symlinkedDir = tempDirPath.Child("to_remove");
+ const TString symlinkedDir = tempDirPath.Child("to_remove");
MakePathIfNotExist(symlinkedDir.c_str());
- const TString originDir = tempDirPath.Child("origin");
+ const TString originDir = tempDirPath.Child("origin");
MakePathIfNotExist(originDir.c_str());
- const TString originFile = TFsPath(originDir).Child("data");
+ const TString originFile = TFsPath(originDir).Child("data");
{
- TFixedBufferFileOutput out(originFile);
+ TFixedBufferFileOutput out(originFile);
out << "data111!!!";
}
- const TString symlinkedFile = TFsPath(symlinkedDir).Child("origin_symlink");
+ const TString symlinkedFile = TFsPath(symlinkedDir).Child("origin_symlink");
NFs::SymLink(originFile, symlinkedFile);
TFsPath(symlinkedDir).ForceDelete();
diff --git a/util/folder/pathsplit.cpp b/util/folder/pathsplit.cpp
index 44a4810fef..81d439a727 100644
--- a/util/folder/pathsplit.cpp
+++ b/util/folder/pathsplit.cpp
@@ -85,8 +85,8 @@ void TPathSplitTraitsWindows::DoParsePart(const TStringBuf part0) {
}
}
-TString TPathSplitStore::DoReconstruct(const TStringBuf slash) const {
- TString r;
+TString TPathSplitStore::DoReconstruct(const TStringBuf slash) const {
+ TString r;
r.reserve(ToReserve(*this));
@@ -126,7 +126,7 @@ void Out<TPathSplit>(IOutputStream& o, const TPathSplit& ps) {
o << ps.Reconstruct();
}
-TString JoinPaths(const TPathSplit& p1, const TPathSplit& p2) {
+TString JoinPaths(const TPathSplit& p1, const TPathSplit& p2) {
if (p2.IsAbsolute) {
ythrow yexception() << "can not join " << p1 << " and " << p2;
}
diff --git a/util/folder/pathsplit.h b/util/folder/pathsplit.h
index af14c672d4..d134338e35 100644
--- a/util/folder/pathsplit.h
+++ b/util/folder/pathsplit.h
@@ -2,11 +2,11 @@
#include <util/generic/vector.h>
#include <util/generic/strbuf.h>
-#include <util/generic/string.h>
+#include <util/generic/string.h>
#include <util/string/ascii.h>
//do not own any data
-struct TPathSplitStore: public TVector<TStringBuf> {
+struct TPathSplitStore: public TVector<TStringBuf> {
TStringBuf Drive;
bool IsAbsolute = false;
@@ -14,7 +14,7 @@ struct TPathSplitStore: public TVector<TStringBuf> {
TStringBuf Extension() const;
protected:
- TString DoReconstruct(const TStringBuf slash) const;
+ TString DoReconstruct(const TStringBuf slash) const;
inline void DoAppendHint(size_t hint) {
reserve(size() + hint);
@@ -24,7 +24,7 @@ protected:
struct TPathSplitTraitsUnix: public TPathSplitStore {
static constexpr char MainPathSep = '/';
- inline TString Reconstruct() const {
+ inline TString Reconstruct() const {
return DoReconstruct(TStringBuf("/"));
}
@@ -43,7 +43,7 @@ struct TPathSplitTraitsUnix: public TPathSplitStore {
struct TPathSplitTraitsWindows: public TPathSplitStore {
static constexpr char MainPathSep = '\\';
- inline TString Reconstruct() const {
+ inline TString Reconstruct() const {
return DoReconstruct(TStringBuf("\\"));
}
@@ -108,6 +108,6 @@ using TPathSplit = TPathSplitBase<TPathSplitTraitsLocal>;
using TPathSplitUnix = TPathSplitBase<TPathSplitTraitsUnix>;
using TPathSplitWindows = TPathSplitBase<TPathSplitTraitsWindows>;
-TString JoinPaths(const TPathSplit& p1, const TPathSplit& p2);
+TString JoinPaths(const TPathSplit& p1, const TPathSplit& p2);
TStringBuf CutExtension(const TStringBuf fileName);
diff --git a/util/folder/tempdir.cpp b/util/folder/tempdir.cpp
index 6574a53009..6fdf8f753c 100644
--- a/util/folder/tempdir.cpp
+++ b/util/folder/tempdir.cpp
@@ -21,7 +21,7 @@ TTempDir::TTempDir(const char* prefix, TCreationToken)
TempDir = tempDir;
}
-TTempDir::TTempDir(const TString& tempDir)
+TTempDir::TTempDir(const TString& tempDir)
: TempDir(tempDir)
, Remove(true)
{
diff --git a/util/folder/tempdir.h b/util/folder/tempdir.h
index a6cac0cfc2..ff458f83b9 100644
--- a/util/folder/tempdir.h
+++ b/util/folder/tempdir.h
@@ -2,7 +2,7 @@
#include "fwd.h"
#include "path.h"
-#include <util/generic/string.h>
+#include <util/generic/string.h>
class TTempDir {
public:
@@ -10,18 +10,18 @@ public:
TTempDir();
/// Create new directory with this fixed name. If it already exists, clear it.
- TTempDir(const TString& tempDir);
+ TTempDir(const TString& tempDir);
~TTempDir();
/// Create new directory in given folder.
static TTempDir NewTempDir(const TString& root);
- const TString& operator()() const {
+ const TString& operator()() const {
return Name();
}
- const TString& Name() const {
+ const TString& Name() const {
return TempDir.GetPath();
}
diff --git a/util/generic/adaptor_ut.cpp b/util/generic/adaptor_ut.cpp
index 3ce6437add..721f849f93 100644
--- a/util/generic/adaptor_ut.cpp
+++ b/util/generic/adaptor_ut.cpp
@@ -34,8 +34,8 @@ struct TState {
Y_UNIT_TEST_SUITE(TReverseAdaptor) {
Y_UNIT_TEST(ReadTest) {
- TVector<int> cont = {1, 2, 3};
- TVector<int> etalon = {3, 2, 1};
+ TVector<int> cont = {1, 2, 3};
+ TVector<int> etalon = {3, 2, 1};
size_t idx = 0;
for (const auto& x : Reversed(cont)) {
UNIT_ASSERT_VALUES_EQUAL(etalon[idx++], x);
@@ -47,8 +47,8 @@ Y_UNIT_TEST_SUITE(TReverseAdaptor) {
}
Y_UNIT_TEST(WriteTest) {
- TVector<int> cont = {1, 2, 3};
- TVector<int> etalon = {3, 6, 9};
+ TVector<int> cont = {1, 2, 3};
+ TVector<int> etalon = {3, 6, 9};
size_t idx = 0;
for (auto& x : Reversed(cont)) {
x *= x + idx++;
@@ -60,7 +60,7 @@ Y_UNIT_TEST_SUITE(TReverseAdaptor) {
}
Y_UNIT_TEST(InnerTypeTest) {
- using TStub = TVector<int>;
+ using TStub = TVector<int>;
TStub stub;
const TStub cstub;
diff --git a/util/generic/algorithm.h b/util/generic/algorithm.h
index 12fd914c15..badfb88993 100644
--- a/util/generic/algorithm.h
+++ b/util/generic/algorithm.h
@@ -487,13 +487,13 @@ static inline Val InnerProduct(It1 begin1, It1 end1, It2 begin2, Val val, BinOp1
return std::inner_product(begin1, end1, begin2, val, binOp1, binOp2);
}
-template <typename TVectorType>
-static inline typename TVectorType::value_type InnerProduct(const TVectorType& lhs, const TVectorType& rhs, typename TVectorType::value_type val = typename TVectorType::value_type()) {
+template <typename TVectorType>
+static inline typename TVectorType::value_type InnerProduct(const TVectorType& lhs, const TVectorType& rhs, typename TVectorType::value_type val = typename TVectorType::value_type()) {
return std::inner_product(lhs.begin(), lhs.end(), rhs.begin(), val);
}
-template <typename TVectorType, typename BinOp1, typename BinOp2>
-static inline typename TVectorType::value_type InnerProduct(const TVectorType& lhs, const TVectorType& rhs, typename TVectorType::value_type val, BinOp1 binOp1, BinOp2 binOp2) {
+template <typename TVectorType, typename BinOp1, typename BinOp2>
+static inline typename TVectorType::value_type InnerProduct(const TVectorType& lhs, const TVectorType& rhs, typename TVectorType::value_type val, BinOp1 binOp1, BinOp2 binOp2) {
return std::inner_product(lhs.begin(), lhs.end(), rhs.begin(), val, binOp1, binOp2);
}
diff --git a/util/generic/algorithm_ut.cpp b/util/generic/algorithm_ut.cpp
index 45f35b7ca7..8d732fcc0c 100644
--- a/util/generic/algorithm_ut.cpp
+++ b/util/generic/algorithm_ut.cpp
@@ -2,7 +2,7 @@
#include "algorithm.h"
#include "strbuf.h"
-#include "string.h"
+#include "string.h"
static auto isOne = [](char c) { return c == '1'; };
@@ -59,7 +59,7 @@ Y_UNIT_TEST_SUITE(TAlgorithm) {
struct TStrokaNoCopy: TString {
public:
TStrokaNoCopy(const char* p)
- : TString(p)
+ : TString(p)
{
}
@@ -80,11 +80,11 @@ Y_UNIT_TEST_SUITE(TAlgorithm) {
UNIT_ASSERT_VALUES_EQUAL(CountOf(0x61, 'a', 'b', 'c', 0x61), 2);
UNIT_ASSERT_VALUES_EQUAL(CountOf(0x61, 'a', 'b', 'c', 0x61ll), 2);
- // TString and const char *
- UNIT_ASSERT_VALUES_EQUAL(CountOf(TString("xyz"), "123", "poi"), 0);
- UNIT_ASSERT_VALUES_EQUAL(CountOf(TString("xyz"), "123", "poi", "xyz"), 1);
+ // TString and const char *
+ UNIT_ASSERT_VALUES_EQUAL(CountOf(TString("xyz"), "123", "poi"), 0);
+ UNIT_ASSERT_VALUES_EQUAL(CountOf(TString("xyz"), "123", "poi", "xyz"), 1);
- // TString and TStringBuf
+ // TString and TStringBuf
UNIT_ASSERT_VALUES_EQUAL(CountOf(TString("xyz"), TStringBuf("123"), TStringBuf("poi")), 0);
UNIT_ASSERT_VALUES_EQUAL(CountOf(TString("xyz"), TStringBuf("123"), TStringBuf("poi"),
TStringBuf("xyz")),
@@ -94,10 +94,10 @@ Y_UNIT_TEST_SUITE(TAlgorithm) {
UNIT_ASSERT_VALUES_EQUAL(CountOf(TStringBuf("xyz"), "123", "poi"), 0);
UNIT_ASSERT_VALUES_EQUAL(CountOf(TStringBuf("xyz"), "123", "poi", "xyz"), 1);
- // TStringBuf and TString
+ // TStringBuf and TString
UNIT_ASSERT_VALUES_EQUAL(CountOf(TStringBuf("xyz"), TString("123"), TString("poi")), 0);
UNIT_ASSERT_VALUES_EQUAL(CountOf(TStringBuf("xyz"), TString("123"), TString("poi"),
- TString("xyz")),
+ TString("xyz")),
1);
}
@@ -221,7 +221,7 @@ Y_UNIT_TEST_SUITE(TAlgorithm) {
UNIT_ASSERT_EQUAL(2, FindIndex(array, 3));
UNIT_ASSERT_EQUAL(NPOS, FindIndex(array, 42));
- TVector<int> empty;
+ TVector<int> empty;
UNIT_ASSERT_EQUAL(NPOS, FindIndex(empty, 0));
}
@@ -249,33 +249,33 @@ Y_UNIT_TEST_SUITE(TAlgorithm) {
Y_UNIT_TEST(SortUniqueTest) {
{
- TVector<TString> v;
+ TVector<TString> v;
SortUnique(v);
- UNIT_ASSERT_EQUAL(v, TVector<TString>());
+ UNIT_ASSERT_EQUAL(v, TVector<TString>());
}
{
const char* ar[] = {"345", "3", "123", "2", "23", "3", "2"};
- TVector<TString> v(ar, ar + Y_ARRAY_SIZE(ar));
+ TVector<TString> v(ar, ar + Y_ARRAY_SIZE(ar));
SortUnique(v);
const char* suAr[] = {"123", "2", "23", "3", "345"};
- TVector<TString> suV(suAr, suAr + Y_ARRAY_SIZE(suAr));
+ TVector<TString> suV(suAr, suAr + Y_ARRAY_SIZE(suAr));
UNIT_ASSERT_EQUAL(v, suV);
}
}
Y_UNIT_TEST(EraseTest) {
- TVector<int> data = {5, 4, 3, 2, 1, 0};
- TVector<int> expected = {5, 4, 2, 1, 0};
+ TVector<int> data = {5, 4, 3, 2, 1, 0};
+ TVector<int> expected = {5, 4, 2, 1, 0};
Erase(data, 3);
UNIT_ASSERT_EQUAL(data, expected);
}
Y_UNIT_TEST(EraseIfTest) {
- TVector<int> data = {5, 4, 3, 2, 1, 0};
- TVector<int> expected = {2, 1, 0};
+ TVector<int> data = {5, 4, 3, 2, 1, 0};
+ TVector<int> expected = {2, 1, 0};
EraseIf(data, [](int i) { return i >= 3; });
UNIT_ASSERT_EQUAL(data, expected);
}
@@ -314,14 +314,14 @@ Y_UNIT_TEST_SUITE(TAlgorithm) {
Y_UNIT_TEST(NthElementTest) {
{
- TVector<TString> v;
+ TVector<TString> v;
NthElement(v.begin(), v.begin(), v.end());
- UNIT_ASSERT_EQUAL(v, TVector<TString>());
+ UNIT_ASSERT_EQUAL(v, TVector<TString>());
}
{
int data[] = {3, 2, 1, 4, 6, 5, 7, 9, 8};
- TVector<int> testVector(data, data + Y_ARRAY_SIZE(data));
+ TVector<int> testVector(data, data + Y_ARRAY_SIZE(data));
size_t medianInd = testVector.size() / 2;
@@ -334,7 +334,7 @@ Y_UNIT_TEST_SUITE(TAlgorithm) {
{
const char* data[] = {"3", "234", "1231", "333", "545345", "11", "111", "55", "66"};
- TVector<TString> testVector(data, data + Y_ARRAY_SIZE(data));
+ TVector<TString> testVector(data, data + Y_ARRAY_SIZE(data));
size_t medianInd = testVector.size() / 2;
NthElement(testVector.begin(), testVector.begin() + medianInd, testVector.end());
@@ -350,7 +350,7 @@ Y_UNIT_TEST_SUITE(TAlgorithm) {
Y_UNIT_TEST(BinarySearchTest) {
{
- TVector<TString> v;
+ TVector<TString> v;
bool test = BinarySearch(v.begin(), v.end(), "test");
UNIT_ASSERT_EQUAL(test, false);
}
@@ -366,7 +366,7 @@ Y_UNIT_TEST_SUITE(TAlgorithm) {
}
{
- TVector<size_t> data = {10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0};
+ TVector<size_t> data = {10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0};
bool test = BinarySearch(data.begin(), data.end(), (size_t)9, TGreater<size_t>());
UNIT_ASSERT_EQUAL(test, true);
@@ -381,8 +381,8 @@ Y_UNIT_TEST_SUITE(TAlgorithm) {
Y_UNIT_TEST(EqualRangeTest) {
{
- TVector<TString> v;
- using PairOfVector = std::pair<TVector<TString>::iterator, TVector<TString>::iterator>;
+ TVector<TString> v;
+ using PairOfVector = std::pair<TVector<TString>::iterator, TVector<TString>::iterator>;
PairOfVector tmp = EqualRange(v.begin(), v.end(), "tmp");
UNIT_ASSERT_EQUAL(tmp.first, tmp.second);
@@ -400,15 +400,15 @@ Y_UNIT_TEST_SUITE(TAlgorithm) {
}
{
- TVector<size_t> data = {9, 9, 8, 8, 8, 5, 4, 3, 3, 0, 0};
+ TVector<size_t> data = {9, 9, 8, 8, 8, 5, 4, 3, 3, 0, 0};
- using PairOfVector = std::pair<TVector<size_t>::iterator, TVector<size_t>::iterator>;
+ using PairOfVector = std::pair<TVector<size_t>::iterator, TVector<size_t>::iterator>;
PairOfVector tmp = EqualRange(data.begin(), data.end(), 8, TGreater<size_t>());
UNIT_ASSERT_EQUAL(tmp.first - data.begin(), 2);
UNIT_ASSERT_EQUAL(tmp.second - tmp.first, 3);
- using PairOfVectorReverse = std::pair<TVector<size_t>::reverse_iterator, TVector<size_t>::reverse_iterator>;
+ using PairOfVectorReverse = std::pair<TVector<size_t>::reverse_iterator, TVector<size_t>::reverse_iterator>;
PairOfVectorReverse tmpR = EqualRange(data.rbegin(), data.rend(), (size_t)0);
UNIT_ASSERT_EQUAL(tmpR.first, data.rbegin());
@@ -417,15 +417,15 @@ Y_UNIT_TEST_SUITE(TAlgorithm) {
}
Y_UNIT_TEST(IsSortedTest) {
- TVector<int> v0;
+ TVector<int> v0;
UNIT_ASSERT_VALUES_EQUAL(IsSorted(v0.begin(), v0.end()), true);
- TVector<int> v1 = {1, 2, 3, 4, 5, 5, 5, 6, 6, 7, 8};
+ TVector<int> v1 = {1, 2, 3, 4, 5, 5, 5, 6, 6, 7, 8};
UNIT_ASSERT_VALUES_EQUAL(IsSorted(v1.begin(), v1.end()), true);
UNIT_ASSERT_VALUES_EQUAL(IsSorted(v1.begin(), v1.end(), TLess<int>()), true);
UNIT_ASSERT_VALUES_EQUAL(IsSorted(v1.begin(), v1.end(), TGreater<int>()), false);
- TVector<int> v2 = {1, 2, 1};
+ TVector<int> v2 = {1, 2, 1};
UNIT_ASSERT_VALUES_EQUAL(IsSorted(v2.begin(), v2.end()), false);
UNIT_ASSERT_VALUES_EQUAL(IsSorted(v2.begin(), v2.end(), TLess<int>()), false);
UNIT_ASSERT_VALUES_EQUAL(IsSorted(v2.begin(), v2.end(), TGreater<int>()), false);
@@ -502,35 +502,35 @@ Y_UNIT_TEST_SUITE(TAlgorithm) {
}
Y_UNIT_TEST(SortByTest) {
- TVector<int> collection = {10, 2, 7};
+ TVector<int> collection = {10, 2, 7};
SortBy(collection, [](int x) { return -x; });
- TVector<int> expected = {10, 7, 2};
+ TVector<int> expected = {10, 7, 2};
UNIT_ASSERT_VALUES_EQUAL(collection, expected);
}
Y_UNIT_TEST(StableSortByTest) {
- TVector<int> collection = {404, 101, 106, 203, 102, 205, 401};
+ TVector<int> collection = {404, 101, 106, 203, 102, 205, 401};
StableSortBy(collection, [](int x) { return x / 100; });
- TVector<int> expected = {101, 106, 102, 203, 205, 404, 401};
+ TVector<int> expected = {101, 106, 102, 203, 205, 404, 401};
UNIT_ASSERT_VALUES_EQUAL(collection, expected);
}
Y_UNIT_TEST(SortUniqueByTest) {
- TVector<int> collection = {404, 101, 101, 203, 101, 203, 404};
+ TVector<int> collection = {404, 101, 101, 203, 101, 203, 404};
StableSortUniqueBy(collection, [](int x) { return x / 100; });
- TVector<int> expected = {101, 203, 404};
+ TVector<int> expected = {101, 203, 404};
UNIT_ASSERT_VALUES_EQUAL(collection, expected);
}
Y_UNIT_TEST(StableSortUniqueByTest) {
- TVector<int> collection = {404, 101, 106, 203, 102, 205, 401};
+ TVector<int> collection = {404, 101, 106, 203, 102, 205, 401};
StableSortUniqueBy(collection, [](int x) { return x / 100; });
- TVector<int> expected = {101, 203, 404};
+ TVector<int> expected = {101, 203, 404};
UNIT_ASSERT_VALUES_EQUAL(collection, expected);
}
Y_UNIT_TEST(IotaTest) {
- TVector<int> v(10);
+ TVector<int> v(10);
Iota(v.begin(), v.end(), 0);
UNIT_ASSERT_VALUES_EQUAL(v[0], 0);
@@ -546,10 +546,10 @@ Y_UNIT_TEST_SUITE(TAlgorithm) {
Y_UNIT_TEST(CopyNTest) {
int data[] = {1, 2, 3, 4, 8, 7, 6, 5};
const size_t vSize = 10;
- TVector<int> result(10, 0);
+ TVector<int> result(10, 0);
size_t toCopy = 5;
- TVector<int>::iterator iter = CopyN(data, toCopy, result.begin());
+ TVector<int>::iterator iter = CopyN(data, toCopy, result.begin());
UNIT_ASSERT_VALUES_EQUAL(iter - result.begin(), toCopy);
UNIT_ASSERT_VALUES_EQUAL(result.size(), 10);
for (size_t idx = 0; idx < toCopy; ++idx) {
@@ -579,9 +579,9 @@ Y_UNIT_TEST_SUITE(TAlgorithm) {
const size_t count = 9;
int data[] = {1, 2, 3, 4, 5, 6, 7, 8, 9};
const size_t vSize = 10;
- TVector<int> v(vSize, 0);
+ TVector<int> v(vSize, 0);
- TVector<int>::iterator iter = CopyIf(data, data + count, v.begin(), [](int x) { return !(x % 3); });
+ TVector<int>::iterator iter = CopyIf(data, data + count, v.begin(), [](int x) { return !(x % 3); });
UNIT_ASSERT_VALUES_EQUAL(v.size(), vSize);
UNIT_ASSERT_VALUES_EQUAL(iter - v.begin(), 3);
v.resize(iter - v.begin());
@@ -591,7 +591,7 @@ Y_UNIT_TEST_SUITE(TAlgorithm) {
}
Y_UNIT_TEST(MinMaxElementTest) {
- TVector<int> v(10);
+ TVector<int> v(10);
Iota(v.begin(), v.end(), 0);
UNIT_ASSERT_EQUAL(*MinMaxElement(v.begin(), v.end()).first, 0);
UNIT_ASSERT_EQUAL(*MinMaxElement(v.begin(), v.end()).second, 9);
@@ -607,9 +607,9 @@ Y_UNIT_TEST_SUITE(TAlgorithm) {
UNIT_ASSERT_EQUAL(p1.first, 5);
UNIT_ASSERT_EQUAL(p1.second, 12);
- std::pair<TString, TString> p2 = MinMax(TString("test"), TString("data"));
- UNIT_ASSERT_EQUAL(p2.first, TString("data"));
- UNIT_ASSERT_EQUAL(p2.second, TString("test"));
+ std::pair<TString, TString> p2 = MinMax(TString("test"), TString("data"));
+ UNIT_ASSERT_EQUAL(p2.first, TString("data"));
+ UNIT_ASSERT_EQUAL(p2.second, TString("test"));
}
Y_UNIT_TEST(TestMaxElementBy) {
@@ -618,7 +618,7 @@ Y_UNIT_TEST_SUITE(TAlgorithm) {
return x * x;
}), 5);
- const TVector<int> vec(array, array + Y_ARRAY_SIZE(array));
+ const TVector<int> vec(array, array + Y_ARRAY_SIZE(array));
UNIT_ASSERT_VALUES_EQUAL(*MaxElementBy(vec, [](int x) {
return -1.0 * x;
}), 1);
@@ -634,8 +634,8 @@ Y_UNIT_TEST_SUITE(TAlgorithm) {
auto singleElementSequence = {'z'};
UNIT_ASSERT_VALUES_EQUAL(*MaxElementBy(singleElementSequence, identity), 'z');
- const TString strings[] = {"one", "two", "three", "four"};
- UNIT_ASSERT_STRINGS_EQUAL(*MaxElementBy(strings, [](TString s) { return s.size(); }), "three");
+ const TString strings[] = {"one", "two", "three", "four"};
+ UNIT_ASSERT_STRINGS_EQUAL(*MaxElementBy(strings, [](TString s) { return s.size(); }), "three");
}
Y_UNIT_TEST(TestMinElementBy) {
@@ -644,7 +644,7 @@ Y_UNIT_TEST_SUITE(TAlgorithm) {
return 'a' + x;
}), 1);
- const TVector<int> vec(std::begin(array), std::end(array));
+ const TVector<int> vec(std::begin(array), std::end(array));
UNIT_ASSERT_VALUES_EQUAL(*MinElementBy(vec, [](int x) {
return -x;
}), 5);
@@ -660,7 +660,7 @@ Y_UNIT_TEST_SUITE(TAlgorithm) {
auto singleElementSequence = {'z'};
UNIT_ASSERT_VALUES_EQUAL(*MinElementBy(singleElementSequence, identity), 'z');
- const TVector<TStringBuf> strings = {"one", "two", "three", "four"};
+ const TVector<TStringBuf> strings = {"one", "two", "three", "four"};
auto stringLength = [](TStringBuf s) {
return s.size();
};
@@ -669,12 +669,12 @@ Y_UNIT_TEST_SUITE(TAlgorithm) {
}
Y_UNIT_TEST(MaxElementByReturnsEndForEmptyRange) {
- const TVector<int> empty;
+ const TVector<int> empty;
UNIT_ASSERT_EQUAL(MaxElementBy(empty, [](int) { return 0; }), empty.end());
}
Y_UNIT_TEST(MaxElementByDoesntCallFunctorForEmptyRange) {
- const TVector<int> empty;
+ const TVector<int> empty;
auto functor = [](int) {
UNIT_ASSERT(false);
return 0;
@@ -683,12 +683,12 @@ Y_UNIT_TEST_SUITE(TAlgorithm) {
}
Y_UNIT_TEST(MinElementByReturnsEndForEmptyRange) {
- const TVector<int> empty;
+ const TVector<int> empty;
UNIT_ASSERT_EQUAL(MinElementBy(empty, [](int) { return 0; }), empty.end());
}
Y_UNIT_TEST(MinElementByDoesntCallFunctorForEmptyRange) {
- const TVector<int> empty;
+ const TVector<int> empty;
auto functor = [](int) {
UNIT_ASSERT(false);
return 0;
@@ -764,7 +764,7 @@ Y_UNIT_TEST_SUITE(TAlgorithm) {
UNIT_ASSERT_EQUAL(FindIf(array, [](int x) { return x == 1; }), begin(array));
UNIT_ASSERT_EQUAL(FindIf(array, [](int x) { return x > 5; }), end(array));
- TVector<int> vector = {1, 2, 3, 4, 5};
+ TVector<int> vector = {1, 2, 3, 4, 5};
UNIT_ASSERT_EQUAL(FindIf(vector, [](int x) { return x == 1; }), begin(vector));
UNIT_ASSERT_EQUAL(FindIf(vector, [](int x) { return x > 5; }), end(vector));
@@ -773,7 +773,7 @@ Y_UNIT_TEST_SUITE(TAlgorithm) {
*iter = 5;
// Compilability test. Check if the returned iterator is const. Should not compile
- const TVector<int> constVector = {1, 2, 3, 4, 5};
+ const TVector<int> constVector = {1, 2, 3, 4, 5};
auto constIter = FindIf(constVector, [](int x) { return x == 1; });
Y_UNUSED(constIter);
// *constIter = 5;
@@ -798,7 +798,7 @@ Y_UNIT_TEST_SUITE(TAlgorithm) {
}
Y_UNIT_TEST(TestLowerBoundBy) {
- using TIntPairs = TVector<std::pair<i32, i32>>;
+ using TIntPairs = TVector<std::pair<i32, i32>>;
auto data = TIntPairs{{1, 5}, {3, 2}, {3, 4}, {8, 0}, {5, 4}};
auto getKey = [](const auto& x) { return x.second; };
@@ -818,7 +818,7 @@ Y_UNIT_TEST_SUITE(TAlgorithm) {
}
Y_UNIT_TEST(TestUpperBoundBy) {
- using TIntPairs = TVector<std::pair<i32, i32>>;
+ using TIntPairs = TVector<std::pair<i32, i32>>;
auto data = TIntPairs{{1, 5}, {3, 2}, {3, 4}, {8, 0}, {5, 4}};
auto getKey = [](const auto& x) { return x.second; };
diff --git a/util/generic/array_ref_ut.cpp b/util/generic/array_ref_ut.cpp
index a8588f65ec..4c8eaf7135 100644
--- a/util/generic/array_ref_ut.cpp
+++ b/util/generic/array_ref_ut.cpp
@@ -1,7 +1,7 @@
-#include "array_ref.h"
-
+#include "array_ref.h"
+
#include <library/cpp/testing/unittest/registar.h>
-
+
Y_UNIT_TEST_SUITE(TestArrayRef) {
Y_UNIT_TEST(TestDefaultConstructor) {
TArrayRef<int> defaulted;
@@ -65,10 +65,10 @@ Y_UNIT_TEST_SUITE(TestArrayRef) {
UNIT_ASSERT(iterator != r.end());
UNIT_ASSERT_VALUES_EQUAL(i, *iterator);
++iterator;
- }
+ }
UNIT_ASSERT(iterator == r.end());
}
-
+
Y_UNIT_TEST(TestReverseIterators) {
const int x[] = {1, 2, 3};
const TArrayRef<const int> rx{x};
@@ -80,8 +80,8 @@ Y_UNIT_TEST_SUITE(TestArrayRef) {
UNIT_ASSERT_VALUES_EQUAL(*i, 1);
++i;
UNIT_ASSERT_EQUAL(i, rx.crend());
- }
-
+ }
+
Y_UNIT_TEST(TestConstIterators) {
int x[] = {1, 2, 3};
TArrayRef<int> rx{x};
@@ -121,16 +121,16 @@ Y_UNIT_TEST_SUITE(TestArrayRef) {
Y_UNIT_TEST(TestCreatingFromStringLiteral) {
TConstArrayRef<char> knownSizeRef("123", 3);
- size_t ret = 0;
-
+ size_t ret = 0;
+
for (char ch : knownSizeRef) {
- ret += ch - '0';
- }
-
- UNIT_ASSERT_VALUES_EQUAL(ret, 6);
+ ret += ch - '0';
+ }
+
+ UNIT_ASSERT_VALUES_EQUAL(ret, 6);
UNIT_ASSERT_VALUES_EQUAL(knownSizeRef.size(), 3);
UNIT_ASSERT_VALUES_EQUAL(knownSizeRef.at(0), '1');
-
+
/*
* When TArrayRef is being constructed from string literal,
* trailing zero will be added into it.
@@ -138,7 +138,7 @@ Y_UNIT_TEST_SUITE(TestArrayRef) {
TConstArrayRef<char> autoSizeRef("456");
UNIT_ASSERT_VALUES_EQUAL(autoSizeRef[0], '4');
UNIT_ASSERT_VALUES_EQUAL(autoSizeRef[3], '\0');
- }
+ }
Y_UNIT_TEST(TestEqualityOperator) {
static constexpr size_t size = 5;
@@ -174,10 +174,10 @@ Y_UNIT_TEST_SUITE(TestArrayRef) {
auto fc = [](TArrayRef<const int>) {};
auto fm = [](TArrayRef<int>) {};
- fc(TVector<int>({1}));
+ fc(TVector<int>({1}));
- const TVector<int> ac = {1};
- TVector<int> am = {1};
+ const TVector<int> ac = {1};
+ TVector<int> am = {1};
fc(ac);
fc(am);
@@ -319,4 +319,4 @@ Y_UNIT_TEST_SUITE(TestArrayRef) {
const TVector<int> constData;
Foo(MakeConstArrayRef(constData));
}
-}
+}
diff --git a/util/generic/benchmark/fastclp2/main.cpp b/util/generic/benchmark/fastclp2/main.cpp
index bd01f97d23..49277db077 100644
--- a/util/generic/benchmark/fastclp2/main.cpp
+++ b/util/generic/benchmark/fastclp2/main.cpp
@@ -19,7 +19,7 @@ namespace {
}
}
- TVector<T> Examples;
+ TVector<T> Examples;
};
}
diff --git a/util/generic/benchmark/log2/main.cpp b/util/generic/benchmark/log2/main.cpp
index 61dcafa319..969f09a309 100644
--- a/util/generic/benchmark/log2/main.cpp
+++ b/util/generic/benchmark/log2/main.cpp
@@ -11,7 +11,7 @@
namespace {
template <typename T, size_t N>
struct TExamplesHolder {
- TVector<T> Examples;
+ TVector<T> Examples;
TExamplesHolder()
: Examples(N)
diff --git a/util/generic/benchmark/rotate_bits/main.cpp b/util/generic/benchmark/rotate_bits/main.cpp
index 31019f1508..057edbe864 100644
--- a/util/generic/benchmark/rotate_bits/main.cpp
+++ b/util/generic/benchmark/rotate_bits/main.cpp
@@ -25,7 +25,7 @@ namespace {
}
}
- TVector<TExample<T>> Examples;
+ TVector<TExample<T>> Examples;
};
}
diff --git a/util/generic/benchmark/sort/main.cpp b/util/generic/benchmark/sort/main.cpp
index fce7ef06ef..d58f491f4d 100644
--- a/util/generic/benchmark/sort/main.cpp
+++ b/util/generic/benchmark/sort/main.cpp
@@ -5,7 +5,7 @@
#include <util/generic/xrange.h>
Y_CPU_BENCHMARK(Sort1, iface) {
- TVector<int> x = {1};
+ TVector<int> x = {1};
for (const auto i : xrange(iface.Iterations())) {
Y_UNUSED(i);
@@ -14,7 +14,7 @@ Y_CPU_BENCHMARK(Sort1, iface) {
}
Y_CPU_BENCHMARK(Sort2, iface) {
- TVector<int> x = {2, 1};
+ TVector<int> x = {2, 1};
for (const auto i : xrange(iface.Iterations())) {
Y_UNUSED(i);
@@ -23,7 +23,7 @@ Y_CPU_BENCHMARK(Sort2, iface) {
}
Y_CPU_BENCHMARK(Sort4, iface) {
- TVector<int> x = {4, 3, 2, 1};
+ TVector<int> x = {4, 3, 2, 1};
for (const auto i : xrange(iface.Iterations())) {
Y_UNUSED(i);
@@ -32,7 +32,7 @@ Y_CPU_BENCHMARK(Sort4, iface) {
}
Y_CPU_BENCHMARK(Sort16, iface) {
- TVector<int> x = {16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1};
+ TVector<int> x = {16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1};
for (const auto i : xrange(iface.Iterations())) {
Y_UNUSED(i);
@@ -41,7 +41,7 @@ Y_CPU_BENCHMARK(Sort16, iface) {
}
Y_CPU_BENCHMARK(StableSort1, iface) {
- TVector<int> x = {1};
+ TVector<int> x = {1};
for (const auto i : xrange(iface.Iterations())) {
Y_UNUSED(i);
@@ -50,7 +50,7 @@ Y_CPU_BENCHMARK(StableSort1, iface) {
}
Y_CPU_BENCHMARK(StableSort2, iface) {
- TVector<int> x = {2, 1};
+ TVector<int> x = {2, 1};
for (const auto i : xrange(iface.Iterations())) {
Y_UNUSED(i);
@@ -59,7 +59,7 @@ Y_CPU_BENCHMARK(StableSort2, iface) {
}
Y_CPU_BENCHMARK(StableSort4, iface) {
- TVector<int> x = {4, 3, 2, 1};
+ TVector<int> x = {4, 3, 2, 1};
for (const auto i : xrange(iface.Iterations())) {
Y_UNUSED(i);
@@ -68,7 +68,7 @@ Y_CPU_BENCHMARK(StableSort4, iface) {
}
Y_CPU_BENCHMARK(StableSort16, iface) {
- TVector<int> x = {16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1};
+ TVector<int> x = {16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1};
for (const auto i : xrange(iface.Iterations())) {
Y_UNUSED(i);
diff --git a/util/generic/benchmark/vector_count_ctor/f.cpp b/util/generic/benchmark/vector_count_ctor/f.cpp
index f758faf808..b89e351ba7 100644
--- a/util/generic/benchmark/vector_count_ctor/f.cpp
+++ b/util/generic/benchmark/vector_count_ctor/f.cpp
@@ -8,7 +8,7 @@
void CreateYvector(const size_t size, const size_t count) {
for (size_t i = 0; i < count; ++i) {
NBench::Clobber();
- TVector<ui8> v(size);
+ TVector<ui8> v(size);
NBench::Escape(v.data());
NBench::Clobber();
}
diff --git a/util/generic/bitmap.h b/util/generic/bitmap.h
index ca82f88bc6..f77d182460 100644
--- a/util/generic/bitmap.h
+++ b/util/generic/bitmap.h
@@ -25,7 +25,7 @@ namespace NBitMapPrivate {
// better than intrinsics without -mpopcnt
template <typename T>
- static unsigned CountBitsPrivate(T v) noexcept {
+ static unsigned CountBitsPrivate(T v) noexcept {
return static_cast<unsigned>(ByteSums(v) >> 56);
}
diff --git a/util/generic/bitops.h b/util/generic/bitops.h
index 11d3b78f3d..2db15fc59b 100644
--- a/util/generic/bitops.h
+++ b/util/generic/bitops.h
@@ -14,7 +14,7 @@ namespace NBitOps {
namespace NPrivate {
template <unsigned N, typename T>
struct TClp2Helper {
- static Y_FORCE_INLINE T Calc(T t) noexcept {
+ static Y_FORCE_INLINE T Calc(T t) noexcept {
const T prev = TClp2Helper<N / 2, T>::Calc(t);
return prev | (prev >> N);
@@ -23,7 +23,7 @@ namespace NBitOps {
template <typename T>
struct TClp2Helper<0u, T> {
- static Y_FORCE_INLINE T Calc(T t) noexcept {
+ static Y_FORCE_INLINE T Calc(T t) noexcept {
return t - 1;
}
};
@@ -58,24 +58,24 @@ namespace NBitOps {
}
#if defined(__GNUC__)
- inline unsigned GetValueBitCountImpl(unsigned int value) noexcept {
+ inline unsigned GetValueBitCountImpl(unsigned int value) noexcept {
Y_ASSERT(value); // because __builtin_clz* have undefined result for zero.
return std::numeric_limits<unsigned int>::digits - __builtin_clz(value);
}
- inline unsigned GetValueBitCountImpl(unsigned long value) noexcept {
+ inline unsigned GetValueBitCountImpl(unsigned long value) noexcept {
Y_ASSERT(value); // because __builtin_clz* have undefined result for zero.
return std::numeric_limits<unsigned long>::digits - __builtin_clzl(value);
}
- inline unsigned GetValueBitCountImpl(unsigned long long value) noexcept {
+ inline unsigned GetValueBitCountImpl(unsigned long long value) noexcept {
Y_ASSERT(value); // because __builtin_clz* have undefined result for zero.
return std::numeric_limits<unsigned long long>::digits - __builtin_clzll(value);
}
#else
/// Stupid realization for non-GCC. Can use BSR from x86 instructions set.
template <typename T>
- inline unsigned GetValueBitCountImpl(T value) noexcept {
+ inline unsigned GetValueBitCountImpl(T value) noexcept {
Y_ASSERT(value); // because __builtin_clz* have undefined result for zero.
unsigned result = 1; // result == 0 - impossible value, see Y_ASSERT().
value >>= 1;
@@ -89,24 +89,24 @@ namespace NBitOps {
#endif
#if defined(__GNUC__)
- inline unsigned CountTrailingZeroBitsImpl(unsigned int value) noexcept {
+ inline unsigned CountTrailingZeroBitsImpl(unsigned int value) noexcept {
Y_ASSERT(value); // because __builtin_ctz* have undefined result for zero.
return __builtin_ctz(value);
}
- inline unsigned CountTrailingZeroBitsImpl(unsigned long value) noexcept {
+ inline unsigned CountTrailingZeroBitsImpl(unsigned long value) noexcept {
Y_ASSERT(value); // because __builtin_ctz* have undefined result for zero.
return __builtin_ctzl(value);
}
- inline unsigned CountTrailingZeroBitsImpl(unsigned long long value) noexcept {
+ inline unsigned CountTrailingZeroBitsImpl(unsigned long long value) noexcept {
Y_ASSERT(value); // because __builtin_ctz* have undefined result for zero.
return __builtin_ctzll(value);
}
#else
/// Stupid realization for non-GCC. Can use BSF from x86 instructions set.
template <typename T>
- inline unsigned CountTrailingZeroBitsImpl(T value) noexcept {
+ inline unsigned CountTrailingZeroBitsImpl(T value) noexcept {
Y_ASSERT(value); // because __builtin_ctz* have undefined result for zero.
unsigned result = 0;
while (!(value & 1)) {
@@ -206,7 +206,7 @@ namespace NBitOps {
* Result is undefined for `t == 0`.
*/
template <typename T>
-static inline T FastClp2(T t) noexcept {
+static inline T FastClp2(T t) noexcept {
Y_ASSERT(t > 0);
using TCvt = typename ::TUnsignedInts::template TSelectBy<TSizeOfPredicate<sizeof(T)>::template TResult>::type;
return 1 + ::NBitOps::NPrivate::TClp2Helper<sizeof(TCvt) * 4, T>::Calc(static_cast<TCvt>(t));
@@ -224,7 +224,7 @@ Y_CONST_FUNCTION constexpr bool IsPowerOf2(T v) noexcept {
* Returns the number of leading 0-bits in `value`, starting at the most significant bit position.
*/
template <typename T>
-static inline unsigned GetValueBitCount(T value) noexcept {
+static inline unsigned GetValueBitCount(T value) noexcept {
Y_ASSERT(value > 0);
using TCvt = typename ::TUnsignedInts::template TSelectBy<TSizeOfPredicate<sizeof(T)>::template TResult>::type;
return ::NBitOps::NPrivate::GetValueBitCountImpl(static_cast<TCvt>(value));
@@ -234,7 +234,7 @@ static inline unsigned GetValueBitCount(T value) noexcept {
* Returns the number of trailing 0-bits in `value`, starting at the least significant bit position
*/
template <typename T>
-static inline unsigned CountTrailingZeroBits(T value) noexcept {
+static inline unsigned CountTrailingZeroBits(T value) noexcept {
Y_ASSERT(value > 0);
using TCvt = typename ::TUnsignedInts::template TSelectBy<TSizeOfPredicate<sizeof(T)>::template TResult>::type;
return ::NBitOps::NPrivate::CountTrailingZeroBitsImpl(static_cast<TCvt>(value));
diff --git a/util/generic/bt_exception.h b/util/generic/bt_exception.h
index 12333e0c4b..018d2bc89a 100644
--- a/util/generic/bt_exception.h
+++ b/util/generic/bt_exception.h
@@ -15,7 +15,7 @@ public:
BT_.Capture();
}
- const TBackTrace* BackTrace() const noexcept override {
+ const TBackTrace* BackTrace() const noexcept override {
return &BT_;
}
diff --git a/util/generic/buffer.cpp b/util/generic/buffer.cpp
index 70f0539d04..b92697e1d0 100644
--- a/util/generic/buffer.cpp
+++ b/util/generic/buffer.cpp
@@ -89,11 +89,11 @@ void TBuffer::Realloc(size_t len) {
Len_ = len;
}
-TBuffer::~TBuffer() {
+TBuffer::~TBuffer() {
y_deallocate(Data_);
}
-void TBuffer::AsString(TString& s) {
+void TBuffer::AsString(TString& s) {
s.assign(Data(), Size());
Clear();
}
diff --git a/util/generic/buffer.h b/util/generic/buffer.h
index f2b29a61b6..9576467404 100644
--- a/util/generic/buffer.h
+++ b/util/generic/buffer.h
@@ -35,18 +35,18 @@ public:
return *this;
}
- ~TBuffer();
+ ~TBuffer();
- inline void Clear() noexcept {
+ inline void Clear() noexcept {
Pos_ = 0;
}
- inline void EraseBack(size_t n) noexcept {
+ inline void EraseBack(size_t n) noexcept {
Y_ASSERT(n <= Pos_);
Pos_ -= n;
}
- inline void Reset() noexcept {
+ inline void Reset() noexcept {
TBuffer().Swap(*this);
}
@@ -59,24 +59,24 @@ public:
Assign(b, e - b);
}
- inline char* Data() noexcept {
+ inline char* Data() noexcept {
return Data_;
}
- inline const char* Data() const noexcept {
+ inline const char* Data() const noexcept {
return Data_;
}
- inline char* Pos() noexcept {
+ inline char* Pos() noexcept {
return Data_ + Pos_;
}
- inline const char* Pos() const noexcept {
+ inline const char* Pos() const noexcept {
return Data_ + Pos_;
}
/// Used space in bytes (do not mix with Capacity!)
- inline size_t Size() const noexcept {
+ inline size_t Size() const noexcept {
return Pos_;
}
@@ -84,11 +84,11 @@ public:
return !Size();
}
- inline explicit operator bool() const noexcept {
+ inline explicit operator bool() const noexcept {
return Size();
}
- inline size_t Avail() const noexcept {
+ inline size_t Avail() const noexcept {
return Len_ - Pos_;
}
@@ -170,7 +170,7 @@ public:
Pos_ = len;
}
- inline size_t Capacity() const noexcept {
+ inline size_t Capacity() const noexcept {
return Len_;
}
@@ -193,7 +193,7 @@ public:
return Size();
}
- inline void Swap(TBuffer& r) noexcept {
+ inline void Swap(TBuffer& r) noexcept {
DoSwap(Data_, r.Data_);
DoSwap(Len_, r.Len_);
DoSwap(Pos_, r.Pos_);
@@ -202,24 +202,24 @@ public:
/*
* after this call buffer becomes empty
*/
- void AsString(TString& s);
+ void AsString(TString& s);
/*
* iterator-like interface
*/
- inline TIterator Begin() noexcept {
+ inline TIterator Begin() noexcept {
return Data();
}
- inline TIterator End() noexcept {
+ inline TIterator End() noexcept {
return Begin() + Size();
}
- inline TConstIterator Begin() const noexcept {
+ inline TConstIterator Begin() const noexcept {
return Data();
}
- inline TConstIterator End() const noexcept {
+ inline TConstIterator End() const noexcept {
return Begin() + Size();
}
diff --git a/util/generic/buffer_ut.cpp b/util/generic/buffer_ut.cpp
index ba4c2e94bb..437d7122ec 100644
--- a/util/generic/buffer_ut.cpp
+++ b/util/generic/buffer_ut.cpp
@@ -1,7 +1,7 @@
#include <library/cpp/testing/unittest/registar.h>
#include <util/system/datetime.h>
-#include "string.h"
+#include "string.h"
#include "vector.h"
#include "buffer.h"
@@ -21,7 +21,7 @@ Y_UNIT_TEST_SUITE(TBufferTest) {
const char data[] = "1234567890qwertyuiop";
TBuffer buf(13);
- TString str;
+ TString str;
for (size_t i = 0; i < 10; ++i) {
for (size_t j = 0; j < sizeof(data) - 1; ++j) {
@@ -91,11 +91,11 @@ Y_UNIT_TEST_SUITE(TBufferTest) {
buf.Append('a');
UNIT_ASSERT_EQUAL(buf.Capacity(), 256);
- TString tmp1 = "abcdef";
+ TString tmp1 = "abcdef";
buf.Append(tmp1.data(), tmp1.size());
UNIT_ASSERT_EQUAL(buf.Capacity(), 256);
- TString tmp2 = "30498290sfokdsflj2308w";
+ TString tmp2 = "30498290sfokdsflj2308w";
buf.Resize(1020);
buf.Append(tmp2.data(), tmp2.size());
UNIT_ASSERT_EQUAL(buf.Capacity(), 2048);
@@ -104,7 +104,7 @@ Y_UNIT_TEST_SUITE(TBufferTest) {
Y_UNIT_TEST(TestShrinkToFit) {
TBuffer buf;
- TString content = "some text";
+ TString content = "some text";
buf.Append(content.data(), content.size());
UNIT_ASSERT_EQUAL(buf.Size(), 9);
UNIT_ASSERT_EQUAL(buf.Capacity(), 16);
@@ -134,13 +134,13 @@ Y_UNIT_TEST(TestAlignUp) {
buf.AlignUp(4, '!');
UNIT_ASSERT(buf.Size() % 4 == 0);
- UNIT_ASSERT_VALUES_EQUAL(TString(~buf, +buf), "some text!!!");
+ UNIT_ASSERT_VALUES_EQUAL(TString(~buf, +buf), "some text!!!");
char addContent[] = "1234";
buf.Append(addContent, sizeof(addContent));
buf.AlignUp(4, 'X');
UNIT_ASSERT(buf.Size() % 4 == 0);
- UNIT_ASSERT_VALUES_EQUAL(TString(~buf, +buf), "some text!!!1234");
+ UNIT_ASSERT_VALUES_EQUAL(TString(~buf, +buf), "some text!!!1234");
}
#endif
@@ -164,7 +164,7 @@ Y_UNIT_TEST(TestSpeed) {
}
{
- TVector<char> buf;
+ TVector<char> buf;
t2 = MicroSeconds();
diff --git a/util/generic/cast.h b/util/generic/cast.h
index 792de22368..0d4a41f385 100644
--- a/util/generic/cast.h
+++ b/util/generic/cast.h
@@ -143,7 +143,7 @@ inline std::enable_if_t<!::NPrivate::TSafelyConvertible<TSmall, TLarge>::Result,
}
template <class TSmallInt, class TLargeInt>
-inline TSmallInt IntegerCast(TLargeInt largeInt) noexcept {
+inline TSmallInt IntegerCast(TLargeInt largeInt) noexcept {
try {
return SafeIntegerCast<TSmallInt>(largeInt);
} catch (const yexception& exc) {
diff --git a/util/generic/deque.h b/util/generic/deque.h
index b32beaca00..2dabaf3177 100644
--- a/util/generic/deque.h
+++ b/util/generic/deque.h
@@ -9,7 +9,7 @@
#include <initializer_list>
template <class T, class A>
-class TDeque: public std::deque<T, TReboundAllocator<A, T>> {
+class TDeque: public std::deque<T, TReboundAllocator<A, T>> {
using TBase = std::deque<T, TReboundAllocator<A, T>>;
public:
diff --git a/util/generic/deque_ut.cpp b/util/generic/deque_ut.cpp
index 1c522bc187..93bf50fa92 100644
--- a/util/generic/deque_ut.cpp
+++ b/util/generic/deque_ut.cpp
@@ -27,7 +27,7 @@ protected:
UNIT_TEST_SUITE_REGISTRATION(TDequeTest);
void TDequeTest::TestConstructorsAndAssignments() {
- using container = TDeque<int>;
+ using container = TDeque<int>;
container c1;
c1.push_back(100);
@@ -66,7 +66,7 @@ void TDequeTest::TestConstructorsAndAssignments() {
}
void TDequeTest::TestDeque1() {
- TDeque<int> d;
+ TDeque<int> d;
UNIT_ASSERT(!d);
d.push_back(4);
@@ -89,8 +89,8 @@ void TDequeTest::TestDeque1() {
UNIT_ASSERT(d[2] == 25);
//Some compile time tests:
- TDeque<int>::iterator dit = d.begin();
- TDeque<int>::const_iterator cdit(d.begin());
+ TDeque<int>::iterator dit = d.begin();
+ TDeque<int>::const_iterator cdit(d.begin());
UNIT_ASSERT((dit - cdit) == 0);
UNIT_ASSERT((cdit - dit) == 0);
@@ -100,14 +100,14 @@ void TDequeTest::TestDeque1() {
}
void TDequeTest::TestInsert() {
- TDeque<int> d;
+ TDeque<int> d;
d.push_back(0);
d.push_back(1);
d.push_back(2);
UNIT_ASSERT(d.size() == 3);
- TDeque<int>::iterator dit;
+ TDeque<int>::iterator dit;
//Insertion before begin:
dit = d.insert(d.begin(), 3);
@@ -177,8 +177,8 @@ void TDequeTest::TestInsert() {
}
void TDequeTest::TestAt() {
- TDeque<int> d;
- TDeque<int> const& cd = d;
+ TDeque<int> d;
+ TDeque<int> const& cd = d;
d.push_back(10);
UNIT_ASSERT(d.at(0) == 10);
@@ -197,12 +197,12 @@ void TDequeTest::TestAt() {
void TDequeTest::TestAutoRef() {
int i;
- TDeque<int> ref;
+ TDeque<int> ref;
for (i = 0; i < 5; ++i) {
ref.push_back(i);
}
- TDeque<TDeque<int>> d_d_int(1, ref);
+ TDeque<TDeque<int>> d_d_int(1, ref);
d_d_int.push_back(d_d_int[0]);
d_d_int.push_back(ref);
d_d_int.push_back(d_d_int[0]);
@@ -215,7 +215,7 @@ void TDequeTest::TestAutoRef() {
}
void TDequeTest::TestErase() {
- TDeque<int> dint;
+ TDeque<int> dint;
dint.push_back(3);
dint.push_front(2);
dint.push_back(4);
@@ -224,7 +224,7 @@ void TDequeTest::TestErase() {
dint.push_front(0);
dint.push_back(6);
- TDeque<int>::iterator it(dint.begin() + 1);
+ TDeque<int>::iterator it(dint.begin() + 1);
UNIT_ASSERT(*it == 1);
dint.erase(dint.begin());
diff --git a/util/generic/explicit_type_ut.cpp b/util/generic/explicit_type_ut.cpp
index f7cb501a35..50a745f090 100644
--- a/util/generic/explicit_type_ut.cpp
+++ b/util/generic/explicit_type_ut.cpp
@@ -17,7 +17,7 @@ public:
template <class T, class Arg>
struct TCallable: public TCallableBase {
enum {
- Result = sizeof(Test(std::declval<T>(), std::declval<Arg>(), 1)) == sizeof(TYes)
+ Result = sizeof(Test(std::declval<T>(), std::declval<Arg>(), 1)) == sizeof(TYes)
};
};
diff --git a/util/generic/fastqueue.h b/util/generic/fastqueue.h
index 461dd52af3..1fee5b86f6 100644
--- a/util/generic/fastqueue.h
+++ b/util/generic/fastqueue.h
@@ -35,7 +35,7 @@ public:
return tmp->Obj;
}
- inline size_t Size() const noexcept {
+ inline size_t Size() const noexcept {
return Size_;
}
@@ -43,7 +43,7 @@ public:
return !this->Size();
}
- inline explicit operator bool() const noexcept {
+ inline explicit operator bool() const noexcept {
return !this->Empty();
}
diff --git a/util/generic/flags_ut.cpp b/util/generic/flags_ut.cpp
index a87d9eb920..5377c6a058 100644
--- a/util/generic/flags_ut.cpp
+++ b/util/generic/flags_ut.cpp
@@ -93,7 +93,7 @@ Y_UNIT_TEST_SUITE(TFlagsTest) {
Y_UNIT_TEST(TestHash) {
ETest1 value0 = nullptr, value1 = Test1;
- THashMap<ETest1, int> hash;
+ THashMap<ETest1, int> hash;
hash[value0] = 0;
hash[value1] = 1;
diff --git a/util/generic/fuzz/vector/main.cpp b/util/generic/fuzz/vector/main.cpp
index ed7eb43ad8..0a0293f795 100644
--- a/util/generic/fuzz/vector/main.cpp
+++ b/util/generic/fuzz/vector/main.cpp
@@ -14,7 +14,7 @@ extern "C" int LLVMFuzzerTestOneInput(const ui8* data, size_t size) {
TMemoryInput mi(data, size);
try {
- TVector<ui16> v;
+ TVector<ui16> v;
while (mi.Avail()) {
char cmd = Read<char>(mi);
diff --git a/util/generic/fwd.h b/util/generic/fwd.h
index 7681b5df5c..5cc2da40e5 100644
--- a/util/generic/fwd.h
+++ b/util/generic/fwd.h
@@ -53,46 +53,46 @@ class TRbTree;
//containers
template <class T, class A = std::allocator<T>>
-class TVector;
+class TVector;
template <class T, class A = std::allocator<T>>
-class TDeque;
+class TDeque;
-template <class T, class S = TDeque<T>>
-class TQueue;
+template <class T, class S = TDeque<T>>
+class TQueue;
-template <class T, class S = TVector<T>, class C = TLess<T>>
-class TPriorityQueue;
+template <class T, class S = TVector<T>, class C = TLess<T>>
+class TPriorityQueue;
template <class Key, class T, class HashFcn = THash<Key>, class EqualKey = TEqualTo<Key>, class Alloc = std::allocator<Key>>
-class THashMap;
+class THashMap;
template <class Key, class T, class HashFcn = THash<Key>, class EqualKey = TEqualTo<Key>, class Alloc = std::allocator<Key>>
-class THashMultiMap;
+class THashMultiMap;
template <class Value, class HashFcn = THash<Value>, class EqualKey = TEqualTo<Value>, class Alloc = std::allocator<Value>>
-class THashSet;
+class THashSet;
template <class Value, class HashFcn = THash<Value>, class EqualKey = TEqualTo<Value>, class Alloc = std::allocator<Value>>
-class THashMultiSet;
+class THashMultiSet;
template <class T, class A = std::allocator<T>>
-class TList;
+class TList;
template <class K, class V, class Less = TLess<K>, class A = std::allocator<K>>
-class TMap;
+class TMap;
template <class K, class V, class Less = TLess<K>, class A = std::allocator<K>>
-class TMultiMap;
+class TMultiMap;
template <class K, class L = TLess<K>, class A = std::allocator<K>>
-class TSet;
+class TSet;
template <class K, class L = TLess<K>, class A = std::allocator<K>>
-class TMultiSet;
+class TMultiSet;
-template <class T, class S = TDeque<T>>
-class TStack;
+template <class T, class S = TDeque<T>>
+class TStack;
template <size_t BitCount, typename TChunkType = ui64>
class TBitMap;
diff --git a/util/generic/guid.cpp b/util/generic/guid.cpp
index e85bcb28ba..8b907457bc 100644
--- a/util/generic/guid.cpp
+++ b/util/generic/guid.cpp
@@ -1,6 +1,6 @@
#include "guid.h"
#include "ylimits.h"
-#include "string.h"
+#include "string.h"
#include <util/string/ascii.h>
#include <util/string/builder.h>
@@ -65,11 +65,11 @@ TGUID TGUID::CreateTimebased() {
return result;
}
-TString GetGuidAsString(const TGUID& g) {
+TString GetGuidAsString(const TGUID& g) {
return g.AsGuidString();
}
-TString CreateGuidAsString() {
+TString CreateGuidAsString() {
return TGUID::Create().AsGuidString();
}
diff --git a/util/generic/guid.h b/util/generic/guid.h
index 9212b3edb6..2bf6c8ad99 100644
--- a/util/generic/guid.h
+++ b/util/generic/guid.h
@@ -66,8 +66,8 @@ struct THash<TGUID> {
};
void CreateGuid(TGUID* res);
-TString GetGuidAsString(const TGUID& g);
-TString CreateGuidAsString();
+TString GetGuidAsString(const TGUID& g);
+TString CreateGuidAsString();
TGUID GetGuid(TStringBuf s);
bool GetGuid(TStringBuf s, TGUID& result);
diff --git a/util/generic/guid_ut.cpp b/util/generic/guid_ut.cpp
index 6b9118851f..048354ff39 100644
--- a/util/generic/guid_ut.cpp
+++ b/util/generic/guid_ut.cpp
@@ -17,7 +17,7 @@ Y_UNIT_TEST_SUITE(TGuidTest) {
struct TTest {
TGUID G;
- TString S;
+ TString S;
};
Y_UNIT_TEST(Test1) {
diff --git a/util/generic/hash.cpp b/util/generic/hash.cpp
index 96b3b13981..a674ee4538 100644
--- a/util/generic/hash.cpp
+++ b/util/generic/hash.cpp
@@ -3,9 +3,9 @@
#include <util/string/escape.h>
#include <util/string/cast.h>
-const void* const _yhashtable_empty_data[] = {(void*)3, nullptr, (void*)1};
+const void* const _yhashtable_empty_data[] = {(void*)3, nullptr, (void*)1};
-TString NPrivate::MapKeyToString(TStringBuf key) {
+TString NPrivate::MapKeyToString(TStringBuf key) {
constexpr size_t HASH_KEY_MAX_LENGTH = 500;
try {
return EscapeC(key.substr(0, HASH_KEY_MAX_LENGTH));
@@ -14,35 +14,35 @@ TString NPrivate::MapKeyToString(TStringBuf key) {
}
}
-TString NPrivate::MapKeyToString(unsigned short key) {
+TString NPrivate::MapKeyToString(unsigned short key) {
return ToString(key);
}
-TString NPrivate::MapKeyToString(short key) {
+TString NPrivate::MapKeyToString(short key) {
return ToString(key);
}
-TString NPrivate::MapKeyToString(unsigned int key) {
+TString NPrivate::MapKeyToString(unsigned int key) {
return ToString(key);
}
-TString NPrivate::MapKeyToString(int key) {
+TString NPrivate::MapKeyToString(int key) {
return ToString(key);
}
-TString NPrivate::MapKeyToString(unsigned long key) {
+TString NPrivate::MapKeyToString(unsigned long key) {
return ToString(key);
}
-TString NPrivate::MapKeyToString(long key) {
+TString NPrivate::MapKeyToString(long key) {
return ToString(key);
}
-TString NPrivate::MapKeyToString(unsigned long long key) {
+TString NPrivate::MapKeyToString(unsigned long long key) {
return ToString(key);
}
-TString NPrivate::MapKeyToString(long long key) {
+TString NPrivate::MapKeyToString(long long key) {
return ToString(key);
}
diff --git a/util/generic/hash.h b/util/generic/hash.h
index aa9981e9f1..e46db21fa9 100644
--- a/util/generic/hash.h
+++ b/util/generic/hash.h
@@ -29,40 +29,40 @@ struct TSelect1st {
};
template <class Value>
-struct __yhashtable_node {
+struct __yhashtable_node {
/** If the first bit is not set, then this is a pointer to the next node in
* the list of nodes for the current bucket. Otherwise this is a pointer of
- * type __yhashtable_node**, pointing back into the buckets array.
+ * type __yhashtable_node**, pointing back into the buckets array.
*
* This trick makes it possible to use only one node pointer in a hash table
* iterator. */
- __yhashtable_node* next;
+ __yhashtable_node* next;
/** Value stored in a node. */
Value val;
- __yhashtable_node& operator=(const __yhashtable_node&) = delete;
+ __yhashtable_node& operator=(const __yhashtable_node&) = delete;
};
template <class Value, class Key, class HashFcn,
class ExtractKey, class EqualKey, class Alloc>
-class THashTable;
+class THashTable;
template <class Key, class T, class HashFcn,
class EqualKey, typename size_type_f>
class sthash;
template <class Value>
-struct __yhashtable_iterator;
+struct __yhashtable_iterator;
template <class Value>
-struct __yhashtable_const_iterator;
+struct __yhashtable_const_iterator;
template <class Value>
-struct __yhashtable_iterator {
- using iterator = __yhashtable_iterator<Value>;
- using const_iterator = __yhashtable_const_iterator<Value>;
- using node = __yhashtable_node<Value>;
+struct __yhashtable_iterator {
+ using iterator = __yhashtable_iterator<Value>;
+ using const_iterator = __yhashtable_const_iterator<Value>;
+ using node = __yhashtable_node<Value>;
using iterator_category = std::forward_iterator_tag;
using value_type = Value;
@@ -73,7 +73,7 @@ struct __yhashtable_iterator {
node* cur;
- explicit __yhashtable_iterator(node* n)
+ explicit __yhashtable_iterator(node* n)
: cur(n)
{
} /*y*/
@@ -96,16 +96,16 @@ struct __yhashtable_iterator {
bool IsEnd() const {
return !cur;
}
- Y_FORCE_INLINE explicit operator bool() const noexcept {
+ Y_FORCE_INLINE explicit operator bool() const noexcept {
return cur != nullptr;
}
};
template <class Value>
-struct __yhashtable_const_iterator {
- using iterator = __yhashtable_iterator<Value>;
- using const_iterator = __yhashtable_const_iterator<Value>;
- using node = __yhashtable_node<Value>;
+struct __yhashtable_const_iterator {
+ using iterator = __yhashtable_iterator<Value>;
+ using const_iterator = __yhashtable_const_iterator<Value>;
+ using node = __yhashtable_node<Value>;
using iterator_category = std::forward_iterator_tag;
using value_type = Value;
@@ -116,13 +116,13 @@ struct __yhashtable_const_iterator {
const node* cur;
- explicit __yhashtable_const_iterator(const node* n)
+ explicit __yhashtable_const_iterator(const node* n)
: cur(n)
{
}
- __yhashtable_const_iterator() {
+ __yhashtable_const_iterator() {
}
- __yhashtable_const_iterator(const iterator& it)
+ __yhashtable_const_iterator(const iterator& it)
: cur(it.cur)
{
}
@@ -143,7 +143,7 @@ struct __yhashtable_const_iterator {
bool IsEnd() const {
return !cur;
}
- Y_FORCE_INLINE explicit operator bool() const noexcept {
+ Y_FORCE_INLINE explicit operator bool() const noexcept {
return cur != nullptr;
}
};
@@ -156,8 +156,8 @@ struct __yhashtable_const_iterator {
template <class Alloc>
class _allocator_base: private Alloc {
public:
- _allocator_base(const Alloc& other)
- : Alloc(other)
+ _allocator_base(const Alloc& other)
+ : Alloc(other)
{
}
@@ -177,12 +177,12 @@ public:
};
/**
- * Wrapper for an array of THashTable buckets.
+ * Wrapper for an array of THashTable buckets.
*
* Is better than vector for this particular use case. Main differences:
* - Occupies one less word on stack.
- * - Doesn't even try to initialize its elements. It is THashTable's responsibility.
- * - Presents a better interface in relation to THashTable's marker element trick.
+ * - Doesn't even try to initialize its elements. It is THashTable's responsibility.
+ * - Presents a better interface in relation to THashTable's marker element trick.
*
* Internally this class is just a pointer-size pair, and the data on the heap
* has the following structure:
@@ -197,13 +197,13 @@ public:
* `raw_size` stores the size of the allocated memory block. It is used to
* support resizing without reallocation.
*
- * `marker` is a special marker element that is set by the THashTable that is
+ * `marker` is a special marker element that is set by the THashTable that is
* then used in iterator implementation to know when the end is reached.
*
* Unused space at the end of the memory block may not be present.
*/
template <class T, class Alloc>
-class _yhashtable_buckets: private _allocator_base<Alloc> {
+class _yhashtable_buckets: private _allocator_base<Alloc> {
using base_type = _allocator_base<Alloc>;
static_assert(sizeof(T) == sizeof(size_t), "T is expected to be the same size as size_t.");
@@ -221,14 +221,14 @@ public:
using difference_type = ptrdiff_t;
using TBucketDivisor = ::NPrivate::THashDivisor;
- _yhashtable_buckets(const Alloc& other)
- : base_type(other)
+ _yhashtable_buckets(const Alloc& other)
+ : base_type(other)
, Data(nullptr)
, Size()
{
}
- ~_yhashtable_buckets() {
+ ~_yhashtable_buckets() {
Y_ASSERT(!Data);
}
@@ -318,7 +318,7 @@ public:
return *(Data + index);
}
- void swap(_yhashtable_buckets& other) {
+ void swap(_yhashtable_buckets& other) {
base_type::swap(other);
DoSwap(Data, other.Data);
DoSwap(Size, other.Size);
@@ -333,7 +333,7 @@ private:
};
/**
- * This class saves one word in THashTable for the most common use case of empty
+ * This class saves one word in THashTable for the most common use case of empty
* functors. The exact implementation picks a specialization with storage allocated
* for the functors if those are non-empty, and another specialization that creates
* functors on the fly if they are empty. It is expected that empty functors have
@@ -348,67 +348,67 @@ private:
* of the functors are empty as this is a case that's just way too rare.
*/
template <class HashFcn, class ExtractKey, class EqualKey, class Alloc, bool IsEmpty = std::is_empty<HashFcn>::value&& std::is_empty<ExtractKey>::value&& std::is_empty<EqualKey>::value>
-class _yhashtable_base: public _allocator_base<Alloc> {
+class _yhashtable_base: public _allocator_base<Alloc> {
using base_type = _allocator_base<Alloc>;
public:
- _yhashtable_base(const HashFcn& hash, const ExtractKey& extract, const EqualKey& equals, const Alloc& alloc)
+ _yhashtable_base(const HashFcn& hash, const ExtractKey& extract, const EqualKey& equals, const Alloc& alloc)
: base_type(alloc)
- , hash_(hash)
- , extract_(extract)
- , equals_(equals)
+ , hash_(hash)
+ , extract_(extract)
+ , equals_(equals)
{
}
const EqualKey& _get_key_eq() const {
- return equals_;
+ return equals_;
}
EqualKey& _get_key_eq() {
- return equals_;
+ return equals_;
}
void _set_key_eq(const EqualKey& equals) {
- this->equals_ = equals;
+ this->equals_ = equals;
}
const ExtractKey& _get_key_extract() const {
- return extract_;
+ return extract_;
}
ExtractKey& _get_key_extract() {
- return extract_;
+ return extract_;
}
void _set_key_extract(const ExtractKey& extract) {
- this->extract_ = extract;
+ this->extract_ = extract;
}
const HashFcn& _get_hash_fun() const {
- return hash_;
+ return hash_;
}
HashFcn& _get_hash_fun() {
- return hash_;
+ return hash_;
}
void _set_hash_fun(const HashFcn& hash) {
- this->hash_ = hash;
+ this->hash_ = hash;
}
- void swap(_yhashtable_base& other) {
+ void swap(_yhashtable_base& other) {
base_type::swap(other);
- DoSwap(equals_, other.equals_);
- DoSwap(extract_, other.extract_);
- DoSwap(hash_, other.hash_);
+ DoSwap(equals_, other.equals_);
+ DoSwap(extract_, other.extract_);
+ DoSwap(hash_, other.hash_);
}
private:
- HashFcn hash_;
- ExtractKey extract_;
- EqualKey equals_;
+ HashFcn hash_;
+ ExtractKey extract_;
+ EqualKey equals_;
};
template <class HashFcn, class ExtractKey, class EqualKey, class Alloc>
-class _yhashtable_base<HashFcn, ExtractKey, EqualKey, Alloc, true>: public _allocator_base<Alloc> {
+class _yhashtable_base<HashFcn, ExtractKey, EqualKey, Alloc, true>: public _allocator_base<Alloc> {
using base_type = _allocator_base<Alloc>;
public:
- _yhashtable_base(const HashFcn&, const ExtractKey&, const EqualKey&, const Alloc& alloc)
+ _yhashtable_base(const HashFcn&, const ExtractKey&, const EqualKey&, const Alloc& alloc)
: base_type(alloc)
{
}
@@ -431,30 +431,30 @@ public:
void _set_hash_fun(const HashFcn&) {
}
- void swap(_yhashtable_base& other) {
+ void swap(_yhashtable_base& other) {
base_type::swap(other);
}
};
template <class Value, class Key, class HashFcn, class ExtractKey, class EqualKey, class Alloc>
-struct _yhashtable_traits {
- using node = __yhashtable_node<Value>;
+struct _yhashtable_traits {
+ using node = __yhashtable_node<Value>;
using node_allocator_type = TReboundAllocator<Alloc, node>;
using nodep_allocator_type = TReboundAllocator<Alloc, node*>;
- using base_type = _yhashtable_base<HashFcn, ExtractKey, EqualKey, node_allocator_type>;
+ using base_type = _yhashtable_base<HashFcn, ExtractKey, EqualKey, node_allocator_type>;
};
-extern const void* const _yhashtable_empty_data[];
+extern const void* const _yhashtable_empty_data[];
template <class Value, class Key, class HashFcn, class ExtractKey, class EqualKey, class Alloc>
-class THashTable: private _yhashtable_traits<Value, Key, HashFcn, ExtractKey, EqualKey, Alloc>::base_type {
- using traits_type = _yhashtable_traits<Value, Key, HashFcn, ExtractKey, EqualKey, Alloc>;
+class THashTable: private _yhashtable_traits<Value, Key, HashFcn, ExtractKey, EqualKey, Alloc>::base_type {
+ using traits_type = _yhashtable_traits<Value, Key, HashFcn, ExtractKey, EqualKey, Alloc>;
using base_type = typename traits_type::base_type;
using node = typename traits_type::node;
using nodep_allocator_type = typename traits_type::nodep_allocator_type;
- using buckets_type = _yhashtable_buckets<node*, nodep_allocator_type>;
+ using buckets_type = _yhashtable_buckets<node*, nodep_allocator_type>;
using TBucketDivisor = ::NPrivate::THashDivisor;
public:
@@ -511,15 +511,15 @@ private:
size_type num_elements;
public:
- using iterator = __yhashtable_iterator<Value>;
- using const_iterator = __yhashtable_const_iterator<Value>;
+ using iterator = __yhashtable_iterator<Value>;
+ using const_iterator = __yhashtable_const_iterator<Value>;
using insert_ctx = node**;
- friend struct __yhashtable_iterator<Value>;
- friend struct __yhashtable_const_iterator<Value>;
+ friend struct __yhashtable_iterator<Value>;
+ friend struct __yhashtable_const_iterator<Value>;
public:
- THashTable()
+ THashTable()
: base_type(HashFcn(), ExtractKey(), EqualKey(), node_allocator_type())
, buckets(nodep_allocator_type())
, num_elements(0)
@@ -527,7 +527,7 @@ public:
initialize_buckets(buckets, 0);
}
- THashTable(size_type n, const HashFcn& hf, const EqualKey& eql, const ExtractKey& ext)
+ THashTable(size_type n, const HashFcn& hf, const EqualKey& eql, const ExtractKey& ext)
: base_type(hf, ext, eql, node_allocator_type())
, buckets(nodep_allocator_type())
, num_elements(0)
@@ -535,7 +535,7 @@ public:
initialize_buckets(buckets, n);
}
- THashTable(size_type n, const HashFcn& hf, const EqualKey& eql)
+ THashTable(size_type n, const HashFcn& hf, const EqualKey& eql)
: base_type(hf, ExtractKey(), eql, node_allocator_type())
, buckets(nodep_allocator_type())
, num_elements(0)
@@ -544,7 +544,7 @@ public:
}
template <class TAllocParam>
- THashTable(size_type n, const HashFcn& hf, const EqualKey& eql, TAllocParam* allocParam)
+ THashTable(size_type n, const HashFcn& hf, const EqualKey& eql, TAllocParam* allocParam)
: base_type(hf, ExtractKey(), eql, allocParam)
, buckets(allocParam)
, num_elements(0)
@@ -552,7 +552,7 @@ public:
initialize_buckets(buckets, n);
}
- THashTable(const THashTable& ht)
+ THashTable(const THashTable& ht)
: base_type(ht._get_hash_fun(), ht._get_key_extract(), ht._get_key_eq(), ht._get_alloc())
, buckets(ht.buckets.get_allocator())
, num_elements(0)
@@ -565,7 +565,7 @@ public:
}
}
- THashTable(THashTable&& ht) noexcept
+ THashTable(THashTable&& ht) noexcept
: base_type(ht._get_hash_fun(), ht._get_key_extract(), ht._get_key_eq(), ht._get_alloc())
, buckets(ht.buckets.get_allocator())
, num_elements(0)
@@ -574,7 +574,7 @@ public:
this->swap(ht);
}
- THashTable& operator=(const THashTable& ht) {
+ THashTable& operator=(const THashTable& ht) {
if (&ht != this) {
basic_clear();
this->_set_hash_fun(ht._get_hash_fun());
@@ -603,14 +603,14 @@ public:
return *this;
}
- THashTable& operator=(THashTable&& ht) noexcept {
+ THashTable& operator=(THashTable&& ht) noexcept {
basic_clear();
swap(ht);
return *this;
}
- ~THashTable() {
+ ~THashTable() {
basic_clear();
deinitialize_buckets(buckets);
}
@@ -626,7 +626,7 @@ public:
return size() == 0;
}
- void swap(THashTable& ht) {
+ void swap(THashTable& ht) {
base_type::swap(ht);
buckets.swap(ht.buckets);
DoSwap(num_elements, ht.num_elements);
@@ -857,7 +857,7 @@ public:
* Clears the hashtable and tries to reasonably downsize it. Note that
* downsizing is mainly for the following use case:
*
- * THashTable hash;
+ * THashTable hash;
* for(...) {
* if (someCond())
* hash.clear();
@@ -951,11 +951,11 @@ private:
void erase_bucket(const size_type n, node* first, node* last);
void erase_bucket(const size_type n, node* last);
- void copy_from_dynamic(const THashTable& ht);
+ void copy_from_dynamic(const THashTable& ht);
};
template <class V>
-__yhashtable_iterator<V>& __yhashtable_iterator<V>::operator++() {
+__yhashtable_iterator<V>& __yhashtable_iterator<V>::operator++() {
Y_ASSERT(cur);
cur = cur->next;
if ((uintptr_t)cur & 1) {
@@ -969,14 +969,14 @@ __yhashtable_iterator<V>& __yhashtable_iterator<V>::operator++() {
}
template <class V>
-inline __yhashtable_iterator<V> __yhashtable_iterator<V>::operator++(int) {
+inline __yhashtable_iterator<V> __yhashtable_iterator<V>::operator++(int) {
iterator tmp = *this;
++*this;
return tmp;
}
template <class V>
-__yhashtable_const_iterator<V>& __yhashtable_const_iterator<V>::operator++() {
+__yhashtable_const_iterator<V>& __yhashtable_const_iterator<V>::operator++() {
Y_ASSERT(cur);
cur = cur->next;
if ((uintptr_t)cur & 1) {
@@ -990,7 +990,7 @@ __yhashtable_const_iterator<V>& __yhashtable_const_iterator<V>::operator++() {
}
template <class V>
-inline __yhashtable_const_iterator<V> __yhashtable_const_iterator<V>::operator++(int) {
+inline __yhashtable_const_iterator<V> __yhashtable_const_iterator<V>::operator++(int) {
const_iterator tmp = *this;
++*this;
return tmp;
@@ -998,7 +998,7 @@ inline __yhashtable_const_iterator<V> __yhashtable_const_iterator<V>::operator++
template <class V, class K, class HF, class Ex, class Eq, class A>
template <typename... Args>
-std::pair<typename THashTable<V, K, HF, Ex, Eq, A>::iterator, bool> THashTable<V, K, HF, Ex, Eq, A>::emplace_unique_noresize(Args&&... args) {
+std::pair<typename THashTable<V, K, HF, Ex, Eq, A>::iterator, bool> THashTable<V, K, HF, Ex, Eq, A>::emplace_unique_noresize(Args&&... args) {
auto deleter = [&](node* tmp) { delete_node(tmp); };
node* tmp = new_node(std::forward<Args>(args)...);
std::unique_ptr<node, decltype(deleter)> guard(tmp, deleter);
@@ -1020,7 +1020,7 @@ std::pair<typename THashTable<V, K, HF, Ex, Eq, A>::iterator, bool> THashTable<V
template <class V, class K, class HF, class Ex, class Eq, class A>
template <class OtherValue>
-std::pair<typename THashTable<V, K, HF, Ex, Eq, A>::iterator, bool> THashTable<V, K, HF, Ex, Eq, A>::insert_unique_noresize(const OtherValue& obj) {
+std::pair<typename THashTable<V, K, HF, Ex, Eq, A>::iterator, bool> THashTable<V, K, HF, Ex, Eq, A>::insert_unique_noresize(const OtherValue& obj) {
const size_type n = bkt_num(obj);
node* first = buckets[n];
@@ -1038,7 +1038,7 @@ std::pair<typename THashTable<V, K, HF, Ex, Eq, A>::iterator, bool> THashTable<V
template <class V, class K, class HF, class Ex, class Eq, class A>
template <typename... Args>
-__yhashtable_iterator<V> THashTable<V, K, HF, Ex, Eq, A>::emplace_equal_noresize(Args&&... args) {
+__yhashtable_iterator<V> THashTable<V, K, HF, Ex, Eq, A>::emplace_equal_noresize(Args&&... args) {
auto deleter = [&](node* tmp) { delete_node(tmp); };
node* tmp = new_node(std::forward<Args>(args)...);
std::unique_ptr<node, decltype(deleter)> guard(tmp, deleter);
@@ -1064,7 +1064,7 @@ __yhashtable_iterator<V> THashTable<V, K, HF, Ex, Eq, A>::emplace_equal_noresize
template <class V, class K, class HF, class Ex, class Eq, class A>
template <class OtherValue>
-typename THashTable<V, K, HF, Ex, Eq, A>::reference THashTable<V, K, HF, Ex, Eq, A>::find_or_insert(const OtherValue& v) {
+typename THashTable<V, K, HF, Ex, Eq, A>::reference THashTable<V, K, HF, Ex, Eq, A>::find_or_insert(const OtherValue& v) {
reserve(num_elements + 1);
size_type n = bkt_num_key(get_key(v));
@@ -1084,7 +1084,7 @@ typename THashTable<V, K, HF, Ex, Eq, A>::reference THashTable<V, K, HF, Ex, Eq,
template <class V, class K, class HF, class Ex, class Eq, class A>
template <class OtherKey>
-__yhashtable_iterator<V> THashTable<V, K, HF, Ex, Eq, A>::find_i(const OtherKey& key, insert_ctx& ins) {
+__yhashtable_iterator<V> THashTable<V, K, HF, Ex, Eq, A>::find_i(const OtherKey& key, insert_ctx& ins) {
size_type n = bkt_num_key(key);
ins = &buckets[n];
node* first = buckets[n];
@@ -1098,7 +1098,7 @@ __yhashtable_iterator<V> THashTable<V, K, HF, Ex, Eq, A>::find_i(const OtherKey&
template <class V, class K, class HF, class Ex, class Eq, class A>
template <class OtherKey>
-std::pair<__yhashtable_iterator<V>, __yhashtable_iterator<V>> THashTable<V, K, HF, Ex, Eq, A>::equal_range(const OtherKey& key) {
+std::pair<__yhashtable_iterator<V>, __yhashtable_iterator<V>> THashTable<V, K, HF, Ex, Eq, A>::equal_range(const OtherKey& key) {
using pii = std::pair<iterator, iterator>;
const size_type n = bkt_num_key(key);
node* first = buckets[n];
@@ -1121,7 +1121,7 @@ std::pair<__yhashtable_iterator<V>, __yhashtable_iterator<V>> THashTable<V, K, H
template <class V, class K, class HF, class Ex, class Eq, class A>
template <class OtherKey>
-std::pair<__yhashtable_const_iterator<V>, __yhashtable_const_iterator<V>> THashTable<V, K, HF, Ex, Eq, A>::equal_range(const OtherKey& key) const {
+std::pair<__yhashtable_const_iterator<V>, __yhashtable_const_iterator<V>> THashTable<V, K, HF, Ex, Eq, A>::equal_range(const OtherKey& key) const {
using pii = std::pair<const_iterator, const_iterator>;
const size_type n = bkt_num_key(key);
const node* first = buckets[n];
@@ -1145,7 +1145,7 @@ std::pair<__yhashtable_const_iterator<V>, __yhashtable_const_iterator<V>> THashT
template <class V, class K, class HF, class Ex, class Eq, class A>
template <class OtherKey>
-typename THashTable<V, K, HF, Ex, Eq, A>::size_type THashTable<V, K, HF, Ex, Eq, A>::erase(const OtherKey& key) {
+typename THashTable<V, K, HF, Ex, Eq, A>::size_type THashTable<V, K, HF, Ex, Eq, A>::erase(const OtherKey& key) {
const size_type n = bkt_num_key(key);
node* first = buckets[n];
size_type erased = 0;
@@ -1177,7 +1177,7 @@ typename THashTable<V, K, HF, Ex, Eq, A>::size_type THashTable<V, K, HF, Ex, Eq,
template <class V, class K, class HF, class Ex, class Eq, class A>
template <class OtherKey>
-typename THashTable<V, K, HF, Ex, Eq, A>::size_type THashTable<V, K, HF, Ex, Eq, A>::erase_one(const OtherKey& key) {
+typename THashTable<V, K, HF, Ex, Eq, A>::size_type THashTable<V, K, HF, Ex, Eq, A>::erase_one(const OtherKey& key) {
const size_type n = bkt_num_key(key);
node* first = buckets[n];
@@ -1206,7 +1206,7 @@ typename THashTable<V, K, HF, Ex, Eq, A>::size_type THashTable<V, K, HF, Ex, Eq,
}
template <class V, class K, class HF, class Ex, class Eq, class A>
-void THashTable<V, K, HF, Ex, Eq, A>::erase(const iterator& it) {
+void THashTable<V, K, HF, Ex, Eq, A>::erase(const iterator& it) {
if (node* const p = it.cur) {
const size_type n = bkt_num(p->val);
node* cur = buckets[n];
@@ -1233,7 +1233,7 @@ void THashTable<V, K, HF, Ex, Eq, A>::erase(const iterator& it) {
}
template <class V, class K, class HF, class Ex, class Eq, class A>
-void THashTable<V, K, HF, Ex, Eq, A>::erase(iterator first, iterator last) {
+void THashTable<V, K, HF, Ex, Eq, A>::erase(iterator first, iterator last) {
size_type f_bucket = first.cur ? bkt_num(first.cur->val) : buckets.size(); /*y*/
size_type l_bucket = last.cur ? bkt_num(last.cur->val) : buckets.size(); /*y*/
@@ -1252,22 +1252,22 @@ void THashTable<V, K, HF, Ex, Eq, A>::erase(iterator first, iterator last) {
template <class V, class K, class HF, class Ex, class Eq, class A>
inline void
-THashTable<V, K, HF, Ex, Eq, A>::erase(const_iterator first, const_iterator last) {
+THashTable<V, K, HF, Ex, Eq, A>::erase(const_iterator first, const_iterator last) {
erase(iterator(const_cast<node*>(first.cur)), iterator(const_cast<node*>(last.cur)));
}
template <class V, class K, class HF, class Ex, class Eq, class A>
-inline void THashTable<V, K, HF, Ex, Eq, A>::erase(const const_iterator& it) {
+inline void THashTable<V, K, HF, Ex, Eq, A>::erase(const const_iterator& it) {
erase(iterator(const_cast<node*>(it.cur)));
}
template <class V, class K, class HF, class Ex, class Eq, class A>
-bool THashTable<V, K, HF, Ex, Eq, A>::reserve(size_type num_elements_hint) {
+bool THashTable<V, K, HF, Ex, Eq, A>::reserve(size_type num_elements_hint) {
const size_type old_n = buckets.size(); /*y*/
if (num_elements_hint + 1 > old_n) {
- if (old_n != 1 && num_elements_hint <= old_n) // TODO: this if is for backwards compatibility down to order-in-buckets level. Can be safely removed.
- return false;
-
+ if (old_n != 1 && num_elements_hint <= old_n) // TODO: this if is for backwards compatibility down to order-in-buckets level. Can be safely removed.
+ return false;
+
const TBucketDivisor n = HashBucketCountExt(num_elements_hint + 1, buckets.BucketDivisorHint() + 1);
if (n() > old_n) {
buckets_type tmp(buckets.get_allocator());
@@ -1311,7 +1311,7 @@ bool THashTable<V, K, HF, Ex, Eq, A>::reserve(size_type num_elements_hint) {
}
template <class V, class K, class HF, class Ex, class Eq, class A>
-void THashTable<V, K, HF, Ex, Eq, A>::erase_bucket(const size_type n, node* first, node* last) {
+void THashTable<V, K, HF, Ex, Eq, A>::erase_bucket(const size_type n, node* first, node* last) {
node* cur = buckets[n];
if (cur == first)
erase_bucket(n, last);
@@ -1329,7 +1329,7 @@ void THashTable<V, K, HF, Ex, Eq, A>::erase_bucket(const size_type n, node* firs
}
template <class V, class K, class HF, class Ex, class Eq, class A>
-void THashTable<V, K, HF, Ex, Eq, A>::erase_bucket(const size_type n, node* last) {
+void THashTable<V, K, HF, Ex, Eq, A>::erase_bucket(const size_type n, node* last) {
node* cur = buckets[n];
while (cur != last) {
node* next = cur->next;
@@ -1341,7 +1341,7 @@ void THashTable<V, K, HF, Ex, Eq, A>::erase_bucket(const size_type n, node* last
}
template <class V, class K, class HF, class Ex, class Eq, class A>
-void THashTable<V, K, HF, Ex, Eq, A>::basic_clear() {
+void THashTable<V, K, HF, Ex, Eq, A>::basic_clear() {
if (!num_elements) {
return;
}
@@ -1363,7 +1363,7 @@ void THashTable<V, K, HF, Ex, Eq, A>::basic_clear() {
}
template <class V, class K, class HF, class Ex, class Eq, class A>
-void THashTable<V, K, HF, Ex, Eq, A>::copy_from_dynamic(const THashTable& ht) {
+void THashTable<V, K, HF, Ex, Eq, A>::copy_from_dynamic(const THashTable& ht) {
Y_ASSERT(buckets.size() == ht.buckets.size() && !ht.empty());
#ifdef __STL_USE_EXCEPTIONS
@@ -1392,29 +1392,29 @@ void THashTable<V, K, HF, Ex, Eq, A>::copy_from_dynamic(const THashTable& ht) {
namespace NPrivate {
template <class Key>
- inline TString MapKeyToString(const Key&) {
+ inline TString MapKeyToString(const Key&) {
return TypeName<Key>();
}
- TString MapKeyToString(TStringBuf key);
- TString MapKeyToString(unsigned short key);
- TString MapKeyToString(short key);
- TString MapKeyToString(unsigned int key);
- TString MapKeyToString(int key);
- TString MapKeyToString(unsigned long key);
- TString MapKeyToString(long key);
- TString MapKeyToString(unsigned long long key);
- TString MapKeyToString(long long key);
+ TString MapKeyToString(TStringBuf key);
+ TString MapKeyToString(unsigned short key);
+ TString MapKeyToString(short key);
+ TString MapKeyToString(unsigned int key);
+ TString MapKeyToString(int key);
+ TString MapKeyToString(unsigned long key);
+ TString MapKeyToString(long key);
+ TString MapKeyToString(unsigned long long key);
+ TString MapKeyToString(long long key);
- inline TString MapKeyToString(const TString& key) {
+ inline TString MapKeyToString(const TString& key) {
return MapKeyToString(TStringBuf(key));
}
- inline TString MapKeyToString(const char* key) {
+ inline TString MapKeyToString(const char* key) {
return MapKeyToString(TStringBuf(key));
}
- inline TString MapKeyToString(char* key) {
+ inline TString MapKeyToString(char* key) {
return MapKeyToString(TStringBuf(key));
}
@@ -1422,9 +1422,9 @@ namespace NPrivate {
}
template <class Key, class T, class HashFcn, class EqualKey, class Alloc>
-class THashMap: public TMapOps<THashMap<Key, T, HashFcn, EqualKey, Alloc>> {
+class THashMap: public TMapOps<THashMap<Key, T, HashFcn, EqualKey, Alloc>> {
private:
- using ht = THashTable<std::pair<const Key, T>, Key, HashFcn, TSelect1st, EqualKey, Alloc>;
+ using ht = THashTable<std::pair<const Key, T>, Key, HashFcn, TSelect1st, EqualKey, Alloc>;
ht rep;
public:
@@ -1455,60 +1455,60 @@ public:
}
public:
- THashMap()
+ THashMap()
: rep(0, hasher(), key_equal())
{
}
template <class TAllocParam>
- explicit THashMap(TAllocParam* allocParam, size_type n = 0)
+ explicit THashMap(TAllocParam* allocParam, size_type n = 0)
: rep(n, hasher(), key_equal(), allocParam)
{
}
- explicit THashMap(size_type n)
+ explicit THashMap(size_type n)
: rep(n, hasher(), key_equal())
{
}
- THashMap(size_type n, const hasher& hf)
+ THashMap(size_type n, const hasher& hf)
: rep(n, hf, key_equal())
{
}
- THashMap(size_type n, const hasher& hf, const key_equal& eql)
+ THashMap(size_type n, const hasher& hf, const key_equal& eql)
: rep(n, hf, eql)
{
}
template <class TAllocParam>
- explicit THashMap(size_type n, TAllocParam* allocParam)
+ explicit THashMap(size_type n, TAllocParam* allocParam)
: rep(n, hasher(), key_equal(), allocParam)
{
}
template <class InputIterator>
- THashMap(InputIterator f, InputIterator l)
+ THashMap(InputIterator f, InputIterator l)
: rep(0, hasher(), key_equal())
{
rep.insert_unique(f, l);
}
template <class InputIterator>
- THashMap(InputIterator f, InputIterator l, size_type n)
+ THashMap(InputIterator f, InputIterator l, size_type n)
: rep(n, hasher(), key_equal())
{
rep.insert_unique(f, l);
}
template <class InputIterator>
- THashMap(InputIterator f, InputIterator l, size_type n,
+ THashMap(InputIterator f, InputIterator l, size_type n,
const hasher& hf)
: rep(n, hf, key_equal())
{
rep.insert_unique(f, l);
}
template <class InputIterator>
- THashMap(InputIterator f, InputIterator l, size_type n,
+ THashMap(InputIterator f, InputIterator l, size_type n,
const hasher& hf, const key_equal& eql)
: rep(n, hf, eql)
{
rep.insert_unique(f, l);
}
- THashMap(const std::initializer_list<std::pair<Key, T>>& list)
+ THashMap(const std::initializer_list<std::pair<Key, T>>& list)
: rep(list.size(), hasher(), key_equal())
{
for (const auto& v : list) {
@@ -1516,8 +1516,8 @@ public:
}
}
- // THashMap has implicit copy/move constructors and copy-/move-assignment operators
- // because its implementation is backed by THashTable.
+ // THashMap has implicit copy/move constructors and copy-/move-assignment operators
+ // because its implementation is backed by THashTable.
// See hash_ut.cpp
public:
@@ -1537,7 +1537,7 @@ public:
explicit operator bool() const noexcept {
return !empty();
}
- void swap(THashMap& hs) {
+ void swap(THashMap& hs) {
rep.swap(hs.rep);
}
@@ -1735,7 +1735,7 @@ public:
};
template <class Key, class T, class HashFcn, class EqualKey, class Alloc>
-inline bool operator==(const THashMap<Key, T, HashFcn, EqualKey, Alloc>& hm1, const THashMap<Key, T, HashFcn, EqualKey, Alloc>& hm2) {
+inline bool operator==(const THashMap<Key, T, HashFcn, EqualKey, Alloc>& hm1, const THashMap<Key, T, HashFcn, EqualKey, Alloc>& hm2) {
if (hm1.size() != hm2.size()) {
return false;
}
@@ -1749,14 +1749,14 @@ inline bool operator==(const THashMap<Key, T, HashFcn, EqualKey, Alloc>& hm1, co
}
template <class Key, class T, class HashFcn, class EqualKey, class Alloc>
-inline bool operator!=(const THashMap<Key, T, HashFcn, EqualKey, Alloc>& hm1, const THashMap<Key, T, HashFcn, EqualKey, Alloc>& hm2) {
+inline bool operator!=(const THashMap<Key, T, HashFcn, EqualKey, Alloc>& hm1, const THashMap<Key, T, HashFcn, EqualKey, Alloc>& hm2) {
return !(hm1 == hm2);
}
template <class Key, class T, class HashFcn, class EqualKey, class Alloc>
-class THashMultiMap {
+class THashMultiMap {
private:
- using ht = THashTable<std::pair<const Key, T>, Key, HashFcn, TSelect1st, EqualKey, Alloc>;
+ using ht = THashTable<std::pair<const Key, T>, Key, HashFcn, TSelect1st, EqualKey, Alloc>;
ht rep;
public:
@@ -1786,54 +1786,54 @@ public:
}
public:
- THashMultiMap()
+ THashMultiMap()
: rep(0, hasher(), key_equal())
{
}
template <typename TAllocParam>
- explicit THashMultiMap(TAllocParam* allocParam)
+ explicit THashMultiMap(TAllocParam* allocParam)
: rep(0, hasher(), key_equal(), allocParam)
{
}
- explicit THashMultiMap(size_type n)
+ explicit THashMultiMap(size_type n)
: rep(n, hasher(), key_equal())
{
}
- THashMultiMap(size_type n, const hasher& hf)
+ THashMultiMap(size_type n, const hasher& hf)
: rep(n, hf, key_equal())
{
}
- THashMultiMap(size_type n, const hasher& hf, const key_equal& eql)
+ THashMultiMap(size_type n, const hasher& hf, const key_equal& eql)
: rep(n, hf, eql)
{
}
template <class InputIterator>
- THashMultiMap(InputIterator f, InputIterator l)
+ THashMultiMap(InputIterator f, InputIterator l)
: rep(0, hasher(), key_equal())
{
rep.insert_equal(f, l);
}
template <class InputIterator>
- THashMultiMap(InputIterator f, InputIterator l, size_type n)
+ THashMultiMap(InputIterator f, InputIterator l, size_type n)
: rep(n, hasher(), key_equal())
{
rep.insert_equal(f, l);
}
template <class InputIterator>
- THashMultiMap(InputIterator f, InputIterator l, size_type n, const hasher& hf)
+ THashMultiMap(InputIterator f, InputIterator l, size_type n, const hasher& hf)
: rep(n, hf, key_equal())
{
rep.insert_equal(f, l);
}
template <class InputIterator>
- THashMultiMap(InputIterator f, InputIterator l, size_type n, const hasher& hf, const key_equal& eql)
+ THashMultiMap(InputIterator f, InputIterator l, size_type n, const hasher& hf, const key_equal& eql)
: rep(n, hf, eql)
{
rep.insert_equal(f, l);
}
- THashMultiMap(std::initializer_list<std::pair<Key, T>> list)
+ THashMultiMap(std::initializer_list<std::pair<Key, T>> list)
: rep(list.size(), hasher(), key_equal())
{
for (const auto& v : list) {
@@ -1841,8 +1841,8 @@ public:
}
}
- // THashMultiMap has implicit copy/move constructors and copy-/move-assignment operators
- // because its implementation is backed by THashTable.
+ // THashMultiMap has implicit copy/move constructors and copy-/move-assignment operators
+ // because its implementation is backed by THashTable.
// See hash_ut.cpp
public:
@@ -1862,7 +1862,7 @@ public:
explicit operator bool() const noexcept {
return !empty();
}
- void swap(THashMultiMap& hs) {
+ void swap(THashMultiMap& hs) {
rep.swap(hs.rep);
}
@@ -1995,14 +1995,14 @@ public:
};
template <class Key, class T, class HF, class EqKey, class Alloc>
-inline bool operator==(const THashMultiMap<Key, T, HF, EqKey, Alloc>& hm1, const THashMultiMap<Key, T, HF, EqKey, Alloc>& hm2) {
+inline bool operator==(const THashMultiMap<Key, T, HF, EqKey, Alloc>& hm1, const THashMultiMap<Key, T, HF, EqKey, Alloc>& hm2) {
// NOTE: copy-pasted from
// contrib/libs/cxxsupp/libcxx/include/unordered_map
- // and adapted to THashMultiMap
+ // and adapted to THashMultiMap
if (hm1.size() != hm2.size()) {
return false;
}
- using const_iterator = typename THashMultiMap<Key, T, HF, EqKey, Alloc>::const_iterator;
+ using const_iterator = typename THashMultiMap<Key, T, HF, EqKey, Alloc>::const_iterator;
using TEqualRange = std::pair<const_iterator, const_iterator>;
for (const_iterator it = hm1.begin(), end = hm1.end(); it != end;) {
TEqualRange eq1 = hm1.equal_range(it->first);
@@ -2018,7 +2018,7 @@ inline bool operator==(const THashMultiMap<Key, T, HF, EqKey, Alloc>& hm1, const
}
template <class Key, class T, class HF, class EqKey, class Alloc>
-inline bool operator!=(const THashMultiMap<Key, T, HF, EqKey, Alloc>& hm1, const THashMultiMap<Key, T, HF, EqKey, Alloc>& hm2) {
+inline bool operator!=(const THashMultiMap<Key, T, HF, EqKey, Alloc>& hm1, const THashMultiMap<Key, T, HF, EqKey, Alloc>& hm2) {
return !(hm1 == hm2);
}
diff --git a/util/generic/hash.pxd b/util/generic/hash.pxd
index fd24d1ef27..385c10d805 100644
--- a/util/generic/hash.pxd
+++ b/util/generic/hash.pxd
@@ -1,7 +1,7 @@
from libcpp.pair cimport pair
cdef extern from "util/generic/hash.h" nogil:
- cdef cppclass THashMap[T, U]:
+ cdef cppclass THashMap[T, U]:
cppclass iterator:
pair[T, U]& operator*()
iterator operator++()
@@ -22,17 +22,17 @@ cdef extern from "util/generic/hash.h" nogil:
cppclass const_reverse_iterator(reverse_iterator):
pass
- THashMap() except +
- THashMap(THashMap&) except +
+ THashMap() except +
+ THashMap(THashMap&) except +
U& operator[](T&)
- THashMap& operator=(THashMap&)
+ THashMap& operator=(THashMap&)
- bint operator==(THashMap&)
- bint operator!=(THashMap&)
- bint operator<(THashMap&)
- bint operator>(THashMap&)
- bint operator<=(THashMap&)
- bint operator>=(THashMap&)
+ bint operator==(THashMap&)
+ bint operator!=(THashMap&)
+ bint operator<(THashMap&)
+ bint operator>(THashMap&)
+ bint operator<=(THashMap&)
+ bint operator>=(THashMap&)
U& at(T&) except +
iterator begin()
@@ -53,7 +53,7 @@ cdef extern from "util/generic/hash.h" nogil:
iterator insert(iterator, pair[T, U]) # XXX pair[T,U]&
size_t max_size()
size_t size()
- void swap(THashMap&)
+ void swap(THashMap&)
iterator lower_bound(T&)
const_iterator const_lower_bound "lower_bound"(T&)
reverse_iterator rbegin()
diff --git a/util/generic/hash_set.h b/util/generic/hash_set.h
index 7890b7ab07..e8088cf23b 100644
--- a/util/generic/hash_set.h
+++ b/util/generic/hash_set.h
@@ -9,9 +9,9 @@
#undef value_type
template <class Value, class HashFcn, class EqualKey, class Alloc>
-class THashSet {
+class THashSet {
private:
- using ht = THashTable<Value, Value, HashFcn, ::TIdentity, EqualKey, Alloc>;
+ using ht = THashTable<Value, Value, HashFcn, ::TIdentity, EqualKey, Alloc>;
ht rep;
using mutable_iterator = typename ht::iterator;
@@ -43,76 +43,76 @@ public:
}
public:
- THashSet() {
+ THashSet() {
}
template <class TT>
- explicit THashSet(TT* allocParam, size_type n = 0)
+ explicit THashSet(TT* allocParam, size_type n = 0)
: rep(n, hasher(), key_equal(), allocParam)
{
}
- explicit THashSet(size_type n)
+ explicit THashSet(size_type n)
: rep(n, hasher(), key_equal())
{
}
- THashSet(size_type n, const hasher& hf)
+ THashSet(size_type n, const hasher& hf)
: rep(n, hf, key_equal())
{
}
- THashSet(size_type n, const hasher& hf, const key_equal& eql)
+ THashSet(size_type n, const hasher& hf, const key_equal& eql)
: rep(n, hf, eql)
{
}
- THashSet(std::initializer_list<value_type> list)
+ THashSet(std::initializer_list<value_type> list)
: rep(list.size(), hasher(), key_equal())
{
rep.insert_unique(list.begin(), list.end());
}
- THashSet(std::initializer_list<value_type> list, size_type n)
+ THashSet(std::initializer_list<value_type> list, size_type n)
: rep(n, hasher(), key_equal())
{
rep.insert_unique(list.begin(), list.end());
}
- THashSet(std::initializer_list<value_type> list, size_type n, const hasher& hf)
+ THashSet(std::initializer_list<value_type> list, size_type n, const hasher& hf)
: rep(n, hf, key_equal())
{
rep.insert_unique(list.begin(), list.end());
}
- THashSet(std::initializer_list<value_type> list, size_type n, const hasher& hf, const key_equal& eql)
+ THashSet(std::initializer_list<value_type> list, size_type n, const hasher& hf, const key_equal& eql)
: rep(n, hf, eql)
{
rep.insert_unique(list.begin(), list.end());
}
template <class InputIterator>
- THashSet(InputIterator f, InputIterator l)
+ THashSet(InputIterator f, InputIterator l)
: rep(0, hasher(), key_equal())
{
rep.insert_unique(f, l);
}
template <class InputIterator>
- THashSet(InputIterator f, InputIterator l, size_type n)
+ THashSet(InputIterator f, InputIterator l, size_type n)
: rep(n, hasher(), key_equal())
{
rep.insert_unique(f, l);
}
template <class InputIterator>
- THashSet(InputIterator f, InputIterator l, size_type n,
+ THashSet(InputIterator f, InputIterator l, size_type n,
const hasher& hf)
: rep(n, hf, key_equal())
{
rep.insert_unique(f, l);
}
template <class InputIterator>
- THashSet(InputIterator f, InputIterator l, size_type n,
+ THashSet(InputIterator f, InputIterator l, size_type n,
const hasher& hf, const key_equal& eql)
: rep(n, hf, eql)
{
rep.insert_unique(f, l);
}
- // THashSet has implicit copy/move constructors and copy-/move-assignment operators
- // because its implementation is backed by THashTable.
+ // THashSet has implicit copy/move constructors and copy-/move-assignment operators
+ // because its implementation is backed by THashTable.
// See hash_ut.cpp
public:
@@ -129,7 +129,7 @@ public:
explicit operator bool() const noexcept {
return !empty();
}
- void swap(THashSet& hs) {
+ void swap(THashSet& hs) {
rep.swap(hs.rep);
}
@@ -261,7 +261,7 @@ public:
};
template <class Value, class HashFcn, class EqualKey, class Alloc>
-inline bool operator==(const THashSet<Value, HashFcn, EqualKey, Alloc>& hs1, const THashSet<Value, HashFcn, EqualKey, Alloc>& hs2) {
+inline bool operator==(const THashSet<Value, HashFcn, EqualKey, Alloc>& hs1, const THashSet<Value, HashFcn, EqualKey, Alloc>& hs2) {
if (hs1.size() != hs2.size()) {
return false;
}
@@ -274,14 +274,14 @@ inline bool operator==(const THashSet<Value, HashFcn, EqualKey, Alloc>& hs1, con
}
template <class Value, class HashFcn, class EqualKey, class Alloc>
-inline bool operator!=(const THashSet<Value, HashFcn, EqualKey, Alloc>& hs1, const THashSet<Value, HashFcn, EqualKey, Alloc>& hs2) {
+inline bool operator!=(const THashSet<Value, HashFcn, EqualKey, Alloc>& hs1, const THashSet<Value, HashFcn, EqualKey, Alloc>& hs2) {
return !(hs1 == hs2);
}
template <class Value, class HashFcn, class EqualKey, class Alloc>
-class THashMultiSet {
+class THashMultiSet {
private:
- using ht = THashTable<Value, Value, HashFcn, ::TIdentity, EqualKey, Alloc>;
+ using ht = THashTable<Value, Value, HashFcn, ::TIdentity, EqualKey, Alloc>;
ht rep;
public:
@@ -310,58 +310,58 @@ public:
}
public:
- THashMultiSet()
+ THashMultiSet()
: rep(0, hasher(), key_equal())
{
}
- explicit THashMultiSet(size_type n)
+ explicit THashMultiSet(size_type n)
: rep(n, hasher(), key_equal())
{
}
- THashMultiSet(size_type n, const hasher& hf)
+ THashMultiSet(size_type n, const hasher& hf)
: rep(n, hf, key_equal())
{
}
- THashMultiSet(size_type n, const hasher& hf, const key_equal& eql)
+ THashMultiSet(size_type n, const hasher& hf, const key_equal& eql)
: rep(n, hf, eql)
{
}
template <class InputIterator>
- THashMultiSet(InputIterator f, InputIterator l)
+ THashMultiSet(InputIterator f, InputIterator l)
: rep(0, hasher(), key_equal())
{
rep.insert_equal(f, l);
}
template <class InputIterator>
- THashMultiSet(InputIterator f, InputIterator l, size_type n)
+ THashMultiSet(InputIterator f, InputIterator l, size_type n)
: rep(n, hasher(), key_equal())
{
rep.insert_equal(f, l);
}
template <class InputIterator>
- THashMultiSet(InputIterator f, InputIterator l, size_type n,
+ THashMultiSet(InputIterator f, InputIterator l, size_type n,
const hasher& hf)
: rep(n, hf, key_equal())
{
rep.insert_equal(f, l);
}
template <class InputIterator>
- THashMultiSet(InputIterator f, InputIterator l, size_type n,
+ THashMultiSet(InputIterator f, InputIterator l, size_type n,
const hasher& hf, const key_equal& eql)
: rep(n, hf, eql)
{
rep.insert_equal(f, l);
}
- THashMultiSet(std::initializer_list<value_type> list)
+ THashMultiSet(std::initializer_list<value_type> list)
: rep(list.size(), hasher(), key_equal())
{
rep.insert_equal(list.begin(), list.end());
}
- // THashMultiSet has implicit copy/move constructors and copy-/move-assignment operators
- // because its implementation is backed by THashTable.
+ // THashMultiSet has implicit copy/move constructors and copy-/move-assignment operators
+ // because its implementation is backed by THashTable.
// See hash_ut.cpp
public:
@@ -378,7 +378,7 @@ public:
explicit operator bool() const noexcept {
return !empty();
}
- void swap(THashMultiSet& hs) {
+ void swap(THashMultiSet& hs) {
rep.swap(hs.rep);
}
@@ -464,7 +464,7 @@ public:
};
template <class Val, class HashFcn, class EqualKey, class Alloc>
-inline bool operator==(const THashMultiSet<Val, HashFcn, EqualKey, Alloc>& hs1, const THashMultiSet<Val, HashFcn, EqualKey, Alloc>& hs2) {
+inline bool operator==(const THashMultiSet<Val, HashFcn, EqualKey, Alloc>& hs1, const THashMultiSet<Val, HashFcn, EqualKey, Alloc>& hs2) {
if (hs1.size() != hs2.size()) {
return false;
}
@@ -483,6 +483,6 @@ inline bool operator==(const THashMultiSet<Val, HashFcn, EqualKey, Alloc>& hs1,
}
template <class Val, class HashFcn, class EqualKey, class Alloc>
-inline bool operator!=(const THashMultiSet<Val, HashFcn, EqualKey, Alloc>& hs1, const THashMultiSet<Val, HashFcn, EqualKey, Alloc>& hs2) {
+inline bool operator!=(const THashMultiSet<Val, HashFcn, EqualKey, Alloc>& hs1, const THashMultiSet<Val, HashFcn, EqualKey, Alloc>& hs2) {
return !(hs1 == hs2);
}
diff --git a/util/generic/hash_ut.cpp b/util/generic/hash_ut.cpp
index 12de252a26..0551d58770 100644
--- a/util/generic/hash_ut.cpp
+++ b/util/generic/hash_ut.cpp
@@ -61,7 +61,7 @@ class THashTest: public TTestBase {
UNIT_TEST(TestTupleHash);
UNIT_TEST_SUITE_END();
- using hmset = THashMultiSet<char, hash<char>, TEqualTo<char>>;
+ using hmset = THashMultiSet<char, hash<char>, TEqualTo<char>>;
protected:
void TestHMapConstructorsAndAssignments();
@@ -115,7 +115,7 @@ protected:
UNIT_TEST_SUITE_REGISTRATION(THashTest);
void THashTest::TestHMapConstructorsAndAssignments() {
- using container = THashMap<TString, int>;
+ using container = THashMap<TString, int>;
container c1;
c1["one"] = 1;
@@ -166,7 +166,7 @@ void THashTest::TestHMapConstructorsAndAssignments() {
}
void THashTest::TestHMap1() {
- using maptype = THashMap<char, TString, THash<char>, TEqualTo<char>>;
+ using maptype = THashMap<char, TString, THash<char>, TEqualTo<char>>;
maptype m;
// Store mappings between roman numerals and decimals.
m['l'] = "50";
@@ -182,11 +182,11 @@ void THashTest::TestHMap1() {
UNIT_ASSERT(m.contains('z'));
UNIT_ASSERT(m.count('z') == 1);
- auto p = m.insert(std::pair<const char, TString>('c', TString("100")));
+ auto p = m.insert(std::pair<const char, TString>('c', TString("100")));
UNIT_ASSERT(p.second);
- p = m.insert(std::pair<const char, TString>('c', TString("100")));
+ p = m.insert(std::pair<const char, TString>('c', TString("100")));
UNIT_ASSERT(!p.second);
//Some iterators compare check, really compile time checks
@@ -203,7 +203,7 @@ void THashTest::TestHMap1() {
}
void THashTest::TestHMapEqualityOperator() {
- using container = THashMap<TString, int>;
+ using container = THashMap<TString, int>;
container base;
base["one"] = 1;
@@ -226,7 +226,7 @@ void THashTest::TestHMapEqualityOperator() {
}
void THashTest::TestHMMapEqualityOperator() {
- using container = THashMultiMap<TString, int>;
+ using container = THashMultiMap<TString, int>;
using value = container::value_type;
container base;
@@ -261,7 +261,7 @@ void THashTest::TestHMMapEqualityOperator() {
}
void THashTest::TestHMMapConstructorsAndAssignments() {
- using container = THashMultiMap<TString, int>;
+ using container = THashMultiMap<TString, int>;
container c1;
c1.insert(container::value_type("one", 1));
@@ -291,7 +291,7 @@ void THashTest::TestHMMapConstructorsAndAssignments() {
}
void THashTest::TestHMMap1() {
- using mmap = THashMultiMap<char, int, THash<char>, TEqualTo<char>>;
+ using mmap = THashMultiMap<char, int, THash<char>, TEqualTo<char>>;
mmap m;
UNIT_ASSERT(m.count('X') == 0);
@@ -329,7 +329,7 @@ void THashTest::TestHMMap1() {
UNIT_ASSERT(cite == (mmap::const_iterator)ite);
UNIT_ASSERT(!(cite != (mmap::const_iterator)ite));
- using HMapType = THashMultiMap<size_t, size_t>;
+ using HMapType = THashMultiMap<size_t, size_t>;
HMapType hmap;
//We fill the map to implicitely start a rehash.
@@ -356,7 +356,7 @@ void THashTest::TestHMMap1() {
}
void THashTest::TestHMMapHas() {
- using mmap = THashMultiMap<char, int, THash<char>, TEqualTo<char>>;
+ using mmap = THashMultiMap<char, int, THash<char>, TEqualTo<char>>;
mmap m;
m.insert(std::pair<const char, int>('X', 10));
m.insert(std::pair<const char, int>('X', 20));
@@ -367,7 +367,7 @@ void THashTest::TestHMMapHas() {
}
void THashTest::TestHSetConstructorsAndAssignments() {
- using container = THashSet<int>;
+ using container = THashSet<int>;
container c1;
c1.insert(100);
@@ -408,7 +408,7 @@ void THashTest::TestHSetConstructorsAndAssignments() {
}
void THashTest::TestHSetSize() {
- using container = THashSet<int>;
+ using container = THashSet<int>;
container c;
c.insert(100);
@@ -422,7 +422,7 @@ void THashTest::TestHSetSize() {
}
void THashTest::TestHSet2() {
- THashSet<int, THash<int>, TEqualTo<int>> s;
+ THashSet<int, THash<int>, TEqualTo<int>> s;
auto p = s.insert(42);
UNIT_ASSERT(p.second);
UNIT_ASSERT(*(p.first) == 42);
@@ -432,7 +432,7 @@ void THashTest::TestHSet2() {
}
void THashTest::TestHSetEqualityOperator() {
- using container = THashSet<int>;
+ using container = THashSet<int>;
container base;
base.insert(1);
@@ -458,7 +458,7 @@ void THashTest::TestHSetEqualityOperator() {
}
void THashTest::TestHMSetConstructorsAndAssignments() {
- using container = THashMultiSet<int>;
+ using container = THashMultiSet<int>;
container c1;
c1.insert(100);
@@ -493,7 +493,7 @@ void THashTest::TestHMSetConstructorsAndAssignments() {
}
void THashTest::TestHMSetSize() {
- using container = THashMultiSet<int>;
+ using container = THashMultiSet<int>;
container c;
c.insert(100);
@@ -523,7 +523,7 @@ void THashTest::TestHMSet1() {
}
void THashTest::TestHMSetEqualityOperator() {
- using container = THashMultiSet<int>;
+ using container = THashMultiSet<int>;
container base;
base.insert(1);
@@ -605,7 +605,7 @@ void THashTest::TestHMSetEmplace() {
}
void THashTest::TestInsertErase() {
- using hmap = THashMap<TString, size_t, THash<TString>, TEqualTo<TString>>;
+ using hmap = THashMap<TString, size_t, THash<TString>, TEqualTo<TString>>;
using val_type = hmap::value_type;
{
@@ -635,10 +635,10 @@ void THashTest::TestInsertErase() {
namespace {
struct TItem: public TSimpleRefCount<TItem> {
- const TString Key;
- const TString Value;
+ const TString Key;
+ const TString Value;
- TItem(const TString& key, const TString& value)
+ TItem(const TString& key, const TString& value)
: Key(key)
, Value(value)
{
@@ -648,26 +648,26 @@ namespace {
using TItemPtr = TIntrusivePtr<TItem>;
struct TSelectKey {
- const TString& operator()(const TItemPtr& item) const {
+ const TString& operator()(const TItemPtr& item) const {
return item->Key;
}
};
- using TItemMapBase = THashTable<
+ using TItemMapBase = THashTable<
TItemPtr,
- TString,
- THash<TString>,
+ TString,
+ THash<TString>,
TSelectKey,
- TEqualTo<TString>,
+ TEqualTo<TString>,
std::allocator<TItemPtr>>;
struct TItemMap: public TItemMapBase {
TItemMap()
- : TItemMapBase(1, THash<TString>(), TEqualTo<TString>())
+ : TItemMapBase(1, THash<TString>(), TEqualTo<TString>())
{
}
- TItem& Add(const TString& key, const TString& value) {
+ TItem& Add(const TString& key, const TString& value) {
insert_ctx ins;
iterator it = find_i(key, ins);
if (it == end()) {
@@ -701,13 +701,13 @@ static void EmptyAndInsertTest(typename T::value_type v) {
}
void THashTest::TestEmpty() {
- EmptyAndInsertTest<THashSet<int>>(1);
- EmptyAndInsertTest<THashMap<int, int>>(std::pair<int, int>(1, 2));
- EmptyAndInsertTest<THashMultiMap<int, int>>(std::pair<int, int>(1, 2));
+ EmptyAndInsertTest<THashSet<int>>(1);
+ EmptyAndInsertTest<THashMap<int, int>>(std::pair<int, int>(1, 2));
+ EmptyAndInsertTest<THashMultiMap<int, int>>(std::pair<int, int>(1, 2));
}
void THashTest::TestDefaultConstructor() {
- THashSet<int> set;
+ THashSet<int> set;
UNIT_ASSERT(set.begin() == set.end());
@@ -719,18 +719,18 @@ void THashTest::TestDefaultConstructor() {
void THashTest::TestSizeOf() {
/* This test checks that we don't waste memory when all functors passed to
- * THashTable are empty. It does rely on knowledge of THashTable internals,
+ * THashTable are empty. It does rely on knowledge of THashTable internals,
* so if those change, the test will have to be adjusted accordingly. */
size_t expectedSize = sizeof(uintptr_t) + 3 * sizeof(size_t);
- UNIT_ASSERT_VALUES_EQUAL(sizeof(THashMap<int, int>), expectedSize);
- UNIT_ASSERT_VALUES_EQUAL(sizeof(THashMap<std::pair<int, int>, std::pair<int, int>>), expectedSize);
+ UNIT_ASSERT_VALUES_EQUAL(sizeof(THashMap<int, int>), expectedSize);
+ UNIT_ASSERT_VALUES_EQUAL(sizeof(THashMap<std::pair<int, int>, std::pair<int, int>>), expectedSize);
}
void THashTest::TestInvariants() {
std::set<int> reference_set;
- THashSet<int> set;
+ THashSet<int> set;
for (int i = 0; i < 1000; i++) {
set.insert(i);
@@ -775,7 +775,7 @@ struct TAllocatorCounters {
size_t Allocations;
size_t Deallocations;
- TSet<std::pair<void*, size_t>> Chunks;
+ TSet<std::pair<void*, size_t>> Chunks;
};
template <class T>
@@ -834,7 +834,7 @@ private:
void THashTest::TestAllocation() {
TAllocatorCounters counters;
- using int_set = THashSet<int, THash<int>, TEqualTo<int>, TCountingAllocator<int>>;
+ using int_set = THashSet<int, THash<int>, TEqualTo<int>, TCountingAllocator<int>>;
{
int_set set0(&counters);
@@ -881,14 +881,14 @@ public:
};
void THashTest::TestInsertCopy() {
- THashMap<int, int> hash;
+ THashMap<int, int> hash;
/* Insertion should not make copies of the provided key. */
hash[TNonCopyableInt<0>(0)] = 0;
}
void THashTest::TestEmplace() {
- using hash_t = THashMap<int, TNonCopyableInt<0>>;
+ using hash_t = THashMap<int, TNonCopyableInt<0>>;
hash_t hash;
hash.emplace(std::piecewise_construct, std::forward_as_tuple(1), std::forward_as_tuple(0));
auto it = hash.find(1);
@@ -896,7 +896,7 @@ void THashTest::TestEmplace() {
}
void THashTest::TestEmplaceNoresize() {
- using hash_t = THashMap<int, TNonCopyableInt<0>>;
+ using hash_t = THashMap<int, TNonCopyableInt<0>>;
hash_t hash;
hash.reserve(1);
hash.emplace_noresize(std::piecewise_construct, std::forward_as_tuple(1), std::forward_as_tuple(0));
@@ -905,7 +905,7 @@ void THashTest::TestEmplaceNoresize() {
}
void THashTest::TestEmplaceDirect() {
- using hash_t = THashMap<int, TNonCopyableInt<0>>;
+ using hash_t = THashMap<int, TNonCopyableInt<0>>;
hash_t hash;
hash_t::insert_ctx ins;
hash.find(1, ins);
@@ -981,7 +981,7 @@ void THashTest::TestTryEmplaceCopyKey() {
}
void THashTest::TestHMMapEmplace() {
- using hash_t = THashMultiMap<int, TNonCopyableInt<0>>;
+ using hash_t = THashMultiMap<int, TNonCopyableInt<0>>;
hash_t hash;
hash.emplace(std::piecewise_construct, std::forward_as_tuple(1), std::forward_as_tuple(0));
auto it = hash.find(1);
@@ -989,7 +989,7 @@ void THashTest::TestHMMapEmplace() {
}
void THashTest::TestHMMapEmplaceNoresize() {
- using hash_t = THashMultiMap<int, TNonCopyableInt<0>>;
+ using hash_t = THashMultiMap<int, TNonCopyableInt<0>>;
hash_t hash;
hash.reserve(1);
hash.emplace_noresize(std::piecewise_construct, std::forward_as_tuple(1), std::forward_as_tuple(0));
@@ -998,7 +998,7 @@ void THashTest::TestHMMapEmplaceNoresize() {
}
void THashTest::TestHMMapEmplaceDirect() {
- using hash_t = THashMultiMap<int, TNonCopyableInt<0>>;
+ using hash_t = THashMultiMap<int, TNonCopyableInt<0>>;
hash_t hash;
hash_t::insert_ctx ins;
hash.find(1, ins);
@@ -1008,7 +1008,7 @@ void THashTest::TestHMMapEmplaceDirect() {
}
void THashTest::TestHSetEmplace() {
- using hash_t = THashSet<TNonCopyableInt<0>, THash<int>, TEqualTo<int>>;
+ using hash_t = THashSet<TNonCopyableInt<0>, THash<int>, TEqualTo<int>>;
hash_t hash;
UNIT_ASSERT(!hash.contains(0));
hash.emplace(0);
@@ -1017,7 +1017,7 @@ void THashTest::TestHSetEmplace() {
}
void THashTest::TestHSetEmplaceNoresize() {
- using hash_t = THashSet<TNonCopyableInt<0>, THash<int>, TEqualTo<int>>;
+ using hash_t = THashSet<TNonCopyableInt<0>, THash<int>, TEqualTo<int>>;
hash_t hash;
hash.reserve(1);
UNIT_ASSERT(!hash.contains(0));
@@ -1027,7 +1027,7 @@ void THashTest::TestHSetEmplaceNoresize() {
}
void THashTest::TestHSetEmplaceDirect() {
- using hash_t = THashSet<TNonCopyableInt<0>, THash<int>, TEqualTo<int>>;
+ using hash_t = THashSet<TNonCopyableInt<0>, THash<int>, TEqualTo<int>>;
hash_t hash;
UNIT_ASSERT(!hash.contains(0));
hash_t::insert_ctx ins;
@@ -1049,7 +1049,7 @@ void THashTest::TestNonCopyable() {
}
};
- THashMap<int, TValue> hash;
+ THashMap<int, TValue> hash;
hash.emplace(std::piecewise_construct, std::forward_as_tuple(1), std::forward_as_tuple(5));
auto&& value = hash[1];
UNIT_ASSERT_VALUES_EQUAL(static_cast<int>(value), 5);
@@ -1058,7 +1058,7 @@ void THashTest::TestNonCopyable() {
}
void THashTest::TestValueInitialization() {
- THashMap<int, int> hash;
+ THashMap<int, int> hash;
int& value = hash[0];
@@ -1070,21 +1070,21 @@ void THashTest::TestAssignmentClear() {
/* This one tests that assigning an empty hash resets the buckets array.
* See operator= for details. */
- THashMap<int, int> hash;
+ THashMap<int, int> hash;
size_t emptyBucketCount = hash.bucket_count();
for (int i = 0; i < 100; i++) {
hash[i] = i;
}
- hash = THashMap<int, int>();
+ hash = THashMap<int, int>();
UNIT_ASSERT_VALUES_EQUAL(hash.bucket_count(), emptyBucketCount);
}
void THashTest::TestReleaseNodes() {
TAllocatorCounters counters;
- using TIntSet = THashSet<int, THash<int>, TEqualTo<int>, TCountingAllocator<int>>;
+ using TIntSet = THashSet<int, THash<int>, TEqualTo<int>, TCountingAllocator<int>>;
TIntSet set(&counters);
for (int i = 0; i < 3; i++) {
@@ -1127,10 +1127,10 @@ void THashTest::TestAt() {
} \
}
- TEST_AT_THROWN_EXCEPTION(TString, TString, TString, "111", "111");
- TEST_AT_THROWN_EXCEPTION(TString, TString, const TString, "111", "111");
- TEST_AT_THROWN_EXCEPTION(TString, TString, TStringBuf, "111", "111");
- TEST_AT_THROWN_EXCEPTION(TString, TString, const TStringBuf, "111", "111");
+ TEST_AT_THROWN_EXCEPTION(TString, TString, TString, "111", "111");
+ TEST_AT_THROWN_EXCEPTION(TString, TString, const TString, "111", "111");
+ TEST_AT_THROWN_EXCEPTION(TString, TString, TStringBuf, "111", "111");
+ TEST_AT_THROWN_EXCEPTION(TString, TString, const TStringBuf, "111", "111");
TEST_AT_THROWN_EXCEPTION(TStringBuf, TStringBuf, const char*, "111", "111");
TEST_AT_THROWN_EXCEPTION(int, int, short, 11, "11");
TEST_AT_THROWN_EXCEPTION(int, int, int, -1, "-1");
@@ -1142,36 +1142,36 @@ void THashTest::TestAt() {
TEST_AT_THROWN_EXCEPTION(int, int, unsigned long long, 1000000000000ll, "1000000000000");
char key[] = {11, 12, 0, 1, 2, 11, 0};
- TEST_AT_THROWN_EXCEPTION(TString, TString, char*, key, "\\x0B\\x0C");
+ TEST_AT_THROWN_EXCEPTION(TString, TString, char*, key, "\\x0B\\x0C");
TEST_AT_THROWN_EXCEPTION(TString, TString, TStringBuf, TStringBuf(key, sizeof(key) - 1), "\\x0B\\x0C\\0\\1\\2\\x0B");
#undef TEST_AT_THROWN_EXCEPTION
}
void THashTest::TestHMapInitializerList() {
- THashMap<TString, TString> h1 = {{"foo", "bar"}, {"bar", "baz"}, {"baz", "qux"}};
- THashMap<TString, TString> h2;
- h2.insert(std::pair<TString, TString>("foo", "bar"));
- h2.insert(std::pair<TString, TString>("bar", "baz"));
- h2.insert(std::pair<TString, TString>("baz", "qux"));
+ THashMap<TString, TString> h1 = {{"foo", "bar"}, {"bar", "baz"}, {"baz", "qux"}};
+ THashMap<TString, TString> h2;
+ h2.insert(std::pair<TString, TString>("foo", "bar"));
+ h2.insert(std::pair<TString, TString>("bar", "baz"));
+ h2.insert(std::pair<TString, TString>("baz", "qux"));
UNIT_ASSERT_EQUAL(h1, h2);
}
void THashTest::TestHMMapInitializerList() {
- THashMultiMap<TString, TString> h1 = {
+ THashMultiMap<TString, TString> h1 = {
{"foo", "bar"},
{"foo", "baz"},
{"baz", "qux"}};
- THashMultiMap<TString, TString> h2;
- h2.insert(std::pair<TString, TString>("foo", "bar"));
- h2.insert(std::pair<TString, TString>("foo", "baz"));
- h2.insert(std::pair<TString, TString>("baz", "qux"));
+ THashMultiMap<TString, TString> h2;
+ h2.insert(std::pair<TString, TString>("foo", "bar"));
+ h2.insert(std::pair<TString, TString>("foo", "baz"));
+ h2.insert(std::pair<TString, TString>("baz", "qux"));
UNIT_ASSERT_EQUAL(h1, h2);
}
void THashTest::TestHSetInitializerList() {
- THashSet<TString> h1 = {"foo", "bar", "baz"};
- THashSet<TString> h2;
+ THashSet<TString> h1 = {"foo", "bar", "baz"};
+ THashSet<TString> h2;
h2.insert("foo");
h2.insert("bar");
h2.insert("baz");
@@ -1179,8 +1179,8 @@ void THashTest::TestHSetInitializerList() {
}
void THashTest::TestHMSetInitializerList() {
- THashMultiSet<TString> h1 = {"foo", "foo", "bar", "baz"};
- THashMultiSet<TString> h2;
+ THashMultiSet<TString> h1 = {"foo", "foo", "bar", "baz"};
+ THashMultiSet<TString> h2;
h2.insert("foo");
h2.insert("foo");
h2.insert("bar");
@@ -1213,20 +1213,20 @@ void Out<TFoo>(IOutputStream& o, const TFoo& v) {
void THashTest::TestHSetInsertInitializerList() {
{
- const THashSet<int> x = {1};
- THashSet<int> y;
+ const THashSet<int> x = {1};
+ THashSet<int> y;
y.insert({1});
UNIT_ASSERT_VALUES_EQUAL(x, y);
}
{
- const THashSet<int> x = {1, 2};
- THashSet<int> y;
+ const THashSet<int> x = {1, 2};
+ THashSet<int> y;
y.insert({1, 2});
UNIT_ASSERT_VALUES_EQUAL(x, y);
}
{
- const THashSet<int> x = {1, 2, 3, 4, 5};
- THashSet<int> y;
+ const THashSet<int> x = {1, 2, 3, 4, 5};
+ THashSet<int> y;
y.insert({
1,
2,
@@ -1237,14 +1237,14 @@ void THashTest::TestHSetInsertInitializerList() {
UNIT_ASSERT_VALUES_EQUAL(x, y);
}
{
- const THashSet<TFoo> x = {{1, 2}};
- THashSet<TFoo> y;
+ const THashSet<TFoo> x = {{1, 2}};
+ THashSet<TFoo> y;
y.insert({{1, 2}});
UNIT_ASSERT_VALUES_EQUAL(x, y);
}
{
- const THashSet<TFoo> x = {{1, 2}, {3, 4}};
- THashSet<TFoo> y;
+ const THashSet<TFoo> x = {{1, 2}, {3, 4}};
+ THashSet<TFoo> y;
y.insert({{1, 2}, {3, 4}});
UNIT_ASSERT_VALUES_EQUAL(x, y);
}
diff --git a/util/generic/hash_ut.pyx b/util/generic/hash_ut.pyx
index ba630cecfd..ecf6dac2e6 100644
--- a/util/generic/hash_ut.pyx
+++ b/util/generic/hash_ut.pyx
@@ -1,6 +1,6 @@
# cython: c_string_type=str, c_string_encoding=utf8
-from util.generic.hash cimport THashMap
+from util.generic.hash cimport THashMap
from util.generic.string cimport TString
import pytest
@@ -10,17 +10,17 @@ from libcpp.pair cimport pair
from cython.operator cimport dereference as deref
-def _check_convert(THashMap[TString, int] x):
+def _check_convert(THashMap[TString, int] x):
return x
class TestHash(unittest.TestCase):
def test_constructors_and_assignments(self):
- cdef THashMap[TString, int] c1
+ cdef THashMap[TString, int] c1
c1["one"] = 1
c1["two"] = 2
- cdef THashMap[TString, int] c2 = THashMap[TString, int](c1)
+ cdef THashMap[TString, int] c2 = THashMap[TString, int](c1)
self.assertEqual(2, c1.size())
self.assertEqual(2, c2.size())
self.assertEqual(1, c1.at("one"))
@@ -34,14 +34,14 @@ class TestHash(unittest.TestCase):
self.assertEqual(3, c1.at("three"))
def test_equality_operator(self):
- cdef THashMap[TString, int] base
+ cdef THashMap[TString, int] base
base["one"] = 1
base["two"] = 2
- cdef THashMap[TString, int] c1 = THashMap[TString, int](base)
+ cdef THashMap[TString, int] c1 = THashMap[TString, int](base)
self.assertTrue(c1==base)
- cdef THashMap[TString, int] c2
+ cdef THashMap[TString, int] c2
c2["one"] = 1
c2["two"] = 2
self.assertTrue(c2 == base)
@@ -49,12 +49,12 @@ class TestHash(unittest.TestCase):
c2["three"] = 3
self.assertTrue(c2 != base)
- cdef THashMap[TString, int] c3 = THashMap[TString, int](base)
+ cdef THashMap[TString, int] c3 = THashMap[TString, int](base)
c3["one"] = 0
self.assertTrue(c3 != base)
def test_insert_erase(self):
- cdef THashMap[TString, int] tmp
+ cdef THashMap[TString, int] tmp
self.assertTrue(tmp.insert(pair[TString, int]("one", 0)).second)
self.assertFalse(tmp.insert(pair[TString, int]("one", 1)).second)
self.assertTrue(tmp.insert(pair[TString, int]("two", 2)).second)
@@ -66,12 +66,12 @@ class TestHash(unittest.TestCase):
self.assertTrue(tmp.empty())
def test_iterators_and_find(self):
- cdef THashMap[TString, int] tmp
+ cdef THashMap[TString, int] tmp
self.assertTrue(tmp.begin() == tmp.end())
self.assertTrue(tmp.find("1") == tmp.end())
tmp["1"] = 1
self.assertTrue(tmp.begin() != tmp.end())
- cdef THashMap[TString, int].iterator it = tmp.find("1")
+ cdef THashMap[TString, int].iterator it = tmp.find("1")
self.assertTrue(it != tmp.end())
self.assertEqual(deref(it).second, 1)
diff --git a/util/generic/intrlist.h b/util/generic/intrlist.h
index f90561e24c..b5d3f2051b 100644
--- a/util/generic/intrlist.h
+++ b/util/generic/intrlist.h
@@ -16,13 +16,13 @@ private:
using TListItem = TIntrusiveListItem<T, Tag>;
public:
- inline TIntrusiveListItem() noexcept
+ inline TIntrusiveListItem() noexcept
: Next_(this)
, Prev_(Next_)
{
}
- inline ~TIntrusiveListItem() {
+ inline ~TIntrusiveListItem() {
Unlink();
}
@@ -31,7 +31,7 @@ public:
return (Prev_ == this) && (Next_ == this);
}
- inline void Unlink() noexcept {
+ inline void Unlink() noexcept {
if (Empty()) {
return;
}
@@ -42,12 +42,12 @@ public:
SetEnd();
}
- inline void LinkBefore(TListItem* before) noexcept {
+ inline void LinkBefore(TListItem* before) noexcept {
Unlink();
LinkBeforeNoUnlink(before);
}
- inline void LinkBeforeNoUnlink(TListItem* before) noexcept {
+ inline void LinkBeforeNoUnlink(TListItem* before) noexcept {
TListItem* const after = before->Prev();
after->SetNext(this);
@@ -56,56 +56,56 @@ public:
before->SetPrev(this);
}
- inline void LinkBefore(TListItem& before) noexcept {
+ inline void LinkBefore(TListItem& before) noexcept {
LinkBefore(&before);
}
- inline void LinkAfter(TListItem* after) noexcept {
+ inline void LinkAfter(TListItem* after) noexcept {
Unlink();
LinkBeforeNoUnlink(after->Next());
}
- inline void LinkAfter(TListItem& after) noexcept {
+ inline void LinkAfter(TListItem& after) noexcept {
LinkAfter(&after);
}
public:
- inline TListItem* Prev() noexcept {
+ inline TListItem* Prev() noexcept {
return Prev_;
}
- inline const TListItem* Prev() const noexcept {
+ inline const TListItem* Prev() const noexcept {
return Prev_;
}
- inline TListItem* Next() noexcept {
+ inline TListItem* Next() noexcept {
return Next_;
}
- inline const TListItem* Next() const noexcept {
+ inline const TListItem* Next() const noexcept {
return Next_;
}
public:
- inline void SetEnd() noexcept {
+ inline void SetEnd() noexcept {
Prev_ = this;
Next_ = Prev_;
}
- inline void SetNext(TListItem* item) noexcept {
+ inline void SetNext(TListItem* item) noexcept {
Next_ = item;
}
- inline void SetPrev(TListItem* item) noexcept {
+ inline void SetPrev(TListItem* item) noexcept {
Prev_ = item;
}
public:
- inline T* Node() noexcept {
+ inline T* Node() noexcept {
return static_cast<T*>(this);
}
- inline const T* Node() const noexcept {
+ inline const T* Node() const noexcept {
return static_cast<const T*>(this);
}
@@ -137,51 +137,51 @@ private:
using reference = TReference;
using pointer = TPointer;
- inline TIteratorBase() noexcept
+ inline TIteratorBase() noexcept
: Item_(nullptr)
{
}
template <class TListItem_, class TNode_>
- inline TIteratorBase(const TIteratorBase<TListItem_, TNode_>& right) noexcept
+ inline TIteratorBase(const TIteratorBase<TListItem_, TNode_>& right) noexcept
: Item_(right.Item())
{
}
- inline TIteratorBase(TItem* item) noexcept
+ inline TIteratorBase(TItem* item) noexcept
: Item_(item)
{
}
- inline TItem* Item() const noexcept {
+ inline TItem* Item() const noexcept {
return Item_;
}
- inline void Next() noexcept {
+ inline void Next() noexcept {
Item_ = Item_->Next();
}
- inline void Prev() noexcept {
+ inline void Prev() noexcept {
Item_ = Item_->Prev();
}
template <class TListItem_, class TNode_>
- inline bool operator==(const TIteratorBase<TListItem_, TNode_>& right) const noexcept {
+ inline bool operator==(const TIteratorBase<TListItem_, TNode_>& right) const noexcept {
return Item() == right.Item();
}
template <class TListItem_, class TNode_>
- inline bool operator!=(const TIteratorBase<TListItem_, TNode_>& right) const noexcept {
+ inline bool operator!=(const TIteratorBase<TListItem_, TNode_>& right) const noexcept {
return Item() != right.Item();
}
- inline TIteratorBase& operator++() noexcept {
+ inline TIteratorBase& operator++() noexcept {
Next();
return *this;
}
- inline TIteratorBase operator++(int) noexcept {
+ inline TIteratorBase operator++(int) noexcept {
TIteratorBase ret(*this);
Next();
@@ -189,13 +189,13 @@ private:
return ret;
}
- inline TIteratorBase& operator--() noexcept {
+ inline TIteratorBase& operator--() noexcept {
Prev();
return *this;
}
- inline TIteratorBase operator--(int) noexcept {
+ inline TIteratorBase operator--(int) noexcept {
TIteratorBase ret(*this);
Prev();
@@ -203,11 +203,11 @@ private:
return ret;
}
- inline TReference operator*() const noexcept {
+ inline TReference operator*() const noexcept {
return *Item_->Node();
}
- inline TPointer operator->() const noexcept {
+ inline TPointer operator->() const noexcept {
return Item_->Node();
}
@@ -232,51 +232,51 @@ private:
inline TReverseIteratorBase() noexcept = default;
template <class TIterator_>
- inline TReverseIteratorBase(const TReverseIteratorBase<TIterator_>& right) noexcept
+ inline TReverseIteratorBase(const TReverseIteratorBase<TIterator_>& right) noexcept
: Current_(right.Base())
{
}
- inline explicit TReverseIteratorBase(TIterator item) noexcept
+ inline explicit TReverseIteratorBase(TIterator item) noexcept
: Current_(item)
{
}
- inline TIterator Base() const noexcept {
+ inline TIterator Base() const noexcept {
return Current_;
}
- inline TItem* Item() const noexcept {
+ inline TItem* Item() const noexcept {
TIterator ret = Current_;
return (--ret).Item();
}
- inline void Next() noexcept {
+ inline void Next() noexcept {
Current_.Prev();
}
- inline void Prev() noexcept {
+ inline void Prev() noexcept {
Current_.Next();
}
template <class TIterator_>
- inline bool operator==(const TReverseIteratorBase<TIterator_>& right) const noexcept {
+ inline bool operator==(const TReverseIteratorBase<TIterator_>& right) const noexcept {
return Base() == right.Base();
}
template <class TIterator_>
- inline bool operator!=(const TReverseIteratorBase<TIterator_>& right) const noexcept {
+ inline bool operator!=(const TReverseIteratorBase<TIterator_>& right) const noexcept {
return Base() != right.Base();
}
- inline TReverseIteratorBase& operator++() noexcept {
+ inline TReverseIteratorBase& operator++() noexcept {
Next();
return *this;
}
- inline TReverseIteratorBase operator++(int) noexcept {
+ inline TReverseIteratorBase operator++(int) noexcept {
TReverseIteratorBase ret(*this);
Next();
@@ -284,13 +284,13 @@ private:
return ret;
}
- inline TReverseIteratorBase& operator--() noexcept {
+ inline TReverseIteratorBase& operator--() noexcept {
Prev();
return *this;
}
- inline TReverseIteratorBase operator--(int) noexcept {
+ inline TReverseIteratorBase operator--(int) noexcept {
TReverseIteratorBase ret(*this);
Prev();
@@ -298,13 +298,13 @@ private:
return ret;
}
- inline TReference operator*() const noexcept {
+ inline TReference operator*() const noexcept {
TIterator ret = Current_;
return *--ret;
}
- inline TPointer operator->() const noexcept {
+ inline TPointer operator->() const noexcept {
TIterator ret = Current_;
return &*--ret;
@@ -328,7 +328,7 @@ public:
using const_reverse_iterator = TConstReverseIterator;
public:
- inline void Swap(TIntrusiveList& right) noexcept {
+ inline void Swap(TIntrusiveList& right) noexcept {
TIntrusiveList temp;
temp.Append(right);
@@ -344,7 +344,7 @@ public:
inline ~TIntrusiveList() = default;
- inline TIntrusiveList(TIntrusiveList&& right) noexcept {
+ inline TIntrusiveList(TIntrusiveList&& right) noexcept {
this->Swap(right);
}
@@ -353,7 +353,7 @@ public:
return *this;
}
- inline explicit operator bool() const noexcept {
+ inline explicit operator bool() const noexcept {
return !Empty();
}
@@ -361,7 +361,7 @@ public:
return End_.Empty();
}
- inline size_t Size() const noexcept {
+ inline size_t Size() const noexcept {
return std::distance(Begin(), End());
}
@@ -369,126 +369,126 @@ public:
item->Unlink();
}
- inline void Clear() noexcept {
+ inline void Clear() noexcept {
End_.Unlink();
}
public:
- inline TIterator Begin() noexcept {
+ inline TIterator Begin() noexcept {
return ++End();
}
- inline TIterator End() noexcept {
+ inline TIterator End() noexcept {
return TIterator(&End_);
}
- inline TConstIterator Begin() const noexcept {
+ inline TConstIterator Begin() const noexcept {
return ++End();
}
- inline TConstIterator End() const noexcept {
+ inline TConstIterator End() const noexcept {
return TConstIterator(&End_);
}
- inline TReverseIterator RBegin() noexcept {
+ inline TReverseIterator RBegin() noexcept {
return TReverseIterator(End());
}
- inline TReverseIterator REnd() noexcept {
+ inline TReverseIterator REnd() noexcept {
return TReverseIterator(Begin());
}
- inline TConstReverseIterator RBegin() const noexcept {
+ inline TConstReverseIterator RBegin() const noexcept {
return TConstReverseIterator(End());
}
- inline TConstReverseIterator REnd() const noexcept {
+ inline TConstReverseIterator REnd() const noexcept {
return TConstReverseIterator(Begin());
}
- inline TConstIterator CBegin() const noexcept {
+ inline TConstIterator CBegin() const noexcept {
return Begin();
}
- inline TConstIterator CEnd() const noexcept {
+ inline TConstIterator CEnd() const noexcept {
return End();
}
- inline TConstReverseIterator CRBegin() const noexcept {
+ inline TConstReverseIterator CRBegin() const noexcept {
return RBegin();
}
- inline TConstReverseIterator CREnd() const noexcept {
+ inline TConstReverseIterator CREnd() const noexcept {
return REnd();
}
public:
- inline iterator begin() noexcept {
+ inline iterator begin() noexcept {
return Begin();
}
- inline iterator end() noexcept {
+ inline iterator end() noexcept {
return End();
}
- inline const_iterator begin() const noexcept {
+ inline const_iterator begin() const noexcept {
return Begin();
}
- inline const_iterator end() const noexcept {
+ inline const_iterator end() const noexcept {
return End();
}
- inline reverse_iterator rbegin() noexcept {
+ inline reverse_iterator rbegin() noexcept {
return RBegin();
}
- inline reverse_iterator rend() noexcept {
+ inline reverse_iterator rend() noexcept {
return REnd();
}
- inline const_iterator cbegin() const noexcept {
+ inline const_iterator cbegin() const noexcept {
return CBegin();
}
- inline const_iterator cend() const noexcept {
+ inline const_iterator cend() const noexcept {
return CEnd();
}
- inline const_reverse_iterator crbegin() const noexcept {
+ inline const_reverse_iterator crbegin() const noexcept {
return CRBegin();
}
- inline const_reverse_iterator crend() const noexcept {
+ inline const_reverse_iterator crend() const noexcept {
return CREnd();
}
public:
- inline T* Back() noexcept {
+ inline T* Back() noexcept {
return End_.Prev()->Node();
}
- inline T* Front() noexcept {
+ inline T* Front() noexcept {
return End_.Next()->Node();
}
- inline const T* Back() const noexcept {
+ inline const T* Back() const noexcept {
return End_.Prev()->Node();
}
- inline const T* Front() const noexcept {
+ inline const T* Front() const noexcept {
return End_.Next()->Node();
}
- inline void PushBack(TListItem* item) noexcept {
+ inline void PushBack(TListItem* item) noexcept {
item->LinkBefore(End_);
}
- inline void PushFront(TListItem* item) noexcept {
+ inline void PushFront(TListItem* item) noexcept {
item->LinkAfter(End_);
}
- inline T* PopBack() noexcept {
+ inline T* PopBack() noexcept {
TListItem* const ret = End_.Prev();
ret->Unlink();
@@ -496,7 +496,7 @@ public:
return ret->Node();
}
- inline T* PopFront() noexcept {
+ inline T* PopFront() noexcept {
TListItem* const ret = End_.Next();
ret->Unlink();
@@ -504,11 +504,11 @@ public:
return ret->Node();
}
- inline void Append(TIntrusiveList& list) noexcept {
+ inline void Append(TIntrusiveList& list) noexcept {
Cut(list.Begin(), list.End(), End());
}
- inline static void Cut(TIterator begin, TIterator end, TIterator pasteBefore) noexcept {
+ inline static void Cut(TIterator begin, TIterator end, TIterator pasteBefore) noexcept {
if (begin == end) {
return;
}
@@ -602,12 +602,12 @@ public:
public:
inline TIntrusiveListWithAutoDelete() noexcept = default;
- inline TIntrusiveListWithAutoDelete(TIntrusiveListWithAutoDelete&& right) noexcept
+ inline TIntrusiveListWithAutoDelete(TIntrusiveListWithAutoDelete&& right) noexcept
: TIntrusiveList<T, Tag>(std::move(right))
{
}
- inline ~TIntrusiveListWithAutoDelete() {
+ inline ~TIntrusiveListWithAutoDelete() {
this->Clear();
}
@@ -617,18 +617,18 @@ public:
}
public:
- inline void Clear() noexcept {
+ inline void Clear() noexcept {
this->ForEach([](auto* item) {
D::Destroy(item);
});
}
- inline static void Cut(TIterator begin, TIterator end) noexcept {
+ inline static void Cut(TIterator begin, TIterator end) noexcept {
TIntrusiveListWithAutoDelete<T, D, Tag> temp;
Cut(begin, end, temp.End());
}
- inline static void Cut(TIterator begin, TIterator end, TIterator pasteBefore) noexcept {
+ inline static void Cut(TIterator begin, TIterator end, TIterator pasteBefore) noexcept {
TIntrusiveList<T, Tag>::Cut(begin, end, pasteBefore);
}
};
@@ -642,35 +642,35 @@ private:
using TListItem = TIntrusiveSListItem<T, Tag>;
public:
- inline TIntrusiveSListItem() noexcept
+ inline TIntrusiveSListItem() noexcept
: Next_(nullptr)
{
}
inline ~TIntrusiveSListItem() = default;
- inline bool IsEnd() const noexcept {
+ inline bool IsEnd() const noexcept {
return Next_ == nullptr;
}
- inline TListItem* Next() noexcept {
+ inline TListItem* Next() noexcept {
return Next_;
}
- inline const TListItem* Next() const noexcept {
+ inline const TListItem* Next() const noexcept {
return Next_;
}
- inline void SetNext(TListItem* item) noexcept {
+ inline void SetNext(TListItem* item) noexcept {
Next_ = item;
}
public:
- inline T* Node() noexcept {
+ inline T* Node() noexcept {
return static_cast<T*>(this);
}
- inline const T* Node() const noexcept {
+ inline const T* Node() const noexcept {
return static_cast<const T*>(this);
}
@@ -697,30 +697,30 @@ public:
using reference = TReference;
using iterator_category = std::forward_iterator_tag;
- inline TIteratorBase(TListItem* item) noexcept
+ inline TIteratorBase(TListItem* item) noexcept
: Item_(item)
{
}
- inline void Next() noexcept {
+ inline void Next() noexcept {
Item_ = Item_->Next();
}
- inline bool operator==(const TIteratorBase& right) const noexcept {
+ inline bool operator==(const TIteratorBase& right) const noexcept {
return Item_ == right.Item_;
}
- inline bool operator!=(const TIteratorBase& right) const noexcept {
+ inline bool operator!=(const TIteratorBase& right) const noexcept {
return Item_ != right.Item_;
}
- inline TIteratorBase& operator++() noexcept {
+ inline TIteratorBase& operator++() noexcept {
Next();
return *this;
}
- inline TIteratorBase operator++(int) noexcept {
+ inline TIteratorBase operator++(int) noexcept {
TIteratorBase ret(*this);
Next();
@@ -728,11 +728,11 @@ public:
return ret;
}
- inline TNode& operator*() noexcept {
+ inline TNode& operator*() noexcept {
return *Item_->Node();
}
- inline TNode* operator->() noexcept {
+ inline TNode* operator->() noexcept {
return Item_->Node();
}
@@ -748,16 +748,16 @@ public:
using const_iterator = TConstIterator;
public:
- inline TIntrusiveSList() noexcept
+ inline TIntrusiveSList() noexcept
: Begin_(nullptr)
{
}
- inline void Swap(TIntrusiveSList& right) noexcept {
+ inline void Swap(TIntrusiveSList& right) noexcept {
DoSwap(Begin_, right.Begin_);
}
- inline explicit operator bool() const noexcept {
+ inline explicit operator bool() const noexcept {
return !Empty();
}
@@ -765,79 +765,79 @@ public:
return Begin_ == nullptr;
}
- inline size_t Size() const noexcept {
+ inline size_t Size() const noexcept {
return std::distance(Begin(), End());
}
- inline void Clear() noexcept {
+ inline void Clear() noexcept {
Begin_ = nullptr;
}
- inline TIterator Begin() noexcept {
+ inline TIterator Begin() noexcept {
return TIterator(Begin_);
}
- inline TIterator End() noexcept {
+ inline TIterator End() noexcept {
return TIterator(nullptr);
}
- inline TConstIterator Begin() const noexcept {
+ inline TConstIterator Begin() const noexcept {
return TConstIterator(Begin_);
}
- inline TConstIterator End() const noexcept {
+ inline TConstIterator End() const noexcept {
return TConstIterator(nullptr);
}
- inline TConstIterator CBegin() const noexcept {
+ inline TConstIterator CBegin() const noexcept {
return Begin();
}
- inline TConstIterator CEnd() const noexcept {
+ inline TConstIterator CEnd() const noexcept {
return End();
}
//compat methods
- inline iterator begin() noexcept {
+ inline iterator begin() noexcept {
return Begin();
}
- inline iterator end() noexcept {
+ inline iterator end() noexcept {
return End();
}
- inline const_iterator begin() const noexcept {
+ inline const_iterator begin() const noexcept {
return Begin();
}
- inline const_iterator end() const noexcept {
+ inline const_iterator end() const noexcept {
return End();
}
- inline const_iterator cbegin() const noexcept {
+ inline const_iterator cbegin() const noexcept {
return CBegin();
}
- inline const_iterator cend() const noexcept {
+ inline const_iterator cend() const noexcept {
return CEnd();
}
- inline T* Front() noexcept {
+ inline T* Front() noexcept {
Y_ASSERT(Begin_);
return Begin_->Node();
}
- inline const T* Front() const noexcept {
+ inline const T* Front() const noexcept {
Y_ASSERT(Begin_);
return Begin_->Node();
}
- inline void PushFront(TListItem* item) noexcept {
+ inline void PushFront(TListItem* item) noexcept {
item->SetNext(Begin_);
Begin_ = item;
}
- inline T* PopFront() noexcept {
+ inline T* PopFront() noexcept {
Y_ASSERT(Begin_);
TListItem* const ret = Begin_;
@@ -846,7 +846,7 @@ public:
return ret->Node();
}
- inline void Reverse() noexcept {
+ inline void Reverse() noexcept {
TIntrusiveSList temp;
while (!Empty()) {
diff --git a/util/generic/intrlist_ut.cpp b/util/generic/intrlist_ut.cpp
index 7d6322d693..eff7cdf2ee 100644
--- a/util/generic/intrlist_ut.cpp
+++ b/util/generic/intrlist_ut.cpp
@@ -45,7 +45,7 @@ UNIT_TEST_SUITE_REGISTRATION(TListTest);
class TInt: public TIntrusiveListItem<TInt> {
public:
- inline TInt(int value) noexcept
+ inline TInt(int value) noexcept
: Value_(value)
{
}
@@ -62,11 +62,11 @@ public:
return *this;
}
- inline operator int&() noexcept {
+ inline operator int&() noexcept {
return Value_;
}
- inline operator const int&() const noexcept {
+ inline operator const int&() const noexcept {
return Value_;
}
@@ -88,7 +88,7 @@ public:
//operator=(const TMyList& rhs) = default;
TMyList& operator=(TMyList&& rhs) noexcept = default;
- inline ~TMyList() {
+ inline ~TMyList() {
while (!Empty()) {
delete PopBack();
}
@@ -96,7 +96,7 @@ public:
};
struct TIntGreater: private TGreater<int> {
- inline bool operator()(const TInt& l, const TInt& r) const noexcept {
+ inline bool operator()(const TInt& l, const TInt& r) const noexcept {
return TGreater<int>::operator()(l, r);
}
};
@@ -154,7 +154,7 @@ public:
{
}
- inline void operator()(const TInt* v) noexcept {
+ inline void operator()(const TInt* v) noexcept {
Sum_ += *v;
}
@@ -169,7 +169,7 @@ public:
{
}
- inline void operator()(TInt* v) noexcept {
+ inline void operator()(TInt* v) noexcept {
if (*v % 2) {
Sum_ += *v;
} else {
@@ -393,10 +393,10 @@ struct TSelfCountingIntDelete {
};
void TListTest::TestListWithAutoDelete() {
- using TListType = TIntrusiveListWithAutoDelete<TSelfCountingInt, TSelfCountingIntDelete>;
+ using TListType = TIntrusiveListWithAutoDelete<TSelfCountingInt, TSelfCountingIntDelete>;
int counter{0};
{
- TListType lst;
+ TListType lst;
UNIT_ASSERT(lst.Empty());
lst.PushFront(new TSelfCountingInt(counter, 2));
UNIT_ASSERT_EQUAL(lst.Size(), 1);
@@ -411,17 +411,17 @@ void TListTest::TestListWithAutoDelete() {
}
void TListTest::TestListWithAutoDeleteMoveCtor() {
- using TListType = TIntrusiveListWithAutoDelete<TSelfCountingInt, TSelfCountingIntDelete>;
+ using TListType = TIntrusiveListWithAutoDelete<TSelfCountingInt, TSelfCountingIntDelete>;
int counter{0};
{
- TListType lst;
+ TListType lst;
lst.PushFront(new TSelfCountingInt(counter, 2));
lst.PushFront(new TSelfCountingInt(counter, 1));
UNIT_ASSERT_EQUAL(lst.Size(), 2);
UNIT_ASSERT_EQUAL(counter, 2);
CheckList(lst);
- TListType nextList(std::move(lst));
+ TListType nextList(std::move(lst));
UNIT_ASSERT_EQUAL(nextList.Size(), 2);
CheckList(nextList);
UNIT_ASSERT_EQUAL(counter, 2);
@@ -431,17 +431,17 @@ void TListTest::TestListWithAutoDeleteMoveCtor() {
}
void TListTest::TestListWithAutoDeleteMoveOpEq() {
- using TListType = TIntrusiveListWithAutoDelete<TSelfCountingInt, TSelfCountingIntDelete>;
+ using TListType = TIntrusiveListWithAutoDelete<TSelfCountingInt, TSelfCountingIntDelete>;
int counter{0};
{
- TListType lst;
+ TListType lst;
lst.PushFront(new TSelfCountingInt(counter, 2));
lst.PushFront(new TSelfCountingInt(counter, 1));
UNIT_ASSERT_EQUAL(lst.Size(), 2);
UNIT_ASSERT_EQUAL(counter, 2);
CheckList(lst);
- TListType nextList;
+ TListType nextList;
UNIT_ASSERT(nextList.Empty());
nextList = std::move(lst);
UNIT_ASSERT_EQUAL(nextList.Size(), 2);
@@ -453,10 +453,10 @@ void TListTest::TestListWithAutoDeleteMoveOpEq() {
}
void TListTest::TestListWithAutoDeleteClear() {
- using TListType = TIntrusiveListWithAutoDelete<TSelfCountingInt, TSelfCountingIntDelete>;
+ using TListType = TIntrusiveListWithAutoDelete<TSelfCountingInt, TSelfCountingIntDelete>;
int counter{0};
{
- TListType lst;
+ TListType lst;
UNIT_ASSERT(lst.Empty());
lst.PushFront(new TSelfCountingInt(counter, 2));
UNIT_ASSERT_EQUAL(lst.Size(), 1);
diff --git a/util/generic/is_in_ut.cpp b/util/generic/is_in_ut.cpp
index b98b37aa70..c668bce807 100644
--- a/util/generic/is_in_ut.cpp
+++ b/util/generic/is_in_ut.cpp
@@ -7,7 +7,7 @@
#include "map.h"
#include "set.h"
#include "strbuf.h"
-#include "string.h"
+#include "string.h"
Y_UNIT_TEST_SUITE(TIsIn) {
template <class TCont, class T>
@@ -41,18 +41,18 @@ Y_UNIT_TEST_SUITE(TIsIn) {
}
Y_UNIT_TEST(IsInTest) {
- TestIsInWithCont<TMap<TString, TString>>(std::make_pair("found", "1"));
- TestIsInWithCont<TMultiMap<TString, TString>>(std::make_pair("found", "1"));
- TestIsInWithCont<THashMap<TString, TString>>(std::make_pair("found", "1"));
- TestIsInWithCont<THashMultiMap<TString, TString>>(std::make_pair("found", "1"));
+ TestIsInWithCont<TMap<TString, TString>>(std::make_pair("found", "1"));
+ TestIsInWithCont<TMultiMap<TString, TString>>(std::make_pair("found", "1"));
+ TestIsInWithCont<THashMap<TString, TString>>(std::make_pair("found", "1"));
+ TestIsInWithCont<THashMultiMap<TString, TString>>(std::make_pair("found", "1"));
- TestIsInWithCont<TSet<TString>>("found");
- TestIsInWithCont<TMultiSet<TString>>("found");
- TestIsInWithCont<THashSet<TString>>("found");
- TestIsInWithCont<THashMultiSet<TString>>("found");
+ TestIsInWithCont<TSet<TString>>("found");
+ TestIsInWithCont<TMultiSet<TString>>("found");
+ TestIsInWithCont<THashSet<TString>>("found");
+ TestIsInWithCont<THashMultiSet<TString>>("found");
// vector also compiles and works
- TVector<TString> v;
+ TVector<TString> v;
v.push_back("found");
UNIT_ASSERT(IsIn(v, "found"));
UNIT_ASSERT(!IsIn(v, "not found"));
@@ -61,8 +61,8 @@ Y_UNIT_TEST_SUITE(TIsIn) {
UNIT_ASSERT(IsIn(v.begin(), v.end(), "found"));
UNIT_ASSERT(!IsIn(v.begin(), v.end(), "not found"));
- // Works with TString (it has find, but find is not used)
- TString s = "found";
+ // Works with TString (it has find, but find is not used)
+ TString s = "found";
UNIT_ASSERT(IsIn(s, 'f'));
UNIT_ASSERT(!IsIn(s, 'z'));
@@ -87,7 +87,7 @@ Y_UNIT_TEST_SUITE(TIsIn) {
UNIT_ASSERT(IsIn({abc, def}, def)); // direct pointer comparison
UNIT_ASSERT(!IsIn({TStringBuf("abc"), TStringBuf("def")}, TStringBuf("ghi")));
UNIT_ASSERT(!IsIn({"abc", "def"}, TStringBuf("ghi")));
- UNIT_ASSERT(!IsIn({"abc", "def"}, TString("ghi")));
+ UNIT_ASSERT(!IsIn({"abc", "def"}, TString("ghi")));
const TStringBuf str = "abc////";
@@ -98,11 +98,11 @@ Y_UNIT_TEST_SUITE(TIsIn) {
UNIT_ASSERT(IsIn({1, 2, 3}, 1));
UNIT_ASSERT(!IsIn({1, 2, 3}, 4));
- const TString b = "b";
+ const TString b = "b";
UNIT_ASSERT(!IsIn({"a", "b", "c"}, b.data())); // compares pointers by value. Whether it's good or not.
UNIT_ASSERT(IsIn(TVector<TStringBuf>({"a", "b", "c"}), b.data()));
- UNIT_ASSERT(IsIn(TVector<TStringBuf>({"a", "b", "c"}), "b"));
+ UNIT_ASSERT(IsIn(TVector<TStringBuf>({"a", "b", "c"}), "b"));
}
Y_UNIT_TEST(IsInArrayTest) {
diff --git a/util/generic/iterator_range_ut.cpp b/util/generic/iterator_range_ut.cpp
index abd59a94cd..a7e3670ae1 100644
--- a/util/generic/iterator_range_ut.cpp
+++ b/util/generic/iterator_range_ut.cpp
@@ -69,7 +69,7 @@ Y_UNIT_TEST_SUITE(IteratorRange) {
}
Y_UNIT_TEST(OperatorsAndReferences) {
- TVector<size_t> values{1, 2, 3, 4, 5};
+ TVector<size_t> values{1, 2, 3, 4, 5};
auto range = MakeIteratorRange(values.begin(), values.end());
UNIT_ASSERT_VALUES_EQUAL(range[2], 3);
UNIT_ASSERT_VALUES_EQUAL(range[range[2]], 4);
@@ -78,7 +78,7 @@ Y_UNIT_TEST_SUITE(IteratorRange) {
range[0] = 100501;
UNIT_ASSERT_VALUES_EQUAL(range[0], 100501);
- TVector<bool> valuesBool{false, true, false, false, false, false, true};
+ TVector<bool> valuesBool{false, true, false, false, false, false, true};
auto rangeBVector = MakeIteratorRange(valuesBool.begin(), valuesBool.end());
UNIT_ASSERT_VALUES_EQUAL(rangeBVector[1], true);
rangeBVector[0] = true;
diff --git a/util/generic/iterator_ut.cpp b/util/generic/iterator_ut.cpp
index a24e7502ef..00be19e10e 100644
--- a/util/generic/iterator_ut.cpp
+++ b/util/generic/iterator_ut.cpp
@@ -4,7 +4,7 @@
Y_UNIT_TEST_SUITE(TIterator) {
Y_UNIT_TEST(ToForwardIteratorTest) {
- TVector<int> x = {1, 2};
+ TVector<int> x = {1, 2};
UNIT_ASSERT_VALUES_EQUAL(*std::prev(x.end()), *ToForwardIterator(x.rbegin()));
UNIT_ASSERT_VALUES_EQUAL(*ToForwardIterator(std::prev(x.rend())), *x.begin());
}
diff --git a/util/generic/lazy_value_ut.cpp b/util/generic/lazy_value_ut.cpp
index 9669204b6b..f6135880c3 100644
--- a/util/generic/lazy_value_ut.cpp
+++ b/util/generic/lazy_value_ut.cpp
@@ -98,7 +98,7 @@ Y_UNIT_TEST_SUITE(TLazyValueTestSuite) {
{
}
- const TString& GetData() const {
+ const TString& GetData() const {
return *Data_;
}
diff --git a/util/generic/list.h b/util/generic/list.h
index 40b99bc474..7b0b8ffc72 100644
--- a/util/generic/list.h
+++ b/util/generic/list.h
@@ -10,7 +10,7 @@
#include <utility>
template <class T, class A>
-class TList: public std::list<T, TReboundAllocator<A, T>> {
+class TList: public std::list<T, TReboundAllocator<A, T>> {
using TBase = std::list<T, TReboundAllocator<A, T>>;
public:
diff --git a/util/generic/list_ut.cpp b/util/generic/list_ut.cpp
index 79c806f827..9e60ecf01b 100644
--- a/util/generic/list_ut.cpp
+++ b/util/generic/list_ut.cpp
@@ -4,8 +4,8 @@
Y_UNIT_TEST_SUITE(TYListSuite) {
Y_UNIT_TEST(TestInitializerList) {
- TList<int> l = {3, 42, 6};
- TList<int> expected;
+ TList<int> l = {3, 42, 6};
+ TList<int> expected;
expected.push_back(3);
expected.push_back(42);
expected.push_back(6);
diff --git a/util/generic/map.h b/util/generic/map.h
index 399a521683..b5001b56c0 100644
--- a/util/generic/map.h
+++ b/util/generic/map.h
@@ -12,7 +12,7 @@
#include <memory>
template <class K, class V, class Less, class A>
-class TMap: public std::map<K, V, Less, TReboundAllocator<A, std::pair<const K, V>>>, public TMapOps<TMap<K, V, Less, A>> {
+class TMap: public std::map<K, V, Less, TReboundAllocator<A, std::pair<const K, V>>>, public TMapOps<TMap<K, V, Less, A>> {
using TBase = std::map<K, V, Less, TReboundAllocator<A, std::pair<const K, V>>>;
public:
@@ -28,7 +28,7 @@ public:
};
template <class K, class V, class Less, class A>
-class TMultiMap: public std::multimap<K, V, Less, TReboundAllocator<A, std::pair<const K, V>>> {
+class TMultiMap: public std::multimap<K, V, Less, TReboundAllocator<A, std::pair<const K, V>>> {
using TBase = std::multimap<K, V, Less, TReboundAllocator<A, std::pair<const K, V>>>;
public:
diff --git a/util/generic/map_ut.cpp b/util/generic/map_ut.cpp
index 0987ecf705..79e832b024 100644
--- a/util/generic/map_ut.cpp
+++ b/util/generic/map_ut.cpp
@@ -13,31 +13,31 @@ Y_UNIT_TEST_SUITE(TYMapTest) {
Y_UNIT_TEST(TestMap1) {
{
- TMap<char, int, TLess<char>> m;
+ TMap<char, int, TLess<char>> m;
DoTestMap1(m);
}
{
TMemoryPool p(100);
- TMap<char, int, TLess<char>, TPoolAllocator> m(&p);
+ TMap<char, int, TLess<char>, TPoolAllocator> m(&p);
DoTestMap1(m);
}
}
Y_UNIT_TEST(TestMMap1) {
{
- TMultiMap<char, int, TLess<char>> mm;
+ TMultiMap<char, int, TLess<char>> mm;
DoTestMMap1(mm);
}
{
TMemoryPool p(100);
- TMultiMap<char, int, TLess<char>, TPoolAllocator> mm(&p);
+ TMultiMap<char, int, TLess<char>, TPoolAllocator> mm(&p);
DoTestMMap1(mm);
}
}
template <typename TAlloc>
void DoTestMap1(TMap<char, int, TLess<char>, TAlloc>& m) {
- using maptype = TMap<char, int, TLess<char>, TAlloc>;
+ using maptype = TMap<char, int, TLess<char>, TAlloc>;
// Store mappings between roman numerals and decimals.
m['l'] = 50;
m['x'] = 20; // Deliberate mistake.
@@ -68,7 +68,7 @@ Y_UNIT_TEST_SUITE(TYMapTest) {
template <typename TAlloc>
void DoTestMMap1(TMultiMap<char, int, TLess<char>, TAlloc>& m) {
- using mmap = TMultiMap<char, int, TLess<char>, TAlloc>;
+ using mmap = TMultiMap<char, int, TLess<char>, TAlloc>;
UNIT_ASSERT(m.count('X') == 0);
@@ -103,7 +103,7 @@ Y_UNIT_TEST_SUITE(TYMapTest) {
pair_type p5(3, 'x');
pair_type p6(6, 'f');
- using mmap = TMultiMap<int, char, TLess<int>>;
+ using mmap = TMultiMap<int, char, TLess<int>>;
pair_type array[] = {
p1,
@@ -125,7 +125,7 @@ Y_UNIT_TEST_SUITE(TYMapTest) {
}
Y_UNIT_TEST(TestIterators) {
- using int_map = TMap<int, char, TLess<int>>;
+ using int_map = TMap<int, char, TLess<int>>;
int_map imap;
{
@@ -138,7 +138,7 @@ Y_UNIT_TEST_SUITE(TYMapTest) {
UNIT_ASSERT(!(cite != ite));
}
- using mmap = TMultiMap<int, char, TLess<int>>;
+ using mmap = TMultiMap<int, char, TLess<int>>;
using pair_type = mmap::value_type;
pair_type p1(3, 'c');
@@ -188,7 +188,7 @@ Y_UNIT_TEST_SUITE(TYMapTest) {
}
Y_UNIT_TEST(TestEqualRange) {
- using maptype = TMap<char, int, TLess<char>>;
+ using maptype = TMap<char, int, TLess<char>>;
{
maptype m;
@@ -276,7 +276,7 @@ Y_UNIT_TEST_SUITE(TYMapTest) {
Y_UNIT_TEST(TestTemplateMethods) {
{
- using Container = TMap<TKey, int, TKeyCmp>;
+ using Container = TMap<TKey, int, TKeyCmp>;
using value = Container::value_type;
Container cont;
@@ -304,7 +304,7 @@ Y_UNIT_TEST_SUITE(TYMapTest) {
}
{
- using Container = TMap<TKey*, int, TKeyCmpPtr>;
+ using Container = TMap<TKey*, int, TKeyCmpPtr>;
using value = Container::value_type;
Container cont;
@@ -333,7 +333,7 @@ Y_UNIT_TEST_SUITE(TYMapTest) {
}
{
- using Container = TMultiMap<TKey, int, TKeyCmp>;
+ using Container = TMultiMap<TKey, int, TKeyCmp>;
using value = Container::value_type;
Container cont;
@@ -361,7 +361,7 @@ Y_UNIT_TEST_SUITE(TYMapTest) {
}
{
- using Container = TMultiMap<TKey const volatile*, int, TKeyCmpPtr>;
+ using Container = TMultiMap<TKey const volatile*, int, TKeyCmpPtr>;
using value = Container::value_type;
Container cont;
@@ -399,8 +399,8 @@ Y_UNIT_TEST_SUITE(TYMapTest) {
}
Y_UNIT_TEST(TestEmpty) {
- EmptyAndInsertTest<TMap<char, int, TLess<char>>>(std::pair<char, int>('a', 1));
- EmptyAndInsertTest<TMultiMap<char, int, TLess<char>>>(std::pair<char, int>('a', 1));
+ EmptyAndInsertTest<TMap<char, int, TLess<char>>>(std::pair<char, int>('a', 1));
+ EmptyAndInsertTest<TMultiMap<char, int, TLess<char>>>(std::pair<char, int>('a', 1));
}
struct TParametrizedKeyCmp {
@@ -421,7 +421,7 @@ Y_UNIT_TEST_SUITE(TYMapTest) {
};
Y_UNIT_TEST(TestMoveComparator) {
- using Container = TMultiMap<TKey, int, TParametrizedKeyCmp>;
+ using Container = TMultiMap<TKey, int, TParametrizedKeyCmp>;
TParametrizedKeyCmp direct(false);
TParametrizedKeyCmp inverse(true);
@@ -434,7 +434,7 @@ Y_UNIT_TEST_SUITE(TYMapTest) {
c.insert(std::make_pair(TKey(2), 102));
c.insert(std::make_pair(TKey(3), 103));
- TVector<int> values;
+ TVector<int> values;
for (auto& i : c) {
values.push_back(i.second);
}
@@ -447,7 +447,7 @@ Y_UNIT_TEST_SUITE(TYMapTest) {
}
Y_UNIT_TEST(TestMapInitializerList) {
- TMap<TString, int> m = {
+ TMap<TString, int> m = {
{"one", 1},
{"two", 2},
{"three", 3},
@@ -462,14 +462,14 @@ Y_UNIT_TEST_SUITE(TYMapTest) {
}
Y_UNIT_TEST(TestMMapInitializerList) {
- TMultiMap<TString, int> mm = {
+ TMultiMap<TString, int> mm = {
{"one", 1},
{"two", 2},
{"two", -2},
{"three", 3},
};
UNIT_ASSERT(mm.contains("two"));
- TMultiMap<TString, int> expected;
+ TMultiMap<TString, int> expected;
expected.emplace("one", 1);
expected.emplace("two", 2);
expected.emplace("two", -2);
@@ -478,7 +478,7 @@ Y_UNIT_TEST_SUITE(TYMapTest) {
}
Y_UNIT_TEST(TestMovePoolAlloc) {
- using TMapInPool = TMap<int, int, TLess<int>, TPoolAllocator>;
+ using TMapInPool = TMap<int, int, TLess<int>, TPoolAllocator>;
TMemoryPool pool(1);
diff --git a/util/generic/mapfindptr.h b/util/generic/mapfindptr.h
index 540b4df20a..bc10cac60f 100644
--- a/util/generic/mapfindptr.h
+++ b/util/generic/mapfindptr.h
@@ -24,7 +24,7 @@ inline auto MapFindPtr(const Map& map, const K& key) {
return (i == map.end() ? nullptr : &i->second);
}
-/** helper for THashMap/TMap */
+/** helper for THashMap/TMap */
template <class Derived>
struct TMapOps {
template <class K>
diff --git a/util/generic/mapfindptr_ut.cpp b/util/generic/mapfindptr_ut.cpp
index 83e3c220bc..613da7a96b 100644
--- a/util/generic/mapfindptr_ut.cpp
+++ b/util/generic/mapfindptr_ut.cpp
@@ -1,4 +1,4 @@
-#include "string.h"
+#include "string.h"
#include "hash.h"
#include <library/cpp/testing/unittest/registar.h>
@@ -19,7 +19,7 @@ Y_UNIT_TEST_SUITE(TMapFindPtrTest) {
UNIT_ASSERT_EQUAL(a.FindPtr(0), nullptr);
//test mutation
- if (TString* p = a.FindPtr(42)) {
+ if (TString* p = a.FindPtr(42)) {
*p = "dog";
}
UNIT_ASSERT(a.FindPtr(42));
@@ -35,9 +35,9 @@ Y_UNIT_TEST_SUITE(TMapFindPtrTest) {
}
Y_UNIT_TEST(TestTemplateFind) {
- THashMap<TString, int> m;
+ THashMap<TString, int> m;
- m[TString("x")] = 2;
+ m[TString("x")] = 2;
UNIT_ASSERT(m.FindPtr(TStringBuf("x")));
UNIT_ASSERT_EQUAL(*m.FindPtr(TStringBuf("x")), 2);
@@ -57,8 +57,8 @@ Y_UNIT_TEST_SUITE(TMapFindPtrTest) {
a[1] = "lol";
- const TString str123 = "123";
- TString str1234 = "1234";
+ const TString str123 = "123";
+ TString str1234 = "1234";
UNIT_ASSERT_VALUES_EQUAL(a.ValueRef(1, str123), "lol");
UNIT_ASSERT_VALUES_EQUAL(a.ValueRef(2, str123), "123");
diff --git a/util/generic/maybe.h b/util/generic/maybe.h
index f5226fee46..34d21aebcd 100644
--- a/util/generic/maybe.h
+++ b/util/generic/maybe.h
@@ -19,21 +19,21 @@ namespace NMaybe {
};
}
-struct TNothing {
+struct TNothing {
explicit constexpr TNothing(int) noexcept {
}
-};
-
-constexpr TNothing NothingObject{0};
-
-constexpr TNothing Nothing() noexcept {
- return NothingObject;
-}
-
-constexpr bool operator==(TNothing, TNothing) noexcept {
- return true;
-}
-
+};
+
+constexpr TNothing NothingObject{0};
+
+constexpr TNothing Nothing() noexcept {
+ return NothingObject;
+}
+
+constexpr bool operator==(TNothing, TNothing) noexcept {
+ return true;
+}
+
template <class T, class Policy /*= ::NMaybe::TPolicyUndefinedExcept*/>
class TMaybe: private TMaybeBase<T> {
public:
@@ -48,7 +48,7 @@ private:
"Instantiation of TMaybe with reference type is ill-formed");
static_assert(std::is_destructible<T>::value,
"Instantiation of TMaybe with non-destructible type is ill-formed");
-
+
template <class U>
struct TConstructibleFromMaybeSomehow {
public:
@@ -152,13 +152,13 @@ private:
};
using TBase = TMaybeBase<T>;
-
+
public:
using value_type = T;
using TValueType = value_type;
-
+
TMaybe() noexcept = default;
-
+
constexpr TMaybe(const TMaybe&) = default;
constexpr TMaybe(TMaybe&&) = default;
@@ -168,15 +168,15 @@ public:
{
}
- template <class U, class... TArgs>
- constexpr explicit TMaybe(TInPlace, std::initializer_list<U> il, TArgs&&... args)
+ template <class U, class... TArgs>
+ constexpr explicit TMaybe(TInPlace, std::initializer_list<U> il, TArgs&&... args)
: TBase(TInPlace{}, il, std::forward<TArgs>(args)...)
{
}
-
+
constexpr TMaybe(TNothing) noexcept {
}
-
+
template <class U, class = std::enable_if_t<TImplicitCopyCtor<U>::value>>
TMaybe(const TMaybe<U, Policy>& right) {
if (right.Defined()) {
@@ -227,10 +227,10 @@ public:
constexpr TMaybe& operator=(TMaybe&&) = default;
TMaybe& operator=(TNothing) noexcept {
- Clear();
- return *this;
- }
-
+ Clear();
+ return *this;
+ }
+
template <class U = T>
std::enable_if_t<TAssignableFromAny<U>::value, TMaybe&> operator=(U&& right) {
if (Defined()) {
@@ -287,7 +287,7 @@ public:
void Clear() noexcept {
if (Defined()) {
this->Defined_ = false;
- Data()->~T();
+ Data()->~T();
}
}
@@ -382,7 +382,7 @@ public:
return Defined() ? TMaybe<U, Policy>(*Data()) : TMaybe<U, Policy>();
}
- constexpr explicit operator bool() const noexcept {
+ constexpr explicit operator bool() const noexcept {
return Defined();
}
@@ -413,25 +413,25 @@ public:
}
void Swap(TMaybe& other) {
- if (this->Defined_ == other.Defined_) {
- if (this->Defined_) {
- ::DoSwap(this->Data_, other.Data_);
- }
- } else {
- if (this->Defined_) {
- other.Init(std::move(this->Data_));
- this->Clear();
- } else {
- this->Init(std::move(other.Data_));
- other.Clear();
- }
- }
- }
-
+ if (this->Defined_ == other.Defined_) {
+ if (this->Defined_) {
+ ::DoSwap(this->Data_, other.Data_);
+ }
+ } else {
+ if (this->Defined_) {
+ other.Init(std::move(this->Data_));
+ this->Clear();
+ } else {
+ this->Init(std::move(other.Data_));
+ other.Clear();
+ }
+ }
+ }
+
void swap(TMaybe& other) {
- Swap(other);
- }
-
+ Swap(other);
+ }
+
private:
constexpr const T* Data() const noexcept {
return std::addressof(this->Data_);
@@ -454,28 +454,28 @@ using TMaybeFail = TMaybe<T, NMaybe::TPolicyUndefinedFail>;
template <class T, class TPolicy = ::NMaybe::TPolicyUndefinedExcept>
constexpr TMaybe<std::decay_t<T>, TPolicy> MakeMaybe(T&& value) {
return TMaybe<std::decay_t<T>, TPolicy>(std::forward<T>(value));
-}
-
-template <class T, class... TArgs>
-constexpr TMaybe<T> MakeMaybe(TArgs&&... args) {
- return TMaybe<T>(typename TMaybe<T>::TInPlace{}, std::forward<TArgs>(args)...);
-}
-
-template <class T, class U, class... TArgs>
-constexpr TMaybe<T> MakeMaybe(std::initializer_list<U> il, TArgs&&... args) {
- return TMaybe<T>(typename TMaybe<T>::TInPlace{}, il, std::forward<TArgs>(args)...);
-}
-
+}
+
+template <class T, class... TArgs>
+constexpr TMaybe<T> MakeMaybe(TArgs&&... args) {
+ return TMaybe<T>(typename TMaybe<T>::TInPlace{}, std::forward<TArgs>(args)...);
+}
+
+template <class T, class U, class... TArgs>
+constexpr TMaybe<T> MakeMaybe(std::initializer_list<U> il, TArgs&&... args) {
+ return TMaybe<T>(typename TMaybe<T>::TInPlace{}, il, std::forward<TArgs>(args)...);
+}
+
template <class T, class TPolicy>
void Swap(TMaybe<T, TPolicy>& lhs, TMaybe<T, TPolicy>& rhs) {
- lhs.Swap(rhs);
-}
-
+ lhs.Swap(rhs);
+}
+
template <class T, class TPolicy>
void swap(TMaybe<T, TPolicy>& lhs, TMaybe<T, TPolicy>& rhs) {
- lhs.Swap(rhs);
-}
-
+ lhs.Swap(rhs);
+}
+
template <typename T, class TPolicy>
struct THash<TMaybe<T, TPolicy>> {
constexpr size_t operator()(const TMaybe<T, TPolicy>& data) const {
@@ -483,7 +483,7 @@ struct THash<TMaybe<T, TPolicy>> {
}
};
-// Comparisons between TMaybe
+// Comparisons between TMaybe
template <class T, class TPolicy>
constexpr bool operator==(const ::TMaybe<T, TPolicy>& left, const ::TMaybe<T, TPolicy>& right) {
return (static_cast<bool>(left) != static_cast<bool>(right))
@@ -496,218 +496,218 @@ constexpr bool operator==(const ::TMaybe<T, TPolicy>& left, const ::TMaybe<T, TP
template <class T, class TPolicy>
constexpr bool operator!=(const TMaybe<T, TPolicy>& left, const TMaybe<T, TPolicy>& right) {
- return !(left == right);
+ return !(left == right);
}
-
+
template <class T, class TPolicy>
constexpr bool operator<(const TMaybe<T, TPolicy>& left, const TMaybe<T, TPolicy>& right) {
- return (!static_cast<bool>(right))
+ return (!static_cast<bool>(right))
? false
: (
!static_cast<bool>(left)
? true
: (*left < *right));
-}
-
+}
+
template <class T, class TPolicy>
constexpr bool operator>(const TMaybe<T, TPolicy>& left, const TMaybe<T, TPolicy>& right) {
- return right < left;
-}
-
+ return right < left;
+}
+
template <class T, class TPolicy>
constexpr bool operator<=(const TMaybe<T, TPolicy>& left, const TMaybe<T, TPolicy>& right) {
- return !(right < left);
-}
-
+ return !(right < left);
+}
+
template <class T, class TPolicy>
constexpr bool operator>=(const TMaybe<T, TPolicy>& left, const TMaybe<T, TPolicy>& right) {
- return !(left < right);
-}
-
-// Comparisons with TNothing
+ return !(left < right);
+}
+
+// Comparisons with TNothing
template <class T, class TPolicy>
constexpr bool operator==(const TMaybe<T, TPolicy>& left, TNothing) noexcept {
- return !static_cast<bool>(left);
-}
-
+ return !static_cast<bool>(left);
+}
+
template <class T, class TPolicy>
constexpr bool operator==(TNothing, const TMaybe<T, TPolicy>& right) noexcept {
- return !static_cast<bool>(right);
-}
-
+ return !static_cast<bool>(right);
+}
+
template <class T, class TPolicy>
constexpr bool operator!=(const TMaybe<T, TPolicy>& left, TNothing) noexcept {
- return static_cast<bool>(left);
-}
-
+ return static_cast<bool>(left);
+}
+
template <class T, class TPolicy>
constexpr bool operator!=(TNothing, const TMaybe<T, TPolicy>& right) noexcept {
- return static_cast<bool>(right);
-}
-
+ return static_cast<bool>(right);
+}
+
template <class T, class TPolicy>
constexpr bool operator<(const TMaybe<T, TPolicy>&, TNothing) noexcept {
- return false;
-}
-
+ return false;
+}
+
template <class T, class TPolicy>
constexpr bool operator<(TNothing, const TMaybe<T, TPolicy>& right) noexcept {
- return static_cast<bool>(right);
-}
-
+ return static_cast<bool>(right);
+}
+
template <class T, class TPolicy>
constexpr bool operator<=(const TMaybe<T, TPolicy>& left, TNothing) noexcept {
- return !static_cast<bool>(left);
-}
-
+ return !static_cast<bool>(left);
+}
+
template <class T, class TPolicy>
constexpr bool operator<=(TNothing, const TMaybe<T, TPolicy>&) noexcept {
- return true;
-}
-
+ return true;
+}
+
template <class T, class TPolicy>
constexpr bool operator>(const TMaybe<T, TPolicy>& left, TNothing) noexcept {
- return static_cast<bool>(left);
-}
-
+ return static_cast<bool>(left);
+}
+
template <class T, class TPolicy>
constexpr bool operator>(TNothing, const TMaybe<T, TPolicy>&) noexcept {
- return false;
-}
-
+ return false;
+}
+
template <class T, class TPolicy>
constexpr bool operator>=(const TMaybe<T, TPolicy>&, TNothing) noexcept {
- return true;
-}
-
+ return true;
+}
+
template <class T, class TPolicy>
constexpr bool operator>=(TNothing, const TMaybe<T, TPolicy>& right) noexcept {
- return !static_cast<bool>(right);
-}
-
-// Comparisons with T
-
+ return !static_cast<bool>(right);
+}
+
+// Comparisons with T
+
template <class T, class TPolicy>
constexpr bool operator==(const TMaybe<T, TPolicy>& maybe, const T& value) {
- return static_cast<bool>(maybe) ? *maybe == value : false;
-}
-
+ return static_cast<bool>(maybe) ? *maybe == value : false;
+}
+
template <class T, class TPolicy>
constexpr bool operator==(const T& value, const TMaybe<T, TPolicy>& maybe) {
- return static_cast<bool>(maybe) ? *maybe == value : false;
-}
-
+ return static_cast<bool>(maybe) ? *maybe == value : false;
+}
+
template <class T, class TPolicy>
constexpr bool operator!=(const TMaybe<T, TPolicy>& maybe, const T& value) {
- return static_cast<bool>(maybe) ? !(*maybe == value) : true;
-}
-
+ return static_cast<bool>(maybe) ? !(*maybe == value) : true;
+}
+
template <class T, class TPolicy>
constexpr bool operator!=(const T& value, const TMaybe<T, TPolicy>& maybe) {
- return static_cast<bool>(maybe) ? !(*maybe == value) : true;
-}
-
+ return static_cast<bool>(maybe) ? !(*maybe == value) : true;
+}
+
template <class T, class TPolicy>
constexpr bool operator<(const TMaybe<T, TPolicy>& maybe, const T& value) {
- return static_cast<bool>(maybe) ? std::less<T>{}(*maybe, value) : true;
-}
-
+ return static_cast<bool>(maybe) ? std::less<T>{}(*maybe, value) : true;
+}
+
template <class T, class TPolicy>
constexpr bool operator<(const T& value, const TMaybe<T, TPolicy>& maybe) {
- return static_cast<bool>(maybe) ? std::less<T>{}(value, *maybe) : false;
-}
-
+ return static_cast<bool>(maybe) ? std::less<T>{}(value, *maybe) : false;
+}
+
template <class T, class TPolicy>
constexpr bool operator<=(const TMaybe<T, TPolicy>& maybe, const T& value) {
- return !(maybe > value);
-}
-
+ return !(maybe > value);
+}
+
template <class T, class TPolicy>
constexpr bool operator<=(const T& value, const TMaybe<T, TPolicy>& maybe) {
- return !(value > maybe);
-}
-
+ return !(value > maybe);
+}
+
template <class T, class TPolicy>
constexpr bool operator>(const TMaybe<T, TPolicy>& maybe, const T& value) {
- return static_cast<bool>(maybe) ? value < maybe : false;
-}
-
+ return static_cast<bool>(maybe) ? value < maybe : false;
+}
+
template <class T, class TPolicy>
constexpr bool operator>(const T& value, const TMaybe<T, TPolicy>& maybe) {
- return static_cast<bool>(maybe) ? maybe < value : true;
-}
-
+ return static_cast<bool>(maybe) ? maybe < value : true;
+}
+
template <class T, class TPolicy>
constexpr bool operator>=(const TMaybe<T, TPolicy>& maybe, const T& value) {
- return !(maybe < value);
-}
-
+ return !(maybe < value);
+}
+
template <class T, class TPolicy>
constexpr bool operator>=(const T& value, const TMaybe<T, TPolicy>& maybe) {
- return !(value < maybe);
-}
-
-// Comparison with values convertible to T
-
+ return !(value < maybe);
+}
+
+// Comparison with values convertible to T
+
template <class T, class TPolicy, class U, std::enable_if_t<std::is_convertible<U, T>::value, int> = 0>
constexpr bool operator==(const ::TMaybe<T, TPolicy>& maybe, const U& value) {
- return static_cast<bool>(maybe) ? *maybe == value : false;
-}
-
+ return static_cast<bool>(maybe) ? *maybe == value : false;
+}
+
template <class T, class TPolicy, class U, std::enable_if_t<std::is_convertible<U, T>::value, int> = 0>
constexpr bool operator==(const U& value, const ::TMaybe<T, TPolicy>& maybe) {
- return static_cast<bool>(maybe) ? *maybe == value : false;
-}
-
+ return static_cast<bool>(maybe) ? *maybe == value : false;
+}
+
template <class T, class TPolicy, class U, std::enable_if_t<std::is_convertible<U, T>::value, int> = 0>
constexpr bool operator!=(const TMaybe<T, TPolicy>& maybe, const U& value) {
- return static_cast<bool>(maybe) ? !(*maybe == value) : true;
-}
-
+ return static_cast<bool>(maybe) ? !(*maybe == value) : true;
+}
+
template <class T, class TPolicy, class U, std::enable_if_t<std::is_convertible<U, T>::value, int> = 0>
constexpr bool operator!=(const U& value, const TMaybe<T, TPolicy>& maybe) {
- return static_cast<bool>(maybe) ? !(*maybe == value) : true;
-}
-
+ return static_cast<bool>(maybe) ? !(*maybe == value) : true;
+}
+
template <class T, class TPolicy, class U, std::enable_if_t<std::is_convertible<U, T>::value, int> = 0>
constexpr bool operator<(const TMaybe<T, TPolicy>& maybe, const U& value) {
- return static_cast<bool>(maybe) ? std::less<T>{}(*maybe, value) : true;
-}
-
+ return static_cast<bool>(maybe) ? std::less<T>{}(*maybe, value) : true;
+}
+
template <class T, class TPolicy, class U, std::enable_if_t<std::is_convertible<U, T>::value, int> = 0>
constexpr bool operator<(const U& value, const TMaybe<T, TPolicy>& maybe) {
- return static_cast<bool>(maybe) ? std::less<T>{}(value, *maybe) : false;
-}
-
+ return static_cast<bool>(maybe) ? std::less<T>{}(value, *maybe) : false;
+}
+
template <class T, class TPolicy, class U, std::enable_if_t<std::is_convertible<U, T>::value, int> = 0>
constexpr bool operator<=(const TMaybe<T, TPolicy>& maybe, const U& value) {
- return !(maybe > value);
-}
-
+ return !(maybe > value);
+}
+
template <class T, class TPolicy, class U, std::enable_if_t<std::is_convertible<U, T>::value, int> = 0>
constexpr bool operator<=(const U& value, const TMaybe<T, TPolicy>& maybe) {
- return !(value > maybe);
-}
-
+ return !(value > maybe);
+}
+
template <class T, class TPolicy, class U, std::enable_if_t<std::is_convertible<U, T>::value, int> = 0>
constexpr bool operator>(const TMaybe<T, TPolicy>& maybe, const U& value) {
- return static_cast<bool>(maybe) ? value < maybe : false;
-}
-
+ return static_cast<bool>(maybe) ? value < maybe : false;
+}
+
template <class T, class TPolicy, class U, std::enable_if_t<std::is_convertible<U, T>::value, int> = 0>
constexpr bool operator>(const U& value, const TMaybe<T, TPolicy>& maybe) {
- return static_cast<bool>(maybe) ? maybe < value : true;
-}
-
+ return static_cast<bool>(maybe) ? maybe < value : true;
+}
+
template <class T, class TPolicy, class U, std::enable_if_t<std::is_convertible<U, T>::value, int> = 0>
constexpr bool operator>=(const TMaybe<T, TPolicy>& maybe, const U& value) {
- return !(maybe < value);
-}
-
+ return !(maybe < value);
+}
+
template <class T, class TPolicy, class U, std::enable_if_t<std::is_convertible<U, T>::value, int> = 0>
constexpr bool operator>=(const U& value, const TMaybe<T, TPolicy>& maybe) {
- return !(value < maybe);
-}
+ return !(value < maybe);
+}
class IOutputStream;
diff --git a/util/generic/maybe_ut.cpp b/util/generic/maybe_ut.cpp
index 85c328309b..2c1a425c5e 100644
--- a/util/generic/maybe_ut.cpp
+++ b/util/generic/maybe_ut.cpp
@@ -1,5 +1,5 @@
-#include <util/generic/string.h>
-#include <util/generic/vector.h>
+#include <util/generic/string.h>
+#include <util/generic/vector.h>
#include <util/stream/str.h>
#include <library/cpp/testing/unittest/registar.h>
@@ -10,12 +10,12 @@ private:
int* Ptr_;
public:
- TIncrementOnDestroy(int* ptr) noexcept
+ TIncrementOnDestroy(int* ptr) noexcept
: Ptr_(ptr)
{
}
- ~TIncrementOnDestroy() {
+ ~TIncrementOnDestroy() {
++*Ptr_;
}
};
@@ -42,13 +42,13 @@ Y_UNIT_TEST_SUITE(TMaybeTest) {
Y_UNIT_TEST(TestWarning) {
TMaybe<size_t> x;
TStringStream ss;
- TString line;
+ TString line;
while (ss.ReadLine(line)) {
x = line.size();
}
- if (x == 5u) {
+ if (x == 5u) {
ss << "5\n";
}
}
@@ -221,575 +221,575 @@ Y_UNIT_TEST_SUITE(TMaybeTest) {
UNIT_ASSERT(longMaybe.Defined());
UNIT_ASSERT_VALUES_EQUAL(34, longMaybe.GetRef());
}
-
+
Y_UNIT_TEST(TestGetOr) {
- UNIT_ASSERT_VALUES_EQUAL(TMaybe<TString>().GetOrElse("xxx"), TString("xxx"));
- UNIT_ASSERT_VALUES_EQUAL(TMaybe<TString>("yyy").GetOrElse("xxx"), TString("yyy"));
+ UNIT_ASSERT_VALUES_EQUAL(TMaybe<TString>().GetOrElse("xxx"), TString("xxx"));
+ UNIT_ASSERT_VALUES_EQUAL(TMaybe<TString>("yyy").GetOrElse("xxx"), TString("yyy"));
{
- TString xxx = "xxx";
- UNIT_ASSERT_VALUES_EQUAL(TMaybe<TString>().GetOrElse(xxx).append('x'), TString("xxxx"));
+ TString xxx = "xxx";
+ UNIT_ASSERT_VALUES_EQUAL(TMaybe<TString>().GetOrElse(xxx).append('x'), TString("xxxx"));
UNIT_ASSERT_VALUES_EQUAL(xxx, "xxxx");
}
{
- TString xxx = "xxx";
- UNIT_ASSERT_VALUES_EQUAL(TMaybe<TString>("yyy").GetOrElse(xxx).append('x'), TString("yyyx"));
+ TString xxx = "xxx";
+ UNIT_ASSERT_VALUES_EQUAL(TMaybe<TString>("yyy").GetOrElse(xxx).append('x'), TString("yyyx"));
UNIT_ASSERT_VALUES_EQUAL(xxx, "xxx");
}
}
/*
- ==
- !=
- <
- <=
- >
- >=
-*/
-
+ ==
+ !=
+ <
+ <=
+ >
+ >=
+*/
+
Y_UNIT_TEST(TestCompareEqualEmpty) {
- TMaybe<int> m1;
- TMaybe<int> m2;
-
- UNIT_ASSERT(m1 == m2);
- UNIT_ASSERT(!(m1 != m2));
- UNIT_ASSERT(!(m1 < m2));
- UNIT_ASSERT(m1 <= m2);
- UNIT_ASSERT(!(m1 > m2));
- UNIT_ASSERT(m1 >= m2);
- }
-
+ TMaybe<int> m1;
+ TMaybe<int> m2;
+
+ UNIT_ASSERT(m1 == m2);
+ UNIT_ASSERT(!(m1 != m2));
+ UNIT_ASSERT(!(m1 < m2));
+ UNIT_ASSERT(m1 <= m2);
+ UNIT_ASSERT(!(m1 > m2));
+ UNIT_ASSERT(m1 >= m2);
+ }
+
Y_UNIT_TEST(TestCompareEqualNonEmpty) {
TMaybe<int> m1{1};
TMaybe<int> m2{1};
-
- UNIT_ASSERT(m1 == m2);
- UNIT_ASSERT(!(m1 != m2));
- UNIT_ASSERT(!(m1 < m2));
- UNIT_ASSERT(m1 <= m2);
- UNIT_ASSERT(!(m1 > m2));
- UNIT_ASSERT(m1 >= m2);
- }
-
+
+ UNIT_ASSERT(m1 == m2);
+ UNIT_ASSERT(!(m1 != m2));
+ UNIT_ASSERT(!(m1 < m2));
+ UNIT_ASSERT(m1 <= m2);
+ UNIT_ASSERT(!(m1 > m2));
+ UNIT_ASSERT(m1 >= m2);
+ }
+
Y_UNIT_TEST(TestCompareOneLessThanOther) {
TMaybe<int> m1{1};
TMaybe<int> m2{2};
-
- UNIT_ASSERT(!(m1 == m2));
- UNIT_ASSERT(m1 != m2);
- UNIT_ASSERT(m1 < m2);
- UNIT_ASSERT(m1 <= m2);
- UNIT_ASSERT(!(m1 > m2));
- UNIT_ASSERT(!(m1 >= m2));
- }
-
+
+ UNIT_ASSERT(!(m1 == m2));
+ UNIT_ASSERT(m1 != m2);
+ UNIT_ASSERT(m1 < m2);
+ UNIT_ASSERT(m1 <= m2);
+ UNIT_ASSERT(!(m1 > m2));
+ UNIT_ASSERT(!(m1 >= m2));
+ }
+
Y_UNIT_TEST(TestCompareTMaybeAndT_Equal) {
TMaybe<int> m{1};
int v{1};
-
- UNIT_ASSERT(m == v);
- UNIT_ASSERT(!(m != v));
- UNIT_ASSERT(!(m < v));
- UNIT_ASSERT(m <= v);
- UNIT_ASSERT(!(m > v));
- UNIT_ASSERT(m >= v);
-
- UNIT_ASSERT(v == m);
- UNIT_ASSERT(!(v != m));
- UNIT_ASSERT(!(v < m));
- UNIT_ASSERT(v <= m);
- UNIT_ASSERT(!(v > m));
- UNIT_ASSERT(v >= m);
- }
-
+
+ UNIT_ASSERT(m == v);
+ UNIT_ASSERT(!(m != v));
+ UNIT_ASSERT(!(m < v));
+ UNIT_ASSERT(m <= v);
+ UNIT_ASSERT(!(m > v));
+ UNIT_ASSERT(m >= v);
+
+ UNIT_ASSERT(v == m);
+ UNIT_ASSERT(!(v != m));
+ UNIT_ASSERT(!(v < m));
+ UNIT_ASSERT(v <= m);
+ UNIT_ASSERT(!(v > m));
+ UNIT_ASSERT(v >= m);
+ }
+
Y_UNIT_TEST(TestCompareTMaybeAndT_TMaybeLessThanT) {
TMaybe<int> m{1};
int v{2};
-
- UNIT_ASSERT(!(m == v));
- UNIT_ASSERT(m != v);
- UNIT_ASSERT(m < v);
- UNIT_ASSERT(m <= v);
- UNIT_ASSERT(!(m > v));
- UNIT_ASSERT(!(m >= v));
-
- UNIT_ASSERT(!(v == m));
- UNIT_ASSERT(v != m);
- UNIT_ASSERT(!(v < m));
- UNIT_ASSERT(!(v <= m));
- UNIT_ASSERT(v > m);
- UNIT_ASSERT(v >= m);
- }
-
+
+ UNIT_ASSERT(!(m == v));
+ UNIT_ASSERT(m != v);
+ UNIT_ASSERT(m < v);
+ UNIT_ASSERT(m <= v);
+ UNIT_ASSERT(!(m > v));
+ UNIT_ASSERT(!(m >= v));
+
+ UNIT_ASSERT(!(v == m));
+ UNIT_ASSERT(v != m);
+ UNIT_ASSERT(!(v < m));
+ UNIT_ASSERT(!(v <= m));
+ UNIT_ASSERT(v > m);
+ UNIT_ASSERT(v >= m);
+ }
+
Y_UNIT_TEST(TestCompareTMaybeAndT_TMaybeGreaterThanT) {
TMaybe<int> m{2};
int v{1};
-
- UNIT_ASSERT(!(m == v));
- UNIT_ASSERT(m != v);
- UNIT_ASSERT(!(m < v));
- UNIT_ASSERT(!(m <= v));
- UNIT_ASSERT(m > v);
- UNIT_ASSERT(m >= v);
-
- UNIT_ASSERT(!(v == m));
- UNIT_ASSERT(v != m);
- UNIT_ASSERT(v < m);
- UNIT_ASSERT(v <= m);
- UNIT_ASSERT(!(v > m));
- UNIT_ASSERT(!(v >= m));
- }
-
+
+ UNIT_ASSERT(!(m == v));
+ UNIT_ASSERT(m != v);
+ UNIT_ASSERT(!(m < v));
+ UNIT_ASSERT(!(m <= v));
+ UNIT_ASSERT(m > v);
+ UNIT_ASSERT(m >= v);
+
+ UNIT_ASSERT(!(v == m));
+ UNIT_ASSERT(v != m);
+ UNIT_ASSERT(v < m);
+ UNIT_ASSERT(v <= m);
+ UNIT_ASSERT(!(v > m));
+ UNIT_ASSERT(!(v >= m));
+ }
+
Y_UNIT_TEST(TestCompareEmptyTMaybeAndT) {
- TMaybe<int> m;
+ TMaybe<int> m;
int v{1};
-
- UNIT_ASSERT(!(m == v));
- UNIT_ASSERT(m != v);
- UNIT_ASSERT(m < v);
- UNIT_ASSERT(m <= v);
- UNIT_ASSERT(!(m > v));
- UNIT_ASSERT(!(m >= v));
-
- UNIT_ASSERT(!(v == m));
- UNIT_ASSERT(v != m);
- UNIT_ASSERT(!(v < m));
- UNIT_ASSERT(!(v <= m));
- UNIT_ASSERT(v > m);
- UNIT_ASSERT(v >= m);
- }
-
+
+ UNIT_ASSERT(!(m == v));
+ UNIT_ASSERT(m != v);
+ UNIT_ASSERT(m < v);
+ UNIT_ASSERT(m <= v);
+ UNIT_ASSERT(!(m > v));
+ UNIT_ASSERT(!(m >= v));
+
+ UNIT_ASSERT(!(v == m));
+ UNIT_ASSERT(v != m);
+ UNIT_ASSERT(!(v < m));
+ UNIT_ASSERT(!(v <= m));
+ UNIT_ASSERT(v > m);
+ UNIT_ASSERT(v >= m);
+ }
+
Y_UNIT_TEST(TestCompareEmptyTMaybeAndNothing) {
- TMaybe<int> m;
- auto n = Nothing();
-
- UNIT_ASSERT(m == n);
- UNIT_ASSERT(!(m != n));
- UNIT_ASSERT(!(m < n));
- UNIT_ASSERT(m <= n);
- UNIT_ASSERT(!(m > n));
- UNIT_ASSERT(m >= n);
-
- UNIT_ASSERT(n == m);
- UNIT_ASSERT(!(n != m));
- UNIT_ASSERT(!(n < m));
- UNIT_ASSERT(n <= m);
- UNIT_ASSERT(!(n > m));
- UNIT_ASSERT(n >= m);
- }
-
+ TMaybe<int> m;
+ auto n = Nothing();
+
+ UNIT_ASSERT(m == n);
+ UNIT_ASSERT(!(m != n));
+ UNIT_ASSERT(!(m < n));
+ UNIT_ASSERT(m <= n);
+ UNIT_ASSERT(!(m > n));
+ UNIT_ASSERT(m >= n);
+
+ UNIT_ASSERT(n == m);
+ UNIT_ASSERT(!(n != m));
+ UNIT_ASSERT(!(n < m));
+ UNIT_ASSERT(n <= m);
+ UNIT_ASSERT(!(n > m));
+ UNIT_ASSERT(n >= m);
+ }
+
Y_UNIT_TEST(TestCompareNonEmptyTMaybeAndNothing) {
TMaybe<int> m{1};
- auto n = Nothing();
-
- UNIT_ASSERT(!(m == n));
- UNIT_ASSERT(m != n);
- UNIT_ASSERT(!(m < n));
- UNIT_ASSERT(!(m <= n));
- UNIT_ASSERT(m > n);
- UNIT_ASSERT(m >= n);
-
- UNIT_ASSERT(!(n == m));
- UNIT_ASSERT(n != m);
- UNIT_ASSERT(n < m);
- UNIT_ASSERT(n <= m);
- UNIT_ASSERT(!(n > m));
- UNIT_ASSERT(!(n >= m));
- }
-
+ auto n = Nothing();
+
+ UNIT_ASSERT(!(m == n));
+ UNIT_ASSERT(m != n);
+ UNIT_ASSERT(!(m < n));
+ UNIT_ASSERT(!(m <= n));
+ UNIT_ASSERT(m > n);
+ UNIT_ASSERT(m >= n);
+
+ UNIT_ASSERT(!(n == m));
+ UNIT_ASSERT(n != m);
+ UNIT_ASSERT(n < m);
+ UNIT_ASSERT(n <= m);
+ UNIT_ASSERT(!(n > m));
+ UNIT_ASSERT(!(n >= m));
+ }
+
Y_UNIT_TEST(TestCompareTMaybeAndConvertibleT_Equal) {
TMaybe<size_t> m{1};
unsigned int v{1};
-
- UNIT_ASSERT(m == v);
- UNIT_ASSERT(!(m != v));
- UNIT_ASSERT(!(m < v));
- UNIT_ASSERT(m <= v);
- UNIT_ASSERT(!(m > v));
- UNIT_ASSERT(m >= v);
-
- UNIT_ASSERT(v == m);
- UNIT_ASSERT(!(v != m));
- UNIT_ASSERT(!(v < m));
- UNIT_ASSERT(v <= m);
- UNIT_ASSERT(!(v > m));
- UNIT_ASSERT(v >= m);
- }
-
+
+ UNIT_ASSERT(m == v);
+ UNIT_ASSERT(!(m != v));
+ UNIT_ASSERT(!(m < v));
+ UNIT_ASSERT(m <= v);
+ UNIT_ASSERT(!(m > v));
+ UNIT_ASSERT(m >= v);
+
+ UNIT_ASSERT(v == m);
+ UNIT_ASSERT(!(v != m));
+ UNIT_ASSERT(!(v < m));
+ UNIT_ASSERT(v <= m);
+ UNIT_ASSERT(!(v > m));
+ UNIT_ASSERT(v >= m);
+ }
+
Y_UNIT_TEST(TestCompareTMaybeAndConvertibleT_TMaybeLessThanT) {
TMaybe<size_t> m{1};
unsigned int v{2};
-
- UNIT_ASSERT(!(m == v));
- UNIT_ASSERT(m != v);
- UNIT_ASSERT(m < v);
- UNIT_ASSERT(m <= v);
- UNIT_ASSERT(!(m > v));
- UNIT_ASSERT(!(m >= v));
-
- UNIT_ASSERT(!(v == m));
- UNIT_ASSERT(v != m);
- UNIT_ASSERT(!(v < m));
- UNIT_ASSERT(!(v <= m));
- UNIT_ASSERT(v > m);
- UNIT_ASSERT(v >= m);
- }
-
+
+ UNIT_ASSERT(!(m == v));
+ UNIT_ASSERT(m != v);
+ UNIT_ASSERT(m < v);
+ UNIT_ASSERT(m <= v);
+ UNIT_ASSERT(!(m > v));
+ UNIT_ASSERT(!(m >= v));
+
+ UNIT_ASSERT(!(v == m));
+ UNIT_ASSERT(v != m);
+ UNIT_ASSERT(!(v < m));
+ UNIT_ASSERT(!(v <= m));
+ UNIT_ASSERT(v > m);
+ UNIT_ASSERT(v >= m);
+ }
+
Y_UNIT_TEST(TestCompareTMaybeAndConvertibleT_TMaybeGreaterThanT) {
TMaybe<size_t> m{2};
unsigned int v{1};
-
- UNIT_ASSERT(!(m == v));
- UNIT_ASSERT(m != v);
- UNIT_ASSERT(!(m < v));
- UNIT_ASSERT(!(m <= v));
- UNIT_ASSERT(m > v);
- UNIT_ASSERT(m >= v);
-
- UNIT_ASSERT(!(v == m));
- UNIT_ASSERT(v != m);
- UNIT_ASSERT(v < m);
- UNIT_ASSERT(v <= m);
- UNIT_ASSERT(!(v > m));
- UNIT_ASSERT(!(v >= m));
- }
-
+
+ UNIT_ASSERT(!(m == v));
+ UNIT_ASSERT(m != v);
+ UNIT_ASSERT(!(m < v));
+ UNIT_ASSERT(!(m <= v));
+ UNIT_ASSERT(m > v);
+ UNIT_ASSERT(m >= v);
+
+ UNIT_ASSERT(!(v == m));
+ UNIT_ASSERT(v != m);
+ UNIT_ASSERT(v < m);
+ UNIT_ASSERT(v <= m);
+ UNIT_ASSERT(!(v > m));
+ UNIT_ASSERT(!(v >= m));
+ }
+
Y_UNIT_TEST(TestCompareEmptyTMaybeAndConvertibleT) {
- TMaybe<size_t> m;
+ TMaybe<size_t> m;
unsigned int v{1};
-
- UNIT_ASSERT(!(m == v));
- UNIT_ASSERT(m != v);
- UNIT_ASSERT(m < v);
- UNIT_ASSERT(m <= v);
- UNIT_ASSERT(!(m > v));
- UNIT_ASSERT(!(m >= v));
-
- UNIT_ASSERT(!(v == m));
- UNIT_ASSERT(v != m);
- UNIT_ASSERT(!(v < m));
- UNIT_ASSERT(!(v <= m));
- UNIT_ASSERT(v > m);
- UNIT_ASSERT(v >= m);
- }
-
+
+ UNIT_ASSERT(!(m == v));
+ UNIT_ASSERT(m != v);
+ UNIT_ASSERT(m < v);
+ UNIT_ASSERT(m <= v);
+ UNIT_ASSERT(!(m > v));
+ UNIT_ASSERT(!(m >= v));
+
+ UNIT_ASSERT(!(v == m));
+ UNIT_ASSERT(v != m);
+ UNIT_ASSERT(!(v < m));
+ UNIT_ASSERT(!(v <= m));
+ UNIT_ASSERT(v > m);
+ UNIT_ASSERT(v >= m);
+ }
+
Y_UNIT_TEST(TestMakeMaybe) {
- {
- auto m1 = MakeMaybe<int>(1);
- UNIT_ASSERT(*m1 == 1);
- }
-
- {
- struct TMockClass {
- TMockClass(int i)
- : I_(i)
- {
- }
-
- TMockClass(const TMockClass& other)
- : I_(other.I_)
- {
- IsCopyConstructorCalled_ = true;
- }
-
- TMockClass& operator=(const TMockClass& other) {
- if (this != &other) {
- I_ = other.I_;
- IsCopyAssignmentOperatorCalled_ = true;
- }
-
- return *this;
- }
-
- TMockClass(TMockClass&& other)
- : I_(other.I_)
- {
- IsMoveConstructorCalled_ = true;
- }
-
- TMockClass& operator=(TMockClass&& other) {
- if (this != &other) {
- I_ = other.I_;
- IsMoveAssignmentOperatorCalled_ = true;
- }
-
- return *this;
- }
-
- int I_;
+ {
+ auto m1 = MakeMaybe<int>(1);
+ UNIT_ASSERT(*m1 == 1);
+ }
+
+ {
+ struct TMockClass {
+ TMockClass(int i)
+ : I_(i)
+ {
+ }
+
+ TMockClass(const TMockClass& other)
+ : I_(other.I_)
+ {
+ IsCopyConstructorCalled_ = true;
+ }
+
+ TMockClass& operator=(const TMockClass& other) {
+ if (this != &other) {
+ I_ = other.I_;
+ IsCopyAssignmentOperatorCalled_ = true;
+ }
+
+ return *this;
+ }
+
+ TMockClass(TMockClass&& other)
+ : I_(other.I_)
+ {
+ IsMoveConstructorCalled_ = true;
+ }
+
+ TMockClass& operator=(TMockClass&& other) {
+ if (this != &other) {
+ I_ = other.I_;
+ IsMoveAssignmentOperatorCalled_ = true;
+ }
+
+ return *this;
+ }
+
+ int I_;
bool IsCopyConstructorCalled_{false};
bool IsMoveConstructorCalled_{false};
bool IsCopyAssignmentOperatorCalled_{false};
bool IsMoveAssignmentOperatorCalled_{false};
- };
-
- auto m2 = MakeMaybe<TMockClass>(1);
- UNIT_ASSERT(m2->I_ == 1);
- UNIT_ASSERT(!m2->IsCopyConstructorCalled_);
- UNIT_ASSERT(!m2->IsMoveConstructorCalled_);
- UNIT_ASSERT(!m2->IsCopyAssignmentOperatorCalled_);
- UNIT_ASSERT(!m2->IsMoveAssignmentOperatorCalled_);
- }
-
- {
- auto m3 = MakeMaybe<TVector<int>>({1, 2, 3, 4, 5});
- UNIT_ASSERT(m3->size() == 5);
- UNIT_ASSERT(m3->at(0) == 1);
- UNIT_ASSERT(m3->at(1) == 2);
- UNIT_ASSERT(m3->at(2) == 3);
- UNIT_ASSERT(m3->at(3) == 4);
- UNIT_ASSERT(m3->at(4) == 5);
- }
-
- {
- struct TMockStruct4 {
- TMockStruct4(int a, int b, int c)
- : A_(a)
- , B_(b)
- , C_(c)
- {
- }
-
- int A_;
- int B_;
- int C_;
- };
-
- auto m4 = MakeMaybe<TMockStruct4>(1, 2, 3);
- UNIT_ASSERT(m4->A_ == 1);
- UNIT_ASSERT(m4->B_ == 2);
- UNIT_ASSERT(m4->C_ == 3);
- }
-
- {
- struct TMockStruct5 {
- TMockStruct5(const TVector<int>& vec, bool someFlag)
- : Vec_(vec)
- , SomeFlag_(someFlag)
- {
- }
-
- TVector<int> Vec_;
- bool SomeFlag_;
- };
-
+ };
+
+ auto m2 = MakeMaybe<TMockClass>(1);
+ UNIT_ASSERT(m2->I_ == 1);
+ UNIT_ASSERT(!m2->IsCopyConstructorCalled_);
+ UNIT_ASSERT(!m2->IsMoveConstructorCalled_);
+ UNIT_ASSERT(!m2->IsCopyAssignmentOperatorCalled_);
+ UNIT_ASSERT(!m2->IsMoveAssignmentOperatorCalled_);
+ }
+
+ {
+ auto m3 = MakeMaybe<TVector<int>>({1, 2, 3, 4, 5});
+ UNIT_ASSERT(m3->size() == 5);
+ UNIT_ASSERT(m3->at(0) == 1);
+ UNIT_ASSERT(m3->at(1) == 2);
+ UNIT_ASSERT(m3->at(2) == 3);
+ UNIT_ASSERT(m3->at(3) == 4);
+ UNIT_ASSERT(m3->at(4) == 5);
+ }
+
+ {
+ struct TMockStruct4 {
+ TMockStruct4(int a, int b, int c)
+ : A_(a)
+ , B_(b)
+ , C_(c)
+ {
+ }
+
+ int A_;
+ int B_;
+ int C_;
+ };
+
+ auto m4 = MakeMaybe<TMockStruct4>(1, 2, 3);
+ UNIT_ASSERT(m4->A_ == 1);
+ UNIT_ASSERT(m4->B_ == 2);
+ UNIT_ASSERT(m4->C_ == 3);
+ }
+
+ {
+ struct TMockStruct5 {
+ TMockStruct5(const TVector<int>& vec, bool someFlag)
+ : Vec_(vec)
+ , SomeFlag_(someFlag)
+ {
+ }
+
+ TVector<int> Vec_;
+ bool SomeFlag_;
+ };
+
auto m5 = MakeMaybe<TMockStruct5>({1, 2, 3}, true);
- UNIT_ASSERT(m5->Vec_.size() == 3);
- UNIT_ASSERT(m5->Vec_[0] == 1);
- UNIT_ASSERT(m5->Vec_[1] == 2);
- UNIT_ASSERT(m5->Vec_[2] == 3);
- UNIT_ASSERT(m5->SomeFlag_);
- }
- }
-
+ UNIT_ASSERT(m5->Vec_.size() == 3);
+ UNIT_ASSERT(m5->Vec_[0] == 1);
+ UNIT_ASSERT(m5->Vec_[1] == 2);
+ UNIT_ASSERT(m5->Vec_[2] == 3);
+ UNIT_ASSERT(m5->SomeFlag_);
+ }
+ }
+
Y_UNIT_TEST(TestSwappingUsingMemberSwap) {
- {
- TMaybe<int> m1 = 1;
- TMaybe<int> m2 = 2;
-
- UNIT_ASSERT(*m1 == 1);
- UNIT_ASSERT(*m2 == 2);
-
- m1.Swap(m2);
-
- UNIT_ASSERT(*m1 == 2);
- UNIT_ASSERT(*m2 == 1);
- }
-
- {
- TMaybe<int> m1 = 1;
- TMaybe<int> m2 = Nothing();
-
- UNIT_ASSERT(*m1 == 1);
- UNIT_ASSERT(m2 == Nothing());
-
- m1.Swap(m2);
-
- UNIT_ASSERT(m1 == Nothing());
- UNIT_ASSERT(*m2 == 1);
- }
-
- {
- TMaybe<int> m1 = Nothing();
- TMaybe<int> m2 = 1;
-
- UNIT_ASSERT(m1 == Nothing());
- UNIT_ASSERT(*m2 == 1);
-
- m1.Swap(m2);
-
- UNIT_ASSERT(*m1 == 1);
- UNIT_ASSERT(m2 == Nothing());
- }
- }
-
+ {
+ TMaybe<int> m1 = 1;
+ TMaybe<int> m2 = 2;
+
+ UNIT_ASSERT(*m1 == 1);
+ UNIT_ASSERT(*m2 == 2);
+
+ m1.Swap(m2);
+
+ UNIT_ASSERT(*m1 == 2);
+ UNIT_ASSERT(*m2 == 1);
+ }
+
+ {
+ TMaybe<int> m1 = 1;
+ TMaybe<int> m2 = Nothing();
+
+ UNIT_ASSERT(*m1 == 1);
+ UNIT_ASSERT(m2 == Nothing());
+
+ m1.Swap(m2);
+
+ UNIT_ASSERT(m1 == Nothing());
+ UNIT_ASSERT(*m2 == 1);
+ }
+
+ {
+ TMaybe<int> m1 = Nothing();
+ TMaybe<int> m2 = 1;
+
+ UNIT_ASSERT(m1 == Nothing());
+ UNIT_ASSERT(*m2 == 1);
+
+ m1.Swap(m2);
+
+ UNIT_ASSERT(*m1 == 1);
+ UNIT_ASSERT(m2 == Nothing());
+ }
+ }
+
Y_UNIT_TEST(TestSwappingUsingMemberLittleSwap) {
- {
- TMaybe<int> m1 = 1;
- TMaybe<int> m2 = 2;
-
- UNIT_ASSERT(*m1 == 1);
- UNIT_ASSERT(*m2 == 2);
-
- m1.swap(m2);
-
- UNIT_ASSERT(*m1 == 2);
- UNIT_ASSERT(*m2 == 1);
- }
-
- {
- TMaybe<int> m1 = 1;
- TMaybe<int> m2 = Nothing();
-
- UNIT_ASSERT(*m1 == 1);
- UNIT_ASSERT(m2 == Nothing());
-
- m1.swap(m2);
-
- UNIT_ASSERT(m1 == Nothing());
- UNIT_ASSERT(*m2 == 1);
- }
-
- {
- TMaybe<int> m1 = Nothing();
- TMaybe<int> m2 = 1;
-
- UNIT_ASSERT(m1 == Nothing());
- UNIT_ASSERT(*m2 == 1);
-
- m1.swap(m2);
-
- UNIT_ASSERT(*m1 == 1);
- UNIT_ASSERT(m2 == Nothing());
- }
- }
-
+ {
+ TMaybe<int> m1 = 1;
+ TMaybe<int> m2 = 2;
+
+ UNIT_ASSERT(*m1 == 1);
+ UNIT_ASSERT(*m2 == 2);
+
+ m1.swap(m2);
+
+ UNIT_ASSERT(*m1 == 2);
+ UNIT_ASSERT(*m2 == 1);
+ }
+
+ {
+ TMaybe<int> m1 = 1;
+ TMaybe<int> m2 = Nothing();
+
+ UNIT_ASSERT(*m1 == 1);
+ UNIT_ASSERT(m2 == Nothing());
+
+ m1.swap(m2);
+
+ UNIT_ASSERT(m1 == Nothing());
+ UNIT_ASSERT(*m2 == 1);
+ }
+
+ {
+ TMaybe<int> m1 = Nothing();
+ TMaybe<int> m2 = 1;
+
+ UNIT_ASSERT(m1 == Nothing());
+ UNIT_ASSERT(*m2 == 1);
+
+ m1.swap(m2);
+
+ UNIT_ASSERT(*m1 == 1);
+ UNIT_ASSERT(m2 == Nothing());
+ }
+ }
+
Y_UNIT_TEST(TestSwappingUsingGlobalSwap) {
- {
- TMaybe<int> m1 = 1;
- TMaybe<int> m2 = 2;
-
- UNIT_ASSERT(*m1 == 1);
- UNIT_ASSERT(*m2 == 2);
-
- ::Swap(m1, m2);
-
- UNIT_ASSERT(*m1 == 2);
- UNIT_ASSERT(*m2 == 1);
- }
-
- {
- TMaybe<int> m1 = 1;
- TMaybe<int> m2 = Nothing();
-
- UNIT_ASSERT(*m1 == 1);
- UNIT_ASSERT(m2 == Nothing());
-
- ::Swap(m1, m2);
-
- UNIT_ASSERT(m1 == Nothing());
- UNIT_ASSERT(*m2 == 1);
- }
-
- {
- TMaybe<int> m1 = Nothing();
- TMaybe<int> m2 = 1;
-
- UNIT_ASSERT(m1 == Nothing());
- UNIT_ASSERT(*m2 == 1);
-
- ::Swap(m1, m2);
-
- UNIT_ASSERT(*m1 == 1);
- UNIT_ASSERT(m2 == Nothing());
- }
- }
-
+ {
+ TMaybe<int> m1 = 1;
+ TMaybe<int> m2 = 2;
+
+ UNIT_ASSERT(*m1 == 1);
+ UNIT_ASSERT(*m2 == 2);
+
+ ::Swap(m1, m2);
+
+ UNIT_ASSERT(*m1 == 2);
+ UNIT_ASSERT(*m2 == 1);
+ }
+
+ {
+ TMaybe<int> m1 = 1;
+ TMaybe<int> m2 = Nothing();
+
+ UNIT_ASSERT(*m1 == 1);
+ UNIT_ASSERT(m2 == Nothing());
+
+ ::Swap(m1, m2);
+
+ UNIT_ASSERT(m1 == Nothing());
+ UNIT_ASSERT(*m2 == 1);
+ }
+
+ {
+ TMaybe<int> m1 = Nothing();
+ TMaybe<int> m2 = 1;
+
+ UNIT_ASSERT(m1 == Nothing());
+ UNIT_ASSERT(*m2 == 1);
+
+ ::Swap(m1, m2);
+
+ UNIT_ASSERT(*m1 == 1);
+ UNIT_ASSERT(m2 == Nothing());
+ }
+ }
+
Y_UNIT_TEST(TestSwappingUsingGlobalDoSwap) {
- {
- TMaybe<int> m1 = 1;
- TMaybe<int> m2 = 2;
-
- UNIT_ASSERT(*m1 == 1);
- UNIT_ASSERT(*m2 == 2);
-
- ::DoSwap(m1, m2);
-
- UNIT_ASSERT(*m1 == 2);
- UNIT_ASSERT(*m2 == 1);
- }
-
- {
- TMaybe<int> m1 = 1;
- TMaybe<int> m2 = Nothing();
-
- UNIT_ASSERT(*m1 == 1);
- UNIT_ASSERT(m2 == Nothing());
-
- ::DoSwap(m1, m2);
-
- UNIT_ASSERT(m1 == Nothing());
- UNIT_ASSERT(*m2 == 1);
- }
-
- {
- TMaybe<int> m1 = Nothing();
- TMaybe<int> m2 = 1;
-
- UNIT_ASSERT(m1 == Nothing());
- UNIT_ASSERT(*m2 == 1);
-
- ::DoSwap(m1, m2);
-
- UNIT_ASSERT(*m1 == 1);
- UNIT_ASSERT(m2 == Nothing());
- }
- }
-
+ {
+ TMaybe<int> m1 = 1;
+ TMaybe<int> m2 = 2;
+
+ UNIT_ASSERT(*m1 == 1);
+ UNIT_ASSERT(*m2 == 2);
+
+ ::DoSwap(m1, m2);
+
+ UNIT_ASSERT(*m1 == 2);
+ UNIT_ASSERT(*m2 == 1);
+ }
+
+ {
+ TMaybe<int> m1 = 1;
+ TMaybe<int> m2 = Nothing();
+
+ UNIT_ASSERT(*m1 == 1);
+ UNIT_ASSERT(m2 == Nothing());
+
+ ::DoSwap(m1, m2);
+
+ UNIT_ASSERT(m1 == Nothing());
+ UNIT_ASSERT(*m2 == 1);
+ }
+
+ {
+ TMaybe<int> m1 = Nothing();
+ TMaybe<int> m2 = 1;
+
+ UNIT_ASSERT(m1 == Nothing());
+ UNIT_ASSERT(*m2 == 1);
+
+ ::DoSwap(m1, m2);
+
+ UNIT_ASSERT(*m1 == 1);
+ UNIT_ASSERT(m2 == Nothing());
+ }
+ }
+
Y_UNIT_TEST(TestSwappingUsingStdSwap) {
- {
- TMaybe<int> m1 = 1;
- TMaybe<int> m2 = 2;
-
- UNIT_ASSERT(*m1 == 1);
- UNIT_ASSERT(*m2 == 2);
-
- ::std::swap(m1, m2);
-
- UNIT_ASSERT(*m1 == 2);
- UNIT_ASSERT(*m2 == 1);
- }
-
- {
- TMaybe<int> m1 = 1;
- TMaybe<int> m2 = Nothing();
-
- UNIT_ASSERT(*m1 == 1);
- UNIT_ASSERT(m2 == Nothing());
-
- ::std::swap(m1, m2);
-
- UNIT_ASSERT(m1 == Nothing());
- UNIT_ASSERT(*m2 == 1);
- }
-
- {
- TMaybe<int> m1 = Nothing();
- TMaybe<int> m2 = 1;
-
- UNIT_ASSERT(m1 == Nothing());
- UNIT_ASSERT(*m2 == 1);
-
- ::std::swap(m1, m2);
-
- UNIT_ASSERT(*m1 == 1);
- UNIT_ASSERT(m2 == Nothing());
- }
- }
+ {
+ TMaybe<int> m1 = 1;
+ TMaybe<int> m2 = 2;
+
+ UNIT_ASSERT(*m1 == 1);
+ UNIT_ASSERT(*m2 == 2);
+
+ ::std::swap(m1, m2);
+
+ UNIT_ASSERT(*m1 == 2);
+ UNIT_ASSERT(*m2 == 1);
+ }
+
+ {
+ TMaybe<int> m1 = 1;
+ TMaybe<int> m2 = Nothing();
+
+ UNIT_ASSERT(*m1 == 1);
+ UNIT_ASSERT(m2 == Nothing());
+
+ ::std::swap(m1, m2);
+
+ UNIT_ASSERT(m1 == Nothing());
+ UNIT_ASSERT(*m2 == 1);
+ }
+
+ {
+ TMaybe<int> m1 = Nothing();
+ TMaybe<int> m2 = 1;
+
+ UNIT_ASSERT(m1 == Nothing());
+ UNIT_ASSERT(*m2 == 1);
+
+ ::std::swap(m1, m2);
+
+ UNIT_ASSERT(*m1 == 1);
+ UNIT_ASSERT(m2 == Nothing());
+ }
+ }
Y_UNIT_TEST(TestOutputStreamEmptyMaybe) {
- TString s;
+ TString s;
TStringOutput output(s);
output << TMaybe<int>();
UNIT_ASSERT_EQUAL("(empty maybe)", s);
@@ -803,7 +803,7 @@ Y_UNIT_TEST_SUITE(TMaybeTest) {
}
Y_UNIT_TEST(TestOutputStreamDefinedMaybe) {
- TString s;
+ TString s;
TStringOutput output(s);
output << TMaybe<int>(42);
UNIT_ASSERT_EQUAL("42", s);
diff --git a/util/generic/mem_copy.h b/util/generic/mem_copy.h
index 6f38fdc1ab..b68c852953 100644
--- a/util/generic/mem_copy.h
+++ b/util/generic/mem_copy.h
@@ -13,7 +13,7 @@ template <class T>
using TIfNotPOD = std::enable_if_t<!TTypeTraits<T>::IsPod, T*>;
template <class T>
-static inline TIfPOD<T> MemCopy(T* to, const T* from, size_t n) noexcept {
+static inline TIfPOD<T> MemCopy(T* to, const T* from, size_t n) noexcept {
if (n) {
memcpy(to, from, n * sizeof(T));
}
@@ -31,7 +31,7 @@ static inline TIfNotPOD<T> MemCopy(T* to, const T* from, size_t n) {
}
template <class T>
-static inline TIfPOD<T> MemMove(T* to, const T* from, size_t n) noexcept {
+static inline TIfPOD<T> MemMove(T* to, const T* from, size_t n) noexcept {
if (n) {
memmove(to, from, n * sizeof(T));
}
diff --git a/util/generic/noncopyable.h b/util/generic/noncopyable.h
index dca012a738..c007934133 100644
--- a/util/generic/noncopyable.h
+++ b/util/generic/noncopyable.h
@@ -15,11 +15,11 @@
namespace NNonCopyable { // protection from unintended ADL
struct TNonCopyable {
- TNonCopyable(const TNonCopyable&) = delete;
- TNonCopyable& operator=(const TNonCopyable&) = delete;
+ TNonCopyable(const TNonCopyable&) = delete;
+ TNonCopyable& operator=(const TNonCopyable&) = delete;
- TNonCopyable() = default;
- ~TNonCopyable() = default;
+ TNonCopyable() = default;
+ ~TNonCopyable() = default;
};
struct TMoveOnly {
diff --git a/util/generic/object_counter.h b/util/generic/object_counter.h
index c69e94c226..5257afa2e6 100644
--- a/util/generic/object_counter.h
+++ b/util/generic/object_counter.h
@@ -19,7 +19,7 @@
template <class T>
class TObjectCounter {
public:
- inline TObjectCounter() noexcept {
+ inline TObjectCounter() noexcept {
AtomicIncrement(Count_);
}
@@ -27,11 +27,11 @@ public:
AtomicIncrement(Count_);
}
- inline ~TObjectCounter() {
+ inline ~TObjectCounter() {
AtomicDecrement(Count_);
}
- static inline long ObjectCount() noexcept {
+ static inline long ObjectCount() noexcept {
return AtomicGet(Count_);
}
diff --git a/util/generic/objects_counter_ut.cpp b/util/generic/objects_counter_ut.cpp
index 6f4ae128fd..4d5da37a56 100644
--- a/util/generic/objects_counter_ut.cpp
+++ b/util/generic/objects_counter_ut.cpp
@@ -8,7 +8,7 @@ Y_UNIT_TEST_SUITE(ObjectsCounter) {
Y_UNIT_TEST(Test1) {
TObject obj;
- TVector<TObject> objects;
+ TVector<TObject> objects;
for (ui32 i = 0; i < 100; ++i) {
objects.push_back(obj);
}
diff --git a/util/generic/ptr.cpp b/util/generic/ptr.cpp
index b28755821f..b29baebc17 100644
--- a/util/generic/ptr.cpp
+++ b/util/generic/ptr.cpp
@@ -6,11 +6,11 @@
#include <new>
#include <cstdlib>
-void TFree::DoDestroy(void* t) noexcept {
+void TFree::DoDestroy(void* t) noexcept {
free(t);
}
-void TDelete::Destroy(void* t) noexcept {
+void TDelete::Destroy(void* t) noexcept {
::operator delete(t);
}
diff --git a/util/generic/ptr.h b/util/generic/ptr.h
index 61bd1f89b5..19db0e3ec5 100644
--- a/util/generic/ptr.h
+++ b/util/generic/ptr.h
@@ -44,33 +44,33 @@ inline void CheckedArrayDelete(T* t) {
class TNoAction {
public:
template <class T>
- static inline void Destroy(T*) noexcept {
+ static inline void Destroy(T*) noexcept {
}
};
class TDelete {
public:
template <class T>
- static inline void Destroy(T* t) noexcept {
+ static inline void Destroy(T* t) noexcept {
CheckedDelete(t);
}
/*
- * special handling for nullptr - call nothing
- */
- static inline void Destroy(std::nullptr_t) noexcept {
- }
-
- /*
+ * special handling for nullptr - call nothing
+ */
+ static inline void Destroy(std::nullptr_t) noexcept {
+ }
+
+ /*
* special handling for void* - call ::operator delete()
*/
- static void Destroy(void* t) noexcept;
+ static void Destroy(void* t) noexcept;
};
class TDeleteArray {
public:
template <class T>
- static inline void Destroy(T* t) noexcept {
+ static inline void Destroy(T* t) noexcept {
CheckedArrayDelete(t);
}
};
@@ -78,7 +78,7 @@ public:
class TDestructor {
public:
template <class T>
- static inline void Destroy(T* t) noexcept {
+ static inline void Destroy(T* t) noexcept {
(void)t;
t->~T();
}
@@ -87,7 +87,7 @@ public:
class TFree {
public:
template <class T>
- static inline void Destroy(T* t) noexcept {
+ static inline void Destroy(T* t) noexcept {
DoDestroy((void*)t);
}
@@ -95,7 +95,7 @@ private:
/*
* we do not want dependancy on cstdlib here...
*/
- static void DoDestroy(void* t) noexcept;
+ static void DoDestroy(void* t) noexcept;
};
template <class Base, class T>
@@ -103,7 +103,7 @@ class TPointerCommon {
public:
using TValueType = T;
- inline T* operator->() const noexcept {
+ inline T* operator->() const noexcept {
T* ptr = AsT();
Y_ASSERT(ptr);
return ptr;
@@ -111,26 +111,26 @@ public:
#ifndef __cpp_impl_three_way_comparison
template <class C>
- inline bool operator==(const C& p) const noexcept {
+ inline bool operator==(const C& p) const noexcept {
return (p == AsT());
}
template <class C>
- inline bool operator!=(const C& p) const noexcept {
+ inline bool operator!=(const C& p) const noexcept {
return (p != AsT());
}
#endif
- inline explicit operator bool() const noexcept {
+ inline explicit operator bool() const noexcept {
return nullptr != AsT();
}
protected:
- inline T* AsT() const noexcept {
+ inline T* AsT() const noexcept {
return (static_cast<const Base*>(this))->Get();
}
- static inline T* DoRelease(T*& t) noexcept {
+ static inline T* DoRelease(T*& t) noexcept {
T* ret = t;
t = nullptr;
return ret;
@@ -140,13 +140,13 @@ protected:
template <class Base, class T>
class TPointerBase: public TPointerCommon<Base, T> {
public:
- inline T& operator*() const noexcept {
+ inline T& operator*() const noexcept {
Y_ASSERT(this->AsT());
return *(this->AsT());
}
- inline T& operator[](size_t n) const noexcept {
+ inline T& operator[](size_t n) const noexcept {
Y_ASSERT(this->AsT());
return (this->AsT())[n];
@@ -163,21 +163,21 @@ class TPointerBase<Base, void>: public TPointerCommon<Base, void> {
template <class T, class D>
class TAutoPtr: public TPointerBase<TAutoPtr<T, D>, T> {
public:
- inline TAutoPtr(T* t = nullptr) noexcept
+ inline TAutoPtr(T* t = nullptr) noexcept
: T_(t)
{
}
- inline TAutoPtr(const TAutoPtr& t) noexcept
+ inline TAutoPtr(const TAutoPtr& t) noexcept
: T_(t.Release())
{
}
- inline ~TAutoPtr() {
+ inline ~TAutoPtr() {
DoDestroy();
}
- inline TAutoPtr& operator=(const TAutoPtr& t) noexcept {
+ inline TAutoPtr& operator=(const TAutoPtr& t) noexcept {
if (this != &t) {
Reset(t.Release());
}
@@ -189,26 +189,26 @@ public:
return this->DoRelease(T_);
}
- inline void Reset(T* t) noexcept {
+ inline void Reset(T* t) noexcept {
if (T_ != t) {
DoDestroy();
T_ = t;
}
}
- inline void Reset() noexcept {
+ inline void Reset() noexcept {
Destroy();
}
- inline void Destroy() noexcept {
+ inline void Destroy() noexcept {
Reset(nullptr);
}
- inline void Swap(TAutoPtr& r) noexcept {
+ inline void Swap(TAutoPtr& r) noexcept {
DoSwap(T_, r.T_);
}
- inline T* Get() const noexcept {
+ inline T* Get() const noexcept {
return T_;
}
@@ -219,7 +219,7 @@ public:
}
#endif
private:
- inline void DoDestroy() noexcept {
+ inline void DoDestroy() noexcept {
if (T_) {
D::Destroy(T_);
}
@@ -232,22 +232,22 @@ private:
template <class T, class D>
class THolder: public TPointerBase<THolder<T, D>, T> {
public:
- constexpr THolder() noexcept
- : T_(nullptr)
- {
- }
-
- constexpr THolder(std::nullptr_t) noexcept
- : T_(nullptr)
- {
- }
-
+ constexpr THolder() noexcept
+ : T_(nullptr)
+ {
+ }
+
+ constexpr THolder(std::nullptr_t) noexcept
+ : T_(nullptr)
+ {
+ }
+
explicit THolder(T* t) noexcept
: T_(t)
{
}
- inline THolder(TAutoPtr<T, D> t) noexcept
+ inline THolder(TAutoPtr<T, D> t) noexcept
: T_(t.Release())
{
}
@@ -272,11 +272,11 @@ public:
THolder(const THolder&) = delete;
THolder& operator=(const THolder&) = delete;
- inline ~THolder() {
+ inline ~THolder() {
DoDestroy();
}
- inline void Destroy() noexcept {
+ inline void Destroy() noexcept {
Reset(nullptr);
}
@@ -284,22 +284,22 @@ public:
return this->DoRelease(T_);
}
- inline void Reset(T* t) noexcept {
+ inline void Reset(T* t) noexcept {
if (T_ != t) {
DoDestroy();
T_ = t;
}
}
- inline void Reset(TAutoPtr<T, D> t) noexcept {
+ inline void Reset(TAutoPtr<T, D> t) noexcept {
Reset(t.Release());
}
- inline void Reset() noexcept {
+ inline void Reset() noexcept {
Destroy();
}
- inline void Swap(THolder& r) noexcept {
+ inline void Swap(THolder& r) noexcept {
DoSwap(T_, r.T_);
}
@@ -307,15 +307,15 @@ public:
return T_;
}
- inline operator TAutoPtr<T, D>() noexcept {
+ inline operator TAutoPtr<T, D>() noexcept {
return Release();
}
- THolder& operator=(std::nullptr_t) noexcept {
- this->Reset(nullptr);
- return *this;
- }
-
+ THolder& operator=(std::nullptr_t) noexcept {
+ this->Reset(nullptr);
+ return *this;
+ }
+
THolder& operator=(THolder&& that) noexcept {
this->Reset(that.Release());
return *this;
@@ -334,7 +334,7 @@ public:
}
#endif
private:
- inline void DoDestroy() noexcept {
+ inline void DoDestroy() noexcept {
if (T_) {
D::Destroy(T_);
}
@@ -358,26 +358,26 @@ template <typename T, typename... Args>
template <class T, class C, class D>
class TRefCounted {
public:
- inline TRefCounted(long initval = 0) noexcept
+ inline TRefCounted(long initval = 0) noexcept
: Counter_(initval)
{
}
inline ~TRefCounted() = default;
- inline void Ref(TAtomicBase d) noexcept {
+ inline void Ref(TAtomicBase d) noexcept {
auto resultCount = Counter_.Add(d);
Y_ASSERT(resultCount >= d);
(void)resultCount;
}
- inline void Ref() noexcept {
+ inline void Ref() noexcept {
auto resultCount = Counter_.Inc();
Y_ASSERT(resultCount != 0);
(void)resultCount;
}
- inline void UnRef(TAtomicBase d) noexcept {
+ inline void UnRef(TAtomicBase d) noexcept {
auto resultCount = Counter_.Sub(d);
Y_ASSERT(resultCount >= 0);
if (resultCount == 0) {
@@ -385,7 +385,7 @@ public:
}
}
- inline void UnRef() noexcept {
+ inline void UnRef() noexcept {
UnRef(1);
}
@@ -393,7 +393,7 @@ public:
return Counter_.Val();
}
- inline void DecRef() noexcept {
+ inline void DecRef() noexcept {
auto resultCount = Counter_.Dec();
Y_ASSERT(resultCount >= 0);
(void)resultCount;
@@ -448,25 +448,25 @@ using TSimpleRefCount = TRefCounted<T, TSimpleCounter, D>;
template <class T>
class TDefaultIntrusivePtrOps {
public:
- static inline void Ref(T* t) noexcept {
+ static inline void Ref(T* t) noexcept {
Y_ASSERT(t);
t->Ref();
}
- static inline void UnRef(T* t) noexcept {
+ static inline void UnRef(T* t) noexcept {
Y_ASSERT(t);
t->UnRef();
}
- static inline void DecRef(T* t) noexcept {
+ static inline void DecRef(T* t) noexcept {
Y_ASSERT(t);
t->DecRef();
}
- static inline long RefCount(const T* t) noexcept {
+ static inline long RefCount(const T* t) noexcept {
Y_ASSERT(t);
return t->RefCount();
@@ -485,7 +485,7 @@ public:
struct TNoIncrement {
};
- inline TIntrusivePtr(T* t = nullptr) noexcept
+ inline TIntrusivePtr(T* t = nullptr) noexcept
: T_(t)
{
Ops();
@@ -498,11 +498,11 @@ public:
Ops();
}
- inline ~TIntrusivePtr() {
+ inline ~TIntrusivePtr() {
UnRef();
}
- inline TIntrusivePtr(const TIntrusivePtr& p) noexcept
+ inline TIntrusivePtr(const TIntrusivePtr& p) noexcept
: T_(p.T_)
{
Ref();
@@ -537,7 +537,7 @@ public:
Swap(p);
}
- inline TIntrusivePtr& operator=(TIntrusivePtr p) noexcept {
+ inline TIntrusivePtr& operator=(TIntrusivePtr p) noexcept {
p.Swap(*this);
return *this;
@@ -550,19 +550,19 @@ public:
Swap(t);
}
- inline void Reset() noexcept {
+ inline void Reset() noexcept {
Drop();
}
- inline T* Get() const noexcept {
+ inline T* Get() const noexcept {
return T_;
}
- inline void Swap(TIntrusivePtr& r) noexcept {
+ inline void Swap(TIntrusivePtr& r) noexcept {
DoSwap(T_, r.T_);
}
- inline void Drop() noexcept {
+ inline void Drop() noexcept {
TIntrusivePtr(nullptr).Swap(*this);
}
@@ -575,7 +575,7 @@ public:
return res;
}
- inline long RefCount() const noexcept {
+ inline long RefCount() const noexcept {
return T_ ? Ops::RefCount(T_) : 0;
}
@@ -586,13 +586,13 @@ public:
}
#endif
private:
- inline void Ref() noexcept {
+ inline void Ref() noexcept {
if (T_) {
Ops::Ref(T_);
}
}
- inline void UnRef() noexcept {
+ inline void UnRef() noexcept {
if (T_) {
Ops::UnRef(T_);
}
@@ -614,18 +614,18 @@ struct THash<TIntrusivePtr<T, Ops>>: THash<const T*> {
template <class T, class Ops>
class TIntrusiveConstPtr: public TPointerBase<TIntrusiveConstPtr<T, Ops>, const T> {
public:
- inline TIntrusiveConstPtr(T* t = nullptr) noexcept // we need a non-const pointer to Ref(), UnRef() and eventually delete it.
+ inline TIntrusiveConstPtr(T* t = nullptr) noexcept // we need a non-const pointer to Ref(), UnRef() and eventually delete it.
: T_(t)
{
Ops();
Ref();
}
- inline ~TIntrusiveConstPtr() {
+ inline ~TIntrusiveConstPtr() {
UnRef();
}
- inline TIntrusiveConstPtr(const TIntrusiveConstPtr& p) noexcept
+ inline TIntrusiveConstPtr(const TIntrusiveConstPtr& p) noexcept
: T_(p.T_)
{
Ref();
@@ -657,7 +657,7 @@ public:
p.T_ = nullptr;
}
- inline TIntrusiveConstPtr& operator=(TIntrusiveConstPtr p) noexcept {
+ inline TIntrusiveConstPtr& operator=(TIntrusiveConstPtr p) noexcept {
p.Swap(*this);
return *this;
@@ -670,19 +670,19 @@ public:
Swap(t);
}
- inline void Reset() noexcept {
+ inline void Reset() noexcept {
Drop();
}
- inline const T* Get() const noexcept {
+ inline const T* Get() const noexcept {
return T_;
}
- inline void Swap(TIntrusiveConstPtr& r) noexcept {
+ inline void Swap(TIntrusiveConstPtr& r) noexcept {
DoSwap(T_, r.T_);
}
- inline void Drop() noexcept {
+ inline void Drop() noexcept {
TIntrusiveConstPtr(nullptr).Swap(*this);
}
@@ -697,13 +697,13 @@ public:
}
#endif
private:
- inline void Ref() noexcept {
+ inline void Ref() noexcept {
if (T_ != nullptr) {
Ops::Ref(T_);
}
}
- inline void UnRef() noexcept {
+ inline void UnRef() noexcept {
if (T_ != nullptr) {
Ops::UnRef(T_);
}
@@ -732,31 +732,31 @@ class TSimpleIntrusiveOps {
#endif
;
- static void DoRef(T* t) noexcept {
+ static void DoRef(T* t) noexcept {
Ops::Ref(t);
}
- static void DoUnRef(T* t) noexcept {
+ static void DoUnRef(T* t) noexcept {
Ops::UnRef(t);
}
public:
- inline TSimpleIntrusiveOps() noexcept {
+ inline TSimpleIntrusiveOps() noexcept {
InitStaticOps();
}
inline ~TSimpleIntrusiveOps() = default;
- static inline void Ref(T* t) noexcept {
+ static inline void Ref(T* t) noexcept {
Ref_(t);
}
- static inline void UnRef(T* t) noexcept {
+ static inline void UnRef(T* t) noexcept {
UnRef_(t);
}
private:
- static inline void InitStaticOps() noexcept {
+ static inline void InitStaticOps() noexcept {
struct TInit {
inline TInit() noexcept {
Ref_ = DoRef;
@@ -794,7 +794,7 @@ class TSharedPtr: public TPointerBase<TSharedPtr<T, C, D>, T> {
friend class TSharedPtr;
public:
- inline TSharedPtr() noexcept
+ inline TSharedPtr() noexcept
: T_(nullptr)
, C_(nullptr)
{
@@ -810,7 +810,7 @@ public:
Init(t);
}
- inline TSharedPtr(T* t, C* c) noexcept
+ inline TSharedPtr(T* t, C* c) noexcept
: T_(t)
, C_(c)
{
@@ -825,7 +825,7 @@ public:
UnRef();
}
- inline TSharedPtr(const TSharedPtr& t) noexcept
+ inline TSharedPtr(const TSharedPtr& t) noexcept
: T_(t.T_)
, C_(t.C_)
{
@@ -840,7 +840,7 @@ public:
}
template <class TT, class = TGuardConversion<T, TT>>
- inline TSharedPtr(const TSharedPtr<TT, C, D>& t) noexcept
+ inline TSharedPtr(const TSharedPtr<TT, C, D>& t) noexcept
: T_(t.T_)
, C_(t.C_)
{
@@ -856,7 +856,7 @@ public:
t.C_ = nullptr;
}
- inline TSharedPtr& operator=(TSharedPtr t) noexcept {
+ inline TSharedPtr& operator=(TSharedPtr t) noexcept {
t.Swap(*this);
return *this;
@@ -869,28 +869,28 @@ public:
Swap(t);
}
- inline void Reset() noexcept {
+ inline void Reset() noexcept {
Drop();
}
- inline void Drop() noexcept {
+ inline void Drop() noexcept {
TSharedPtr().Swap(*this);
}
- inline T* Get() const noexcept {
+ inline T* Get() const noexcept {
return T_;
}
- inline C* ReferenceCounter() const noexcept {
+ inline C* ReferenceCounter() const noexcept {
return C_;
}
- inline void Swap(TSharedPtr& r) noexcept {
+ inline void Swap(TSharedPtr& r) noexcept {
DoSwap(T_, r.T_);
DoSwap(C_, r.C_);
}
- inline long RefCount() const noexcept {
+ inline long RefCount() const noexcept {
return C_ ? C_->Val() : 0;
}
@@ -907,19 +907,19 @@ private:
T_ = t.Release();
}
- inline void Ref() noexcept {
+ inline void Ref() noexcept {
if (C_) {
C_->Inc();
}
}
- inline void UnRef() noexcept {
+ inline void UnRef() noexcept {
if (C_ && !C_->Dec()) {
DoDestroy();
}
}
- inline void DoDestroy() noexcept {
+ inline void DoDestroy() noexcept {
if (T_) {
D::Destroy(T_);
}
@@ -985,7 +985,7 @@ public:
template <class T, class C, class D>
class TCopyPtr: public TPointerBase<TCopyPtr<T, C, D>, T> {
public:
- inline TCopyPtr(T* t = nullptr) noexcept
+ inline TCopyPtr(T* t = nullptr) noexcept
: T_(t)
{
}
@@ -1001,7 +1001,7 @@ public:
Swap(t);
}
- inline ~TCopyPtr() {
+ inline ~TCopyPtr() {
DoDestroy();
}
@@ -1015,26 +1015,26 @@ public:
return DoRelease(T_);
}
- inline void Reset(T* t) noexcept {
+ inline void Reset(T* t) noexcept {
if (T_ != t) {
DoDestroy();
T_ = t;
}
}
- inline void Reset() noexcept {
+ inline void Reset() noexcept {
Destroy();
}
- inline void Destroy() noexcept {
+ inline void Destroy() noexcept {
Reset(nullptr);
}
- inline void Swap(TCopyPtr& r) noexcept {
+ inline void Swap(TCopyPtr& r) noexcept {
DoSwap(T_, r.T_);
}
- inline T* Get() const noexcept {
+ inline T* Get() const noexcept {
return T_;
}
@@ -1045,7 +1045,7 @@ public:
}
#endif
private:
- inline void DoDestroy() noexcept {
+ inline void DoDestroy() noexcept {
if (T_)
D::Destroy(T_);
}
@@ -1072,11 +1072,11 @@ public:
{
}
- inline const T* Get() const noexcept {
+ inline const T* Get() const noexcept {
return Const();
}
- inline const T* Const() const noexcept {
+ inline const T* Const() const noexcept {
return T_.Get();
}
@@ -1086,11 +1086,11 @@ public:
return T_.Get();
}
- inline bool Shared() const noexcept {
+ inline bool Shared() const noexcept {
return T_.RefCount() > 1;
}
- inline void Swap(TCowPtr& r) noexcept {
+ inline void Swap(TCowPtr& r) noexcept {
T_.Swap(r.T_);
}
diff --git a/util/generic/ptr_ut.cpp b/util/generic/ptr_ut.cpp
index 8dab40aa5e..c2dcff23f6 100644
--- a/util/generic/ptr_ut.cpp
+++ b/util/generic/ptr_ut.cpp
@@ -268,10 +268,10 @@ void TPointerTest::TestAutoToHolder() {
UNIT_ASSERT_VALUES_EQUAL(cnt, 0);
{
- class B1: public A {
+ class B1: public A {
};
- TAutoPtr<B1> x(new B1());
+ TAutoPtr<B1> x(new B1());
THolder<A> y = x;
}
@@ -340,9 +340,9 @@ void TPointerTest::TestIntrPtr() {
TIntrusivePtr<TOp> p, p2;
TOp3 op3;
{
- TVector<TIntrusivePtr<TOp>> f1;
+ TVector<TIntrusivePtr<TOp>> f1;
{
- TVector<TIntrusivePtr<TOp>> f2;
+ TVector<TIntrusivePtr<TOp>> f2;
f2.push_back(new TOp);
p = new TOp;
f2.push_back(p);
@@ -560,7 +560,7 @@ namespace {
}
void TPointerTest::TestOperatorBool() {
- using TVec = TVector<ui32>;
+ using TVec = TVector<ui32>;
// to be sure TImplicitlyCastable works as expected
UNIT_ASSERT((TImplicitlyCastable<int, bool>::Result));
diff --git a/util/generic/queue.h b/util/generic/queue.h
index 9f1cd02f17..f5959f68f2 100644
--- a/util/generic/queue.h
+++ b/util/generic/queue.h
@@ -10,7 +10,7 @@
#include <queue>
template <class T, class S>
-class TQueue: public std::queue<T, S> {
+class TQueue: public std::queue<T, S> {
using TBase = std::queue<T, S>;
public:
@@ -34,7 +34,7 @@ public:
};
template <class T, class S, class C>
-class TPriorityQueue: public std::priority_queue<T, S, C> {
+class TPriorityQueue: public std::priority_queue<T, S, C> {
using TBase = std::priority_queue<T, S, C>;
public:
diff --git a/util/generic/queue_ut.cpp b/util/generic/queue_ut.cpp
index afaea028ad..a33399e104 100644
--- a/util/generic/queue_ut.cpp
+++ b/util/generic/queue_ut.cpp
@@ -9,7 +9,7 @@
Y_UNIT_TEST_SUITE(TYQueueTest) {
Y_UNIT_TEST(ConstructorsAndAssignments) {
{
- using container = TQueue<int>;
+ using container = TQueue<int>;
container c1;
UNIT_ASSERT(!c1);
@@ -41,7 +41,7 @@ Y_UNIT_TEST_SUITE(TYQueueTest) {
}
{
- using container = TPriorityQueue<int>;
+ using container = TPriorityQueue<int>;
container c1;
UNIT_ASSERT(!c1);
@@ -74,7 +74,7 @@ Y_UNIT_TEST_SUITE(TYQueueTest) {
}
Y_UNIT_TEST(pqueue1) {
- TPriorityQueue<int, TDeque<int>, TLess<int>> q;
+ TPriorityQueue<int, TDeque<int>, TLess<int>> q;
q.push(42);
q.push(101);
@@ -92,7 +92,7 @@ Y_UNIT_TEST_SUITE(TYQueueTest) {
}
Y_UNIT_TEST(pqueue2) {
- using TPQueue = TPriorityQueue<int, TDeque<int>, TLess<int>>;
+ using TPQueue = TPriorityQueue<int, TDeque<int>, TLess<int>>;
TPQueue q;
{
@@ -118,7 +118,7 @@ Y_UNIT_TEST_SUITE(TYQueueTest) {
}
Y_UNIT_TEST(pqueue3) {
- TPriorityQueue<int, TDeque<int>, TLess<int>> q;
+ TPriorityQueue<int, TDeque<int>, TLess<int>> q;
q.push(42);
q.push(101);
@@ -129,12 +129,12 @@ Y_UNIT_TEST_SUITE(TYQueueTest) {
}
Y_UNIT_TEST(pqueue4) {
- TDeque<int> c;
+ TDeque<int> c;
c.push_back(42);
c.push_back(101);
c.push_back(69);
- TPriorityQueue<int, TDeque<int>, TLess<int>> q(TLess<int>(), std::move(c));
+ TPriorityQueue<int, TDeque<int>, TLess<int>> q(TLess<int>(), std::move(c));
UNIT_ASSERT(c.empty());
@@ -153,7 +153,7 @@ Y_UNIT_TEST_SUITE(TYQueueTest) {
}
Y_UNIT_TEST(queue1) {
- TQueue<int, TList<int>> q;
+ TQueue<int, TList<int>> q;
q.push(42);
q.push(101);
@@ -171,11 +171,11 @@ Y_UNIT_TEST_SUITE(TYQueueTest) {
}
Y_UNIT_TEST(queue2) {
- using TQueueType = TQueue<int>;
- TQueueType q;
+ using TQueueType = TQueue<int>;
+ TQueueType q;
{
- TQueueType qq;
+ TQueueType qq;
qq.push(42);
qq.push(101);
@@ -197,8 +197,8 @@ Y_UNIT_TEST_SUITE(TYQueueTest) {
}
Y_UNIT_TEST(queue3) {
- using TQueueType = TQueue<int>;
- TQueueType q;
+ using TQueueType = TQueue<int>;
+ TQueueType q;
q.push(42);
q.push(101);
diff --git a/util/generic/refcount.h b/util/generic/refcount.h
index c21be4f579..966e853b77 100644
--- a/util/generic/refcount.h
+++ b/util/generic/refcount.h
@@ -10,12 +10,12 @@ class TSimpleCounterTemplate: public TCounterCheckPolicy {
using TCounterCheckPolicy::Check;
public:
- inline TSimpleCounterTemplate(long initial = 0) noexcept
+ inline TSimpleCounterTemplate(long initial = 0) noexcept
: Counter_(initial)
{
}
- inline ~TSimpleCounterTemplate() {
+ inline ~TSimpleCounterTemplate() {
Check();
}
@@ -37,7 +37,7 @@ public:
return Sub(1);
}
- inline bool TryWeakInc() noexcept {
+ inline bool TryWeakInc() noexcept {
if (!Counter_) {
return false;
}
@@ -91,18 +91,18 @@ using TExplicitSimpleCounter = TSimpleCounterTemplate<TNoCheckPolicy>;
template <class TCounterCheckPolicy>
struct TCommonLockOps<TSimpleCounterTemplate<TCounterCheckPolicy>> {
- static inline void Acquire(TSimpleCounterTemplate<TCounterCheckPolicy>* t) noexcept {
+ static inline void Acquire(TSimpleCounterTemplate<TCounterCheckPolicy>* t) noexcept {
t->Inc();
}
- static inline void Release(TSimpleCounterTemplate<TCounterCheckPolicy>* t) noexcept {
+ static inline void Release(TSimpleCounterTemplate<TCounterCheckPolicy>* t) noexcept {
t->Dec();
}
};
class TAtomicCounter {
public:
- inline TAtomicCounter(long initial = 0) noexcept
+ inline TAtomicCounter(long initial = 0) noexcept
: Counter_(initial)
{
}
@@ -117,19 +117,19 @@ public:
return Add(1);
}
- inline TAtomicBase Sub(TAtomicBase d) noexcept {
+ inline TAtomicBase Sub(TAtomicBase d) noexcept {
return AtomicSub(Counter_, d);
}
- inline TAtomicBase Dec() noexcept {
+ inline TAtomicBase Dec() noexcept {
return Sub(1);
}
- inline TAtomicBase Val() const noexcept {
+ inline TAtomicBase Val() const noexcept {
return AtomicGet(Counter_);
}
- inline bool TryWeakInc() noexcept {
+ inline bool TryWeakInc() noexcept {
while (true) {
intptr_t curValue = Counter_;
@@ -152,11 +152,11 @@ private:
template <>
struct TCommonLockOps<TAtomicCounter> {
- static inline void Acquire(TAtomicCounter* t) noexcept {
+ static inline void Acquire(TAtomicCounter* t) noexcept {
t->Inc();
}
- static inline void Release(TAtomicCounter* t) noexcept {
+ static inline void Release(TAtomicCounter* t) noexcept {
t->Dec();
}
};
diff --git a/util/generic/serialized_enum.h b/util/generic/serialized_enum.h
index 50eda8a4bf..79df2bac22 100644
--- a/util/generic/serialized_enum.h
+++ b/util/generic/serialized_enum.h
@@ -1,34 +1,34 @@
-#pragma once
-
+#pragma once
+
#include <util/generic/fwd.h>
#include <util/generic/vector.h>
#include <util/generic/map.h>
-#include <cstddef>
+#include <cstddef>
#include <type_traits>
-
-/*
-
+
+/*
+
A file with declarations of enumeration-related functions.
It doesn't contains definitions. To generate them you have to add
-
- GENERATE_ENUM_SERIALIZATION_WITH_HEADER(your_header_with_your_enum.h)
+
+ GENERATE_ENUM_SERIALIZATION_WITH_HEADER(your_header_with_your_enum.h)
or
GENERATE_ENUM_SERIALIZATION(your_header_with_your_enum.h)
-
+
in your ya.make
-
-@see https://st.yandex-team.ru/IGNIETFERRO-333
-@see https://wiki.yandex-team.ru/PoiskovajaPlatforma/Build/WritingCmakefiles/#generate-enum-with-header
-
-*/
-
-/**
- * Returns number of distinct items in enum or enum class
- *
- * @tparam EnumT enum type
- */
-template <typename EnumT>
+
+@see https://st.yandex-team.ru/IGNIETFERRO-333
+@see https://wiki.yandex-team.ru/PoiskovajaPlatforma/Build/WritingCmakefiles/#generate-enum-with-header
+
+*/
+
+/**
+ * Returns number of distinct items in enum or enum class
+ *
+ * @tparam EnumT enum type
+ */
+template <typename EnumT>
Y_CONST_FUNCTION constexpr size_t GetEnumItemsCount();
namespace NEnumSerializationRuntime {
diff --git a/util/generic/set.h b/util/generic/set.h
index 6a5f639e0c..4c437ca26f 100644
--- a/util/generic/set.h
+++ b/util/generic/set.h
@@ -10,7 +10,7 @@
#include <set>
template <class K, class L, class A>
-class TSet: public std::set<K, L, TReboundAllocator<A, K>> {
+class TSet: public std::set<K, L, TReboundAllocator<A, K>> {
public:
using TBase = std::set<K, L, TReboundAllocator<A, K>>;
using TBase::TBase;
@@ -26,7 +26,7 @@ public:
};
template <class K, class L, class A>
-class TMultiSet: public std::multiset<K, L, TReboundAllocator<A, K>> {
+class TMultiSet: public std::multiset<K, L, TReboundAllocator<A, K>> {
public:
using TBase = std::multiset<K, L, TReboundAllocator<A, K>>;
using TBase::TBase;
diff --git a/util/generic/set_ut.cpp b/util/generic/set_ut.cpp
index 00938e3999..d2769d327f 100644
--- a/util/generic/set_ut.cpp
+++ b/util/generic/set_ut.cpp
@@ -8,7 +8,7 @@
Y_UNIT_TEST_SUITE(YSetTest) {
Y_UNIT_TEST(TestSet1) {
- TSet<int, TLess<int>> s;
+ TSet<int, TLess<int>> s;
UNIT_ASSERT(!s);
UNIT_ASSERT(s.count(42) == 0);
s.insert(42);
@@ -21,7 +21,7 @@ Y_UNIT_TEST_SUITE(YSetTest) {
}
Y_UNIT_TEST(TestSet2) {
- using int_set = TSet<int, TLess<int>>;
+ using int_set = TSet<int, TLess<int>>;
int_set s;
std::pair<int_set::iterator, bool> p = s.insert(42);
UNIT_ASSERT(p.second == true);
@@ -46,7 +46,7 @@ Y_UNIT_TEST_SUITE(YSetTest) {
}
Y_UNIT_TEST(TestErase) {
- TSet<int, TLess<int>> s;
+ TSet<int, TLess<int>> s;
s.insert(1);
s.erase(s.begin());
UNIT_ASSERT(s.empty());
@@ -56,26 +56,26 @@ Y_UNIT_TEST_SUITE(YSetTest) {
}
Y_UNIT_TEST(TestInsert) {
- TSet<int> s;
- TSet<int>::iterator i = s.insert(s.end(), 0);
+ TSet<int> s;
+ TSet<int>::iterator i = s.insert(s.end(), 0);
UNIT_ASSERT(*i == 0);
}
Y_UNIT_TEST(TestFind) {
- TSet<int> s;
+ TSet<int> s;
UNIT_ASSERT(s.find(0) == s.end());
- TSet<int> const& crs = s;
+ TSet<int> const& crs = s;
UNIT_ASSERT(crs.find(0) == crs.end());
}
Y_UNIT_TEST(TestHas) {
- TSet<int> s;
+ TSet<int> s;
UNIT_ASSERT(!s.contains(0));
- TSet<int> const& crs = s;
+ TSet<int> const& crs = s;
UNIT_ASSERT(!crs.contains(0));
s.insert(1);
@@ -91,13 +91,13 @@ Y_UNIT_TEST_SUITE(YSetTest) {
Y_UNIT_TEST(TestBounds) {
int array1[] = {1, 3, 6, 7};
- TSet<int> s(array1, array1 + sizeof(array1) / sizeof(array1[0]));
- TSet<int> const& crs = s;
+ TSet<int> s(array1, array1 + sizeof(array1) / sizeof(array1[0]));
+ TSet<int> const& crs = s;
- TSet<int>::iterator sit;
- TSet<int>::const_iterator scit;
- std::pair<TSet<int>::iterator, TSet<int>::iterator> pit;
- std::pair<TSet<int>::const_iterator, TSet<int>::const_iterator> pcit;
+ TSet<int>::iterator sit;
+ TSet<int>::const_iterator scit;
+ std::pair<TSet<int>::iterator, TSet<int>::iterator> pit;
+ std::pair<TSet<int>::const_iterator, TSet<int>::const_iterator> pcit;
//Check iterator on mutable set
sit = s.lower_bound(2);
@@ -156,35 +156,35 @@ Y_UNIT_TEST_SUITE(YSetTest) {
}
Y_UNIT_TEST(TestImplementationCheck) {
- TSet<int> tree;
+ TSet<int> tree;
tree.insert(1);
- TSet<int>::iterator it = tree.begin();
+ TSet<int>::iterator it = tree.begin();
int const& int_ref = *it++;
UNIT_ASSERT(int_ref == 1);
UNIT_ASSERT(it == tree.end());
UNIT_ASSERT(it != tree.begin());
- TSet<int>::const_iterator cit = tree.begin();
+ TSet<int>::const_iterator cit = tree.begin();
int const& int_cref = *cit++;
UNIT_ASSERT(int_cref == 1);
}
Y_UNIT_TEST(TestReverseIteratorTest) {
- TSet<int> tree;
+ TSet<int> tree;
tree.insert(1);
tree.insert(2);
{
- TSet<int>::reverse_iterator rit(tree.rbegin());
+ TSet<int>::reverse_iterator rit(tree.rbegin());
UNIT_ASSERT(*(rit++) == 2);
UNIT_ASSERT(*(rit++) == 1);
UNIT_ASSERT(rit == tree.rend());
}
{
- TSet<int> const& ctree = tree;
- TSet<int>::const_reverse_iterator rit(ctree.rbegin());
+ TSet<int> const& ctree = tree;
+ TSet<int>::const_reverse_iterator rit(ctree.rbegin());
UNIT_ASSERT(*(rit++) == 2);
UNIT_ASSERT(*(rit++) == 1);
UNIT_ASSERT(rit == ctree.rend());
@@ -193,7 +193,7 @@ Y_UNIT_TEST_SUITE(YSetTest) {
Y_UNIT_TEST(TestConstructorsAndAssignments) {
{
- using container = TSet<int>;
+ using container = TSet<int>;
container c1;
c1.insert(100);
@@ -228,7 +228,7 @@ Y_UNIT_TEST_SUITE(YSetTest) {
}
{
- using container = TMultiSet<int>;
+ using container = TMultiSet<int>;
container c1;
c1.insert(100);
@@ -311,7 +311,7 @@ Y_UNIT_TEST_SUITE(YSetTest) {
Y_UNIT_TEST(TestTemplateMethods) {
{
- using KeySet = TSet<TKey, TKeyCmp>;
+ using KeySet = TSet<TKey, TKeyCmp>;
KeySet keySet;
keySet.insert(TKey(1));
keySet.insert(TKey(2));
@@ -335,7 +335,7 @@ Y_UNIT_TEST_SUITE(YSetTest) {
}
{
- using KeySet = TSet<TKey*, TKeyCmpPtr>;
+ using KeySet = TSet<TKey*, TKeyCmpPtr>;
KeySet keySet;
TKey key1(1), key2(2), key3(3), key4(4);
keySet.insert(&key1);
@@ -358,7 +358,7 @@ Y_UNIT_TEST_SUITE(YSetTest) {
UNIT_ASSERT(ckeySet.equal_range(2) != std::make_pair(ckeySet.begin(), ckeySet.end()));
}
{
- using KeySet = TMultiSet<TKey, TKeyCmp>;
+ using KeySet = TMultiSet<TKey, TKeyCmp>;
KeySet keySet;
keySet.insert(TKey(1));
keySet.insert(TKey(2));
@@ -382,7 +382,7 @@ Y_UNIT_TEST_SUITE(YSetTest) {
}
{
- using KeySet = TMultiSet<TKey const volatile*, TKeyCmpPtr>;
+ using KeySet = TMultiSet<TKey const volatile*, TKeyCmpPtr>;
KeySet keySet;
TKey key1(1), key2(2), key3(3), key4(4);
keySet.insert(&key1);
diff --git a/util/generic/singleton.cpp b/util/generic/singleton.cpp
index cec1e997f1..eb5a0662f8 100644
--- a/util/generic/singleton.cpp
+++ b/util/generic/singleton.cpp
@@ -7,15 +7,15 @@
#include <cstring>
namespace {
- static inline bool MyAtomicTryLock(TAtomic& a, TAtomicBase v) noexcept {
+ static inline bool MyAtomicTryLock(TAtomic& a, TAtomicBase v) noexcept {
return AtomicCas(&a, v, 0);
}
- static inline bool MyAtomicTryAndTryLock(TAtomic& a, TAtomicBase v) noexcept {
+ static inline bool MyAtomicTryAndTryLock(TAtomic& a, TAtomicBase v) noexcept {
return (AtomicGet(a) == 0) && MyAtomicTryLock(a, v);
}
- static inline TAtomicBase MyThreadId() noexcept {
+ static inline TAtomicBase MyThreadId() noexcept {
const TAtomicBase ret = TThread::CurrentThreadId();
if (ret) {
@@ -41,7 +41,7 @@ void NPrivate::FillWithTrash(void* ptr, size_t len) {
#endif
}
-void NPrivate::LockRecursive(TAtomic& lock) noexcept {
+void NPrivate::LockRecursive(TAtomic& lock) noexcept {
const TAtomicBase id = MyThreadId();
Y_VERIFY(AtomicGet(lock) != id, "recursive singleton initialization");
@@ -55,7 +55,7 @@ void NPrivate::LockRecursive(TAtomic& lock) noexcept {
}
}
-void NPrivate::UnlockRecursive(TAtomic& lock) noexcept {
+void NPrivate::UnlockRecursive(TAtomic& lock) noexcept {
Y_VERIFY(AtomicGet(lock) == MyThreadId(), "unlock from another thread?!?!");
AtomicUnlock(&lock);
}
diff --git a/util/generic/singleton.h b/util/generic/singleton.h
index 5b118b4221..f5fa047f5c 100644
--- a/util/generic/singleton.h
+++ b/util/generic/singleton.h
@@ -14,8 +14,8 @@ struct TSingletonTraits {
namespace NPrivate {
void FillWithTrash(void* ptr, size_t len);
- void LockRecursive(TAtomic& lock) noexcept;
- void UnlockRecursive(TAtomic& lock) noexcept;
+ void LockRecursive(TAtomic& lock) noexcept;
+ void UnlockRecursive(TAtomic& lock) noexcept;
template <class T>
void Destroyer(void* ptr) {
@@ -80,7 +80,7 @@ namespace NPrivate {
{
}
- inline const T* Get() const noexcept {
+ inline const T* Get() const noexcept {
return &T_;
}
@@ -96,7 +96,7 @@ namespace NPrivate {
{
}
- inline ~THeapStore() {
+ inline ~THeapStore() {
delete D;
}
diff --git a/util/generic/stack.h b/util/generic/stack.h
index fd3848b154..dbcbf2b5c9 100644
--- a/util/generic/stack.h
+++ b/util/generic/stack.h
@@ -6,7 +6,7 @@
#include <stack>
template <class T, class S>
-class TStack: public std::stack<T, S> {
+class TStack: public std::stack<T, S> {
using TBase = std::stack<T, S>;
public:
diff --git a/util/generic/stack_ut.cpp b/util/generic/stack_ut.cpp
index 68ceda4bdd..248127d326 100644
--- a/util/generic/stack_ut.cpp
+++ b/util/generic/stack_ut.cpp
@@ -4,7 +4,7 @@
Y_UNIT_TEST_SUITE(TYStackTest) {
Y_UNIT_TEST(ExplicitBool) {
- TStack<int> s;
+ TStack<int> s;
UNIT_ASSERT(!s);
UNIT_ASSERT(s.empty());
diff --git a/util/generic/strbase.h b/util/generic/strbase.h
index 1592afc85d..ab39fc7537 100644
--- a/util/generic/strbase.h
+++ b/util/generic/strbase.h
@@ -127,27 +127,27 @@ public:
* @param Pointer to character inside the string, or nullptr.
* @return Offset from string beginning (in chars), or npos on nullptr.
*/
- inline size_t off(const TCharType* ret) const noexcept {
+ inline size_t off(const TCharType* ret) const noexcept {
return ret ? (size_t)(ret - Ptr()) : npos;
}
- inline size_t IterOff(const_iterator it) const noexcept {
+ inline size_t IterOff(const_iterator it) const noexcept {
return begin() <= it && end() > it ? size_t(it - begin()) : npos;
}
- inline const_iterator begin() const noexcept {
+ inline const_iterator begin() const noexcept {
return Ptr();
}
- inline const_iterator end() const noexcept {
+ inline const_iterator end() const noexcept {
return Ptr() + size();
}
- inline const_iterator cbegin() const noexcept {
+ inline const_iterator cbegin() const noexcept {
return begin();
}
- inline const_iterator cend() const noexcept {
+ inline const_iterator cend() const noexcept {
return end();
}
@@ -167,7 +167,7 @@ public:
return rend();
}
- inline TCharType back() const noexcept {
+ inline TCharType back() const noexcept {
Y_ASSERT(!this->empty());
return Ptr()[Len() - 1];
}
@@ -181,11 +181,11 @@ public:
return Ptr();
}
- constexpr inline size_t size() const noexcept {
+ constexpr inline size_t size() const noexcept {
return Len();
}
- constexpr inline bool is_null() const noexcept {
+ constexpr inline bool is_null() const noexcept {
return *Ptr() == 0;
}
@@ -193,16 +193,16 @@ public:
return Len() == 0;
}
- constexpr inline explicit operator bool() const noexcept {
+ constexpr inline explicit operator bool() const noexcept {
return !empty();
}
public: // style-guide compliant methods
- constexpr const TCharType* Data() const noexcept {
+ constexpr const TCharType* Data() const noexcept {
return Ptr();
}
- constexpr size_t Size() const noexcept {
+ constexpr size_t Size() const noexcept {
return Len();
}
@@ -218,16 +218,16 @@ private:
public:
// ~~~ Comparison ~~~ : FAMILY0(int, compare)
- static int compare(const TSelf& s1, const TSelf& s2) noexcept {
+ static int compare(const TSelf& s1, const TSelf& s2) noexcept {
return s1.AsStringView().compare(s2.AsStringView());
}
- static int compare(const TCharType* p, const TSelf& s2) noexcept {
+ static int compare(const TCharType* p, const TSelf& s2) noexcept {
TCharType null{0};
return TStringViewWithTraits(p ? p : &null).compare(s2.AsStringView());
}
- static int compare(const TSelf& s1, const TCharType* p) noexcept {
+ static int compare(const TSelf& s1, const TCharType* p) noexcept {
TCharType null{0};
return s1.AsStringView().compare(p ? p : &null);
}
@@ -237,7 +237,7 @@ public:
}
template <class T>
- inline int compare(const T& t) const noexcept {
+ inline int compare(const T& t) const noexcept {
return compare(*this, t);
}
@@ -257,7 +257,7 @@ public:
return compare(*this, TStringView(p, len));
}
- static bool equal(const TSelf& s1, const TSelf& s2) noexcept {
+ static bool equal(const TSelf& s1, const TSelf& s2) noexcept {
return s1.AsStringView() == s2.AsStringView();
}
@@ -278,7 +278,7 @@ public:
}
template <class T>
- inline bool equal(const T& t) const noexcept {
+ inline bool equal(const T& t) const noexcept {
return equal(*this, t);
}
@@ -340,12 +340,12 @@ public:
}
#ifndef __cpp_impl_three_way_comparison
- friend bool operator==(const TCharType* pc, const TSelf& s) noexcept {
+ friend bool operator==(const TCharType* pc, const TSelf& s) noexcept {
return equal(pc, s);
}
template <typename TDerived2, typename TTraits2>
- friend bool operator!=(const TSelf& s1, const TStringBase<TDerived2, TChar, TTraits2>& s2) noexcept {
+ friend bool operator!=(const TSelf& s1, const TStringBase<TDerived2, TChar, TTraits2>& s2) noexcept {
return !(s1 == s2);
}
@@ -353,17 +353,17 @@ public:
return !(s1 == s2);
}
- friend bool operator!=(const TSelf& s, const TCharType* pc) noexcept {
+ friend bool operator!=(const TSelf& s, const TCharType* pc) noexcept {
return !(s == pc);
}
- friend bool operator!=(const TCharType* pc, const TSelf& s) noexcept {
+ friend bool operator!=(const TCharType* pc, const TSelf& s) noexcept {
return !(pc == s);
}
#endif
template <typename TDerived2, typename TTraits2>
- friend bool operator<(const TSelf& s1, const TStringBase<TDerived2, TChar, TTraits2>& s2) noexcept {
+ friend bool operator<(const TSelf& s1, const TStringBase<TDerived2, TChar, TTraits2>& s2) noexcept {
return compare(s1, s2) < 0;
}
@@ -371,16 +371,16 @@ public:
return compare(s1, s2) < 0;
}
- friend bool operator<(const TSelf& s, const TCharType* pc) noexcept {
+ friend bool operator<(const TSelf& s, const TCharType* pc) noexcept {
return compare(s, pc) < 0;
}
- friend bool operator<(const TCharType* pc, const TSelf& s) noexcept {
+ friend bool operator<(const TCharType* pc, const TSelf& s) noexcept {
return compare(pc, s) < 0;
}
template <typename TDerived2, typename TTraits2>
- friend bool operator<=(const TSelf& s1, const TStringBase<TDerived2, TChar, TTraits2>& s2) noexcept {
+ friend bool operator<=(const TSelf& s1, const TStringBase<TDerived2, TChar, TTraits2>& s2) noexcept {
return compare(s1, s2) <= 0;
}
@@ -388,16 +388,16 @@ public:
return compare(s1, s2) <= 0;
}
- friend bool operator<=(const TSelf& s, const TCharType* pc) noexcept {
+ friend bool operator<=(const TSelf& s, const TCharType* pc) noexcept {
return compare(s, pc) <= 0;
}
- friend bool operator<=(const TCharType* pc, const TSelf& s) noexcept {
+ friend bool operator<=(const TCharType* pc, const TSelf& s) noexcept {
return compare(pc, s) <= 0;
}
template <typename TDerived2, typename TTraits2>
- friend bool operator>(const TSelf& s1, const TStringBase<TDerived2, TChar, TTraits2>& s2) noexcept {
+ friend bool operator>(const TSelf& s1, const TStringBase<TDerived2, TChar, TTraits2>& s2) noexcept {
return compare(s1, s2) > 0;
}
@@ -405,16 +405,16 @@ public:
return compare(s1, s2) > 0;
}
- friend bool operator>(const TSelf& s, const TCharType* pc) noexcept {
+ friend bool operator>(const TSelf& s, const TCharType* pc) noexcept {
return compare(s, pc) > 0;
}
- friend bool operator>(const TCharType* pc, const TSelf& s) noexcept {
+ friend bool operator>(const TCharType* pc, const TSelf& s) noexcept {
return compare(pc, s) > 0;
}
template <typename TDerived2, typename TTraits2>
- friend bool operator>=(const TSelf& s1, const TStringBase<TDerived2, TChar, TTraits2>& s2) noexcept {
+ friend bool operator>=(const TSelf& s1, const TStringBase<TDerived2, TChar, TTraits2>& s2) noexcept {
return compare(s1, s2) >= 0;
}
@@ -422,23 +422,23 @@ public:
return compare(s1, s2) >= 0;
}
- friend bool operator>=(const TSelf& s, const TCharType* pc) noexcept {
+ friend bool operator>=(const TSelf& s, const TCharType* pc) noexcept {
return compare(s, pc) >= 0;
}
- friend bool operator>=(const TCharType* pc, const TSelf& s) noexcept {
+ friend bool operator>=(const TCharType* pc, const TSelf& s) noexcept {
return compare(pc, s) >= 0;
}
// ~~ Read access ~~
- inline TCharType at(size_t pos) const noexcept {
+ inline TCharType at(size_t pos) const noexcept {
if (Y_LIKELY(pos < Len())) {
return (Ptr())[pos];
}
return 0;
}
- inline TCharType operator[](size_t pos) const noexcept {
+ inline TCharType operator[](size_t pos) const noexcept {
Y_ASSERT(pos < this->size());
return Ptr()[pos];
@@ -456,15 +456,15 @@ public:
return AsStringView().find(s, pos, count);
}
- inline size_t find(TCharType c, size_t pos = 0) const noexcept {
+ inline size_t find(TCharType c, size_t pos = 0) const noexcept {
return AsStringView().find(c, pos);
}
- inline size_t rfind(TCharType c) const noexcept {
+ inline size_t rfind(TCharType c) const noexcept {
return AsStringView().rfind(c);
}
- inline size_t rfind(TCharType c, size_t pos) const noexcept {
+ inline size_t rfind(TCharType c, size_t pos) const noexcept {
if (pos == 0) {
return npos;
}
@@ -492,11 +492,11 @@ public:
}
//~~~~Character Set Search~~~
- inline size_t find_first_of(TCharType c) const noexcept {
+ inline size_t find_first_of(TCharType c) const noexcept {
return find_first_of(c, 0);
}
- inline size_t find_first_of(TCharType c, size_t pos) const noexcept {
+ inline size_t find_first_of(TCharType c, size_t pos) const noexcept {
return find(c, pos);
}
@@ -508,11 +508,11 @@ public:
return AsStringView().find_first_of(set.data(), pos, set.size());
}
- inline size_t find_first_not_of(TCharType c) const noexcept {
+ inline size_t find_first_not_of(TCharType c) const noexcept {
return find_first_not_of(c, 0);
}
- inline size_t find_first_not_of(TCharType c, size_t pos) const noexcept {
+ inline size_t find_first_not_of(TCharType c, size_t pos) const noexcept {
return find_first_not_of(TStringView(&c, 1), pos);
}
@@ -524,7 +524,7 @@ public:
return AsStringView().find_first_not_of(set.data(), pos, set.size());
}
- inline size_t find_last_of(TCharType c, size_t pos = npos) const noexcept {
+ inline size_t find_last_of(TCharType c, size_t pos = npos) const noexcept {
return find_last_of(&c, pos, 1);
}
@@ -532,7 +532,7 @@ public:
return find_last_of(set.data(), pos, set.length());
}
- inline size_t find_last_of(const TCharType* set, size_t pos, size_t n) const noexcept {
+ inline size_t find_last_of(const TCharType* set, size_t pos, size_t n) const noexcept {
return AsStringView().find_last_of(set, pos, n);
}
@@ -560,7 +560,7 @@ public:
return CopyImpl(pc, n, 0);
}
- inline size_t strcpy(TCharType* pc, size_t n) const noexcept {
+ inline size_t strcpy(TCharType* pc, size_t n) const noexcept {
if (n) {
n = copy(pc, n - 1);
pc[n] = 0;
@@ -585,19 +585,19 @@ private:
return static_cast<TStringViewWithTraits>(*this);
}
- constexpr inline const TCharType* Ptr() const noexcept {
+ constexpr inline const TCharType* Ptr() const noexcept {
return This()->data();
}
- constexpr inline size_t Len() const noexcept {
+ constexpr inline size_t Len() const noexcept {
return This()->length();
}
- constexpr inline const TDerived* This() const noexcept {
+ constexpr inline const TDerived* This() const noexcept {
return static_cast<const TDerived*>(this);
}
- inline size_t CopyImpl(TCharType* pc, size_t n, size_t pos) const noexcept {
+ inline size_t CopyImpl(TCharType* pc, size_t n, size_t pos) const noexcept {
const size_t toCopy = Min(Len() - pos, n);
TTraits::copy(pc, Ptr() + pos, toCopy);
diff --git a/util/generic/strbuf.h b/util/generic/strbuf.h
index 4ec008e267..70b9360d58 100644
--- a/util/generic/strbuf.h
+++ b/util/generic/strbuf.h
@@ -167,7 +167,7 @@ public:
*this = TdSelf();
}
- constexpr bool IsInited() const noexcept {
+ constexpr bool IsInited() const noexcept {
return data() != nullptr;
}
@@ -213,7 +213,7 @@ public:
* @param[out] r The second part of split result.
* @returns Whether the split was actually performed.
*/
- inline bool TrySplit(TdSelf delim, TdSelf& l, TdSelf& r) const noexcept {
+ inline bool TrySplit(TdSelf delim, TdSelf& l, TdSelf& r) const noexcept {
return TrySplitOn(TBase::find(delim), l, r, delim.size());
}
@@ -228,7 +228,7 @@ public:
* @param[out] r The second part of split result.
* @returns Whether the split was actually performed.
*/
- inline bool TryRSplit(TdSelf delim, TdSelf& l, TdSelf& r) const noexcept {
+ inline bool TryRSplit(TdSelf delim, TdSelf& l, TdSelf& r) const noexcept {
return TrySplitOn(TBase::rfind(delim), l, r, delim.size());
}
@@ -240,17 +240,17 @@ public:
RSplitTemplate(delim, l, r);
}
- inline void Split(TdSelf delim, TdSelf& l, TdSelf& r) const noexcept {
+ inline void Split(TdSelf delim, TdSelf& l, TdSelf& r) const noexcept {
SplitTemplate(delim, l, r);
}
- inline void RSplit(TdSelf delim, TdSelf& l, TdSelf& r) const noexcept {
+ inline void RSplit(TdSelf delim, TdSelf& l, TdSelf& r) const noexcept {
RSplitTemplate(delim, l, r);
}
private:
// splits on a delimiter at a given position; delimiter is excluded
- void DoSplitOn(size_t pos, TdSelf& l, TdSelf& r, size_t len) const noexcept {
+ void DoSplitOn(size_t pos, TdSelf& l, TdSelf& r, size_t len) const noexcept {
Y_ASSERT(pos != TBase::npos);
// make a copy in case one of l/r is really *this
@@ -267,7 +267,7 @@ public:
// For example, for TStringBuf s("abc"):
// s.TrySplitOn(s.find('z'), ...) is false, but s.TrySplitOn(100500, ...) is true.
- bool TrySplitOn(size_t pos, TdSelf& l, TdSelf& r, size_t len = 1) const noexcept {
+ bool TrySplitOn(size_t pos, TdSelf& l, TdSelf& r, size_t len = 1) const noexcept {
if (TBase::npos == pos)
return false;
@@ -275,25 +275,25 @@ public:
return true;
}
- void SplitOn(size_t pos, TdSelf& l, TdSelf& r, size_t len = 1) const noexcept {
+ void SplitOn(size_t pos, TdSelf& l, TdSelf& r, size_t len = 1) const noexcept {
if (!TrySplitOn(pos, l, r, len)) {
l = *this;
r = TdSelf();
}
}
- bool TrySplitAt(size_t pos, TdSelf& l, TdSelf& r) const noexcept {
+ bool TrySplitAt(size_t pos, TdSelf& l, TdSelf& r) const noexcept {
return TrySplitOn(pos, l, r, 0);
}
- void SplitAt(size_t pos, TdSelf& l, TdSelf& r) const noexcept {
+ void SplitAt(size_t pos, TdSelf& l, TdSelf& r) const noexcept {
SplitOn(pos, l, r, 0);
}
/*
// Not implemented intentionally, use TrySplitOn() instead
- void RSplitOn(size_t pos, TdSelf& l, TdSelf& r) const noexcept;
- void RSplitAt(size_t pos, TdSelf& l, TdSelf& r) const noexcept;
+ void RSplitOn(size_t pos, TdSelf& l, TdSelf& r) const noexcept;
+ void RSplitAt(size_t pos, TdSelf& l, TdSelf& r) const noexcept;
*/
public:
@@ -318,7 +318,7 @@ public:
}
public:
- inline bool AfterPrefix(const TdSelf& prefix, TdSelf& result) const noexcept {
+ inline bool AfterPrefix(const TdSelf& prefix, TdSelf& result) const noexcept {
if (this->StartsWith(prefix)) {
result = Tail(prefix.size());
return true;
@@ -326,7 +326,7 @@ public:
return false;
}
- inline bool BeforeSuffix(const TdSelf& suffix, TdSelf& result) const noexcept {
+ inline bool BeforeSuffix(const TdSelf& suffix, TdSelf& result) const noexcept {
if (this->EndsWith(suffix)) {
result = Head(size() - suffix.size());
return true;
@@ -335,12 +335,12 @@ public:
}
// returns true if string started with `prefix`, false otherwise
- inline bool SkipPrefix(const TdSelf& prefix) noexcept {
+ inline bool SkipPrefix(const TdSelf& prefix) noexcept {
return AfterPrefix(prefix, *this);
}
// returns true if string ended with `suffix`, false otherwise
- inline bool ChopSuffix(const TdSelf& suffix) noexcept {
+ inline bool ChopSuffix(const TdSelf& suffix) noexcept {
return BeforeSuffix(suffix, *this);
}
@@ -435,13 +435,13 @@ public:
public: // string subsequences
/// Cut last @c shift characters (or less if length is less than @c shift)
- inline TdSelf& Chop(size_t shift) noexcept {
+ inline TdSelf& Chop(size_t shift) noexcept {
this->remove_suffix(std::min(shift, size()));
return *this;
}
/// Cut first @c shift characters (or less if length is less than @c shift)
- inline TdSelf& Skip(size_t shift) noexcept {
+ inline TdSelf& Skip(size_t shift) noexcept {
this->remove_prefix(std::min(shift, size()));
return *this;
}
@@ -520,7 +520,7 @@ private:
}
template <typename TDelimiterType>
- inline void SplitTemplate(TDelimiterType delim, TdSelf& l, TdSelf& r) const noexcept {
+ inline void SplitTemplate(TDelimiterType delim, TdSelf& l, TdSelf& r) const noexcept {
if (!TrySplit(delim, l, r)) {
l = *this;
r = TdSelf();
@@ -528,7 +528,7 @@ private:
}
template <typename TDelimiterType>
- inline void RSplitTemplate(TDelimiterType delim, TdSelf& l, TdSelf& r) const noexcept {
+ inline void RSplitTemplate(TDelimiterType delim, TdSelf& l, TdSelf& r) const noexcept {
if (!TryRSplit(delim, l, r)) {
r = *this;
l = TdSelf();
diff --git a/util/generic/strbuf_ut.cpp b/util/generic/strbuf_ut.cpp
index 4bec3f1ab0..69cde785af 100644
--- a/util/generic/strbuf_ut.cpp
+++ b/util/generic/strbuf_ut.cpp
@@ -150,7 +150,7 @@ Y_UNIT_TEST_SUITE(TStrBufTest) {
str = qw;
UNIT_ASSERT_EQUAL(str.SubStr(2), TStringBuf("erty"));
- UNIT_ASSERT_EQUAL(str.Skip(3), qw.SubStr(3));
+ UNIT_ASSERT_EQUAL(str.Skip(3), qw.SubStr(3));
str.Chop(1);
UNIT_ASSERT_EQUAL(str, TStringBuf("rt"));
}
diff --git a/util/generic/string.cpp b/util/generic/string.cpp
index 0c949f814e..3c655f1f66 100644
--- a/util/generic/string.cpp
+++ b/util/generic/string.cpp
@@ -1,4 +1,4 @@
-#include "string.h"
+#include "string.h"
#include <util/string/ascii.h>
#include <util/system/sanitizers.h>
diff --git a/util/generic/string.h b/util/generic/string.h
index 89fd6cd2fa..8cd8aa6917 100644
--- a/util/generic/string.h
+++ b/util/generic/string.h
@@ -20,10 +20,10 @@
#include "strbuf.h"
#include "string_hash.h"
-#if defined(address_sanitizer_enabled) || defined(thread_sanitizer_enabled)
+#if defined(address_sanitizer_enabled) || defined(thread_sanitizer_enabled)
#include "hide_ptr.h"
-#endif
-
+#endif
+
template <class TCharType, class TCharTraits, class TAllocator>
void ResizeUninitialized(std::basic_string<TCharType, TCharTraits, TAllocator>& s, size_t len) {
#if defined(_YNDX_LIBCXX_ENABLE_STRING_RESIZE_UNINITIALIZED)
@@ -103,12 +103,12 @@ private:
}
};
-template <class TStringType>
+template <class TStringType>
class TBasicCharRef {
public:
- using TChar = typename TStringType::TChar;
+ using TChar = typename TStringType::TChar;
- TBasicCharRef(TStringType& s, size_t pos)
+ TBasicCharRef(TStringType& s, size_t pos)
: S_(s)
, Pos_(pos)
{
@@ -150,7 +150,7 @@ public:
TBasicCharRef(const TBasicCharRef&) = default;
private:
- TStringType& S_;
+ TStringType& S_;
size_t Pos_;
};
#endif
@@ -294,11 +294,11 @@ public:
#endif
}
- inline size_t length() const noexcept {
+ inline size_t length() const noexcept {
return ConstRef().length();
}
- inline const TCharType* data() const noexcept {
+ inline const TCharType* data() const noexcept {
return ConstRef().data();
}
@@ -541,7 +541,7 @@ private:
return 1 + SumLength(r...);
}
- static constexpr size_t SumLength() noexcept {
+ static constexpr size_t SumLength() noexcept {
return 0;
}
@@ -557,11 +557,11 @@ private:
CopyAll(p + 1, r...);
}
- static void CopyAll(TCharType*) noexcept {
+ static void CopyAll(TCharType*) noexcept {
}
public:
- inline void clear() noexcept {
+ inline void clear() noexcept {
#ifdef TSTRING_IS_STD_STRING
Storage_.clear();
#else
@@ -623,7 +623,7 @@ public:
}
TBasicString& assign(const TCharType* first, const TCharType* last) {
- return assign(first, last - first);
+ return assign(first, last - first);
}
TBasicString& assign(const TCharType* pc, size_t pos, size_t n) {
diff --git a/util/generic/string.pxd b/util/generic/string.pxd
index 1b3850c0b2..c25f7392a1 100644
--- a/util/generic/string.pxd
+++ b/util/generic/string.pxd
@@ -12,22 +12,22 @@ cdef extern from "<util/generic/strbuf.h>" nogil:
size_t Size()
-cdef extern from "<util/generic/string.h>" nogil:
+cdef extern from "<util/generic/string.h>" nogil:
- size_t npos "TString::npos"
+ size_t npos "TString::npos"
# Inheritance is bogus, but it's safe to assume TString is-a TStringBuf via implicit cast
cdef cppclass TString(TStringBuf):
- TString() except +
- TString(TString&) except +
- TString(_std_string&) except +
- TString(TString&, size_t, size_t) except +
- TString(char*) except +
- TString(char*, size_t) except +
- TString(char*, size_t, size_t) except +
- # as a TString formed by a repetition of character c, n times.
- TString(size_t, char) except +
- TString(char*, char*) except +
+ TString() except +
+ TString(TString&) except +
+ TString(_std_string&) except +
+ TString(TString&, size_t, size_t) except +
+ TString(char*) except +
+ TString(char*, size_t) except +
+ TString(char*, size_t, size_t) except +
+ # as a TString formed by a repetition of character c, n times.
+ TString(size_t, char) except +
+ TString(char*, char*) except +
TString(TStringBuf&) except +
TString(TStringBuf&, TStringBuf&) except +
TString(TStringBuf&, TStringBuf&, TStringBuf&) except +
@@ -48,22 +48,22 @@ cdef extern from "<util/generic/string.h>" nogil:
TString& append(TStringBuf&) except +
TString& append(TStringBuf&, size_t, size_t) except +
- TString& append(char *) except +
- TString& append(char *, size_t) except +
- TString& append(size_t, char) except +
+ TString& append(char *) except +
+ TString& append(char *, size_t) except +
+ TString& append(size_t, char) except +
void push_back(char c) except +
TString& assign(TStringBuf&) except +
TString& assign(TStringBuf&, size_t, size_t) except +
- TString& assign(char *) except +
- TString& assign(char *, size_t) except +
+ TString& assign(char *) except +
+ TString& assign(char *, size_t) except +
- TString& insert(size_t, TString&) except +
- TString& insert(size_t, TString&, size_t, size_t) except +
- TString& insert(size_t, char* s) except +
- TString& insert(size_t, char* s, size_t) except +
- TString& insert(size_t, size_t, char c) except +
+ TString& insert(size_t, TString&) except +
+ TString& insert(size_t, TString&, size_t, size_t) except +
+ TString& insert(size_t, char* s) except +
+ TString& insert(size_t, char* s, size_t) except +
+ TString& insert(size_t, size_t, char c) except +
size_t copy(char *, size_t) except +
size_t copy(char *, size_t, size_t) except +
@@ -93,11 +93,11 @@ cdef extern from "<util/generic/string.h>" nogil:
size_t find_last_of(TStringBuf& set)
size_t find_last_of(TStringBuf& set, size_t pos)
- TString substr(size_t pos) except +
- TString substr(size_t pos, size_t n) except +
+ TString substr(size_t pos) except +
+ TString substr(size_t pos, size_t n) except +
TString operator+(TStringBuf& rhs) except +
- TString operator+(char* rhs) except +
+ TString operator+(char* rhs) except +
bint operator==(TStringBuf&)
bint operator==(char*)
diff --git a/util/generic/string_transparent_hash_ut.cpp b/util/generic/string_transparent_hash_ut.cpp
index 99aaeb55c4..b87fa2843e 100644
--- a/util/generic/string_transparent_hash_ut.cpp
+++ b/util/generic/string_transparent_hash_ut.cpp
@@ -1,4 +1,4 @@
-#include "string.h"
+#include "string.h"
#include "vector.h"
#include "strbuf.h"
diff --git a/util/generic/string_ut.cpp b/util/generic/string_ut.cpp
index e1ca6d358e..ac82e9091d 100644
--- a/util/generic/string_ut.cpp
+++ b/util/generic/string_ut.cpp
@@ -17,7 +17,7 @@
#ifdef TSTRING_IS_STD_STRING
static_assert(sizeof(TString) == sizeof(std::string), "expect sizeof(TString) == sizeof(std::string)");
#else
-static_assert(sizeof(TString) == sizeof(const char*), "expect sizeof(TString) == sizeof(const char*)");
+static_assert(sizeof(TString) == sizeof(const char*), "expect sizeof(TString) == sizeof(const char*)");
#endif
class TStringTestZero: public TTestBase {
@@ -28,7 +28,7 @@ class TStringTestZero: public TTestBase {
public:
void TestZero() {
const char data[] = "abc\0def\0";
- TString s(data, sizeof(data));
+ TString s(data, sizeof(data));
UNIT_ASSERT(s.size() == sizeof(data));
UNIT_ASSERT(s.StartsWith(s));
UNIT_ASSERT(s.EndsWith(s));
@@ -36,8 +36,8 @@ public:
const char raw_def[] = "def";
const char raw_zero[] = "\0";
- TString def(raw_def, sizeof(raw_def) - 1);
- TString zero(raw_zero, sizeof(raw_zero) - 1);
+ TString def(raw_def, sizeof(raw_def) - 1);
+ TString zero(raw_zero, sizeof(raw_zero) - 1);
UNIT_ASSERT_EQUAL(4, s.find(raw_def));
UNIT_ASSERT_EQUAL(4, s.find(def));
UNIT_ASSERT_EQUAL(4, s.find_first_of(raw_def));
@@ -45,15 +45,15 @@ public:
UNIT_ASSERT_EQUAL(7, s.find_first_not_of(def, 4));
const char nonSubstring[] = "def\0ghi";
- UNIT_ASSERT_EQUAL(TString::npos, s.find(TString(nonSubstring, sizeof(nonSubstring))));
+ UNIT_ASSERT_EQUAL(TString::npos, s.find(TString(nonSubstring, sizeof(nonSubstring))));
- TString copy = s;
+ TString copy = s;
copy.replace(copy.size() - 1, 1, "z");
UNIT_ASSERT(s != copy);
copy.replace(copy.size() - 1, 1, "\0", 0, 1);
UNIT_ASSERT(s == copy);
- TString prefix(data, 5);
+ TString prefix(data, 5);
UNIT_ASSERT(s.StartsWith(prefix));
UNIT_ASSERT(s != prefix);
UNIT_ASSERT(s > prefix);
@@ -68,7 +68,7 @@ public:
UNIT_TEST_SUITE_REGISTRATION(TStringTestZero);
-template <typename TStringType, typename TTestData>
+template <typename TStringType, typename TTestData>
class TStringStdTestImpl {
using TChar = typename TStringType::char_type;
using TTraits = typename TStringType::traits_type;
@@ -92,7 +92,7 @@ protected:
void reserve() {
#if 0
- TStringType s;
+ TStringType s;
// @todo use UNIT_TEST_EXCEPTION
try {
s.reserve(s.max_size() + 1);
@@ -129,7 +129,7 @@ protected:
#ifndef TSTRING_IS_STD_STRING
// Shared behaviour - always reallocate, just as much as requisted
- TStringType holder = s;
+ TStringType holder = s;
UNIT_ASSERT(s.capacity() >= 256);
@@ -152,22 +152,22 @@ protected:
void short_string() {
TStringType const ref_short_str1(Data_.str1()), ref_short_str2(Data_.str2());
- TStringType short_str1(ref_short_str1), short_str2(ref_short_str2);
+ TStringType short_str1(ref_short_str1), short_str2(ref_short_str2);
TStringType const ref_long_str1(Data_.str__________________________________________________1());
TStringType const ref_long_str2(Data_.str__________________________________________________2());
- TStringType long_str1(ref_long_str1), long_str2(ref_long_str2);
+ TStringType long_str1(ref_long_str1), long_str2(ref_long_str2);
UNIT_ASSERT(short_str1 == ref_short_str1);
UNIT_ASSERT(long_str1 == ref_long_str1);
{
- TStringType str1(short_str1);
+ TStringType str1(short_str1);
str1 = long_str1;
UNIT_ASSERT(str1 == ref_long_str1);
}
{
- TStringType str1(long_str1);
+ TStringType str1(long_str1);
str1 = short_str1;
UNIT_ASSERT(str1 == ref_short_str1);
}
@@ -198,7 +198,7 @@ protected:
{
//This is to test move constructor
- TVector<TStringType> str_vect;
+ TVector<TStringType> str_vect;
str_vect.push_back(short_str1);
str_vect.push_back(long_str1);
@@ -214,7 +214,7 @@ protected:
void erase() {
TChar const* c_str = Data_.Hello_World();
- TStringType str(c_str);
+ TStringType str(c_str);
UNIT_ASSERT(str == c_str);
str.erase(str.begin() + 1, str.end() - 1); // Erase all but first and last.
@@ -266,7 +266,7 @@ protected:
}
void data() {
- TStringType xx;
+ TStringType xx;
// ISO-IEC-14882:1998(E), 21.3.6, paragraph 3
UNIT_ASSERT(xx.data() != nullptr);
@@ -274,8 +274,8 @@ protected:
void c_str() {
TStringType low(Data_._2004_01_01());
- TStringType xx;
- TStringType yy;
+ TStringType xx;
+ TStringType yy;
// ISO-IEC-14882:1998(E), 21.3.6, paragraph 1
UNIT_ASSERT(*(yy.c_str()) == 0);
@@ -357,10 +357,10 @@ protected:
void insert() {
TStringType strorg = Data_.This_is_test_string_for_string_calls();
- TStringType str;
+ TStringType str;
// In case of reallocation there is no auto reference problem
- // so we reserve a big enough TStringType to be sure to test this
+ // so we reserve a big enough TStringType to be sure to test this
// particular point.
str.reserve(100);
@@ -383,9 +383,9 @@ protected:
UNIT_ASSERT(str == Data_.ng_for_string_callsThis_is_test_string_for_string_calls());
str = strorg;
- typename TStringType::iterator b = str.begin();
- typename TStringType::const_iterator s = str.begin() + str.size() / 2 - 1;
- typename TStringType::const_iterator e = str.end();
+ typename TStringType::iterator b = str.begin();
+ typename TStringType::const_iterator s = str.begin() + str.size() / 2 - 1;
+ typename TStringType::const_iterator e = str.end();
str.insert(b, s, e);
UNIT_ASSERT(str == Data_.ng_for_string_callsThis_is_test_string_for_string_calls());
@@ -396,13 +396,13 @@ protected:
UNIT_ASSERT(str == Data.ng_for_string_callsThis_is_test_string_for_string_calls());
#endif
- TStringType str0;
+ TStringType str0;
str0.insert(str0.begin(), 5, *Data_._0());
UNIT_ASSERT(str0 == Data_._00000());
- TStringType str1;
+ TStringType str1;
{
- typename TStringType::size_type pos = 0, nb = 2;
+ typename TStringType::size_type pos = 0, nb = 2;
str1.insert(pos, nb, *Data_._1());
}
UNIT_ASSERT(str1 == Data_._11());
@@ -428,7 +428,7 @@ protected:
}
void resize() {
- TStringType s;
+ TStringType s;
s.resize(0);
@@ -472,7 +472,7 @@ protected:
}
void capacity() {
- TStringType s;
+ TStringType s;
UNIT_ASSERT(s.capacity() < s.max_size());
UNIT_ASSERT(s.capacity() >= s.size());
@@ -487,7 +487,7 @@ protected:
}
void assign() {
- TStringType s;
+ TStringType s;
TChar const* cstr = Data_.test_string_for_assign();
s.assign(cstr, cstr + 22);
@@ -497,12 +497,12 @@ protected:
s.assign(s2);
UNIT_ASSERT(s == s2);
- static TStringType str1;
- static TStringType str2;
+ static TStringType str1;
+ static TStringType str2;
- // short TStringType optim:
+ // short TStringType optim:
str1 = Data_._123456();
- // longer than short TStringType:
+ // longer than short TStringType:
str2 = Data_._1234567890123456789012345678901234567890();
UNIT_ASSERT(str1[5] == *Data_._6());
@@ -539,7 +539,7 @@ protected:
void cbegin_cend() {
const char helloThere[] = "Hello there";
- TString s = helloThere;
+ TString s = helloThere;
size_t index = 0;
for (auto it = s.cbegin(); s.cend() != it; ++it, ++index) {
UNIT_ASSERT_VALUES_EQUAL(helloThere[index], *it);
@@ -548,7 +548,7 @@ protected:
void compare() {
TStringType str1(Data_.abcdef());
- TStringType str2;
+ TStringType str2;
str2 = Data_.abcdef();
UNIT_ASSERT(str1.compare(str2) == 0);
@@ -601,14 +601,14 @@ protected:
#if 0
void rfind() {
// 21.3.6.2
- TStringType s(Data.one_two_three_one_two_three());
+ TStringType s(Data.one_two_three_one_two_three());
UNIT_ASSERT(s.rfind(Data.two()) == 18);
- UNIT_ASSERT(s.rfind(Data.two(), 0) == TStringType::npos);
+ UNIT_ASSERT(s.rfind(Data.two(), 0) == TStringType::npos);
UNIT_ASSERT(s.rfind(Data.two(), 11) == 4);
UNIT_ASSERT(s.rfind(*Data.w()) == 19);
- TStringType test(Data.aba());
+ TStringType test(Data.aba());
UNIT_ASSERT(test.rfind(Data.a(), 2, 1) == 2);
UNIT_ASSERT(test.rfind(Data.a(), 1, 1) == 0);
@@ -643,15 +643,15 @@ protected:
}
#if 0
void replace() {
- // This test case is for the non template basic_TString::replace method,
+ // This test case is for the non template basic_TString::replace method,
// this is why we play with the const iterators and reference to guaranty
// that the right method is called.
- const TStringType v(Data._78());
- TStringType s(Data._123456());
- TStringType const& cs = s;
+ const TStringType v(Data._78());
+ TStringType s(Data._123456());
+ TStringType const& cs = s;
- typename TStringType::iterator i = s.begin() + 1;
+ typename TStringType::iterator i = s.begin() + 1;
s.replace(i, i + 3, v.begin(), v.end());
UNIT_ASSERT(s == Data._17856());
@@ -662,7 +662,7 @@ protected:
s = Data._123456();
i = s.begin() + 1;
- typename TStringType::const_iterator ci = s.begin() + 1;
+ typename TStringType::const_iterator ci = s.begin() + 1;
s.replace(i, i + 3, ci + 3, cs.end());
UNIT_ASSERT(s == Data._15656());
@@ -691,10 +691,10 @@ protected:
// This is the test for the template replace method.
s = Data._123456();
- typename TStringType::iterator b = s.begin() + 4;
- typename TStringType::iterator e = s.end();
- typename TStringType::const_iterator rb = s.begin();
- typename TStringType::const_iterator re = s.end();
+ typename TStringType::iterator b = s.begin() + 4;
+ typename TStringType::iterator e = s.end();
+ typename TStringType::const_iterator rb = s.begin();
+ typename TStringType::const_iterator re = s.end();
s.replace(b, e, rb, re);
UNIT_ASSERT(s == Data._1234123456());
@@ -702,8 +702,8 @@ protected:
s.replace(s.begin() + 4, s.end(), s.begin(), s.end());
UNIT_ASSERT(s == Data._1234123456());
- TStringType strorg(Data.This_is_test_StringT_for_StringT_calls());
- TStringType str = strorg;
+ TStringType strorg(Data.This_is_test_StringT_for_StringT_calls());
+ TStringType str = strorg;
str.replace(5, 15, str.c_str(), 10);
UNIT_ASSERT(str == Data.This_This_is_tefor_StringT_calls());
@@ -721,7 +721,7 @@ protected:
#endif
}; // TStringStdTestImpl
-class TStringTest: public TTestBase, private TStringTestImpl<TString, TTestData<char>> {
+class TStringTest: public TTestBase, private TStringTestImpl<TString, TTestData<char>> {
public:
UNIT_TEST_SUITE(TStringTest);
UNIT_TEST(TestMaxSize);
@@ -783,7 +783,7 @@ public:
UNIT_TEST_SUITE_REGISTRATION(TStringTest);
-class TWideStringTest: public TTestBase, private TStringTestImpl<TUtf16String, TTestData<wchar16>> {
+class TWideStringTest: public TTestBase, private TStringTestImpl<TUtf16String, TTestData<wchar16>> {
public:
UNIT_TEST_SUITE(TWideStringTest);
UNIT_TEST(TestConstructors);
@@ -816,21 +816,21 @@ public:
private:
void TestDecodingMethods() {
- UNIT_ASSERT(TUtf16String::FromAscii("").empty());
- UNIT_ASSERT(TUtf16String::FromAscii("abc") == ASCIIToWide("abc"));
+ UNIT_ASSERT(TUtf16String::FromAscii("").empty());
+ UNIT_ASSERT(TUtf16String::FromAscii("abc") == ASCIIToWide("abc"));
const char* text = "123kx83abcd ej)#$%ddja&%J&";
- TUtf16String wtext = ASCIIToWide(text);
+ TUtf16String wtext = ASCIIToWide(text);
- UNIT_ASSERT(wtext == TUtf16String::FromAscii(text));
+ UNIT_ASSERT(wtext == TUtf16String::FromAscii(text));
- TString strtext(text);
- UNIT_ASSERT(wtext == TUtf16String::FromAscii(strtext));
+ TString strtext(text);
+ UNIT_ASSERT(wtext == TUtf16String::FromAscii(strtext));
TStringBuf strbuftext(text);
- UNIT_ASSERT(wtext == TUtf16String::FromAscii(strbuftext));
+ UNIT_ASSERT(wtext == TUtf16String::FromAscii(strbuftext));
- UNIT_ASSERT(wtext.substr(5) == TUtf16String::FromAscii(text + 5));
+ UNIT_ASSERT(wtext.substr(5) == TUtf16String::FromAscii(text + 5));
const wchar16 wideCyrillicAlphabet[] = {
0x0410, 0x0411, 0x0412, 0x0413, 0x0414, 0x0415, 0x0416, 0x0417, 0x0418, 0x0419, 0x041A, 0x041B, 0x041C, 0x041D, 0x041E, 0x041F,
@@ -839,16 +839,16 @@ private:
0x0440, 0x0441, 0x0442, 0x0443, 0x0444, 0x0445, 0x0446, 0x0447, 0x0448, 0x0449, 0x044A, 0x044B, 0x044C, 0x044D, 0x044E, 0x044F,
0x00};
- TUtf16String strWide(wideCyrillicAlphabet);
- TString strUtf8 = WideToUTF8(strWide);
+ TUtf16String strWide(wideCyrillicAlphabet);
+ TString strUtf8 = WideToUTF8(strWide);
- UNIT_ASSERT(strWide == TUtf16String::FromUtf8(strUtf8.c_str()));
- UNIT_ASSERT(strWide == TUtf16String::FromUtf8(strUtf8));
- UNIT_ASSERT(strWide == TUtf16String::FromUtf8(TStringBuf(strUtf8)));
+ UNIT_ASSERT(strWide == TUtf16String::FromUtf8(strUtf8.c_str()));
+ UNIT_ASSERT(strWide == TUtf16String::FromUtf8(strUtf8));
+ UNIT_ASSERT(strWide == TUtf16String::FromUtf8(TStringBuf(strUtf8)));
// assign
- TUtf16String s1;
+ TUtf16String s1;
s1.AssignAscii("1234");
UNIT_ASSERT(s1 == ASCIIToWide("1234"));
@@ -860,8 +860,8 @@ private:
// append
- TUtf16String s2;
- TUtf16String testAppend = strWide;
+ TUtf16String s2;
+ TUtf16String testAppend = strWide;
s2.AppendUtf8(strUtf8);
UNIT_ASSERT(testAppend == s2);
@@ -883,12 +883,12 @@ private:
}
void TestLetOperator() {
- TUtf16String str;
+ TUtf16String str;
str = wchar16('X');
- UNIT_ASSERT(str == TUtf16String::FromAscii("X"));
+ UNIT_ASSERT(str == TUtf16String::FromAscii("X"));
- const TUtf16String hello = TUtf16String::FromAscii("hello");
+ const TUtf16String hello = TUtf16String::FromAscii("hello");
str = hello.data();
UNIT_ASSERT(str == hello);
@@ -1105,7 +1105,7 @@ private:
UNIT_TEST_SUITE_REGISTRATION(TUtf32StringTest);
-class TStringStdTest: public TTestBase, private TStringStdTestImpl<TString, TTestData<char>> {
+class TStringStdTest: public TTestBase, private TStringStdTestImpl<TString, TTestData<char>> {
public:
UNIT_TEST_SUITE(TStringStdTest);
UNIT_TEST(Constructor);
@@ -1141,7 +1141,7 @@ public:
UNIT_TEST_SUITE_REGISTRATION(TStringStdTest);
-class TWideStringStdTest: public TTestBase, private TStringStdTestImpl<TUtf16String, TTestData<wchar16>> {
+class TWideStringStdTest: public TTestBase, private TStringStdTestImpl<TUtf16String, TTestData<wchar16>> {
public:
UNIT_TEST_SUITE(TWideStringStdTest);
UNIT_TEST(Constructor);
diff --git a/util/generic/string_ut.h b/util/generic/string_ut.h
index 548b735453..44bb10bdeb 100644
--- a/util/generic/string_ut.h
+++ b/util/generic/string_ut.h
@@ -1,6 +1,6 @@
#pragma once
-#include "string.h"
+#include "string.h"
#include <library/cpp/testing/unittest/registar.h>
@@ -508,11 +508,11 @@ size_t TTestData<wchar16>::HashOf_0123456() {
return 2775195331ul;
}
-template <class TStringType, typename TTestData>
+template <class TStringType, typename TTestData>
class TStringTestImpl {
protected:
- using char_type = typename TStringType::char_type;
- using traits_type = typename TStringType::traits_type;
+ using char_type = typename TStringType::char_type;
+ using traits_type = typename TStringType::traits_type;
TTestData Data;
@@ -525,13 +525,13 @@ public:
}
void TestConstructors() {
- TStringType s0(nullptr);
+ TStringType s0(nullptr);
UNIT_ASSERT(s0.size() == 0);
- UNIT_ASSERT_EQUAL(s0, TStringType());
+ UNIT_ASSERT_EQUAL(s0, TStringType());
- TStringType s;
- TStringType s1(*Data._0());
- TStringType s2(Data._0());
+ TStringType s;
+ TStringType s1(*Data._0());
+ TStringType s2(Data._0());
UNIT_ASSERT(s1 == s2);
TStringType fromZero(0);
@@ -542,37 +542,37 @@ public:
UNIT_ASSERT_VALUES_EQUAL(fromChar[0], char_type('a'));
#ifndef TSTRING_IS_STD_STRING
- TStringType s3 = TStringType::Uninitialized(10);
+ TStringType s3 = TStringType::Uninitialized(10);
UNIT_ASSERT(s3.size() == 10);
#endif
- TStringType s4(Data._0123456(), 1, 3);
+ TStringType s4(Data._0123456(), 1, 3);
UNIT_ASSERT(s4 == Data._123());
- TStringType s5(5, *Data._0());
+ TStringType s5(5, *Data._0());
UNIT_ASSERT(s5 == Data._00000());
- TStringType s6(Data._0123456());
+ TStringType s6(Data._0123456());
UNIT_ASSERT(s6 == Data._0123456());
- TStringType s7(s6);
+ TStringType s7(s6);
UNIT_ASSERT(s7 == s6);
#ifndef TSTRING_IS_STD_STRING
UNIT_ASSERT(s7.c_str() == s6.c_str());
#endif
- TStringType s8(s7, 1, 3);
+ TStringType s8(s7, 1, 3);
UNIT_ASSERT(s8 == Data._123());
- TStringType s9(*Data._1());
+ TStringType s9(*Data._1());
UNIT_ASSERT(s9 == Data._1());
- TStringType s10(Reserve(100));
+ TStringType s10(Reserve(100));
UNIT_ASSERT(s10.empty());
UNIT_ASSERT(s10.capacity() >= 100);
}
void TestReplace() {
- TStringType s(Data._0123456());
+ TStringType s(Data._0123456());
UNIT_ASSERT(s.copy() == Data._0123456());
// append family
@@ -586,10 +586,10 @@ public:
#endif
UNIT_ASSERT(s == Data._0123456xy());
- s.append(TStringType(Data.z()));
+ s.append(TStringType(Data.z()));
UNIT_ASSERT(s == Data._0123456xyz());
- s.append(TStringType(Data.XYZ()), 2, 1);
+ s.append(TStringType(Data.XYZ()), 2, 1);
UNIT_ASSERT(s == Data._0123456xyzZ());
s.append(*Data._0());
@@ -597,10 +597,10 @@ public:
// prepend family
s = Data._0123456xyz();
- s.prepend(TStringType(Data.abc()));
+ s.prepend(TStringType(Data.abc()));
UNIT_ASSERT(s == Data.abc0123456xyz());
- s.prepend(TStringType(Data.ABC()), 1, 2);
+ s.prepend(TStringType(Data.ABC()), 1, 2);
UNIT_ASSERT(s == Data.BCabc0123456xyz());
s.prepend(Data.qwe());
@@ -618,10 +618,10 @@ public:
s.insert(2, Data.abc());
UNIT_ASSERT(s == Data._01abc23456());
- s.insert(2, TStringType(Data.ABC()));
+ s.insert(2, TStringType(Data.ABC()));
UNIT_ASSERT(s == Data._01ABCabc23456());
- s.insert(0, TStringType(Data.QWE()), 1, 1);
+ s.insert(0, TStringType(Data.QWE()), 1, 1);
UNIT_ASSERT(s == Data.W01ABCabc23456());
// replace family
@@ -629,10 +629,10 @@ public:
s.replace(0, 7, Data.abcd());
UNIT_ASSERT(s == Data.abcd456());
- s.replace(4, 3, TStringType(Data.ABCD()));
+ s.replace(4, 3, TStringType(Data.ABCD()));
UNIT_ASSERT(s == Data.abcdABCD());
- s.replace(7, 10, TStringType(Data._01234()), 1, 3);
+ s.replace(7, 10, TStringType(Data._01234()), 1, 3);
UNIT_ASSERT(s == Data.abcdABC123());
UNIT_ASSERT(Data.abcdABC123() == s);
@@ -677,18 +677,18 @@ public:
// Find family
void TestFind() {
- const TStringType s(Data._0123456_12345());
- const TStringType s2(Data._0123());
+ const TStringType s(Data._0123456_12345());
+ const TStringType s2(Data._0123());
UNIT_ASSERT(s.find(Data._345()) == 3);
UNIT_ASSERT(s.find(Data._345(), 5) == 10);
- UNIT_ASSERT(s.find(Data._345(), 20) == TStringType::npos);
+ UNIT_ASSERT(s.find(Data._345(), 20) == TStringType::npos);
UNIT_ASSERT(s.find(*Data._3()) == 3);
- UNIT_ASSERT(s.find(TStringType(Data._345())) == 3);
- UNIT_ASSERT(s.find(TStringType(Data._345()), 2) == 3);
+ UNIT_ASSERT(s.find(TStringType(Data._345())) == 3);
+ UNIT_ASSERT(s.find(TStringType(Data._345()), 2) == 3);
- UNIT_ASSERT(s.find_first_of(TStringType(Data._389())) == 3);
+ UNIT_ASSERT(s.find_first_of(TStringType(Data._389())) == 3);
UNIT_ASSERT(s.find_first_of(Data._389()) == 3);
UNIT_ASSERT(s.find_first_of(Data._389(), s.size()) == TStringType::npos);
UNIT_ASSERT(s.find_first_not_of(Data._123()) == 0);
@@ -697,34 +697,34 @@ public:
UNIT_ASSERT(s.find_first_not_of('0') == 1);
UNIT_ASSERT(s.find_first_not_of('1', 1) == 2);
- const TStringType rs = Data._0123401234();
+ const TStringType rs = Data._0123401234();
UNIT_ASSERT(rs.rfind(*Data._3()) == 8);
- const TStringType empty;
+ const TStringType empty;
UNIT_ASSERT(empty.find(empty) == 0);
UNIT_ASSERT(s.find(empty, 0) == 0);
UNIT_ASSERT(s.find(empty, 1) == 1);
UNIT_ASSERT(s.find(empty, s.length()) == s.length());
- UNIT_ASSERT(s.find(empty, s.length() + 1) == TStringType::npos);
+ UNIT_ASSERT(s.find(empty, s.length() + 1) == TStringType::npos);
UNIT_ASSERT(s.rfind(empty) == s.length());
UNIT_ASSERT(empty.rfind(empty) == 0);
- UNIT_ASSERT(empty.rfind(s) == TStringType::npos);
+ UNIT_ASSERT(empty.rfind(s) == TStringType::npos);
- UNIT_ASSERT(s2.rfind(s) == TStringType::npos);
+ UNIT_ASSERT(s2.rfind(s) == TStringType::npos);
UNIT_ASSERT(s.rfind(s2) == 0);
- UNIT_ASSERT(s.rfind(TStringType(Data._345())) == 10);
- UNIT_ASSERT(s.rfind(TStringType(Data._345()), 13) == 10);
- UNIT_ASSERT(s.rfind(TStringType(Data._345()), 10) == 10);
- UNIT_ASSERT(s.rfind(TStringType(Data._345()), 9) == 3);
- UNIT_ASSERT(s.rfind(TStringType(Data._345()), 6) == 3);
- UNIT_ASSERT(s.rfind(TStringType(Data._345()), 3) == 3);
- UNIT_ASSERT(s.rfind(TStringType(Data._345()), 2) == TStringType::npos);
+ UNIT_ASSERT(s.rfind(TStringType(Data._345())) == 10);
+ UNIT_ASSERT(s.rfind(TStringType(Data._345()), 13) == 10);
+ UNIT_ASSERT(s.rfind(TStringType(Data._345()), 10) == 10);
+ UNIT_ASSERT(s.rfind(TStringType(Data._345()), 9) == 3);
+ UNIT_ASSERT(s.rfind(TStringType(Data._345()), 6) == 3);
+ UNIT_ASSERT(s.rfind(TStringType(Data._345()), 3) == 3);
+ UNIT_ASSERT(s.rfind(TStringType(Data._345()), 2) == TStringType::npos);
}
void TestContains() {
- const TStringType s(Data._0123456_12345());
- const TStringType s2(Data._0123());
+ const TStringType s(Data._0123456_12345());
+ const TStringType s2(Data._0123());
UNIT_ASSERT(s.Contains(Data._345()));
UNIT_ASSERT(!s2.Contains(Data._345()));
@@ -732,7 +732,7 @@ public:
UNIT_ASSERT(s.Contains('1'));
UNIT_ASSERT(!s.Contains('*'));
- TStringType empty;
+ TStringType empty;
UNIT_ASSERT(s.Contains(empty));
UNIT_ASSERT(!empty.Contains(s));
UNIT_ASSERT(empty.Contains(empty));
@@ -742,10 +742,10 @@ public:
// Operators
void TestOperators() {
- TStringType s(Data._0123456());
+ TStringType s(Data._0123456());
// operator +=
- s += TStringType(Data.x());
+ s += TStringType(Data.x());
UNIT_ASSERT(s == Data._0123456x());
s += Data.y();
@@ -756,7 +756,7 @@ public:
// operator +
s = Data._0123456();
- s = s + TStringType(Data.x());
+ s = s + TStringType(Data.x());
UNIT_ASSERT(s == Data._0123456x());
s = s + Data.y();
@@ -767,33 +767,33 @@ public:
// operator !=
s = Data._012345();
- UNIT_ASSERT(s != TStringType(Data.xyz()));
+ UNIT_ASSERT(s != TStringType(Data.xyz()));
UNIT_ASSERT(s != Data.xyz());
UNIT_ASSERT(Data.xyz() != s);
// operator <
- UNIT_ASSERT_EQUAL(s < TStringType(Data.xyz()), true);
+ UNIT_ASSERT_EQUAL(s < TStringType(Data.xyz()), true);
UNIT_ASSERT_EQUAL(s < Data.xyz(), true);
UNIT_ASSERT_EQUAL(Data.xyz() < s, false);
// operator <=
- UNIT_ASSERT_EQUAL(s <= TStringType(Data.xyz()), true);
+ UNIT_ASSERT_EQUAL(s <= TStringType(Data.xyz()), true);
UNIT_ASSERT_EQUAL(s <= Data.xyz(), true);
UNIT_ASSERT_EQUAL(Data.xyz() <= s, false);
// operator >
- UNIT_ASSERT_EQUAL(s > TStringType(Data.xyz()), false);
+ UNIT_ASSERT_EQUAL(s > TStringType(Data.xyz()), false);
UNIT_ASSERT_EQUAL(s > Data.xyz(), false);
UNIT_ASSERT_EQUAL(Data.xyz() > s, true);
// operator >=
- UNIT_ASSERT_EQUAL(s >= TStringType(Data.xyz()), false);
+ UNIT_ASSERT_EQUAL(s >= TStringType(Data.xyz()), false);
UNIT_ASSERT_EQUAL(s >= Data.xyz(), false);
UNIT_ASSERT_EQUAL(Data.xyz() >= s, true);
}
void TestOperatorsCI() {
- TStringType s(Data.ABCD());
+ TStringType s(Data.ABCD());
UNIT_ASSERT(s > Data.abc0123456xyz());
UNIT_ASSERT(s == Data.abcd());
@@ -806,20 +806,20 @@ public:
void TestMulOperators() {
{
- TStringType s(Data._0());
+ TStringType s(Data._0());
s *= 10;
- UNIT_ASSERT_EQUAL(s, TStringType(Data._0000000000()));
+ UNIT_ASSERT_EQUAL(s, TStringType(Data._0000000000()));
}
{
- TStringType s = TStringType(Data._0()) * 2;
- UNIT_ASSERT_EQUAL(s, TStringType(Data._00()));
+ TStringType s = TStringType(Data._0()) * 2;
+ UNIT_ASSERT_EQUAL(s, TStringType(Data._00()));
}
}
// Test any other functions
void TestFuncs() {
- TStringType s(Data._0123456());
+ TStringType s(Data._0123456());
UNIT_ASSERT(s.c_str() == s.data());
// length()
@@ -827,12 +827,12 @@ public:
UNIT_ASSERT(s.length() == traits_type::length(s.data()));
// is_null()
- TStringType s1(Data.Empty());
+ TStringType s1(Data.Empty());
UNIT_ASSERT(s1.is_null() == true);
UNIT_ASSERT(s1.is_null() == s1.empty());
UNIT_ASSERT(s1.is_null() == !s1);
- TStringType s2(s);
+ TStringType s2(s);
UNIT_ASSERT(s2 == s);
// reverse()
@@ -859,7 +859,7 @@ public:
// Friend functions
s2 = Data.asdf1234qwer();
- TStringType s3 = to_upper(s2);
+ TStringType s3 = to_upper(s2);
UNIT_ASSERT(s3 == Data.ASDF1234QWER());
s3 = to_lower(s2);
UNIT_ASSERT(s3 == Data.asdf1234qwer());
@@ -892,7 +892,7 @@ public:
UNIT_ASSERT(s2 == Data._0123456());
// hash()
- TStringType sS = s2; // type 'TStringType' is used as is
+ TStringType sS = s2; // type 'TStringType' is used as is
ComputeHash(sS); /*size_t hash_val = sS.hash();
@@ -908,42 +908,42 @@ public:
//s2.reserve();
- TStringType s5(Data.abcde());
+ TStringType s5(Data.abcde());
s5.clear();
UNIT_ASSERT(s5 == Data.Empty());
}
void TestUtils() {
- TStringType s;
+ TStringType s;
s = Data._01230123();
- TStringType from = Data._0();
- TStringType to = Data.z();
+ TStringType from = Data._0();
+ TStringType to = Data.z();
SubstGlobal(s, from, to);
UNIT_ASSERT(s == Data.z123z123());
}
void TestEmpty() {
- TStringType s;
+ TStringType s;
s = Data._2();
- s = TStringType(Data.fdfdsfds(), (size_t)0, (size_t)0);
+ s = TStringType(Data.fdfdsfds(), (size_t)0, (size_t)0);
UNIT_ASSERT(s.empty());
}
void TestJoin() {
- UNIT_ASSERT_EQUAL(TStringType::Join(Data._12(), Data._3456()), Data._123456());
- UNIT_ASSERT_EQUAL(TStringType::Join(Data._12(), TStringType(Data._3456())), Data._123456());
- UNIT_ASSERT_EQUAL(TStringType::Join(TStringType(Data._12()), Data._3456()), Data._123456());
- UNIT_ASSERT_EQUAL(TStringType::Join(Data._12(), Data._345(), Data._6()), Data._123456());
- UNIT_ASSERT_EQUAL(TStringType::Join(Data._12(), TStringType(Data._345()), Data._6()), Data._123456());
- UNIT_ASSERT_EQUAL(TStringType::Join(TStringType(Data._12()), TStringType(Data._345()), Data._6()), Data._123456());
- UNIT_ASSERT_EQUAL(TStringType::Join(TStringType(Data.a()), Data.b(), TStringType(Data.cd()), TStringType(Data.e()), Data.fg(), TStringType(Data.h())), Data.abcdefgh());
+ UNIT_ASSERT_EQUAL(TStringType::Join(Data._12(), Data._3456()), Data._123456());
+ UNIT_ASSERT_EQUAL(TStringType::Join(Data._12(), TStringType(Data._3456())), Data._123456());
+ UNIT_ASSERT_EQUAL(TStringType::Join(TStringType(Data._12()), Data._3456()), Data._123456());
+ UNIT_ASSERT_EQUAL(TStringType::Join(Data._12(), Data._345(), Data._6()), Data._123456());
+ UNIT_ASSERT_EQUAL(TStringType::Join(Data._12(), TStringType(Data._345()), Data._6()), Data._123456());
+ UNIT_ASSERT_EQUAL(TStringType::Join(TStringType(Data._12()), TStringType(Data._345()), Data._6()), Data._123456());
+ UNIT_ASSERT_EQUAL(TStringType::Join(TStringType(Data.a()), Data.b(), TStringType(Data.cd()), TStringType(Data.e()), Data.fg(), TStringType(Data.h())), Data.abcdefgh());
UNIT_ASSERT_EQUAL(TStringType::Join(TStringType(Data.a()), static_cast<typename TStringType::char_type>('b'), TStringType(Data.cd()), TStringType(Data.e()), Data.fg(), TStringType(Data.h())), Data.abcdefgh());
}
void TestCopy() {
- TStringType s(Data.abcd());
- TStringType c = s.copy();
+ TStringType s(Data.abcd());
+ TStringType c = s.copy();
UNIT_ASSERT_EQUAL(s, c);
UNIT_ASSERT(s.end() != c.end());
@@ -951,7 +951,7 @@ public:
void TestStrCpy() {
{
- TStringType s(Data.abcd());
+ TStringType s(Data.abcd());
char_type data[5];
data[4] = 1;
@@ -966,7 +966,7 @@ public:
}
{
- TStringType s(Data.abcd());
+ TStringType s(Data.abcd());
char_type data[5];
s.strcpy(data, 5);
@@ -980,7 +980,7 @@ public:
}
void TestPrefixSuffix() {
- const TStringType emptyStr;
+ const TStringType emptyStr;
UNIT_ASSERT_EQUAL(emptyStr.StartsWith('x'), false);
UNIT_ASSERT_EQUAL(emptyStr.EndsWith('x'), false);
UNIT_ASSERT_EQUAL(emptyStr.StartsWith(0), false);
@@ -989,7 +989,7 @@ public:
UNIT_ASSERT_EQUAL(emptyStr.EndsWith(emptyStr), true);
const char_type chars[] = {'h', 'e', 'l', 'l', 'o', 0};
- const TStringType str(chars);
+ const TStringType str(chars);
UNIT_ASSERT_EQUAL(str.StartsWith('h'), true);
UNIT_ASSERT_EQUAL(str.StartsWith('o'), false);
UNIT_ASSERT_EQUAL(str.EndsWith('o'), true);
@@ -1004,8 +1004,8 @@ public:
const char_type bbc[] = {'b', 'b', 'c', 0};
const char_type cbc[] = {'c', 'b', 'c', 0};
- TStringType s0 = abc;
- TStringType s1 = s0;
+ TStringType s0 = abc;
+ TStringType s1 = s0;
UNIT_ASSERT(!s0.IsDetached());
UNIT_ASSERT(!s1.IsDetached());
@@ -1017,7 +1017,7 @@ public:
/* Writing should detach. */
s1[0] = (ui8)'b';
- TStringType s2 = s0;
+ TStringType s2 = s0;
s0[0] = (ui8)'c';
UNIT_ASSERT_VALUES_EQUAL(s0, cbc);
@@ -1050,8 +1050,8 @@ public:
void TestBack() {
const char_type chars[] = {'f', 'o', 'o', 0};
- TStringType str = chars;
- const TStringType constStr = str;
+ TStringType str = chars;
+ const TStringType constStr = str;
UNIT_ASSERT_VALUES_EQUAL(constStr.back(), (ui8)'o');
UNIT_ASSERT_VALUES_EQUAL(str.back(), (ui8)'o');
diff --git a/util/generic/string_ut.pyx b/util/generic/string_ut.pyx
index 2149748e33..5407f5b4c1 100644
--- a/util/generic/string_ut.pyx
+++ b/util/generic/string_ut.pyx
@@ -1,7 +1,7 @@
# cython: c_string_type=str, c_string_encoding=utf8
from libcpp.string cimport string as std_string
-from util.generic.string cimport TString, npos
+from util.generic.string cimport TString, npos
import pytest
import unittest
@@ -16,39 +16,39 @@ class TestStroka(unittest.TestCase):
def test_ctor1(self):
- cdef TString tmp = TString()
- cdef TString tmp2 = TString(tmp)
+ cdef TString tmp = TString()
+ cdef TString tmp2 = TString(tmp)
self.assertEquals(tmp2, "")
def test_ctor2(self):
cdef std_string tmp = b"hello"
- cdef TString tmp2 = TString(tmp)
+ cdef TString tmp2 = TString(tmp)
self.assertEquals(tmp2, "hello")
def test_ctor3(self):
cdef TString tmp = b"hello"
- cdef TString tmp2 = TString(tmp, 0, 4)
+ cdef TString tmp2 = TString(tmp, 0, 4)
self.assertEquals(tmp2, "hell")
def test_ctor4(self):
- cdef TString tmp = TString(<char*>b"hello")
+ cdef TString tmp = TString(<char*>b"hello")
self.assertEquals(tmp, "hello")
def test_ctor5(self):
- cdef TString tmp = TString(<char*>b"hello", 4)
+ cdef TString tmp = TString(<char*>b"hello", 4)
self.assertEquals(tmp, "hell")
def test_ctor6(self):
- cdef TString tmp = TString(<char*>b"hello", 1, 3)
+ cdef TString tmp = TString(<char*>b"hello", 1, 3)
self.assertEquals(tmp, "ell")
def test_ctor7(self):
- cdef TString tmp = TString(3, <char>'x')
+ cdef TString tmp = TString(3, <char>'x')
self.assertEquals(tmp, "xxx")
def test_ctor8(self):
cdef bytes tmp = b"hello"
- cdef TString tmp2 = TString(<char*>tmp, <char*>tmp + 4)
+ cdef TString tmp2 = TString(<char*>tmp, <char*>tmp + 4)
self.assertEquals(tmp2, "hell")
def test_compare(self):
@@ -71,7 +71,7 @@ class TestStroka(unittest.TestCase):
def test_operator_assign(self):
cdef TString tmp = b"hello"
- cdef TString tmp2 = tmp
+ cdef TString tmp2 = tmp
self.assertEquals(tmp2, "hello")
def test_operator_plus(self):
@@ -98,12 +98,12 @@ class TestStroka(unittest.TestCase):
self.assertEquals(<bytes>tmp[4], b'o')
self.assertEquals(<bytes>tmp.at(4), b'o')
- # Actually, TString::at() is noexcept
+ # Actually, TString::at() is noexcept
# with pytest.raises(IndexError):
# tmp.at(100)
def test_append(self):
- cdef TString tmp
+ cdef TString tmp
cdef TString tmp2 = b"fuu"
tmp.append(tmp2)
@@ -125,7 +125,7 @@ class TestStroka(unittest.TestCase):
self.assertEquals(tmp, "fuuuull of gooz")
def test_assign(self):
- cdef TString tmp
+ cdef TString tmp
tmp.assign(b"one")
self.assertEquals(tmp, "one")
@@ -140,7 +140,7 @@ class TestStroka(unittest.TestCase):
self.assertEquals(tmp, "three")
def test_insert(self):
- cdef TString tmp
+ cdef TString tmp
tmp = b"xx"
tmp.insert(1, b"foo")
diff --git a/util/generic/typelist_ut.cpp b/util/generic/typelist_ut.cpp
index 18fad0efbf..eeabfa97b1 100644
--- a/util/generic/typelist_ut.cpp
+++ b/util/generic/typelist_ut.cpp
@@ -16,24 +16,24 @@ class TTypeListTest: public TTestBase {
public:
void TestGet() {
- using TListType = TTypeList<int, char, float>;
+ using TListType = TTypeList<int, char, float>;
- UNIT_ASSERT_TYPES_EQUAL(TListType::TGet<0>, int);
- UNIT_ASSERT_TYPES_EQUAL(TListType::TGet<1>, char);
- UNIT_ASSERT_TYPES_EQUAL(TListType::TGet<2>, float);
+ UNIT_ASSERT_TYPES_EQUAL(TListType::TGet<0>, int);
+ UNIT_ASSERT_TYPES_EQUAL(TListType::TGet<1>, char);
+ UNIT_ASSERT_TYPES_EQUAL(TListType::TGet<2>, float);
}
void TestSimple() {
- using TListType = TTypeList<int, char, float>;
- UNIT_ASSERT_EQUAL(TListType::Length, 3);
- UNIT_ASSERT_TYPES_EQUAL(TListType::THead, int);
+ using TListType = TTypeList<int, char, float>;
+ UNIT_ASSERT_EQUAL(TListType::Length, 3);
+ UNIT_ASSERT_TYPES_EQUAL(TListType::THead, int);
}
struct TA {};
struct TB {};
struct TC {};
void TestHave() {
- using TListType = TTypeList<TA, TB*, const TC&>;
+ using TListType = TTypeList<TA, TB*, const TC&>;
UNIT_ASSERT(TListType::THave<TA>::value);
UNIT_ASSERT(TListType::THave<TB*>::value);
UNIT_ASSERT(!TListType::THave<TB>::value);
@@ -66,7 +66,7 @@ public:
struct TMyMap {};
void TestSelectBy() {
- using TListType = TTypeList<TA, TB, TMyMap<TA*, TB>, TMyVector<TA>, TC>;
+ using TListType = TTypeList<TA, TB, TMyMap<TA*, TB>, TMyVector<TA>, TC>;
UNIT_ASSERT_TYPES_EQUAL(TListType::TSelectBy<TAnyType>::type, TA);
UNIT_ASSERT_TYPES_EQUAL(TListType::TSelectBy<TIs1ArgTemplate>::type, TMyVector<TA>);
diff --git a/util/generic/typetraits.h b/util/generic/typetraits.h
index fc46648080..d165bd1a06 100644
--- a/util/generic/typetraits.h
+++ b/util/generic/typetraits.h
@@ -90,11 +90,11 @@ public:
TPodTraits<std::remove_cv_t<std::remove_all_extents_t<T>>>::IsPod);
};
-namespace NPrivate {
- template <class T>
+namespace NPrivate {
+ template <class T>
struct TIsSmall: std::integral_constant<bool, (sizeof(T) <= sizeof(void*))> {};
-}
-
+}
+
template <class T>
class TTypeTraits: public TTypeTraitsBase<T> {
using TBase = TTypeTraitsBase<T>;
@@ -102,10 +102,10 @@ class TTypeTraits: public TTypeTraitsBase<T> {
/*
* can be effectively passed to function as value
*/
- static constexpr bool IsValueType = std::is_scalar<T>::value ||
- std::is_array<T>::value ||
- std::is_reference<T>::value ||
- (TBase::IsPod &&
+ static constexpr bool IsValueType = std::is_scalar<T>::value ||
+ std::is_array<T>::value ||
+ std::is_reference<T>::value ||
+ (TBase::IsPod &&
std::conditional_t<
std::is_function<T>::value,
std::false_type,
@@ -222,8 +222,8 @@ class TTypeTraits<void>: public TTypeTraitsBase<void> {};
* std::false_type,
* >;
*
- * static_assert(TIsAssocCont<TVector<int>>::value == false, "");
- * static_assert(TIsAssocCont<THashMap<int>>::value == true, "");
+ * static_assert(TIsAssocCont<TVector<int>>::value == false, "");
+ * static_assert(TIsAssocCont<THashMap<int>>::value == true, "");
* @endcode
*/
#define Y_HAS_SUBTYPE(...) Y_PASS_VA_ARGS(Y_MACRO_IMPL_DISPATCHER_2(__VA_ARGS__, Y_HAS_SUBTYPE_IMPL_2, Y_HAS_SUBTYPE_IMPL_1)(__VA_ARGS__))
diff --git a/util/generic/typetraits_ut.cpp b/util/generic/typetraits_ut.cpp
index 8a9a2de1ce..e7571c75ec 100644
--- a/util/generic/typetraits_ut.cpp
+++ b/util/generic/typetraits_ut.cpp
@@ -97,23 +97,23 @@ Y_UNIT_TEST_SUITE(TTypeTraitsTest) {
}
Y_UNIT_TEST(TestRemoveConst) {
- ASSERT_SAME_TYPE(std::remove_const_t<const int>, int);
+ ASSERT_SAME_TYPE(std::remove_const_t<const int>, int);
}
Y_UNIT_TEST(TestRemoveVolatile) {
- ASSERT_SAME_TYPE(std::remove_volatile_t<volatile int>, int);
+ ASSERT_SAME_TYPE(std::remove_volatile_t<volatile int>, int);
}
Y_UNIT_TEST(TestRemoveCV) {
- ASSERT_SAME_TYPE(std::remove_cv_t<const volatile int>, int);
+ ASSERT_SAME_TYPE(std::remove_cv_t<const volatile int>, int);
}
Y_UNIT_TEST(TestAddCV) {
- ASSERT_SAME_TYPE(std::add_cv_t<int>, const volatile int);
+ ASSERT_SAME_TYPE(std::add_cv_t<int>, const volatile int);
}
Y_UNIT_TEST(TestClass) {
- UNIT_ASSERT(std::is_class<TString>::value);
+ UNIT_ASSERT(std::is_class<TString>::value);
UNIT_ASSERT(!std::is_class<ETestEnum>::value);
UNIT_ASSERT(!std::is_class<int>::value);
UNIT_ASSERT(!std::is_class<void*>::value);
@@ -197,12 +197,12 @@ Y_UNIT_TEST_SUITE(TTypeTraitsTest) {
}
Y_UNIT_TEST(TestAddRValueReference) {
- ASSERT_SAME_TYPE(std::add_rvalue_reference_t<int>, int&&);
- ASSERT_SAME_TYPE(std::add_rvalue_reference_t<int const&>, int const&);
- ASSERT_SAME_TYPE(std::add_rvalue_reference_t<int*>, int*&&);
- ASSERT_SAME_TYPE(std::add_rvalue_reference_t<int*&>, int*&);
- ASSERT_SAME_TYPE(std::add_rvalue_reference_t<int&&>, int&&);
- ASSERT_SAME_TYPE(std::add_rvalue_reference_t<void>, void);
+ ASSERT_SAME_TYPE(std::add_rvalue_reference_t<int>, int&&);
+ ASSERT_SAME_TYPE(std::add_rvalue_reference_t<int const&>, int const&);
+ ASSERT_SAME_TYPE(std::add_rvalue_reference_t<int*>, int*&&);
+ ASSERT_SAME_TYPE(std::add_rvalue_reference_t<int*&>, int*&);
+ ASSERT_SAME_TYPE(std::add_rvalue_reference_t<int&&>, int&&);
+ ASSERT_SAME_TYPE(std::add_rvalue_reference_t<void>, void);
}
Y_UNIT_TEST(TestIsEmpty) {
@@ -228,7 +228,7 @@ Y_UNIT_TEST_SUITE(TTypeTraitsTest) {
}
template <class T>
- using TTrySum = decltype(std::declval<T>() + std::declval<T>());
+ using TTrySum = decltype(std::declval<T>() + std::declval<T>());
Y_UNIT_TEST(TestIsTriviallyCopyable) {
struct TPod {
diff --git a/util/generic/ut/ya.make b/util/generic/ut/ya.make
index fed74217f0..6eaf24cc5f 100644
--- a/util/generic/ut/ya.make
+++ b/util/generic/ut/ya.make
@@ -8,7 +8,7 @@ FORK_TESTS()
SRCS(
generic/adaptor_ut.cpp
generic/algorithm_ut.cpp
- generic/array_ref_ut.cpp
+ generic/array_ref_ut.cpp
generic/array_size_ut.cpp
generic/bitmap_ut.cpp
generic/bitops_ut.cpp
@@ -42,7 +42,7 @@ SRCS(
generic/stack_ut.cpp
generic/store_policy_ut.cpp
generic/strbuf_ut.cpp
- generic/string_ut.cpp
+ generic/string_ut.cpp
generic/typelist_ut.cpp
generic/typetraits_ut.cpp
generic/utility_ut.cpp
diff --git a/util/generic/utility.cpp b/util/generic/utility.cpp
index a4173d06ee..e1ed101c76 100644
--- a/util/generic/utility.cpp
+++ b/util/generic/utility.cpp
@@ -1,21 +1,21 @@
#include "utility.h"
-
-#ifdef _MSC_VER
+
+#ifdef _MSC_VER
#include <Windows.h>
-#endif
-
-void SecureZero(void* pointer, size_t count) noexcept {
-#ifdef _MSC_VER
- SecureZeroMemory(pointer, count);
-#elif defined(memset_s)
- memset_s(pointer, count, 0, count);
-#else
+#endif
+
+void SecureZero(void* pointer, size_t count) noexcept {
+#ifdef _MSC_VER
+ SecureZeroMemory(pointer, count);
+#elif defined(memset_s)
+ memset_s(pointer, count, 0, count);
+#else
volatile char* vPointer = (volatile char*)pointer;
-
- while (count) {
- *vPointer = 0;
- vPointer++;
- count--;
- }
-#endif
-}
+
+ while (count) {
+ *vPointer = 0;
+ vPointer++;
+ count--;
+ }
+#endif
+}
diff --git a/util/generic/utility.h b/util/generic/utility.h
index 876d67a89f..43b98eeafc 100644
--- a/util/generic/utility.h
+++ b/util/generic/utility.h
@@ -43,28 +43,28 @@ static T Mean(const Args&... other) noexcept {
}
template <class T>
-static inline void Zero(T& t) noexcept {
+static inline void Zero(T& t) noexcept {
memset((void*)&t, 0, sizeof(t));
}
-/**
- * Securely zero memory (compiler does not optimize this out)
- *
- * @param pointer void pointer to start of memory block to be zeroed
- * @param count size of memory block to be zeroed (in bytes)
- */
-void SecureZero(void* pointer, size_t count) noexcept;
-
-/**
- * Securely zero memory of given object (compiler does not optimize this out)
- *
- * @param t reference to object, which must be zeroed
- */
-template <class T>
-static inline void SecureZero(T& t) noexcept {
- SecureZero((void*)&t, sizeof(t));
-}
-
+/**
+ * Securely zero memory (compiler does not optimize this out)
+ *
+ * @param pointer void pointer to start of memory block to be zeroed
+ * @param count size of memory block to be zeroed (in bytes)
+ */
+void SecureZero(void* pointer, size_t count) noexcept;
+
+/**
+ * Securely zero memory of given object (compiler does not optimize this out)
+ *
+ * @param t reference to object, which must be zeroed
+ */
+template <class T>
+static inline void SecureZero(T& t) noexcept {
+ SecureZero((void*)&t, sizeof(t));
+}
+
namespace NSwapCheck {
Y_HAS_MEMBER(swap);
Y_HAS_MEMBER(Swap);
@@ -111,18 +111,18 @@ struct TNullTmpl {
};
using TNull = TNullTmpl<0>;
-
-/*
- * Class for zero-initialize padding bytes in derived classes
- */
-template <typename TDerived>
-class TZeroInit {
-protected:
- TZeroInit() {
- // Actually, safe because this as TDerived is not initialized yet.
- Zero(*static_cast<TDerived*>(this));
- }
-};
+
+/*
+ * Class for zero-initialize padding bytes in derived classes
+ */
+template <typename TDerived>
+class TZeroInit {
+protected:
+ TZeroInit() {
+ // Actually, safe because this as TDerived is not initialized yet.
+ Zero(*static_cast<TDerived*>(this));
+ }
+};
struct TIdentity {
template <class T>
diff --git a/util/generic/utility_ut.cpp b/util/generic/utility_ut.cpp
index fab7984aea..8e9d5afff9 100644
--- a/util/generic/utility_ut.cpp
+++ b/util/generic/utility_ut.cpp
@@ -74,7 +74,7 @@ Y_UNIT_TEST_SUITE(TUtilityTest) {
UNIT_ASSERT_EQUAL(Mean(1, 2), 1.5);
UNIT_ASSERT(Abs(Mean(1., 2., 7.5) - 3.5) < std::numeric_limits<double>::epsilon());
}
-
+
Y_UNIT_TEST(TestZeroInitWithDefaultZeros) {
struct TStructWithPaddingBytes: public TZeroInit<TStructWithPaddingBytes> {
TStructWithPaddingBytes()
@@ -84,17 +84,17 @@ Y_UNIT_TEST_SUITE(TUtilityTest) {
// here between Field1_ and Field2_ will be padding bytes
i64 Field2_ = 0;
};
-
+
TStructWithPaddingBytes foo{};
-
+
// all bytes must be zeroes, and MSAN will not complain about reading from padding bytes
const char* const fooPtr = (char*)&foo;
for (size_t i = 0; i < sizeof(TStructWithPaddingBytes); ++i) {
const char byte = fooPtr[i];
UNIT_ASSERT_EQUAL(byte, 0);
}
- }
-
+ }
+
Y_UNIT_TEST(TestZeroInitWithDefaultNonZeros) {
struct TStructWithPaddingBytes: public TZeroInit<TStructWithPaddingBytes> {
TStructWithPaddingBytes()
@@ -104,20 +104,20 @@ Y_UNIT_TEST_SUITE(TUtilityTest) {
// here between Field1_ and Field2_ will be padding bytes
i64 Field2_ = 100500;
};
-
+
TStructWithPaddingBytes foo{};
-
+
// check that default values are set correctly
UNIT_ASSERT_EQUAL(foo.Field1_, true);
UNIT_ASSERT_EQUAL(foo.Field2_, 100500);
-
+
const char* const fooPtr = (char*)&foo;
// just reading all bytes, and MSAN must not complain about reading padding bytes
for (size_t i = 0; i < sizeof(TStructWithPaddingBytes); ++i) {
const char byte = fooPtr[i];
UNIT_ASSERT_EQUAL(byte, byte);
}
- }
+ }
Y_UNIT_TEST(TestClampValNoClamp) {
double val = 2;
@@ -145,36 +145,36 @@ Y_UNIT_TEST_SUITE(TUtilityTest) {
UNIT_ASSERT_EQUAL(clamped, hi);
UNIT_ASSERT_EQUAL(&clamped, &hi);
}
-
+
Y_UNIT_TEST(TestSecureZero) {
constexpr size_t checkSize = 128;
char test[checkSize];
-
+
// fill with garbage
for (size_t i = 0; i < checkSize; ++i) {
test[i] = i;
}
-
+
SecureZero(test, checkSize);
-
+
for (size_t i = 0; i < checkSize; ++i) {
UNIT_ASSERT_EQUAL(test[i], 0);
}
- }
-
+ }
+
Y_UNIT_TEST(TestSecureZeroTemplate) {
constexpr size_t checkSize = 128;
char test[checkSize];
-
+
// fill with garbage
for (size_t i = 0; i < checkSize; ++i) {
test[i] = i;
}
-
+
SecureZero(test);
-
+
for (size_t i = 0; i < checkSize; ++i) {
UNIT_ASSERT_EQUAL(test[i], 0);
}
- }
+ }
};
diff --git a/util/generic/vector.h b/util/generic/vector.h
index c24bc5b8c5..a5b258955a 100644
--- a/util/generic/vector.h
+++ b/util/generic/vector.h
@@ -9,35 +9,35 @@
#include <initializer_list>
template <class T, class A>
-class TVector: public std::vector<T, TReboundAllocator<A, T>> {
+class TVector: public std::vector<T, TReboundAllocator<A, T>> {
public:
using TBase = std::vector<T, TReboundAllocator<A, T>>;
- using TSelf = TVector<T, A>;
+ using TSelf = TVector<T, A>;
using size_type = typename TBase::size_type;
- inline TVector()
+ inline TVector()
: TBase()
{
}
- inline TVector(const typename TBase::allocator_type& a)
+ inline TVector(const typename TBase::allocator_type& a)
: TBase(a)
{
}
- inline explicit TVector(::NDetail::TReserveTag rt)
+ inline explicit TVector(::NDetail::TReserveTag rt)
: TBase()
{
this->reserve(rt.Capacity);
}
- inline explicit TVector(::NDetail::TReserveTag rt, const typename TBase::allocator_type& a)
+ inline explicit TVector(::NDetail::TReserveTag rt, const typename TBase::allocator_type& a)
: TBase(a)
{
this->reserve(rt.Capacity);
}
- inline explicit TVector(size_type count)
+ inline explicit TVector(size_type count)
: TBase(count)
{
}
@@ -47,38 +47,38 @@ public:
{
}
- inline TVector(size_type count, const T& val)
+ inline TVector(size_type count, const T& val)
: TBase(count, val)
{
}
- inline TVector(size_type count, const T& val, const typename TBase::allocator_type& a)
+ inline TVector(size_type count, const T& val, const typename TBase::allocator_type& a)
: TBase(count, val, a)
{
}
- inline TVector(std::initializer_list<T> il)
+ inline TVector(std::initializer_list<T> il)
: TBase(il)
{
}
- inline TVector(std::initializer_list<T> il, const typename TBase::allocator_type& a)
+ inline TVector(std::initializer_list<T> il, const typename TBase::allocator_type& a)
: TBase(il, a)
{
}
- inline TVector(const TSelf& src)
+ inline TVector(const TSelf& src)
: TBase(src)
{
}
- inline TVector(TSelf&& src) noexcept
+ inline TVector(TSelf&& src) noexcept
: TBase(std::forward<TSelf>(src))
{
}
template <class TIter>
- inline TVector(TIter first, TIter last)
+ inline TVector(TIter first, TIter last)
: TBase(first, last)
{
}
diff --git a/util/generic/vector.pxd b/util/generic/vector.pxd
index 459da7eb40..99dde95d48 100644
--- a/util/generic/vector.pxd
+++ b/util/generic/vector.pxd
@@ -1,5 +1,5 @@
cdef extern from "<util/generic/vector.h>" nogil:
- cdef cppclass TVector[T]:
+ cdef cppclass TVector[T]:
cppclass iterator:
T& operator*()
iterator operator++()
@@ -32,17 +32,17 @@ cdef extern from "<util/generic/vector.h>" nogil:
cppclass const_reverse_iterator(reverse_iterator):
pass
- TVector() except +
- TVector(TVector&) except +
- TVector(size_t) except +
- TVector(size_t, T&) except +
+ TVector() except +
+ TVector(TVector&) except +
+ TVector(size_t) except +
+ TVector(size_t, T&) except +
- bint operator==(TVector&)
- bint operator!=(TVector&)
- bint operator<(TVector&)
- bint operator>(TVector&)
- bint operator<=(TVector&)
- bint operator>=(TVector&)
+ bint operator==(TVector&)
+ bint operator!=(TVector&)
+ bint operator<(TVector&)
+ bint operator>(TVector&)
+ bint operator<=(TVector&)
+ bint operator>=(TVector&)
void assign(size_t, const T&) except +
void assign[input_iterator](input_iterator, input_iterator) except +
@@ -76,7 +76,7 @@ cdef extern from "<util/generic/vector.h>" nogil:
void resize(size_t) except +
void resize(size_t, T&) except +
size_t size()
- void swap(TVector&) except +
+ void swap(TVector&) except +
# C++11 methods
T* data()
diff --git a/util/generic/vector_ut.cpp b/util/generic/vector_ut.cpp
index 59ed6f3b95..0f6b4037a0 100644
--- a/util/generic/vector_ut.cpp
+++ b/util/generic/vector_ut.cpp
@@ -34,7 +34,7 @@ class TYVectorTest: public TTestBase {
private:
void TestConstructorsAndAssignments() {
- using container = TVector<int>;
+ using container = TVector<int>;
container c1;
c1.push_back(100);
@@ -69,12 +69,12 @@ private:
}
inline void TestTildeEmptyToNull() {
- TVector<int> v;
+ TVector<int> v;
UNIT_ASSERT_EQUAL(nullptr, v.data());
}
inline void TestTilde() {
- TVector<int> v;
+ TVector<int> v;
v.push_back(10);
v.push_back(20);
@@ -94,7 +94,7 @@ private:
// Copy-paste of STLPort tests
void Test1() {
- TVector<int> v1; // Empty vector of integers.
+ TVector<int> v1; // Empty vector of integers.
UNIT_ASSERT(v1.empty() == true);
UNIT_ASSERT(v1.size() == 0);
@@ -110,8 +110,8 @@ private:
UNIT_ASSERT(v1[0] == 42);
{
- TVector<TVector<int>> vect(10);
- TVector<TVector<int>>::iterator it(vect.begin()), end(vect.end());
+ TVector<TVector<int>> vect(10);
+ TVector<TVector<int>>::iterator it(vect.begin()), end(vect.end());
for (; it != end; ++it) {
UNIT_ASSERT((*it).empty());
UNIT_ASSERT((*it).size() == 0);
@@ -122,10 +122,10 @@ private:
}
void Test2() {
- TVector<double> v1; // Empty vector of doubles.
+ TVector<double> v1; // Empty vector of doubles.
v1.push_back(32.1);
v1.push_back(40.5);
- TVector<double> v2; // Another empty vector of doubles.
+ TVector<double> v2; // Another empty vector of doubles.
v2.push_back(3.56);
UNIT_ASSERT(v1.size() == 2);
@@ -150,7 +150,7 @@ private:
}
void Test3() {
- using vec_type = TVector<char>;
+ using vec_type = TVector<char>;
vec_type v1; // Empty vector of characters.
v1.push_back('h');
@@ -173,7 +173,7 @@ private:
}
void Test4() {
- TVector<int> v(4);
+ TVector<int> v(4);
v[0] = 1;
v[1] = 4;
@@ -197,7 +197,7 @@ private:
void Test5() {
int array[] = {1, 4, 9, 16};
- TVector<int> v(array, array + 4);
+ TVector<int> v(array, array + 4);
UNIT_ASSERT(v.size() == 4);
@@ -210,8 +210,8 @@ private:
void Test6() {
int array[] = {1, 4, 9, 16, 25, 36};
- TVector<int> v(array, array + 6);
- TVector<int>::iterator vit;
+ TVector<int> v(array, array + 6);
+ TVector<int>::iterator vit;
UNIT_ASSERT(v.size() == 6);
UNIT_ASSERT(v[0] == 1);
@@ -251,8 +251,8 @@ private:
int array1[] = {1, 4, 25};
int array2[] = {9, 16};
- TVector<int> v(array1, array1 + 3);
- TVector<int>::iterator vit;
+ TVector<int> v(array1, array1 + 3);
+ TVector<int>::iterator vit;
vit = v.insert(v.begin(), 0); // Insert before first element.
UNIT_ASSERT(*vit == 0);
@@ -301,7 +301,7 @@ private:
void TestCapacity() {
{
- TVector<int> v;
+ TVector<int> v;
UNIT_ASSERT(v.capacity() == 0);
v.push_back(42);
@@ -311,7 +311,7 @@ private:
}
{
- TVector<int> v(Reserve(100));
+ TVector<int> v(Reserve(100));
UNIT_ASSERT(v.capacity() >= 100);
UNIT_ASSERT(v.size() == 0);
@@ -319,15 +319,15 @@ private:
{
//Test that used to generate an assertion when using __debug_alloc.
- TVector<TestStruct> va;
+ TVector<TestStruct> va;
va.reserve(1);
va.reserve(2);
}
}
void TestAt() {
- TVector<int> v;
- TVector<int> const& cv = v;
+ TVector<int> v;
+ TVector<int> const& cv = v;
v.push_back(10);
UNIT_ASSERT(v.at(0) == 10);
@@ -347,27 +347,27 @@ private:
}
void TestPointer() {
- TVector<int*> v1;
- TVector<int*> v2 = v1;
- TVector<int*> v3;
+ TVector<int*> v1;
+ TVector<int*> v2 = v1;
+ TVector<int*> v3;
v3.insert(v3.end(), v1.begin(), v1.end());
}
void TestAutoRef() {
- TVector<int> ref;
+ TVector<int> ref;
for (int i = 0; i < 5; ++i) {
ref.push_back(i);
}
- TVector<TVector<int>> v_v_int(1, ref);
+ TVector<TVector<int>> v_v_int(1, ref);
v_v_int.push_back(v_v_int[0]);
v_v_int.push_back(ref);
v_v_int.push_back(v_v_int[0]);
v_v_int.push_back(v_v_int[0]);
v_v_int.push_back(ref);
- TVector<TVector<int>>::iterator vvit(v_v_int.begin()), vvitEnd(v_v_int.end());
+ TVector<TVector<int>>::iterator vvit(v_v_int.begin()), vvitEnd(v_v_int.end());
for (; vvit != vvitEnd; ++vvit) {
UNIT_ASSERT(*vvit == ref);
}
@@ -391,8 +391,8 @@ private:
};
void TestIterators() {
- TVector<int> vint(10, 0);
- TVector<int> const& crvint = vint;
+ TVector<int> vint(10, 0);
+ TVector<int> const& crvint = vint;
UNIT_ASSERT(vint.begin() == vint.begin());
UNIT_ASSERT(crvint.begin() == vint.begin());
@@ -418,7 +418,7 @@ private:
}
void TestShrink() {
- TVector<int> v;
+ TVector<int> v;
v.resize(1000);
v.resize(10);
v.shrink_to_fit();
@@ -436,7 +436,7 @@ private:
// representation making executable crash on vector destructor invocation.
// We prefer a simple memory leak, internal corruption should be reveal
// by size or capacity checks.
- using V = TVector<int>;
+ using V = TVector<int>;
V* pv1 = new V(1, 1);
V* pv2 = new V(10, 2);
@@ -459,7 +459,7 @@ private:
void TestFillInConstructor() {
for (int k = 0; k < 3; ++k) {
- TVector<int> v(100);
+ TVector<int> v(100);
UNIT_ASSERT_VALUES_EQUAL(100u, v.size());
for (size_t i = 0; i < v.size(); ++i) {
UNIT_ASSERT_VALUES_EQUAL(0, v[i]);
@@ -517,7 +517,7 @@ private:
constexpr bool ALLOW_UNINITIALIZED = false;
#endif
- TVector<T, TDebugAlloc<T>> v;
+ TVector<T, TDebugAlloc<T>> v;
v.reserve(5);
auto firstBegin = v.begin();
@@ -564,7 +564,7 @@ private:
TestYResize<TNonPod>();
}
- void CheckInitializeList(const TVector<int>& v) {
+ void CheckInitializeList(const TVector<int>& v) {
for (size_t i = 0; i < v.size(); ++i) {
UNIT_ASSERT_EQUAL(v[i], static_cast<int>(i));
}
@@ -572,21 +572,21 @@ private:
void TestInitializeList() {
{
- TVector<int> v;
+ TVector<int> v;
v.assign({0, 1, 2});
CheckInitializeList(v);
}
{
- TVector<int> v = {0, 1, 2};
+ TVector<int> v = {0, 1, 2};
CheckInitializeList(v);
}
{
- TVector<int> v;
+ TVector<int> v;
v = {0, 1, 2};
CheckInitializeList(v);
}
{
- TVector<int> v = {0, 3};
+ TVector<int> v = {0, 3};
v.insert(v.begin() + 1, {1, 2});
CheckInitializeList(v);
}
diff --git a/util/generic/vector_ut.pyx b/util/generic/vector_ut.pyx
index 631b73fa63..904e67733b 100644
--- a/util/generic/vector_ut.pyx
+++ b/util/generic/vector_ut.pyx
@@ -1,44 +1,44 @@
# cython: c_string_type=str, c_string_encoding=utf8
-from util.generic.vector cimport TVector
+from util.generic.vector cimport TVector
from util.generic.string cimport TString
import pytest
import unittest
-def _check_convert(TVector[TString] x):
+def _check_convert(TVector[TString] x):
return x
class TestVector(unittest.TestCase):
def test_ctor1(self):
- cdef TVector[int] tmp = TVector[int]()
+ cdef TVector[int] tmp = TVector[int]()
self.assertEqual(tmp.size(), 0)
def test_ctor2(self):
- cdef TVector[int] tmp = TVector[int](10)
+ cdef TVector[int] tmp = TVector[int](10)
self.assertEqual(tmp.size(), 10)
self.assertEqual(tmp[0], 0)
def test_ctor3(self):
- cdef TVector[int] tmp = TVector[int](10, 42)
+ cdef TVector[int] tmp = TVector[int](10, 42)
self.assertEqual(tmp.size(), 10)
self.assertEqual(tmp[0], 42)
def test_ctor4(self):
- cdef TVector[int] tmp = TVector[int](10, 42)
- cdef TVector[int] tmp2 = TVector[int](tmp)
+ cdef TVector[int] tmp = TVector[int](10, 42)
+ cdef TVector[int] tmp2 = TVector[int](tmp)
self.assertEqual(tmp2.size(), 10)
self.assertEqual(tmp2[0], 42)
def test_operator_assign(self):
- cdef TVector[int] tmp2
+ cdef TVector[int] tmp2
tmp2.push_back(1)
tmp2.push_back(2)
- cdef TVector[int] tmp3
+ cdef TVector[int] tmp3
tmp3.push_back(1)
tmp3.push_back(3)
@@ -51,15 +51,15 @@ class TestVector(unittest.TestCase):
self.assertEqual(tmp3[1], 2)
def test_compare(self):
- cdef TVector[int] tmp1
+ cdef TVector[int] tmp1
tmp1.push_back(1)
tmp1.push_back(2)
- cdef TVector[int] tmp2
+ cdef TVector[int] tmp2
tmp2.push_back(1)
tmp2.push_back(2)
- cdef TVector[int] tmp3
+ cdef TVector[int] tmp3
tmp3.push_back(1)
tmp3.push_back(3)
@@ -73,7 +73,7 @@ class TestVector(unittest.TestCase):
self.assertTrue(tmp3 >= tmp1)
def test_index(self):
- cdef TVector[int] tmp = TVector[int](10, 42)
+ cdef TVector[int] tmp = TVector[int](10, 42)
self.assertEqual(tmp[0], 42)
self.assertEqual(tmp[5], 42)
@@ -88,7 +88,7 @@ class TestVector(unittest.TestCase):
tmp.at(100)
def test_push_pop_back(self):
- cdef TVector[int] tmp
+ cdef TVector[int] tmp
self.assertEqual(tmp.size(), 0)
tmp.push_back(42)
@@ -107,22 +107,22 @@ class TestVector(unittest.TestCase):
self.assertEqual(tmp.size(), 0)
def test_front(self):
- cdef TVector[int] tmp
+ cdef TVector[int] tmp
tmp.push_back(42)
self.assertEqual(tmp.front(), 42)
def test_empty(self):
- cdef TVector[int] tmp
+ cdef TVector[int] tmp
self.assertTrue(tmp.empty())
tmp.push_back(42)
self.assertFalse(tmp.empty())
def test_max_size(self):
- cdef TVector[int] tmp
+ cdef TVector[int] tmp
self.assertTrue(tmp.max_size() > 0)
def test_reserve_resize(self):
- cdef TVector[int] tmp
+ cdef TVector[int] tmp
tmp.reserve(1000)
self.assertEqual(tmp.capacity(), 1000)
@@ -140,7 +140,7 @@ class TestVector(unittest.TestCase):
self.assertEqual(tmp.back(), 42)
def test_iter(self):
- cdef TVector[int] tmp
+ cdef TVector[int] tmp
tmp.push_back(1)
tmp.push_back(20)
tmp.push_back(300)
@@ -148,7 +148,7 @@ class TestVector(unittest.TestCase):
self.assertEqual([i for i in tmp], [1, 20, 300])
def test_iterator(self):
- cdef TVector[int] tmp
+ cdef TVector[int] tmp
self.assertTrue(tmp.begin() == tmp.end())
self.assertTrue(tmp.rbegin() == tmp.rend())
@@ -173,7 +173,7 @@ class TestVector(unittest.TestCase):
self.assertTrue(tmp.const_rbegin() + 1 == tmp.const_rend())
def test_assign(self):
- cdef TVector[int] tmp
+ cdef TVector[int] tmp
tmp.assign(10, 42)
self.assertEqual(tmp.size(), 10)
@@ -181,12 +181,12 @@ class TestVector(unittest.TestCase):
self.assertEqual(tmp.back(), 42)
def test_insert(self):
- cdef TVector[int] tmp
+ cdef TVector[int] tmp
tmp.push_back(1)
tmp.push_back(2)
tmp.push_back(3)
- cdef TVector[int] tmp2
+ cdef TVector[int] tmp2
tmp2.push_back(7)
tmp2.push_back(9)
@@ -200,7 +200,7 @@ class TestVector(unittest.TestCase):
self.assertEqual([i for i in tmp], [7, 9, 6, 6, 8, 1, 2, 3])
def test_erase(self):
- cdef TVector[int] tmp
+ cdef TVector[int] tmp
tmp.push_back(1)
tmp.push_back(2)
tmp.push_back(3)
diff --git a/util/generic/xrange.h b/util/generic/xrange.h
index 89c773002e..5fc8c82912 100644
--- a/util/generic/xrange.h
+++ b/util/generic/xrange.h
@@ -14,7 +14,7 @@
* DoSomething(i, MyVector[i]);
* }
*
- * TVector<int> arithmeticSeq = xrange(10); // instead: TVector<int> arithmeticSeq; for(size_t i = 0; i < 10; ++i) { arithmeticSeq.push_back(i); }
+ * TVector<int> arithmeticSeq = xrange(10); // instead: TVector<int> arithmeticSeq; for(size_t i = 0; i < 10; ++i) { arithmeticSeq.push_back(i); }
*
*/
diff --git a/util/generic/xrange_ut.cpp b/util/generic/xrange_ut.cpp
index 66c8b1d83a..8106da03e7 100644
--- a/util/generic/xrange_ut.cpp
+++ b/util/generic/xrange_ut.cpp
@@ -30,7 +30,7 @@ Y_UNIT_TEST_SUITE(XRange) {
UNIT_ASSERT_VALUES_EQUAL(sum, count * (first + last) / 2);
}
- void TestSteppedXRangeImpl(int begin, int end, int step, const TVector<int>& expected) {
+ void TestSteppedXRangeImpl(int begin, int end, int step, const TVector<int>& expected) {
size_t expInd = 0;
for (auto i : xrange(begin, end, step)) {
UNIT_ASSERT(expInd < expected.size());
@@ -65,7 +65,7 @@ Y_UNIT_TEST_SUITE(XRange) {
}
Y_UNIT_TEST(PointersWorks) {
- TVector<size_t> data = {3, 1, 4, 1, 5, 9, 2, 6};
+ TVector<size_t> data = {3, 1, 4, 1, 5, 9, 2, 6};
const size_t digSumExpected = Accumulate(data.begin(), data.end(), static_cast<size_t>(0));
size_t digSumByIt = 0;
for (auto ptr : xrange(data.begin(), data.end())) {
@@ -85,19 +85,19 @@ Y_UNIT_TEST_SUITE(XRange) {
UNIT_ASSERT_VALUES_EQUAL(xrange(0, 6, 2).size(), 3);
}
- class TVectorChild: public TVector<size_t> {
+ class TVectorChild: public TVector<size_t> {
public:
template <typename TIterator>
TVectorChild(TIterator a, TIterator b)
- : TVector<size_t>(a, b)
+ : TVector<size_t>(a, b)
{
}
};
Y_UNIT_TEST(ConvertionWorks) {
- TVector<size_t> data = {0, 1, 2, 3, 4, 5, 6, 7, 8};
+ TVector<size_t> data = {0, 1, 2, 3, 4, 5, 6, 7, 8};
- TVector<size_t> convertionResults[] = {xrange<size_t>(9),
+ TVector<size_t> convertionResults[] = {xrange<size_t>(9),
xrange<ui32>(0, 9),
xrange(0, 9, 1)};
@@ -124,7 +124,7 @@ Y_UNIT_TEST_SUITE(XRange) {
}
using TValueType = decltype(*emptyRange.begin());
- const TVector<TValueType> asVector = emptyRange;
+ const TVector<TValueType> asVector = emptyRange;
UNIT_ASSERT(asVector.empty());
}
}
diff --git a/util/generic/yexception.cpp b/util/generic/yexception.cpp
index 5508a63ec6..2ce6c4369d 100644
--- a/util/generic/yexception.cpp
+++ b/util/generic/yexception.cpp
@@ -14,31 +14,31 @@ TString FormatExc(const std::exception& exception) {
return TString::Join(TStringBuf("("), TypeName(exception), TStringBuf(") "), exception.what());
}
-TString CurrentExceptionMessage() {
- auto exceptionPtr = std::current_exception();
- if (exceptionPtr) {
- try {
- std::rethrow_exception(exceptionPtr);
- } catch (const yexception& e) {
- const TBackTrace* bt = e.BackTrace();
-
- if (bt) {
+TString CurrentExceptionMessage() {
+ auto exceptionPtr = std::current_exception();
+ if (exceptionPtr) {
+ try {
+ std::rethrow_exception(exceptionPtr);
+ } catch (const yexception& e) {
+ const TBackTrace* bt = e.BackTrace();
+
+ if (bt) {
return TString::Join(bt->PrintToString(), TStringBuf("\n"), FormatExc(e));
- }
-
- return FormatExc(e);
- } catch (const std::exception& e) {
- return FormatExc(e);
- } catch (...) {
+ }
+
+ return FormatExc(e);
+ } catch (const std::exception& e) {
+ return FormatExc(e);
+ } catch (...) {
}
- return "unknown error";
+ return "unknown error";
}
- return "(NO EXCEPTION)";
+ return "(NO EXCEPTION)";
}
-bool UncaughtException() noexcept {
+bool UncaughtException() noexcept {
// FIXME: use std::uncaught_exceptions() unconditionally after DEVTOOLS-8811
#if defined(__cpp_lib_uncaught_exceptions) && !defined(_LIBCPP_AVAILABILITY_UNCAUGHT_EXCEPTIONS)
return std::uncaught_exceptions() > 0;
@@ -97,11 +97,11 @@ void NPrivateException::yexception::ZeroTerminate() noexcept {
*end = 0;
}
-const char* NPrivateException::yexception::what() const noexcept {
+const char* NPrivateException::yexception::what() const noexcept {
return Buf_.Data();
}
-const TBackTrace* NPrivateException::yexception::BackTrace() const noexcept {
+const TBackTrace* NPrivateException::yexception::BackTrace() const noexcept {
return nullptr;
}
diff --git a/util/generic/yexception.h b/util/generic/yexception.h
index 10fa8c7c70..b0c604e8c4 100644
--- a/util/generic/yexception.h
+++ b/util/generic/yexception.h
@@ -2,7 +2,7 @@
#include "bt_exception.h"
#include "strbuf.h"
-#include "string.h"
+#include "string.h"
#include "utility.h"
#include "va_args.h"
#include <utility>
@@ -46,8 +46,8 @@ namespace NPrivateException {
yexception& operator=(const yexception&) = default;
yexception& operator=(yexception&&) = default;
- const char* what() const noexcept override;
- virtual const TBackTrace* BackTrace() const noexcept;
+ const char* what() const noexcept override;
+ virtual const TBackTrace* BackTrace() const noexcept;
template <class T>
inline void Append(const T& t) {
@@ -154,7 +154,7 @@ namespace NPrivate {
void fputs(const std::exception& e, FILE* f = stderr);
-TString CurrentExceptionMessage();
+TString CurrentExceptionMessage();
/*
* A neat method that detects wrether stack unwinding is in progress.
@@ -169,7 +169,7 @@ TString CurrentExceptionMessage();
*
* DO NOT USE THIS METHOD IN DESTRUCTORS.
*/
-bool UncaughtException() noexcept;
+bool UncaughtException() noexcept;
std::string CurrentExceptionTypeName();
diff --git a/util/generic/yexception_ut.cpp b/util/generic/yexception_ut.cpp
index cbdab1740c..cb3e29fed8 100644
--- a/util/generic/yexception_ut.cpp
+++ b/util/generic/yexception_ut.cpp
@@ -39,7 +39,7 @@ class TExceptionTest: public TTestBase {
UNIT_TEST_SUITE(TExceptionTest);
UNIT_TEST_EXCEPTION(TestException, yexception)
UNIT_TEST_EXCEPTION(TestLineInfo, yexception)
- UNIT_TEST(TestCurrentExceptionMessageWhenThereisNoException)
+ UNIT_TEST(TestCurrentExceptionMessageWhenThereisNoException)
UNIT_TEST(TestFormat1)
UNIT_TEST(TestRaise1)
UNIT_TEST(TestVirtuality)
@@ -70,15 +70,15 @@ private:
}
}
- inline void TestCurrentExceptionMessageWhenThereisNoException() {
- UNIT_ASSERT(CurrentExceptionMessage() == "(NO EXCEPTION)");
- }
-
+ inline void TestCurrentExceptionMessageWhenThereisNoException() {
+ UNIT_ASSERT(CurrentExceptionMessage() == "(NO EXCEPTION)");
+ }
+
inline void TestBackTrace() {
try {
ythrow TWithBackTrace<TIoSystemError>() << "test";
} catch (...) {
- UNIT_ASSERT(CurrentExceptionMessage().find('\n') != TString::npos);
+ UNIT_ASSERT(CurrentExceptionMessage().find('\n') != TString::npos);
return;
}
@@ -212,14 +212,14 @@ private:
throw yexception() << 1 << " qw " << 12.1;
UNIT_ASSERT(false);
} catch (...) {
- const TString err = CurrentExceptionMessage();
+ const TString err = CurrentExceptionMessage();
UNIT_ASSERT(err.Contains("1 qw 12.1"));
}
}
static inline void CheckCurrentExceptionContains(const char* message) {
- TString err = CurrentExceptionMessage();
+ TString err = CurrentExceptionMessage();
SubstGlobal(err, '\\', '/'); // remove backslashes from path in message
UNIT_ASSERT(err.Contains(message));
}
diff --git a/util/generic/ylimits.h b/util/generic/ylimits.h
index 61a311e43e..fe42b4dfc0 100644
--- a/util/generic/ylimits.h
+++ b/util/generic/ylimits.h
@@ -7,12 +7,12 @@
#endif
template <class T>
-static constexpr T Max() noexcept {
+static constexpr T Max() noexcept {
return std::numeric_limits<T>::max();
}
template <class T>
-static constexpr T Min() noexcept {
+static constexpr T Min() noexcept {
return std::numeric_limits<T>::min();
}
@@ -32,11 +32,11 @@ namespace NPrivate {
};
}
-static constexpr ::NPrivate::TMax Max() noexcept {
+static constexpr ::NPrivate::TMax Max() noexcept {
return {};
}
-static constexpr ::NPrivate::TMin Min() noexcept {
+static constexpr ::NPrivate::TMin Min() noexcept {
return {};
}
diff --git a/util/generic/ymath_ut.cpp b/util/generic/ymath_ut.cpp
index 3e3009540c..29190b55eb 100644
--- a/util/generic/ymath_ut.cpp
+++ b/util/generic/ymath_ut.cpp
@@ -9,7 +9,7 @@
#include <limits>
template <class T>
-static inline T SlowClp2(T t) noexcept {
+static inline T SlowClp2(T t) noexcept {
Y_ASSERT(t > 0);
T ret = 1;
diff --git a/util/memory/addstorage.h b/util/memory/addstorage.h
index 53b12c68bd..597c73a988 100644
--- a/util/memory/addstorage.h
+++ b/util/memory/addstorage.h
@@ -41,15 +41,15 @@ public:
return data;
}
- inline void operator delete(void* ptr) noexcept {
+ inline void operator delete(void* ptr) noexcept {
DoDelete(ptr);
}
- inline void operator delete(void* ptr, size_t) noexcept {
+ inline void operator delete(void* ptr, size_t) noexcept {
DoDelete(ptr);
}
- inline void operator delete(void* ptr, size_t, size_t) noexcept {
+ inline void operator delete(void* ptr, size_t, size_t) noexcept {
/*
* this delete operator can be called automagically by compiler
*/
@@ -57,20 +57,20 @@ public:
DoDelete(ptr);
}
- inline void* AdditionalData() const noexcept {
+ inline void* AdditionalData() const noexcept {
return (char*)(static_cast<const T*>(this)) + CombinedSizeOfInstanceWithTInfo();
}
- static inline T* ObjectFromData(void* data) noexcept {
+ static inline T* ObjectFromData(void* data) noexcept {
return reinterpret_cast<T*>(static_cast<char*>(data) - CombinedSizeOfInstanceWithTInfo());
}
- inline size_t AdditionalDataLength() const noexcept {
+ inline size_t AdditionalDataLength() const noexcept {
return InfoPtr(static_cast<const T*>(this))->Length();
}
private:
- static inline void DoDelete(void* ptr) noexcept {
+ static inline void DoDelete(void* ptr) noexcept {
TInfo* info = InfoPtr(static_cast<T*>(ptr));
info->~TInfo();
::operator delete(ptr);
diff --git a/util/memory/alloc.cpp b/util/memory/alloc.cpp
index 0ce76855e1..49f012d857 100644
--- a/util/memory/alloc.cpp
+++ b/util/memory/alloc.cpp
@@ -15,6 +15,6 @@ void TDefaultAllocator::Release(const TBlock& block) {
y_deallocate(block.Data);
}
-IAllocator* TDefaultAllocator::Instance() noexcept {
+IAllocator* TDefaultAllocator::Instance() noexcept {
return SingletonWithPriority<TDefaultAllocator, 0>();
}
diff --git a/util/memory/alloc.h b/util/memory/alloc.h
index bb51a1a6a6..d59575aef5 100644
--- a/util/memory/alloc.h
+++ b/util/memory/alloc.h
@@ -23,5 +23,5 @@ public:
TBlock Allocate(size_t len) override;
void Release(const TBlock& block) override;
- static IAllocator* Instance() noexcept;
+ static IAllocator* Instance() noexcept;
};
diff --git a/util/memory/blob.cpp b/util/memory/blob.cpp
index 40b0cab8f4..91da5cadca 100644
--- a/util/memory/blob.cpp
+++ b/util/memory/blob.cpp
@@ -6,7 +6,7 @@
#include <util/system/mlock.h>
#include <util/stream/buffer.h>
#include <util/generic/ptr.h>
-#include <util/generic/string.h>
+#include <util/generic/string.h>
#include <util/generic/buffer.h>
#include <util/generic/ylimits.h>
#include <util/generic/singleton.h>
@@ -23,19 +23,19 @@ public:
~TDynamicBlobBase() override = default;
- void Ref() noexcept override {
+ void Ref() noexcept override {
TRefBase::Ref();
}
- void UnRef() noexcept override {
+ void UnRef() noexcept override {
TRefBase::UnRef();
}
- inline void* Data() const noexcept {
+ inline void* Data() const noexcept {
return this->AdditionalData();
}
- inline size_t Length() const noexcept {
+ inline size_t Length() const noexcept {
return this->AdditionalDataLength();
}
};
@@ -51,15 +51,15 @@ public:
~TBufferBlobBase() override = default;
- void Ref() noexcept override {
+ void Ref() noexcept override {
TRefBase::Ref();
}
- void UnRef() noexcept override {
+ void UnRef() noexcept override {
TRefBase::UnRef();
}
- inline const TBuffer& Buffer() const noexcept {
+ inline const TBuffer& Buffer() const noexcept {
return Buf_;
}
@@ -72,7 +72,7 @@ class TStringBlobBase: public TBlob::TBase, public TRefCounted<TStringBlobBase<T
using TRefBase = TRefCounted<TStringBlobBase, TCounter>;
public:
- inline TStringBlobBase(const TString& s)
+ inline TStringBlobBase(const TString& s)
: S_(s)
{
}
@@ -84,20 +84,20 @@ public:
~TStringBlobBase() override = default;
- void Ref() noexcept override {
+ void Ref() noexcept override {
TRefBase::Ref();
}
- void UnRef() noexcept override {
+ void UnRef() noexcept override {
TRefBase::UnRef();
}
- inline const TString& String() const noexcept {
+ inline const TString& String() const noexcept {
return S_;
}
private:
- const TString S_;
+ const TString S_;
};
template <class TCounter>
@@ -128,19 +128,19 @@ public:
}
}
- void Ref() noexcept override {
+ void Ref() noexcept override {
TRefBase::Ref();
}
- void UnRef() noexcept override {
+ void UnRef() noexcept override {
TRefBase::UnRef();
}
- inline const void* Data() const noexcept {
+ inline const void* Data() const noexcept {
return Map_.Ptr();
}
- inline size_t Length() const noexcept {
+ inline size_t Length() const noexcept {
return Map_.MappedSize();
}
@@ -324,12 +324,12 @@ static inline TBlob ConstructFromFileContent(const TFile& file, ui64 offset, ui6
return ReadFromFile<TCounter>(file, offset, static_cast<size_t>(length));
}
-TBlob TBlob::FromFileContentSingleThreaded(const TString& path) {
+TBlob TBlob::FromFileContentSingleThreaded(const TString& path) {
TFile file(path, RdOnly);
return ConstructFromFileContent<TSimpleCounter>(file, 0, file.GetLength());
}
-TBlob TBlob::FromFileContent(const TString& path) {
+TBlob TBlob::FromFileContent(const TString& path) {
TFile file(path, RdOnly);
return ConstructFromFileContent<TAtomicCounter>(file, 0, file.GetLength());
}
@@ -401,7 +401,7 @@ TBlob ConstructFromString(S&& s) {
return ret;
}
-TBlob TBlob::FromStringSingleThreaded(const TString& s) {
+TBlob TBlob::FromStringSingleThreaded(const TString& s) {
return ConstructFromString<TSimpleCounter>(s);
}
@@ -409,7 +409,7 @@ TBlob TBlob::FromStringSingleThreaded(TString&& s) {
return ConstructFromString<TSimpleCounter>(std::move(s));
}
-TBlob TBlob::FromString(const TString& s) {
+TBlob TBlob::FromString(const TString& s) {
return ConstructFromString<TAtomicCounter>(s);
}
diff --git a/util/memory/blob.h b/util/memory/blob.h
index 46a82d5195..20c02a68df 100644
--- a/util/memory/blob.h
+++ b/util/memory/blob.h
@@ -28,8 +28,8 @@ public:
inline TBase() noexcept = default;
virtual ~TBase() = default;
- virtual void Ref() noexcept = 0;
- virtual void UnRef() noexcept = 0;
+ virtual void Ref() noexcept = 0;
+ virtual void UnRef() noexcept = 0;
};
private:
@@ -38,7 +38,7 @@ private:
size_t Length;
TBase* Base;
- inline TStorage(const void* data, size_t length, TBase* base) noexcept
+ inline TStorage(const void* data, size_t length, TBase* base) noexcept
: Data(data)
, Length(length)
, Base(base)
@@ -47,7 +47,7 @@ private:
inline ~TStorage() = default;
- inline void Swap(TStorage& r) noexcept {
+ inline void Swap(TStorage& r) noexcept {
DoSwap(Data, r.Data);
DoSwap(Length, r.Length);
DoSwap(Base, r.Base);
@@ -68,7 +68,7 @@ public:
{
}
- inline TBlob(const TBlob& r) noexcept
+ inline TBlob(const TBlob& r) noexcept
: S_(r.S_)
{
Ref();
@@ -80,34 +80,34 @@ public:
this->Swap(r);
}
- inline TBlob(const void* data, size_t length, TBase* base) noexcept
+ inline TBlob(const void* data, size_t length, TBase* base) noexcept
: S_(data, length, base)
{
Ref();
}
- inline ~TBlob() {
+ inline ~TBlob() {
UnRef();
}
- inline TBlob& operator=(const TBlob& r) noexcept {
+ inline TBlob& operator=(const TBlob& r) noexcept {
TBlob(r).Swap(*this);
return *this;
}
/// Swaps content of two data arrays.
- inline void Swap(TBlob& r) noexcept {
+ inline void Swap(TBlob& r) noexcept {
S_.Swap(r.S_);
}
/// Returns a const reference to the data array.
- inline const void* Data() const noexcept {
+ inline const void* Data() const noexcept {
return S_.Data;
}
/// Returns the size of the data array in bytes.
- inline size_t Length() const noexcept {
+ inline size_t Length() const noexcept {
return S_.Length;
}
@@ -122,17 +122,17 @@ public:
}
/// Checks if the object has a data array.
- inline bool IsNull() const noexcept {
+ inline bool IsNull() const noexcept {
return !Data();
}
/// Returns a const pointer of char type to the data array.
- inline const char* AsCharPtr() const noexcept {
+ inline const char* AsCharPtr() const noexcept {
return (const char*)Data();
}
/// Returns a const pointer of unsigned char type to the data array.
- inline const unsigned char* AsUnsignedCharPtr() const noexcept {
+ inline const unsigned char* AsUnsignedCharPtr() const noexcept {
return (const unsigned char*)Data();
}
@@ -141,7 +141,7 @@ public:
}
/// Drops the data array.
- inline void Drop() noexcept {
+ inline void Drop() noexcept {
TBlob().Swap(*this);
}
@@ -163,21 +163,21 @@ public:
}
/// Returns the size of the data array in bytes.
- inline size_t Size() const noexcept {
+ inline size_t Size() const noexcept {
return Length();
}
/// Standard iterator.
- inline const_iterator Begin() const noexcept {
+ inline const_iterator Begin() const noexcept {
return AsUnsignedCharPtr();
}
/// Standard iterator.
- inline const_iterator End() const noexcept {
+ inline const_iterator End() const noexcept {
return Begin() + Size();
}
- inline value_type operator[](size_t n) const noexcept {
+ inline value_type operator[](size_t n) const noexcept {
return *(Begin() + n);
}
@@ -263,10 +263,10 @@ public:
static TBlob FromMemoryMap(const TMemoryMap& map, ui64 offset, size_t length);
/// Creates a blob with a single-threaded (non atomic) refcounter. Dynamically allocates memory and copies data from the file on the path using pread().
- static TBlob FromFileContentSingleThreaded(const TString& path);
+ static TBlob FromFileContentSingleThreaded(const TString& path);
/// Creates a blob with a multi-threaded (atomic) refcounter. Dynamically allocates memory and copies data from the file on the path using pread().
- static TBlob FromFileContent(const TString& path);
+ static TBlob FromFileContent(const TString& path);
/// Creates a blob with a single-threaded (non atomic) refcounter. Dynamically allocates memory and copies data from the file using pread().
static TBlob FromFileContentSingleThreaded(const TFile& file);
@@ -295,25 +295,25 @@ public:
static TBlob FromBuffer(TBuffer& in);
/// Creates a blob from TString with a single-threaded (non atomic) refcounter.
- static TBlob FromStringSingleThreaded(const TString& s);
+ static TBlob FromStringSingleThreaded(const TString& s);
/// Creates a blob from TString with a single-threaded (non atomic) refcounter. Doesn't copy its content.
static TBlob FromStringSingleThreaded(TString&& s);
/// Creates a blob from TString with a multi-threaded (atomic) refcounter.
- static TBlob FromString(const TString& s);
+ static TBlob FromString(const TString& s);
/// Creates a blob from TString with a multi-threaded (atomic) refcounter. Doesn't copy its content.
static TBlob FromString(TString&& s);
private:
- inline void Ref() noexcept {
+ inline void Ref() noexcept {
if (S_.Base) {
S_.Base->Ref();
}
}
- inline void UnRef() noexcept {
+ inline void UnRef() noexcept {
if (S_.Base) {
S_.Base->UnRef();
}
diff --git a/util/memory/pool.cpp b/util/memory/pool.cpp
index 4addca2fe6..9a011f0e4f 100644
--- a/util/memory/pool.cpp
+++ b/util/memory/pool.cpp
@@ -1,11 +1,11 @@
#include "pool.h"
-TMemoryPool::IGrowPolicy* TMemoryPool::TLinearGrow::Instance() noexcept {
+TMemoryPool::IGrowPolicy* TMemoryPool::TLinearGrow::Instance() noexcept {
return SingletonWithPriority<TLinearGrow, 0>();
}
-TMemoryPool::IGrowPolicy* TMemoryPool::TExpGrow::Instance() noexcept {
+TMemoryPool::IGrowPolicy* TMemoryPool::TExpGrow::Instance() noexcept {
return SingletonWithPriority<TExpGrow, 0>();
}
diff --git a/util/memory/pool.h b/util/memory/pool.h
index 7fe26e8120..13c8b6b9ed 100644
--- a/util/memory/pool.h
+++ b/util/memory/pool.h
@@ -29,14 +29,14 @@ private:
class TChunk: public TIntrusiveListItem<TChunk> {
public:
- inline TChunk(size_t len = 0) noexcept
+ inline TChunk(size_t len = 0) noexcept
: Cur_((char*)(this + 1))
, Left_(len)
{
Y_ASSERT((((size_t)Cur_) % PLATFORM_DATA_ALIGN) == 0);
}
- inline void* Allocate(size_t len) noexcept {
+ inline void* Allocate(size_t len) noexcept {
if (Left_ >= len) {
char* ret = Cur_;
@@ -49,7 +49,7 @@ private:
return nullptr;
}
- inline void* Allocate(size_t len, size_t align) noexcept {
+ inline void* Allocate(size_t len, size_t align) noexcept {
size_t pad = AlignUp(Cur_, align) - Cur_;
void* ret = Allocate(pad + len);
@@ -60,31 +60,31 @@ private:
return nullptr;
}
- inline size_t BlockLength() const noexcept {
+ inline size_t BlockLength() const noexcept {
return (Cur_ + Left_) - (char*)this;
}
- inline size_t Used() const noexcept {
+ inline size_t Used() const noexcept {
return Cur_ - (const char*)this;
}
- inline size_t Left() const noexcept {
+ inline size_t Left() const noexcept {
return Left_;
}
- inline const char* Data() const noexcept {
+ inline const char* Data() const noexcept {
return (const char*)(this + 1);
}
- inline char* Data() noexcept {
+ inline char* Data() noexcept {
return (char*)(this + 1);
}
- inline size_t DataSize() const noexcept {
+ inline size_t DataSize() const noexcept {
return Cur_ - Data();
}
- inline void ResetChunk() noexcept {
+ inline void ResetChunk() noexcept {
size_t total = DataSize() + Left();
Cur_ = Data();
Left_ = total;
@@ -102,25 +102,25 @@ public:
public:
virtual ~IGrowPolicy() = default;
- virtual size_t Next(size_t prev) const noexcept = 0;
+ virtual size_t Next(size_t prev) const noexcept = 0;
};
class TLinearGrow: public IGrowPolicy {
public:
- size_t Next(size_t prev) const noexcept override {
+ size_t Next(size_t prev) const noexcept override {
return prev;
}
- static IGrowPolicy* Instance() noexcept;
+ static IGrowPolicy* Instance() noexcept;
};
class TExpGrow: public IGrowPolicy {
public:
- size_t Next(size_t prev) const noexcept override {
+ size_t Next(size_t prev) const noexcept override {
return prev * 2;
}
- static IGrowPolicy* Instance() noexcept;
+ static IGrowPolicy* Instance() noexcept;
};
struct TOptions {
@@ -143,7 +143,7 @@ public:
{
}
- inline ~TMemoryPool() {
+ inline ~TMemoryPool() {
Clear();
}
@@ -232,28 +232,28 @@ public:
return TBasicStringBuf<TChar>(ret, buf.size());
}
- inline size_t Available() const noexcept {
+ inline size_t Available() const noexcept {
return Current_->Left();
}
- inline void Clear() noexcept {
+ inline void Clear() noexcept {
DoClear(false);
}
- inline void ClearKeepFirstChunk() noexcept {
+ inline void ClearKeepFirstChunk() noexcept {
DoClear(true);
}
- inline size_t MemoryAllocated() const noexcept {
+ inline size_t MemoryAllocated() const noexcept {
return MemoryAllocatedBeforeCurrent_ + (Current_ != &Empty_ ? Current_->Used() : 0);
}
- inline size_t MemoryWaste() const noexcept {
+ inline size_t MemoryWaste() const noexcept {
return MemoryWasteBeforeCurrent_ + (Current_ != &Empty_ ? Current_->Left() : 0);
}
template <class TOp>
- inline void Traverse(TOp& op) const noexcept {
+ inline void Traverse(TOp& op) const noexcept {
for (TChunkList::TConstIterator i = Chunks_.Begin(); i != Chunks_.End(); ++i) {
op(i->Data(), i->DataSize());
}
@@ -316,10 +316,10 @@ struct TPoolableBase {
return pool.Allocate(bytes, (size_t)align);
}
- inline void operator delete(void*, size_t) noexcept {
+ inline void operator delete(void*, size_t) noexcept {
}
- inline void operator delete(void*, TPool&) noexcept {
+ inline void operator delete(void*, TPool&) noexcept {
}
private:
@@ -384,7 +384,7 @@ public:
using other = TPoolAllocBase<T1, TPool>;
};
- inline size_type max_size() const noexcept {
+ inline size_type max_size() const noexcept {
return size_type(-1) / sizeof(T);
}
@@ -393,7 +393,7 @@ public:
new (p) T(std::forward<Args>(args)...);
}
- inline void destroy(pointer p) noexcept {
+ inline void destroy(pointer p) noexcept {
(void)p; /* Make MSVC happy. */
p->~T();
}
@@ -421,11 +421,11 @@ using TPoolAlloc = TPoolAllocBase<T, TMemoryPool>;
using TPoolAllocator = TPoolAlloc<int>;
template <class T>
-inline bool operator==(const TPoolAlloc<T>&, const TPoolAlloc<T>&) noexcept {
+inline bool operator==(const TPoolAlloc<T>&, const TPoolAlloc<T>&) noexcept {
return true;
}
template <class T>
-inline bool operator!=(const TPoolAlloc<T>&, const TPoolAlloc<T>&) noexcept {
+inline bool operator!=(const TPoolAlloc<T>&, const TPoolAlloc<T>&) noexcept {
return false;
}
diff --git a/util/memory/pool_ut.cpp b/util/memory/pool_ut.cpp
index 88812b2310..1158a8ca42 100644
--- a/util/memory/pool_ut.cpp
+++ b/util/memory/pool_ut.cpp
@@ -146,11 +146,11 @@ private:
: ConstructorType(2)
{
}
- TConstructorTest(const TString&, const TString&)
+ TConstructorTest(const TString&, const TString&)
: ConstructorType(3)
{
}
- TConstructorTest(TString&&, TString&&)
+ TConstructorTest(TString&&, TString&&)
: ConstructorType(4)
{
}
@@ -228,7 +228,7 @@ private:
void CheckMoveAlloc() {
TMemoryPool pool(10 * sizeof(T));
- TVector<T, TPoolAllocator> elems(&pool);
+ TVector<T, TPoolAllocator> elems(&pool);
elems.reserve(1);
elems.emplace_back();
elems.resize(100);
diff --git a/util/memory/segmented_string_pool.h b/util/memory/segmented_string_pool.h
index 1bd06d8dc7..a40aa408f5 100644
--- a/util/memory/segmented_string_pool.h
+++ b/util/memory/segmented_string_pool.h
@@ -35,7 +35,7 @@ protected:
{
}
};
- using seg_container = TVector<seg_inf>;
+ using seg_container = TVector<seg_inf>;
using seg_iterator = typename seg_container::iterator;
using seg_const_iterator = typename seg_container::const_iterator;
const size_t segment_size; // default size of a memory chunk in sizeof(T)-units
diff --git a/util/memory/segpool_alloc.h b/util/memory/segpool_alloc.h
index d2a08055a7..1a83b7a543 100644
--- a/util/memory/segpool_alloc.h
+++ b/util/memory/segpool_alloc.h
@@ -15,7 +15,7 @@
Use segpool_alloc_vt as allocator template parameter for container.
Example:
- using TSomething = THashMap<A, B, hash<A>, TEqualTo<A>, segpool_alloc_vt>;
+ using TSomething = THashMap<A, B, hash<A>, TEqualTo<A>, segpool_alloc_vt>;
...
TSomething something;
something.GetNodeAllocator().pool = &alloc_pool;
@@ -25,7 +25,7 @@
hack them, or fix segpool_alloc so that it would create ref-counted
segmented_pool object on it's own
- ! Only tested with THashMap
+ ! Only tested with THashMap
*/
template <class _Tp>
diff --git a/util/memory/smallobj.h b/util/memory/smallobj.h
index e4d71ddb4f..63de666bae 100644
--- a/util/memory/smallobj.h
+++ b/util/memory/smallobj.h
@@ -8,11 +8,11 @@
class TFixedSizeAllocator {
struct TAlloc: public TIntrusiveSListItem<TAlloc> {
- inline void* ToPointer() noexcept {
+ inline void* ToPointer() noexcept {
return this;
}
- static inline TAlloc* FromPointer(void* ptr) noexcept {
+ static inline TAlloc* FromPointer(void* ptr) noexcept {
return (TAlloc*)ptr;
}
@@ -24,7 +24,7 @@ class TFixedSizeAllocator {
return Max(alignof(TAlloc), align);
}
- static inline TAlloc* Construct(void* ptr) noexcept {
+ static inline TAlloc* Construct(void* ptr) noexcept {
return (TAlloc*)ptr;
}
};
@@ -62,11 +62,11 @@ public:
return Free_.PopFront()->ToPointer();
}
- inline void Release(void* ptr) noexcept {
+ inline void Release(void* ptr) noexcept {
Free_.PushFront(TAlloc::FromPointer(ptr));
}
- inline size_t Size() const noexcept {
+ inline size_t Size() const noexcept {
return AllocSize_;
}
@@ -96,7 +96,7 @@ public:
return (T*)Alloc_.Allocate();
}
- inline void Release(T* t) noexcept {
+ inline void Release(T* t) noexcept {
Alloc_.Release(t);
}
@@ -120,11 +120,11 @@ public:
return &ret->Obj;
}
- inline void operator delete(void* ptr, size_t) noexcept {
+ inline void operator delete(void* ptr, size_t) noexcept {
DoDelete(ptr);
}
- inline void operator delete(void* ptr, TPool*) noexcept {
+ inline void operator delete(void* ptr, TPool*) noexcept {
/*
* this delete operator can be called automagically by compiler
*/
@@ -133,7 +133,7 @@ public:
}
private:
- static inline void DoDelete(void* ptr) noexcept {
+ static inline void DoDelete(void* ptr) noexcept {
static_assert(std::is_standard_layout<THeader>::value, "offsetof is only defined for standard layout types");
THeader* header = (THeader*)((char*)ptr - offsetof(THeader, Obj));
((TPool*)header->Pool)->Release(header);
diff --git a/util/memory/smallobj_ut.cpp b/util/memory/smallobj_ut.cpp
index 78435de9bb..86003d1d53 100644
--- a/util/memory/smallobj_ut.cpp
+++ b/util/memory/smallobj_ut.cpp
@@ -61,7 +61,7 @@ private:
inline void TestAllocate() {
TClass::TPool pool(TDefaultAllocator::Instance());
- THashSet<TClass*> alloced;
+ THashSet<TClass*> alloced;
for (size_t i = 0; i < 10000; ++i) {
TClass* c = new (&pool) TClass;
diff --git a/util/memory/tempbuf.cpp b/util/memory/tempbuf.cpp
index f21b1bbc06..09a2d0f140 100644
--- a/util/memory/tempbuf.cpp
+++ b/util/memory/tempbuf.cpp
@@ -16,7 +16,7 @@
class TTempBuf::TImpl: public TRefCounted<TImpl, TSimpleCounter, TImpl> {
public:
- inline TImpl(void* data, size_t size) noexcept
+ inline TImpl(void* data, size_t size) noexcept
: Data_(data)
, Size_(size)
, Offset_(0)
@@ -29,27 +29,27 @@ public:
*/
virtual ~TImpl() = default;
- inline void* Data() noexcept {
+ inline void* Data() noexcept {
return Data_;
}
- const void* Data() const noexcept {
+ const void* Data() const noexcept {
return Data_;
}
- inline size_t Size() const noexcept {
+ inline size_t Size() const noexcept {
return Size_;
}
- inline size_t Filled() const noexcept {
+ inline size_t Filled() const noexcept {
return Offset_;
}
- inline void Reset() noexcept {
+ inline void Reset() noexcept {
Offset_ = 0;
}
- inline size_t Left() const noexcept {
+ inline size_t Left() const noexcept {
return Size() - Filled();
}
@@ -64,12 +64,12 @@ public:
Offset_ += off;
}
- static inline void Destroy(TImpl* This) noexcept {
+ static inline void Destroy(TImpl* This) noexcept {
This->Dispose();
}
protected:
- virtual void Dispose() noexcept = 0;
+ virtual void Dispose() noexcept = 0;
private:
void* Data_;
@@ -90,7 +90,7 @@ namespace {
inline ~TAllocedBuf() override = default;
private:
- void Dispose() noexcept override {
+ void Dispose() noexcept override {
delete this;
}
};
@@ -99,7 +99,7 @@ namespace {
friend class TTempBufManager;
public:
- inline TPerThreadedBuf(TTempBufManager* manager) noexcept
+ inline TPerThreadedBuf(TTempBufManager* manager) noexcept
: TImpl(Data_, sizeof(Data_))
, Manager_(manager)
{
@@ -108,7 +108,7 @@ namespace {
inline ~TPerThreadedBuf() override = default;
private:
- void Dispose() noexcept override;
+ void Dispose() noexcept override;
private:
char Data_[TMP_BUF_LEN];
@@ -117,16 +117,16 @@ namespace {
class TTempBufManager {
struct TDelete {
- inline void operator()(TPerThreadedBuf* p) noexcept {
+ inline void operator()(TPerThreadedBuf* p) noexcept {
delete p;
}
};
public:
- inline TTempBufManager() noexcept {
+ inline TTempBufManager() noexcept {
}
- inline ~TTempBufManager() {
+ inline ~TTempBufManager() {
TDelete deleter;
Unused_.ForEach(deleter);
@@ -140,7 +140,7 @@ namespace {
return new TPerThreadedBuf(this);
}
- inline void Return(TPerThreadedBuf* buf) noexcept {
+ inline void Return(TPerThreadedBuf* buf) noexcept {
buf->Reset();
Unused_.PushFront(buf);
}
@@ -163,7 +163,7 @@ static inline TTempBuf::TImpl* AcquireSmallBuffer(size_t size) {
#endif
}
-void TPerThreadedBuf::Dispose() noexcept {
+void TPerThreadedBuf::Dispose() noexcept {
if (Manager_ == TempBufManager()) {
Manager_->Return(this);
} else {
@@ -196,14 +196,14 @@ TTempBuf::TTempBuf(size_t len)
TTempBuf::TTempBuf(const TTempBuf&) noexcept = default;
-TTempBuf::TTempBuf(TTempBuf&& b) noexcept
+TTempBuf::TTempBuf(TTempBuf&& b) noexcept
: Impl_(std::move(b.Impl_))
{
}
TTempBuf::~TTempBuf() = default;
-TTempBuf& TTempBuf::operator=(const TTempBuf& b) noexcept {
+TTempBuf& TTempBuf::operator=(const TTempBuf& b) noexcept {
if (this != &b) {
Impl_ = b.Impl_;
}
@@ -211,43 +211,43 @@ TTempBuf& TTempBuf::operator=(const TTempBuf& b) noexcept {
return *this;
}
-TTempBuf& TTempBuf::operator=(TTempBuf&& b) noexcept {
- if (this != &b) {
- Impl_ = std::move(b.Impl_);
- }
-
- return *this;
-}
-
-char* TTempBuf::Data() noexcept {
+TTempBuf& TTempBuf::operator=(TTempBuf&& b) noexcept {
+ if (this != &b) {
+ Impl_ = std::move(b.Impl_);
+ }
+
+ return *this;
+}
+
+char* TTempBuf::Data() noexcept {
return (char*)Impl_->Data();
}
-const char* TTempBuf::Data() const noexcept {
+const char* TTempBuf::Data() const noexcept {
return static_cast<const char*>(Impl_->Data());
}
-size_t TTempBuf::Size() const noexcept {
+size_t TTempBuf::Size() const noexcept {
return Impl_->Size();
}
-char* TTempBuf::Current() noexcept {
+char* TTempBuf::Current() noexcept {
return Data() + Filled();
}
-const char* TTempBuf::Current() const noexcept {
+const char* TTempBuf::Current() const noexcept {
return Data() + Filled();
}
-size_t TTempBuf::Filled() const noexcept {
+size_t TTempBuf::Filled() const noexcept {
return Impl_->Filled();
}
-size_t TTempBuf::Left() const noexcept {
+size_t TTempBuf::Left() const noexcept {
return Impl_->Left();
}
-void TTempBuf::Reset() noexcept {
+void TTempBuf::Reset() noexcept {
Impl_->Reset();
}
@@ -270,7 +270,7 @@ void TTempBuf::Append(const void* data, size_t len) {
Proceed(len);
}
-bool TTempBuf::IsNull() const noexcept {
+bool TTempBuf::IsNull() const noexcept {
return !Impl_;
}
diff --git a/util/memory/tempbuf.h b/util/memory/tempbuf.h
index 15a475680e..334670eb1e 100644
--- a/util/memory/tempbuf.h
+++ b/util/memory/tempbuf.h
@@ -18,12 +18,12 @@ public:
TTempBuf();
TTempBuf(size_t len);
- TTempBuf(const TTempBuf& b) noexcept;
- TTempBuf(TTempBuf&& b) noexcept;
- ~TTempBuf();
+ TTempBuf(const TTempBuf& b) noexcept;
+ TTempBuf(TTempBuf&& b) noexcept;
+ ~TTempBuf();
- TTempBuf& operator=(const TTempBuf& b) noexcept;
- TTempBuf& operator=(TTempBuf&& b) noexcept;
+ TTempBuf& operator=(const TTempBuf& b) noexcept;
+ TTempBuf& operator=(TTempBuf&& b) noexcept;
Y_PURE_FUNCTION char* Data() noexcept;
@@ -39,7 +39,7 @@ public:
Y_PURE_FUNCTION size_t Left() const noexcept;
- void Reset() noexcept;
+ void Reset() noexcept;
void SetPos(size_t off);
char* Proceed(size_t off);
void Append(const void* data, size_t len);
@@ -53,10 +53,10 @@ private:
template <typename T>
class TTempArray: private TTempBuf {
private:
- static T* TypedPointer(char* pointer) noexcept {
+ static T* TypedPointer(char* pointer) noexcept {
return reinterpret_cast<T*>(pointer);
}
- static const T* TypedPointer(const char* pointer) noexcept {
+ static const T* TypedPointer(const char* pointer) noexcept {
return reinterpret_cast<const T*>(pointer);
}
static constexpr size_t RawSize(const size_t size) noexcept {
@@ -74,26 +74,26 @@ public:
{
}
- T* Data() noexcept {
+ T* Data() noexcept {
return TypedPointer(TTempBuf::Data());
}
- const T* Data() const noexcept {
+ const T* Data() const noexcept {
return TypedPointer(TTempBuf::Data());
}
- T* Current() noexcept {
+ T* Current() noexcept {
return TypedPointer(TTempBuf::Current());
}
- const T* Current() const noexcept {
+ const T* Current() const noexcept {
return TypedPointer(TTempBuf::Current());
}
- size_t Size() const noexcept {
+ size_t Size() const noexcept {
return TypedSize(TTempBuf::Size());
}
- size_t Filled() const noexcept {
+ size_t Filled() const noexcept {
return TypedSize(TTempBuf::Filled());
}
diff --git a/util/memory/tempbuf_ut.cpp b/util/memory/tempbuf_ut.cpp
index 8cb5fa86b7..d6bcf9d546 100644
--- a/util/memory/tempbuf_ut.cpp
+++ b/util/memory/tempbuf_ut.cpp
@@ -27,7 +27,7 @@ public:
tmp.Append("def", 3);
UNIT_ASSERT_EQUAL(tmp.Filled(), 6);
- UNIT_ASSERT_EQUAL(TString(tmp.Data(), tmp.Filled()), "abcdef");
+ UNIT_ASSERT_EQUAL(TString(tmp.Data(), tmp.Filled()), "abcdef");
}
};
diff --git a/util/network/address.cpp b/util/network/address.cpp
index 91d2608235..a81a9e6994 100644
--- a/util/network/address.cpp
+++ b/util/network/address.cpp
@@ -118,13 +118,13 @@ void NAddr::PrintHost(IOutputStream& out, const IRemoteAddr& addr) {
PrintAddr<false>(out, addr);
}
-TString NAddr::PrintHost(const IRemoteAddr& addr) {
+TString NAddr::PrintHost(const IRemoteAddr& addr) {
TStringStream ss;
PrintAddr<false>(ss, addr);
return ss.Str();
}
-TString NAddr::PrintHostAndPort(const IRemoteAddr& addr) {
+TString NAddr::PrintHostAndPort(const IRemoteAddr& addr) {
TStringStream ss;
PrintAddr<true>(ss, addr);
return ss.Str();
diff --git a/util/network/address.h b/util/network/address.h
index 7bbf25331c..448fcac0c9 100644
--- a/util/network/address.h
+++ b/util/network/address.h
@@ -4,7 +4,7 @@
#include "socket.h"
#include <util/generic/ptr.h>
-#include <util/generic/string.h>
+#include <util/generic/string.h>
namespace NAddr {
class IRemoteAddr {
@@ -22,8 +22,8 @@ namespace NAddr {
IRemoteAddrPtr GetPeerAddr(SOCKET s);
void PrintHost(IOutputStream& out, const IRemoteAddr& addr);
- TString PrintHost(const IRemoteAddr& addr);
- TString PrintHostAndPort(const IRemoteAddr& addr);
+ TString PrintHost(const IRemoteAddr& addr);
+ TString PrintHostAndPort(const IRemoteAddr& addr);
bool IsLoopback(const IRemoteAddr& addr);
bool IsSame(const IRemoteAddr& lhs, const IRemoteAddr& rhs);
@@ -33,13 +33,13 @@ namespace NAddr {
//for accept, recvfrom - see LenPtr()
class TOpaqueAddr: public IRemoteAddr {
public:
- inline TOpaqueAddr() noexcept
+ inline TOpaqueAddr() noexcept
: L_(sizeof(S_))
{
Zero(S_);
}
- inline TOpaqueAddr(const IRemoteAddr* addr) noexcept {
+ inline TOpaqueAddr(const IRemoteAddr* addr) noexcept {
Assign(addr->Addr(), addr->Len());
}
@@ -55,16 +55,16 @@ namespace NAddr {
return L_;
}
- inline sockaddr* MutableAddr() const noexcept {
+ inline sockaddr* MutableAddr() const noexcept {
return (sockaddr*)&S_;
}
- inline socklen_t* LenPtr() noexcept {
+ inline socklen_t* LenPtr() noexcept {
return &L_;
}
private:
- inline void Assign(const sockaddr* addr, socklen_t len) noexcept {
+ inline void Assign(const sockaddr* addr, socklen_t len) noexcept {
L_ = len;
memcpy(MutableAddr(), addr, L_);
}
@@ -77,7 +77,7 @@ namespace NAddr {
//for TNetworkAddress
class TAddrInfo: public IRemoteAddr {
public:
- inline TAddrInfo(const addrinfo* ai) noexcept
+ inline TAddrInfo(const addrinfo* ai) noexcept
: AI_(ai)
{
}
@@ -97,7 +97,7 @@ namespace NAddr {
//compat, for TIpAddress
class TIPv4Addr: public IRemoteAddr {
public:
- inline TIPv4Addr(const TIpAddress& addr) noexcept
+ inline TIPv4Addr(const TIpAddress& addr) noexcept
: A_(addr)
{
}
@@ -117,7 +117,7 @@ namespace NAddr {
//same, for ipv6 addresses
class TIPv6Addr: public IRemoteAddr {
public:
- inline TIPv6Addr(const sockaddr_in6& a) noexcept
+ inline TIPv6Addr(const sockaddr_in6& a) noexcept
: A_(a)
{
}
diff --git a/util/network/address_ut.cpp b/util/network/address_ut.cpp
index 71d225c692..28f45172ff 100644
--- a/util/network/address_ut.cpp
+++ b/util/network/address_ut.cpp
@@ -9,12 +9,12 @@ Y_UNIT_TEST_SUITE(IRemoteAddr_ToString) {
THolder<TOpaqueAddr> opaque(new TOpaqueAddr);
IRemoteAddr* addr = opaque.Get();
- TString s = ToString(*addr);
+ TString s = ToString(*addr);
UNIT_ASSERT_VALUES_EQUAL("(raw all zeros)", s);
opaque->MutableAddr()->sa_data[10] = 17;
- TString t = ToString(*addr);
+ TString t = ToString(*addr);
UNIT_ASSERT_C(t.StartsWith("(raw 0 0"), t);
UNIT_ASSERT_C(t.EndsWith(')'), t);
@@ -25,8 +25,8 @@ Y_UNIT_TEST_SUITE(IRemoteAddr_ToString) {
TNetworkAddress::TIterator it = address.Begin();
UNIT_ASSERT(it != address.End());
UNIT_ASSERT(it->ai_family == AF_INET6);
- TString toString = ToString((const IRemoteAddr&)TAddrInfo(&*it));
- UNIT_ASSERT_VALUES_EQUAL(TString("[::1]:22"), toString);
+ TString toString = ToString((const IRemoteAddr&)TAddrInfo(&*it));
+ UNIT_ASSERT_VALUES_EQUAL(TString("[::1]:22"), toString);
}
Y_UNIT_TEST(Loopback) {
diff --git a/util/network/endpoint.cpp b/util/network/endpoint.cpp
index 3b1ee85c4a..9acdd06940 100644
--- a/util/network/endpoint.cpp
+++ b/util/network/endpoint.cpp
@@ -32,7 +32,7 @@ void TEndpoint::SetPort(ui16 port) {
}
}
-ui16 TEndpoint::Port() const noexcept {
+ui16 TEndpoint::Port() const noexcept {
if (Addr_->Addr()->sa_family == AF_UNIX) {
return 0;
}
diff --git a/util/network/endpoint.h b/util/network/endpoint.h
index abd58c15a0..a3e59b4925 100644
--- a/util/network/endpoint.h
+++ b/util/network/endpoint.h
@@ -12,7 +12,7 @@ public:
TEndpoint(const TAddrRef& addr);
TEndpoint();
- inline const TAddrRef& Addr() const noexcept {
+ inline const TAddrRef& Addr() const noexcept {
return Addr_;
}
inline const sockaddr* SockAddr() const {
@@ -32,12 +32,12 @@ public:
return Addr_->Addr()->sa_family == AF_UNIX;
}
- inline TString IpToString() const {
+ inline TString IpToString() const {
return NAddr::PrintHost(*Addr_);
}
void SetPort(ui16 port);
- ui16 Port() const noexcept;
+ ui16 Port() const noexcept;
size_t Hash() const;
diff --git a/util/network/endpoint_ut.cpp b/util/network/endpoint_ut.cpp
index 69117dd3d3..d5e40dd6e1 100644
--- a/util/network/endpoint_ut.cpp
+++ b/util/network/endpoint_ut.cpp
@@ -7,7 +7,7 @@
Y_UNIT_TEST_SUITE(TEndpointTest) {
Y_UNIT_TEST(TestSimple) {
- TVector<TNetworkAddress> addrs;
+ TVector<TNetworkAddress> addrs;
TEndpoint ep0;
@@ -64,7 +64,7 @@ Y_UNIT_TEST_SUITE(TEndpointTest) {
ep3_.SetPort(54321);
- THashSet<TEndpoint> he;
+ THashSet<TEndpoint> he;
he.insert(ep0);
he.insert(ep1);
@@ -87,8 +87,8 @@ Y_UNIT_TEST_SUITE(TEndpointTest) {
}
Y_UNIT_TEST(TestEqual) {
- const TString ip1 = "2a02:6b8:0:1410::5f6c:f3c2";
- const TString ip2 = "2a02:6b8:0:1410::5f6c:f3c3";
+ const TString ip1 = "2a02:6b8:0:1410::5f6c:f3c2";
+ const TString ip2 = "2a02:6b8:0:1410::5f6c:f3c3";
TNetworkAddress na1(ip1, 24242);
TEndpoint ep1(new NAddr::TAddrInfo(&*na1.Begin()));
diff --git a/util/network/interface.cpp b/util/network/interface.cpp
index c4652c3c28..256776c6d3 100644
--- a/util/network/interface.cpp
+++ b/util/network/interface.cpp
@@ -18,7 +18,7 @@ namespace NAddr {
TNetworkInterfaceList result;
#ifdef _win_
- TVector<char> buf;
+ TVector<char> buf;
buf.resize(1000000);
PIP_ADAPTER_ADDRESSES adapterBuf = (PIP_ADAPTER_ADDRESSES)&buf[0];
ULONG bufSize = buf.ysize();
diff --git a/util/network/interface.h b/util/network/interface.h
index c828144b08..dda4555021 100644
--- a/util/network/interface.h
+++ b/util/network/interface.h
@@ -6,12 +6,12 @@
namespace NAddr {
struct TNetworkInterface {
- TString Name;
+ TString Name;
IRemoteAddrRef Address;
IRemoteAddrRef Mask;
};
- using TNetworkInterfaceList = TVector<TNetworkInterface>;
+ using TNetworkInterfaceList = TVector<TNetworkInterface>;
TNetworkInterfaceList GetNetworkInterfaces();
}
diff --git a/util/network/iovec.h b/util/network/iovec.h
index 46b753cee8..ac15a41f54 100644
--- a/util/network/iovec.h
+++ b/util/network/iovec.h
@@ -14,7 +14,7 @@ public:
{
}
- inline void Proceed(size_t len) noexcept {
+ inline void Proceed(size_t len) noexcept {
while (Count_) {
if (len < Parts_->len) {
Parts_->len -= len;
@@ -33,15 +33,15 @@ public:
}
}
- inline const TPart* Parts() const noexcept {
+ inline const TPart* Parts() const noexcept {
return Parts_;
}
- inline size_t Count() const noexcept {
+ inline size_t Count() const noexcept {
return Count_;
}
- static inline size_t Bytes(const TPart* parts, size_t count) noexcept {
+ static inline size_t Bytes(const TPart* parts, size_t count) noexcept {
size_t ret = 0;
for (size_t i = 0; i < count; ++i) {
@@ -51,11 +51,11 @@ public:
return ret;
}
- inline size_t Bytes() const noexcept {
+ inline size_t Bytes() const noexcept {
return Bytes(Parts_, Count_);
}
- inline bool Complete() const noexcept {
+ inline bool Complete() const noexcept {
return !Count();
}
diff --git a/util/network/ip.h b/util/network/ip.h
index acaa1a9146..dc7c2d24a0 100644
--- a/util/network/ip.h
+++ b/util/network/ip.h
@@ -5,7 +5,7 @@
#include <util/system/error.h>
#include <util/system/byteorder.h>
-#include <util/generic/string.h>
+#include <util/generic/string.h>
#include <util/generic/yexception.h>
/// IPv4 address in network format
@@ -36,15 +36,15 @@ static inline char* IpToString(TIpHost ip, char* buf, size_t len) {
return buf;
}
-static inline TString IpToString(TIpHost ip) {
+static inline TString IpToString(TIpHost ip) {
char buf[INET_ADDRSTRLEN];
- return TString(IpToString(ip, buf, sizeof(buf)));
+ return TString(IpToString(ip, buf, sizeof(buf)));
}
static inline TIpHost ResolveHost(const char* data, size_t len) {
TIpHost ret;
- const TString s(data, len);
+ const TString s(data, len);
if (NResolver::GetHostIP(s.data(), &ret) != 0) {
ythrow TSystemError(NResolver::GetDnsError()) << "can not resolve(" << s << ")";
@@ -55,17 +55,17 @@ static inline TIpHost ResolveHost(const char* data, size_t len) {
/// socket address
struct TIpAddress: public sockaddr_in {
- inline TIpAddress() noexcept {
+ inline TIpAddress() noexcept {
Clear();
}
- inline TIpAddress(const sockaddr_in& addr) noexcept
+ inline TIpAddress(const sockaddr_in& addr) noexcept
: sockaddr_in(addr)
, tmp(0)
{
}
- inline TIpAddress(TIpHost ip, TIpPort port) noexcept {
+ inline TIpAddress(TIpHost ip, TIpPort port) noexcept {
Set(ip, port);
}
@@ -77,27 +77,27 @@ struct TIpAddress: public sockaddr_in {
Set(ResolveHost(ip, strlen(ip)), port);
}
- inline operator sockaddr*() const noexcept {
+ inline operator sockaddr*() const noexcept {
return (sockaddr*)(sockaddr_in*)this;
}
- inline operator socklen_t*() const noexcept {
+ inline operator socklen_t*() const noexcept {
tmp = sizeof(sockaddr_in);
return (socklen_t*)&tmp;
}
- inline operator socklen_t() const noexcept {
+ inline operator socklen_t() const noexcept {
tmp = sizeof(sockaddr_in);
return tmp;
}
- inline void Clear() noexcept {
+ inline void Clear() noexcept {
Zero((sockaddr_in&)(*this));
}
- inline void Set(TIpHost ip, TIpPort port) noexcept {
+ inline void Set(TIpHost ip, TIpPort port) noexcept {
Clear();
sin_family = AF_INET;
@@ -105,11 +105,11 @@ struct TIpAddress: public sockaddr_in {
sin_port = HostToInet(port);
}
- inline TIpHost Host() const noexcept {
+ inline TIpHost Host() const noexcept {
return sin_addr.s_addr;
}
- inline TIpPort Port() const noexcept {
+ inline TIpPort Port() const noexcept {
return InetToHost(sin_port);
}
diff --git a/util/network/nonblock.cpp b/util/network/nonblock.cpp
index bee7ec539d..e515c27cc5 100644
--- a/util/network/nonblock.cpp
+++ b/util/network/nonblock.cpp
@@ -85,7 +85,7 @@ namespace {
return ret;
}
- static inline const TFeatureCheck* Instance() noexcept {
+ static inline const TFeatureCheck* Instance() noexcept {
return Singleton<TFeatureCheck>();
}
diff --git a/util/network/poller.h b/util/network/poller.h
index 28476bffc9..8dccd73140 100644
--- a/util/network/poller.h
+++ b/util/network/poller.h
@@ -8,7 +8,7 @@
class TSocketPoller {
public:
TSocketPoller();
- ~TSocketPoller();
+ ~TSocketPoller();
void WaitRead(SOCKET sock, void* cookie);
void WaitWrite(SOCKET sock, void* cookie);
diff --git a/util/network/pollerimpl.h b/util/network/pollerimpl.h
index 196092cecd..e8c7e40fba 100644
--- a/util/network/pollerimpl.h
+++ b/util/network/pollerimpl.h
@@ -7,7 +7,7 @@
#include <util/system/defaults.h>
#include <util/generic/ylimits.h>
#include <util/generic/utility.h>
-#include <util/generic/vector.h>
+#include <util/generic/vector.h>
#include <util/generic/yexception.h>
#include <util/datetime/base.h>
@@ -40,7 +40,7 @@ enum EContPoll {
CONT_POLL_BACKLOG_EMPTY = 64, // Backlog is empty (seen end of request, EAGAIN or truncated read)
};
-static inline bool IsSocket(SOCKET fd) noexcept {
+static inline bool IsSocket(SOCKET fd) noexcept {
int val = 0;
socklen_t len = sizeof(val);
@@ -51,7 +51,7 @@ static inline bool IsSocket(SOCKET fd) noexcept {
return LastSystemError() != ENOTSOCK;
}
-static inline int MicroToMilli(int timeout) noexcept {
+static inline int MicroToMilli(int timeout) noexcept {
if (timeout) {
/*
* 1. API of epoll syscall allows to specify timeout with millisecond
@@ -74,7 +74,7 @@ struct TWithoutLocking {
#if defined(HAVE_KQUEUE_POLLER)
static inline int Kevent(int kq, struct kevent* changelist, int nchanges,
- struct kevent* eventlist, int nevents, const struct timespec* timeout) noexcept {
+ struct kevent* eventlist, int nevents, const struct timespec* timeout) noexcept {
int ret;
do {
@@ -97,11 +97,11 @@ public:
}
}
- inline ~TKqueuePoller() {
+ inline ~TKqueuePoller() {
close(Fd_);
}
- inline int Fd() const noexcept {
+ inline int Fd() const noexcept {
return Fd_;
}
@@ -131,7 +131,7 @@ public:
}
}
- inline void Remove(int fd) noexcept {
+ inline void Remove(int fd) noexcept {
TEvent e[2];
Zero(e);
@@ -142,7 +142,7 @@ public:
Y_VERIFY(!(Kevent(Fd_, e, 2, nullptr, 0, nullptr) == -1 && errno != ENOENT), "kevent remove failed: %s", LastSystemErrorText());
}
- inline size_t Wait(TEvent* events, size_t len, int timeout) noexcept {
+ inline size_t Wait(TEvent* events, size_t len, int timeout) noexcept {
struct timespec ts;
ts.tv_sec = timeout / 1000000;
@@ -155,11 +155,11 @@ public:
return (size_t)ret;
}
- static inline void* ExtractEvent(const TEvent* event) noexcept {
+ static inline void* ExtractEvent(const TEvent* event) noexcept {
return event->udata;
}
- static inline int ExtractStatus(const TEvent* event) noexcept {
+ static inline int ExtractStatus(const TEvent* event) noexcept {
if (event->flags & EV_ERROR) {
return EIO;
}
@@ -167,7 +167,7 @@ public:
return event->fflags;
}
- static inline int ExtractFilterImpl(const TEvent* event) noexcept {
+ static inline int ExtractFilterImpl(const TEvent* event) noexcept {
if (event->filter == EVFILT_READ) {
return CONT_POLL_READ;
}
@@ -189,7 +189,7 @@ private:
#endif
#if defined(HAVE_EPOLL_POLLER)
-static inline int ContEpollWait(int epfd, struct epoll_event* events, int maxevents, int timeout) noexcept {
+static inline int ContEpollWait(int epfd, struct epoll_event* events, int maxevents, int timeout) noexcept {
int ret;
do {
@@ -212,11 +212,11 @@ public:
}
}
- inline ~TEpollPoller() {
+ inline ~TEpollPoller() {
close(Fd_);
}
- inline int Fd() const noexcept {
+ inline int Fd() const noexcept {
return Fd_;
}
@@ -258,7 +258,7 @@ public:
}
}
- inline void Remove(int fd) noexcept {
+ inline void Remove(int fd) noexcept {
TEvent e;
Zero(e);
@@ -266,7 +266,7 @@ public:
epoll_ctl(Fd_, EPOLL_CTL_DEL, fd, &e);
}
- inline size_t Wait(TEvent* events, size_t len, int timeout) noexcept {
+ inline size_t Wait(TEvent* events, size_t len, int timeout) noexcept {
const int ret = ContEpollWait(Fd_, events, len, MicroToMilli(timeout));
Y_VERIFY(ret >= 0, "epoll wait error: %s", LastSystemErrorText());
@@ -274,11 +274,11 @@ public:
return (size_t)ret;
}
- static inline void* ExtractEvent(const TEvent* event) noexcept {
+ static inline void* ExtractEvent(const TEvent* event) noexcept {
return event->data.ptr;
}
- static inline int ExtractStatus(const TEvent* event) noexcept {
+ static inline int ExtractStatus(const TEvent* event) noexcept {
if (event->events & (EPOLLERR | EPOLLHUP)) {
return EIO;
}
@@ -286,7 +286,7 @@ public:
return 0;
}
- static inline int ExtractFilterImpl(const TEvent* event) noexcept {
+ static inline int ExtractFilterImpl(const TEvent* event) noexcept {
int ret = 0;
if (event->events & EPOLLIN) {
@@ -315,7 +315,7 @@ private:
#include "pair.h"
-static inline int ContSelect(int n, fd_set* r, fd_set* w, fd_set* e, struct timeval* t) noexcept {
+static inline int ContSelect(int n, fd_set* r, fd_set* w, fd_set* e, struct timeval* t) noexcept {
int ret;
do {
@@ -336,11 +336,11 @@ struct TSelectPollerNoTemplate {
{
}
- inline void* Data() const noexcept {
+ inline void* Data() const noexcept {
return Data_;
}
- inline void Set(void* d, int s) noexcept {
+ inline void Set(void* d, int s) noexcept {
Data_ = d;
Filter_ = s;
}
@@ -349,12 +349,12 @@ struct TSelectPollerNoTemplate {
Filter_ &= ~c;
}
- inline int Filter() const noexcept {
+ inline int Filter() const noexcept {
return Filter_;
}
};
- class TFds: public THashMap<SOCKET, THandle> {
+ class TFds: public THashMap<SOCKET, THandle> {
public:
inline void Set(SOCKET fd, void* data, int filter) {
(*this)[fd].Set(data, filter);
@@ -364,7 +364,7 @@ struct TSelectPollerNoTemplate {
erase(fd);
}
- inline SOCKET Build(fd_set* r, fd_set* w, fd_set* e) const noexcept {
+ inline SOCKET Build(fd_set* r, fd_set* w, fd_set* e) const noexcept {
SOCKET ret = 0;
for (const auto& it : *this) {
@@ -391,15 +391,15 @@ struct TSelectPollerNoTemplate {
};
struct TEvent: public THandle {
- inline int Status() const noexcept {
+ inline int Status() const noexcept {
return -Min(Filter(), 0);
}
- inline void Error(void* d, int err) noexcept {
+ inline void Error(void* d, int err) noexcept {
Set(d, -err);
}
- inline void Success(void* d, int what) noexcept {
+ inline void Success(void* d, int what) noexcept {
Set(d, what);
}
};
@@ -419,7 +419,7 @@ public:
SetNonBlock(SigSock());
}
- inline ~TSelectPoller() {
+ inline ~TSelectPoller() {
closesocket(Signal_[0]);
closesocket(Signal_[1]);
}
@@ -432,7 +432,7 @@ public:
Signal();
}
- inline void Remove(SOCKET fd) noexcept {
+ inline void Remove(SOCKET fd) noexcept {
with_lock (CommandLock_) {
Commands_.push_back(TCommand(fd, 0));
}
@@ -440,7 +440,7 @@ public:
Signal();
}
- inline size_t Wait(TEvent* events, size_t len, int timeout) noexcept {
+ inline size_t Wait(TEvent* events, size_t len, int timeout) noexcept {
auto guard = Guard(Lock_);
do {
@@ -472,7 +472,7 @@ public:
return SavedEvents_.Get();
}
- inline size_t WaitBase(TEvent* events, size_t len, int timeout) noexcept {
+ inline size_t WaitBase(TEvent* events, size_t len, int timeout) noexcept {
with_lock (CommandLock_) {
for (auto command = Commands_.begin(); command != Commands_.end(); ++command) {
if (command->Filter_ != 0) {
@@ -571,24 +571,24 @@ public:
return events - eventsStart;
}
- inline size_t EventNumberHint() const noexcept {
+ inline size_t EventNumberHint() const noexcept {
return sizeof(fd_set) * 8 * 2;
}
- static inline void* ExtractEvent(const TEvent* event) noexcept {
+ static inline void* ExtractEvent(const TEvent* event) noexcept {
return event->Data();
}
- static inline int ExtractStatus(const TEvent* event) noexcept {
+ static inline int ExtractStatus(const TEvent* event) noexcept {
return event->Status();
}
- static inline int ExtractFilterImpl(const TEvent* event) noexcept {
+ static inline int ExtractFilterImpl(const TEvent* event) noexcept {
return event->Filter();
}
private:
- inline void Signal() noexcept {
+ inline void Signal() noexcept {
char ch = 13;
send(SigSock(), &ch, 1, 0);
@@ -602,11 +602,11 @@ private:
}
}
- inline SOCKET WaitSock() const noexcept {
+ inline SOCKET WaitSock() const noexcept {
return Signal_[1];
}
- inline SOCKET SigSock() const noexcept {
+ inline SOCKET SigSock() const noexcept {
return Signal_[0];
}
@@ -638,13 +638,13 @@ private:
TEvent* End_;
TMyMutex CommandLock_;
- TVector<TCommand> Commands_;
+ TVector<TCommand> Commands_;
SOCKET Signal_[2];
};
#endif
-static inline TDuration PollStep(const TInstant& deadLine, const TInstant& now) noexcept {
+static inline TDuration PollStep(const TInstant& deadLine, const TInstant& now) noexcept {
if (deadLine < now) {
return TDuration::Zero();
}
@@ -667,7 +667,7 @@ public:
}
}
- static inline int ExtractFilter(const TEvent* event) noexcept {
+ static inline int ExtractFilter(const TEvent* event) noexcept {
if (TBase::ExtractStatus(event)) {
return CONT_POLL_READ | CONT_POLL_WRITE | CONT_POLL_RDHUP;
}
@@ -675,7 +675,7 @@ public:
return TBase::ExtractFilterImpl(event);
}
- inline size_t WaitD(TEvent* events, size_t len, TInstant deadLine, TInstant now = TInstant::Now()) noexcept {
+ inline size_t WaitD(TEvent* events, size_t len, TInstant deadLine, TInstant now = TInstant::Now()) noexcept {
if (!len) {
return 0;
}
diff --git a/util/network/sock.h b/util/network/sock.h
index b651ab6296..b10be2f715 100644
--- a/util/network/sock.h
+++ b/util/network/sock.h
@@ -30,7 +30,7 @@ struct ISockAddr {
virtual sockaddr* SockAddr() = 0;
virtual const sockaddr* SockAddr() const = 0;
// address in human readable form
- virtual TString ToString() const = 0;
+ virtual TString ToString() const = 0;
protected:
// below are the implemetation methods that can be called by T*Socket classes
@@ -64,12 +64,12 @@ struct TSockAddrLocal: public ISockAddr {
return Size();
}
- inline void Clear() noexcept {
+ inline void Clear() noexcept {
Zero(in);
Zero(Path);
}
- inline void Set(const char* path) noexcept {
+ inline void Set(const char* path) noexcept {
Clear();
in.sin_family = AF_INET;
in.sin_addr.s_addr = IpFromString("127.0.0.1");
@@ -85,8 +85,8 @@ struct TSockAddrLocal: public ISockAddr {
return (const struct sockaddr*)(&in);
}
- TString ToString() const {
- return TString(Path);
+ TString ToString() const {
+ return TString(Path);
}
TFsPath ToPath() const {
@@ -160,11 +160,11 @@ struct TSockAddrLocal: public sockaddr_un, public ISockAddr {
return strlen(sun_path) + 2;
}
- inline void Clear() noexcept {
+ inline void Clear() noexcept {
Zero(*(sockaddr_un*)this);
}
- inline void Set(const char* path) noexcept {
+ inline void Set(const char* path) noexcept {
Clear();
sun_family = AF_UNIX;
strlcpy(sun_path, path, sizeof(sun_path));
@@ -178,8 +178,8 @@ struct TSockAddrLocal: public sockaddr_un, public ISockAddr {
return (const struct sockaddr*)(const struct sockaddr_un*)this;
}
- TString ToString() const override {
- return TString(sun_path);
+ TString ToString() const override {
+ return TString(sun_path);
}
TFsPath ToPath() const {
@@ -222,11 +222,11 @@ struct TSockAddrInet: public sockaddr_in, public ISockAddr {
return Size();
}
- inline void Clear() noexcept {
+ inline void Clear() noexcept {
Zero(*(sockaddr_in*)this);
}
- inline void Set(TIpHost ip, TIpPort port) noexcept {
+ inline void Set(TIpHost ip, TIpPort port) noexcept {
Clear();
sin_family = AF_INET;
sin_addr.s_addr = ip;
@@ -241,7 +241,7 @@ struct TSockAddrInet: public sockaddr_in, public ISockAddr {
return (const struct sockaddr*)(const struct sockaddr_in*)this;
}
- TString ToString() const override {
+ TString ToString() const override {
return IpToString(sin_addr.s_addr) + ":" + ::ToString(InetToHost(sin_port));
}
@@ -258,11 +258,11 @@ struct TSockAddrInet: public sockaddr_in, public ISockAddr {
return 0;
}
- TIpHost GetIp() const noexcept {
+ TIpHost GetIp() const noexcept {
return sin_addr.s_addr;
}
- TIpPort GetPort() const noexcept {
+ TIpPort GetPort() const noexcept {
return InetToHost(sin_port);
}
@@ -288,11 +288,11 @@ struct TSockAddrInet6: public sockaddr_in6, public ISockAddr {
return Size();
}
- inline void Clear() noexcept {
+ inline void Clear() noexcept {
Zero(*(sockaddr_in6*)this);
}
- inline void Set(const char* ip6, const TIpPort port) noexcept {
+ inline void Set(const char* ip6, const TIpPort port) noexcept {
Clear();
sin6_family = AF_INET6;
inet_pton(AF_INET6, ip6, &sin6_addr);
@@ -307,7 +307,7 @@ struct TSockAddrInet6: public sockaddr_in6, public ISockAddr {
return (const struct sockaddr*)(const struct sockaddr_in6*)this;
}
- TString ToString() const override {
+ TString ToString() const override {
return "[" + GetIp() + "]:" + ::ToString(InetToHost(sin6_port));
}
@@ -324,13 +324,13 @@ struct TSockAddrInet6: public sockaddr_in6, public ISockAddr {
return 0;
}
- TString GetIp() const noexcept {
+ TString GetIp() const noexcept {
char ip6[INET6_ADDRSTRLEN];
inet_ntop(AF_INET6, (void*)&sin6_addr, ip6, INET6_ADDRSTRLEN);
- return TString(ip6);
+ return TString(ip6);
}
- TIpPort GetPort() const noexcept {
+ TIpPort GetPort() const noexcept {
return InetToHost(sin6_port);
}
@@ -583,9 +583,9 @@ public:
Socket = socket;
}
- TStreamSocketOutput(TStreamSocketOutput&&) noexcept = default;
- TStreamSocketOutput& operator=(TStreamSocketOutput&&) noexcept = default;
-
+ TStreamSocketOutput(TStreamSocketOutput&&) noexcept = default;
+ TStreamSocketOutput& operator=(TStreamSocketOutput&&) noexcept = default;
+
protected:
TStreamSocket* Socket;
diff --git a/util/network/socket.cpp b/util/network/socket.cpp
index 7f117a47b7..4f6e804346 100644
--- a/util/network/socket.cpp
+++ b/util/network/socket.cpp
@@ -103,7 +103,7 @@ static const evpair evpairs_to_unix[] = {
static const size_t nevpairs_to_unix = sizeof(evpairs_to_unix) / sizeof(evpairs_to_unix[0]);
-static int convert_events(int events, const evpair* evpairs, size_t nevpairs, bool ignoreUnknown) noexcept {
+static int convert_events(int events, const evpair* evpairs, size_t nevpairs, bool ignoreUnknown) noexcept {
int result = 0;
for (size_t i = 0; i < nevpairs; ++i) {
int event = evpairs[i].event;
@@ -127,21 +127,21 @@ private:
HANDLE Event;
public:
- inline TWSAEventHolder(HANDLE event) noexcept
+ inline TWSAEventHolder(HANDLE event) noexcept
: Event(event)
{
}
- inline ~TWSAEventHolder() {
+ inline ~TWSAEventHolder() {
WSACloseEvent(Event);
}
- inline HANDLE Get() noexcept {
+ inline HANDLE Get() noexcept {
return Event;
}
};
-int poll(struct pollfd fds[], nfds_t nfds, int timeout) noexcept {
+int poll(struct pollfd fds[], nfds_t nfds, int timeout) noexcept {
HANDLE rawEvent = WSACreateEvent();
if (rawEvent == WSA_INVALID_EVENT) {
errno = EIO;
@@ -553,7 +553,7 @@ static ssize_t DoSendMsg(SOCKET sock, const struct iovec* iov, int iovcnt) {
}
#endif
-void TSocketHolder::Close() noexcept {
+void TSocketHolder::Close() noexcept {
if (Fd_ != INVALID_SOCKET) {
bool ok = (closesocket(Fd_) == 0);
if (!ok) {
@@ -585,7 +585,7 @@ public:
inline ~TImpl() = default;
- inline SOCKET Fd() const noexcept {
+ inline SOCKET Fd() const noexcept {
return Fd_;
}
@@ -752,7 +752,7 @@ class TCommonSockOps: public TSocket::TOps {
using TPart = TSocket::TPart;
public:
- inline TCommonSockOps() noexcept {
+ inline TCommonSockOps() noexcept {
}
~TCommonSockOps() override = default;
@@ -832,7 +832,7 @@ ssize_t TCommonSockOps::SendVPartial(SOCKET fd, const TPart* constParts, size_t
return written;
}
-static inline TSocket::TOps* GetCommonSockOps() noexcept {
+static inline TSocket::TOps* GetCommonSockOps() noexcept {
return Singleton<TCommonSockOps>();
}
@@ -868,7 +868,7 @@ TSocket::TSocket(const TNetworkAddress& addr, const TInstant& deadLine)
TSocket::~TSocket() = default;
-SOCKET TSocket::Fd() const noexcept {
+SOCKET TSocket::Fd() const noexcept {
return Impl_->Fd();
}
@@ -888,7 +888,7 @@ void TSocket::Close() {
Impl_->Close();
}
-TSocketInput::TSocketInput(const TSocket& s) noexcept
+TSocketInput::TSocketInput(const TSocket& s) noexcept
: S_(s)
{
}
@@ -905,12 +905,12 @@ size_t TSocketInput::DoRead(void* buf, size_t len) {
ythrow TSystemError(-(int)ret) << "can not read from socket input stream";
}
-TSocketOutput::TSocketOutput(const TSocket& s) noexcept
+TSocketOutput::TSocketOutput(const TSocket& s) noexcept
: S_(s)
{
}
-TSocketOutput::~TSocketOutput() {
+TSocketOutput::~TSocketOutput() {
try {
Finish();
} catch (...) {
@@ -947,7 +947,7 @@ void TSocketOutput::DoWriteV(const TPart* parts, size_t count) {
namespace {
//https://bugzilla.mozilla.org/attachment.cgi?id=503263&action=diff
- struct TLocalNames: public THashSet<TStringBuf> {
+ struct TLocalNames: public THashSet<TStringBuf> {
inline TLocalNames() {
insert("localhost");
insert("localhost.localdomain");
@@ -1004,7 +1004,7 @@ public:
inline TImpl(const char* host, ui16 port, int flags)
: Info_(nullptr, TAddrInfoDeleter{})
{
- const TString port_st(ToString(port));
+ const TString port_st(ToString(port));
struct addrinfo hints;
memset(&hints, 0, sizeof(hints));
@@ -1054,7 +1054,7 @@ public:
Info_.reset(hints.release());
}
- inline struct addrinfo* Info() const noexcept {
+ inline struct addrinfo* Info() const noexcept {
return Info_.get();
}
@@ -1069,12 +1069,12 @@ TNetworkAddress::TNetworkAddress(const TUnixSocketPath& unixSocketPath, int flag
{
}
-TNetworkAddress::TNetworkAddress(const TString& host, ui16 port, int flags)
+TNetworkAddress::TNetworkAddress(const TString& host, ui16 port, int flags)
: Impl_(new TImpl(host.data(), port, flags))
{
}
-TNetworkAddress::TNetworkAddress(const TString& host, ui16 port)
+TNetworkAddress::TNetworkAddress(const TString& host, ui16 port)
: Impl_(new TImpl(host.data(), port, 0))
{
}
@@ -1086,7 +1086,7 @@ TNetworkAddress::TNetworkAddress(ui16 port)
TNetworkAddress::~TNetworkAddress() = default;
-struct addrinfo* TNetworkAddress::Info() const noexcept {
+struct addrinfo* TNetworkAddress::Info() const noexcept {
return Impl_->Info();
}
@@ -1227,7 +1227,7 @@ void SetDeferAccept(SOCKET s) {
#endif
}
-ssize_t PollD(struct pollfd fds[], nfds_t nfds, const TInstant& deadLine) noexcept {
+ssize_t PollD(struct pollfd fds[], nfds_t nfds, const TInstant& deadLine) noexcept {
TInstant now = TInstant::Now();
do {
diff --git a/util/network/socket.h b/util/network/socket.h
index e19b77a5b6..40c8648b40 100644
--- a/util/network/socket.h
+++ b/util/network/socket.h
@@ -42,7 +42,7 @@ struct pollfd {
#define POLLNVAL (1 << 9)
const char* inet_ntop(int af, const void* src, char* dst, socklen_t size);
-int poll(struct pollfd fds[], nfds_t nfds, int timeout) noexcept;
+int poll(struct pollfd fds[], nfds_t nfds, int timeout) noexcept;
#else
#define poll(fds, nfds, timeout) WSAPoll(fds, nfds, timeout)
#endif
@@ -59,12 +59,12 @@ int inet_aton(const char* cp, struct in_addr* inp);
#endif
template <class T>
-static inline int SetSockOpt(SOCKET s, int level, int optname, T opt) noexcept {
+static inline int SetSockOpt(SOCKET s, int level, int optname, T opt) noexcept {
return setsockopt(s, level, optname, (const char*)&opt, sizeof(opt));
}
template <class T>
-static inline int GetSockOpt(SOCKET s, int level, int optname, T& opt) noexcept {
+static inline int GetSockOpt(SOCKET s, int level, int optname, T& opt) noexcept {
socklen_t len = sizeof(opt);
return getsockopt(s, level, optname, (char*)&opt, &len);
@@ -174,11 +174,11 @@ public:
{
}
- inline void Next() noexcept {
+ inline void Next() noexcept {
C_ = C_->ai_next;
}
- inline TIterator operator++(int) noexcept {
+ inline TIterator operator++(int) noexcept {
TIterator old(*this);
Next();
@@ -186,25 +186,25 @@ public:
return old;
}
- inline TIterator& operator++() noexcept {
+ inline TIterator& operator++() noexcept {
Next();
return *this;
}
- friend inline bool operator==(const TIterator& l, const TIterator& r) noexcept {
+ friend inline bool operator==(const TIterator& l, const TIterator& r) noexcept {
return l.C_ == r.C_;
}
- friend inline bool operator!=(const TIterator& l, const TIterator& r) noexcept {
+ friend inline bool operator!=(const TIterator& l, const TIterator& r) noexcept {
return !(l == r);
}
- inline struct addrinfo& operator*() const noexcept {
+ inline struct addrinfo& operator*() const noexcept {
return *C_;
}
- inline struct addrinfo* operator->() const noexcept {
+ inline struct addrinfo* operator->() const noexcept {
return C_;
}
@@ -213,21 +213,21 @@ public:
};
TNetworkAddress(ui16 port);
- TNetworkAddress(const TString& host, ui16 port);
- TNetworkAddress(const TString& host, ui16 port, int flags);
+ TNetworkAddress(const TString& host, ui16 port);
+ TNetworkAddress(const TString& host, ui16 port, int flags);
TNetworkAddress(const TUnixSocketPath& unixSocketPath, int flags = 0);
- ~TNetworkAddress();
+ ~TNetworkAddress();
- inline TIterator Begin() const noexcept {
+ inline TIterator Begin() const noexcept {
return TIterator(Info());
}
- inline TIterator End() const noexcept {
+ inline TIterator End() const noexcept {
return TIterator(nullptr);
}
private:
- struct addrinfo* Info() const noexcept;
+ struct addrinfo* Info() const noexcept;
private:
class TImpl;
@@ -260,31 +260,31 @@ public:
return *this;
}
- inline ~TSocketHolder() {
+ inline ~TSocketHolder() {
Close();
}
- inline SOCKET Release() noexcept {
+ inline SOCKET Release() noexcept {
SOCKET ret = Fd_;
Fd_ = INVALID_SOCKET;
return ret;
}
- void Close() noexcept;
+ void Close() noexcept;
inline void ShutDown(int mode) const {
::ShutDown(Fd_, mode);
}
- inline void Swap(TSocketHolder& r) noexcept {
+ inline void Swap(TSocketHolder& r) noexcept {
DoSwap(Fd_, r.Fd_);
}
- inline bool Closed() const noexcept {
+ inline bool Closed() const noexcept {
return Fd_ == INVALID_SOCKET;
}
- inline operator SOCKET() const noexcept {
+ inline operator SOCKET() const noexcept {
return Fd_;
}
@@ -316,7 +316,7 @@ public:
TSocket(const TNetworkAddress& addr, const TDuration& timeOut);
TSocket(const TNetworkAddress& addr, const TInstant& deadLine);
- ~TSocket();
+ ~TSocket();
template <class T>
inline void SetSockOpt(int level, int optname, T opt) {
@@ -377,12 +377,12 @@ public:
*/
ssize_t SendV(const TPart* parts, size_t count);
- inline operator SOCKET() const noexcept {
+ inline operator SOCKET() const noexcept {
return Fd();
}
private:
- SOCKET Fd() const noexcept;
+ SOCKET Fd() const noexcept;
private:
class TImpl;
@@ -391,13 +391,13 @@ private:
class TSocketInput: public IInputStream {
public:
- TSocketInput(const TSocket& s) noexcept;
- ~TSocketInput() override;
+ TSocketInput(const TSocket& s) noexcept;
+ ~TSocketInput() override;
- TSocketInput(TSocketInput&&) noexcept = default;
- TSocketInput& operator=(TSocketInput&&) noexcept = default;
-
- const TSocket& GetSocket() const noexcept {
+ TSocketInput(TSocketInput&&) noexcept = default;
+ TSocketInput& operator=(TSocketInput&&) noexcept = default;
+
+ const TSocket& GetSocket() const noexcept {
return S_;
}
@@ -410,13 +410,13 @@ private:
class TSocketOutput: public IOutputStream {
public:
- TSocketOutput(const TSocket& s) noexcept;
- ~TSocketOutput() override;
+ TSocketOutput(const TSocket& s) noexcept;
+ ~TSocketOutput() override;
+
+ TSocketOutput(TSocketOutput&&) noexcept = default;
+ TSocketOutput& operator=(TSocketOutput&&) noexcept = default;
- TSocketOutput(TSocketOutput&&) noexcept = default;
- TSocketOutput& operator=(TSocketOutput&&) noexcept = default;
-
- const TSocket& GetSocket() const noexcept {
+ const TSocket& GetSocket() const noexcept {
return S_;
}
@@ -429,4 +429,4 @@ private:
};
//return -(error code) if error occured, or number of ready fds
-ssize_t PollD(struct pollfd fds[], nfds_t nfds, const TInstant& deadLine) noexcept;
+ssize_t PollD(struct pollfd fds[], nfds_t nfds, const TInstant& deadLine) noexcept;
diff --git a/util/network/socket_ut.cpp b/util/network/socket_ut.cpp
index 6d700ac8af..6b20e11f70 100644
--- a/util/network/socket_ut.cpp
+++ b/util/network/socket_ut.cpp
@@ -63,7 +63,7 @@ void TSockTest::TestTimeout() {
}
int realTimeout = (int)(millisec() - startTime);
if (realTimeout > timeout + 2000) {
- TString err = TStringBuilder() << "Timeout exceeded: " << realTimeout << " ms (expected " << timeout << " ms)";
+ TString err = TStringBuilder() << "Timeout exceeded: " << realTimeout << " ms (expected " << timeout << " ms)";
UNIT_FAIL(err);
}
}
@@ -74,7 +74,7 @@ void TSockTest::TestConnectionRefused() {
}
void TSockTest::TestNetworkResolutionError() {
- TString errMsg;
+ TString errMsg;
try {
TNetworkAddress addr("", 0);
} catch (const TNetworkResolutionError& e) {
@@ -86,8 +86,8 @@ void TSockTest::TestNetworkResolutionError() {
}
int expectedErr = EAI_NONAME;
- TString expectedErrMsg = gai_strerror(expectedErr);
- if (errMsg.find(expectedErrMsg) == TString::npos) {
+ TString expectedErrMsg = gai_strerror(expectedErr);
+ if (errMsg.find(expectedErrMsg) == TString::npos) {
UNIT_FAIL("TNetworkResolutionError contains\nInvalid msg: " + errMsg + "\nExpected msg: " + expectedErrMsg + "\n");
}
}
@@ -289,9 +289,9 @@ void TPollTest::TestPollInOut() {
ui32 localIp = ntohl(inet_addr("127.0.0.1"));
- TVector<TSimpleSharedPtr<TSocketHolder>> clientSockets;
- TVector<TSimpleSharedPtr<TSocketHolder>> connectedSockets;
- TVector<pollfd> fds;
+ TVector<TSimpleSharedPtr<TSocketHolder>> clientSockets;
+ TVector<TSimpleSharedPtr<TSocketHolder>> connectedSockets;
+ TVector<pollfd> fds;
for (size_t i = 0; i < socketCount; ++i) {
TSimpleSharedPtr<TSocketHolder> clientSocket(new TSocketHolder(StartClientSocket(localIp, port)));
diff --git a/util/random/common_ops.h b/util/random/common_ops.h
index a88a5aa150..602eede351 100644
--- a/util/random/common_ops.h
+++ b/util/random/common_ops.h
@@ -33,7 +33,7 @@ namespace NPrivate {
}
template <class T>
- static inline ui64 ToRand64(T&& rng, ui32 x) noexcept {
+ static inline ui64 ToRand64(T&& rng, ui32 x) noexcept {
return ((ui64)x) | (((ui64)rng.GenRand()) << 32);
}
@@ -65,7 +65,7 @@ struct TCommonRNG {
using TResult = TRandType;
using result_type = TRandType;
- inline T& Engine() noexcept {
+ inline T& Engine() noexcept {
return static_cast<T&>(*this);
}
@@ -81,42 +81,42 @@ struct TCommonRNG {
}
/* generates uniformly distributed random number on [0, t) interval */
- inline TResult Uniform(TResult t) noexcept {
+ inline TResult Uniform(TResult t) noexcept {
return ::NPrivate::GenUniform(t, Engine());
}
/* generates uniformly distributed random number on [f, t) interval */
- inline TResult Uniform(TResult f, TResult t) noexcept {
+ inline TResult Uniform(TResult f, TResult t) noexcept {
return f + Uniform(t - f);
}
/* generates 64-bit random number for current(may be 32 bit) rng */
- inline ui64 GenRand64() noexcept {
+ inline ui64 GenRand64() noexcept {
return ::NPrivate::ToRand64(Engine(), Engine().GenRand());
}
/* generates a random number on [0, 1]-real-interval */
- inline double GenRandReal1() noexcept {
+ inline double GenRandReal1() noexcept {
return ::NPrivate::ToRandReal1(Engine().GenRand());
}
/* generates a random number on [0, 1)-real-interval */
- inline double GenRandReal2() noexcept {
+ inline double GenRandReal2() noexcept {
return ::NPrivate::ToRandReal2(Engine().GenRand());
}
/* generates a random number on (0, 1)-real-interval */
- inline double GenRandReal3() noexcept {
+ inline double GenRandReal3() noexcept {
return ::NPrivate::ToRandReal3(Engine().GenRand());
}
/* generates a random number on [0, 1) with 53-bit resolution */
- inline double GenRandReal4() noexcept {
+ inline double GenRandReal4() noexcept {
return ::NPrivate::ToRandReal4(Engine().GenRand64());
}
//compatibility stuff
- inline TResult operator()() noexcept {
+ inline TResult operator()() noexcept {
return Engine().GenRand();
}
diff --git a/util/random/common_ops_ut.cpp b/util/random/common_ops_ut.cpp
index f88a58d847..905912bd1e 100644
--- a/util/random/common_ops_ut.cpp
+++ b/util/random/common_ops_ut.cpp
@@ -10,7 +10,7 @@
Y_UNIT_TEST_SUITE(TestCommonRNG) {
template <class T>
struct TRng: public TCommonRNG<T, TRng<T>> {
- inline T GenRand() noexcept {
+ inline T GenRand() noexcept {
return IntHash(C_++);
}
diff --git a/util/random/easy.h b/util/random/easy.h
index 275d160710..fd5b826fbe 100644
--- a/util/random/easy.h
+++ b/util/random/easy.h
@@ -42,6 +42,6 @@ namespace NPrivate {
};
}
-static inline ::NPrivate::TRandom Random() noexcept {
+static inline ::NPrivate::TRandom Random() noexcept {
return {};
}
diff --git a/util/random/fast.cpp b/util/random/fast.cpp
index 43cc1f53b6..2f98dfc5d3 100644
--- a/util/random/fast.cpp
+++ b/util/random/fast.cpp
@@ -2,7 +2,7 @@
#include <util/stream/input.h>
-static inline ui32 FixSeq(ui32 seq1, ui32 seq2) noexcept {
+static inline ui32 FixSeq(ui32 seq1, ui32 seq2) noexcept {
const ui32 mask = (~(ui32)(0)) >> 1;
if ((seq1 & mask) == (seq2 & mask)) {
@@ -12,13 +12,13 @@ static inline ui32 FixSeq(ui32 seq1, ui32 seq2) noexcept {
return seq2;
}
-TFastRng64::TFastRng64(ui64 seed1, ui32 seq1, ui64 seed2, ui32 seq2) noexcept
+TFastRng64::TFastRng64(ui64 seed1, ui32 seq1, ui64 seed2, ui32 seq2) noexcept
: R1_(seed1, seq1)
, R2_(seed2, FixSeq(seq1, seq2))
{
}
-TFastRng64::TArgs::TArgs(ui64 seed) noexcept {
+TFastRng64::TArgs::TArgs(ui64 seed) noexcept {
TReallyFastRng32 rng(seed);
Seed1 = rng.GenRand64();
diff --git a/util/random/fast.h b/util/random/fast.h
index 8aad8a489d..ddc5711641 100644
--- a/util/random/fast.h
+++ b/util/random/fast.h
@@ -9,7 +9,7 @@
// based on http://www.pcg-random.org/. See T*FastRng* family below.
struct TPCGMixer {
- static inline ui32 Mix(ui64 x) noexcept {
+ static inline ui32 Mix(ui64 x) noexcept {
const ui32 xorshifted = ((x >> 18u) ^ x) >> 27u;
const ui32 rot = x >> 59u;
@@ -44,7 +44,7 @@ struct TReallyFastRng32: public TCommonRNG<ui32, TReallyFastRng32>, public TReal
class TFastRng64: public TCommonRNG<ui64, TFastRng64> {
public:
struct TArgs {
- TArgs(ui64 seed) noexcept;
+ TArgs(ui64 seed) noexcept;
TArgs(IInputStream& entropy);
ui64 Seed1;
@@ -53,26 +53,26 @@ public:
ui32 Seq2;
};
- TFastRng64(ui64 seed1, ui32 seq1, ui64 seed2, ui32 seq2) noexcept;
+ TFastRng64(ui64 seed1, ui32 seq1, ui64 seed2, ui32 seq2) noexcept;
/*
* simplify constructions like
* TFastRng64 rng(17);
* TFastRng64 rng(Seek()); //from any IInputStream
*/
- inline TFastRng64(const TArgs& args) noexcept
+ inline TFastRng64(const TArgs& args) noexcept
: TFastRng64(args.Seed1, args.Seq1, args.Seed2, args.Seq2)
{
}
- inline ui64 GenRand() noexcept {
+ inline ui64 GenRand() noexcept {
const ui64 x = R1_.GenRand();
const ui64 y = R2_.GenRand();
return (x << 32) | y;
}
- inline void Advance(ui64 delta) noexcept {
+ inline void Advance(ui64 delta) noexcept {
R1_.Advance(delta);
R2_.Advance(delta);
}
diff --git a/util/random/lcg_engine.cpp b/util/random/lcg_engine.cpp
index 01075e388a..e1469104fa 100644
--- a/util/random/lcg_engine.cpp
+++ b/util/random/lcg_engine.cpp
@@ -2,7 +2,7 @@
namespace NPrivate {
template <typename T>
- T LcgAdvance(T seed, T lcgBase, T lcgAddend, T delta) noexcept {
+ T LcgAdvance(T seed, T lcgBase, T lcgAddend, T delta) noexcept {
// seed[n+1] = A * seed[n] + B, A = lcgBase, B = lcgAddend
// seed[n] = A**n * seed[0] + (A**n - 1) / (A - 1) * B
// (initial value of n) = m * 2**k + (lower bits of n)
@@ -25,6 +25,6 @@ namespace NPrivate {
return seed * apow + lcgAddend * adiv;
}
- template ui32 LcgAdvance<ui32>(ui32, ui32, ui32, ui32) noexcept;
- template ui64 LcgAdvance<ui64>(ui64, ui64, ui64, ui64) noexcept;
+ template ui32 LcgAdvance<ui32>(ui32, ui32, ui32, ui32) noexcept;
+ template ui64 LcgAdvance<ui64>(ui64, ui64, ui64, ui64) noexcept;
}
diff --git a/util/random/lcg_engine.h b/util/random/lcg_engine.h
index a73d7aa7fc..08cc93c845 100644
--- a/util/random/lcg_engine.h
+++ b/util/random/lcg_engine.h
@@ -8,7 +8,7 @@
namespace NPrivate {
template <typename T>
- T LcgAdvance(T seed, T lcgBase, T lcgAddend, T delta) noexcept;
+ T LcgAdvance(T seed, T lcgBase, T lcgAddend, T delta) noexcept;
};
template <typename T, T A, T C>
@@ -19,23 +19,23 @@ struct TFastLcgIterator {
return x * A + C;
}
- static inline T IterateMultiple(T x, T delta) noexcept {
+ static inline T IterateMultiple(T x, T delta) noexcept {
return ::NPrivate::LcgAdvance(x, A, C, delta);
}
};
template <typename T, T A>
struct TLcgIterator {
- inline TLcgIterator(T seq) noexcept
+ inline TLcgIterator(T seq) noexcept
: C((seq << 1u) | (T)1) // C must be odd
{
}
- inline T Iterate(T x) noexcept {
+ inline T Iterate(T x) noexcept {
return x * A + C;
}
- inline T IterateMultiple(T x, T delta) noexcept {
+ inline T IterateMultiple(T x, T delta) noexcept {
return ::NPrivate::LcgAdvance(x, A, C, delta);
}
@@ -44,8 +44,8 @@ struct TLcgIterator {
template <class TIterator, class TMixer>
struct TLcgRngBase: public TIterator, public TMixer {
- using TStateType = decltype(std::declval<TIterator>().Iterate(0));
- using TResultType = decltype(std::declval<TMixer>().Mix(TStateType()));
+ using TStateType = decltype(std::declval<TIterator>().Iterate(0));
+ using TResultType = decltype(std::declval<TMixer>().Mix(TStateType()));
template <typename... Args>
inline TLcgRngBase(TStateType seed, Args&&... args)
@@ -54,11 +54,11 @@ struct TLcgRngBase: public TIterator, public TMixer {
{
}
- inline TResultType GenRand() noexcept {
+ inline TResultType GenRand() noexcept {
return this->Mix(X = this->Iterate(X));
}
- inline void Advance(TStateType delta) noexcept {
+ inline void Advance(TStateType delta) noexcept {
X = this->IterateMultiple(X, delta);
}
diff --git a/util/random/mersenne.h b/util/random/mersenne.h
index 9e94c6e2f9..b2044604ac 100644
--- a/util/random/mersenne.h
+++ b/util/random/mersenne.h
@@ -26,10 +26,10 @@ class TMersenne: public TCommonRNG<T, TMersenne<T>>, public ::NPrivate::TMersenn
public:
using TBase = typename ::NPrivate::TMersenneTraits<T>::TImpl;
- inline TMersenne() noexcept {
+ inline TMersenne() noexcept {
}
- inline TMersenne(T seed) noexcept
+ inline TMersenne(T seed) noexcept
: TBase(seed)
{
}
@@ -39,7 +39,7 @@ public:
{
}
- inline TMersenne(const T* keys, size_t len) noexcept
+ inline TMersenne(const T* keys, size_t len) noexcept
: TBase(keys, len)
{
}
diff --git a/util/random/mersenne32.cpp b/util/random/mersenne32.cpp
index cc708702cc..cb8aad8b03 100644
--- a/util/random/mersenne32.cpp
+++ b/util/random/mersenne32.cpp
@@ -10,7 +10,7 @@ using namespace NPrivate;
#define UPPER_MASK 0x80000000UL
#define LOWER_MASK 0x7fffffffUL
-void TMersenne32::InitGenRand(ui32 s) noexcept {
+void TMersenne32::InitGenRand(ui32 s) noexcept {
mt[0] = s;
for (mti = 1; mti < N; ++mti) {
@@ -18,7 +18,7 @@ void TMersenne32::InitGenRand(ui32 s) noexcept {
}
}
-void TMersenne32::InitByArray(const ui32 init_key[], size_t key_length) noexcept {
+void TMersenne32::InitByArray(const ui32 init_key[], size_t key_length) noexcept {
InitGenRand(19650218UL);
ui32 i = 1;
@@ -55,7 +55,7 @@ void TMersenne32::InitByArray(const ui32 init_key[], size_t key_length) noexcept
mt[0] = 0x80000000UL;
}
-void TMersenne32::InitNext() noexcept {
+void TMersenne32::InitNext() noexcept {
int kk;
ui32 y;
ui32 mag01[2] = {
diff --git a/util/random/mersenne32.h b/util/random/mersenne32.h
index 5192f4b9d6..861f3a3d38 100644
--- a/util/random/mersenne32.h
+++ b/util/random/mersenne32.h
@@ -9,13 +9,13 @@ namespace NPrivate {
static constexpr int N = 624;
public:
- inline TMersenne32(ui32 s = 19650218UL) noexcept
+ inline TMersenne32(ui32 s = 19650218UL) noexcept
: mti(N + 1)
{
InitGenRand(s);
}
- inline TMersenne32(const ui32* init_key, size_t key_length) noexcept
+ inline TMersenne32(const ui32* init_key, size_t key_length) noexcept
: mti(N + 1)
{
InitByArray(init_key, key_length);
@@ -23,7 +23,7 @@ namespace NPrivate {
TMersenne32(IInputStream& input);
- inline ui32 GenRand() noexcept {
+ inline ui32 GenRand() noexcept {
if (mti >= N) {
InitNext();
}
@@ -39,9 +39,9 @@ namespace NPrivate {
}
private:
- void InitNext() noexcept;
- void InitGenRand(ui32 s) noexcept;
- void InitByArray(const ui32* init_key, size_t key_length) noexcept;
+ void InitNext() noexcept;
+ void InitGenRand(ui32 s) noexcept;
+ void InitByArray(const ui32* init_key, size_t key_length) noexcept;
private:
ui32 mt[N];
diff --git a/util/random/mersenne64.cpp b/util/random/mersenne64.cpp
index c74d726020..4ede2c6dca 100644
--- a/util/random/mersenne64.cpp
+++ b/util/random/mersenne64.cpp
@@ -10,7 +10,7 @@
using namespace NPrivate;
-void TMersenne64::InitGenRand(ui64 seed) noexcept {
+void TMersenne64::InitGenRand(ui64 seed) noexcept {
mt[0] = seed;
for (mti = 1; mti < NN; ++mti) {
@@ -18,7 +18,7 @@ void TMersenne64::InitGenRand(ui64 seed) noexcept {
}
}
-void TMersenne64::InitByArray(const ui64* init_key, size_t key_length) noexcept {
+void TMersenne64::InitByArray(const ui64* init_key, size_t key_length) noexcept {
ui64 i = 1;
ui64 j = 0;
ui64 k;
@@ -57,7 +57,7 @@ void TMersenne64::InitByArray(const ui64* init_key, size_t key_length) noexcept
mt[0] = ULL(1) << 63;
}
-void TMersenne64::InitNext() noexcept {
+void TMersenne64::InitNext() noexcept {
int i;
ui64 x;
ui64 mag01[2] = {
diff --git a/util/random/mersenne64.h b/util/random/mersenne64.h
index b4b03895d2..12ca43b6af 100644
--- a/util/random/mersenne64.h
+++ b/util/random/mersenne64.h
@@ -15,7 +15,7 @@ namespace NPrivate {
InitGenRand(s);
}
- inline TMersenne64(const ui64* keys, size_t len) noexcept
+ inline TMersenne64(const ui64* keys, size_t len) noexcept
: mti(NN + 1)
{
InitByArray(keys, len);
@@ -23,7 +23,7 @@ namespace NPrivate {
TMersenne64(IInputStream& input);
- inline ui64 GenRand() noexcept {
+ inline ui64 GenRand() noexcept {
if (mti >= NN) {
InitNext();
}
@@ -39,9 +39,9 @@ namespace NPrivate {
}
private:
- void InitNext() noexcept;
- void InitGenRand(ui64 seed) noexcept;
- void InitByArray(const ui64* init_key, size_t key_length) noexcept;
+ void InitNext() noexcept;
+ void InitGenRand(ui64 seed) noexcept;
+ void InitByArray(const ui64* init_key, size_t key_length) noexcept;
private:
ui64 mt[NN];
diff --git a/util/random/normal_ut.cpp b/util/random/normal_ut.cpp
index 77e8050d24..42b6cc4ba2 100644
--- a/util/random/normal_ut.cpp
+++ b/util/random/normal_ut.cpp
@@ -16,7 +16,7 @@ Y_UNIT_TEST_SUITE(TestNormalDistribution) {
template <class T>
static void TestMD(std::function<T()> f, T m, T d) {
- TVector<T> v;
+ TVector<T> v;
v.reserve(20000);
diff --git a/util/random/shuffle_ut.cpp b/util/random/shuffle_ut.cpp
index 45f9baa262..87cbae94c0 100644
--- a/util/random/shuffle_ut.cpp
+++ b/util/random/shuffle_ut.cpp
@@ -9,7 +9,7 @@
Y_UNIT_TEST_SUITE(TRandUtilsTest) {
template <typename... A>
static void TestRange(A&&... args) {
- TString s0, s1;
+ TString s0, s1;
ShuffleRange(s1, args...);
s1 = "0";
ShuffleRange(s1, args...);
@@ -23,7 +23,7 @@ Y_UNIT_TEST_SUITE(TRandUtilsTest) {
template <typename... A>
static void TestIter(A&&... args) {
- TString s0, s1;
+ TString s0, s1;
auto f = [&]() {
auto b = s1.begin();
diff --git a/util/str_stl.h b/util/str_stl.h
index 4038303dab..f1e137181d 100644
--- a/util/str_stl.h
+++ b/util/str_stl.h
@@ -2,7 +2,7 @@
#include <util/memory/alloc.h>
#include <util/digest/numeric.h>
-#include <util/generic/string.h>
+#include <util/generic/string.h>
#include <util/generic/string_hash.h>
#include <util/generic/strbuf.h>
#include <util/generic/typetraits.h>
@@ -33,7 +33,7 @@ namespace std {
namespace NHashPrivate {
template <class T, bool needNumericHashing>
struct THashHelper {
- inline size_t operator()(const T& t) const noexcept {
+ inline size_t operator()(const T& t) const noexcept {
return (size_t)t; // If you have a compilation error here, look at explanation below:
// Probably error is caused by undefined template specialization of THash<T>
// You can find examples of specialization in this file
@@ -42,7 +42,7 @@ namespace NHashPrivate {
template <class T>
struct THashHelper<T, true> {
- inline size_t operator()(const T& t) const noexcept {
+ inline size_t operator()(const T& t) const noexcept {
return NumericHash(t);
}
};
@@ -63,7 +63,7 @@ struct hash: public NHashPrivate::THashHelper<T, std::is_scalar<T>::value && !st
template <typename T>
struct hash<const T*> {
- inline size_t operator()(const T* t) const noexcept {
+ inline size_t operator()(const T* t) const noexcept {
return NumericHash(t);
}
};
@@ -185,12 +185,12 @@ struct TEqualTo: public std::equal_to<T> {
};
template <>
-struct TEqualTo<TString>: public TEqualTo<TStringBuf> {
+struct TEqualTo<TString>: public TEqualTo<TStringBuf> {
using is_transparent = void;
};
template <>
-struct TEqualTo<TUtf16String>: public TEqualTo<TWtringBuf> {
+struct TEqualTo<TUtf16String>: public TEqualTo<TWtringBuf> {
using is_transparent = void;
};
@@ -227,8 +227,8 @@ struct TCIEqualTo<TStringBuf> {
};
template <>
-struct TCIEqualTo<TString> {
- inline bool operator()(const TString& a, const TString& b) const {
+struct TCIEqualTo<TString> {
+ inline bool operator()(const TString& a, const TString& b) const {
return a.size() == b.size() && strnicmp(a.data(), b.data(), a.size()) == 0;
}
};
@@ -238,12 +238,12 @@ struct TLess: public std::less<T> {
};
template <>
-struct TLess<TString>: public TLess<TStringBuf> {
+struct TLess<TString>: public TLess<TStringBuf> {
using is_transparent = void;
};
template <>
-struct TLess<TUtf16String>: public TLess<TWtringBuf> {
+struct TLess<TUtf16String>: public TLess<TWtringBuf> {
using is_transparent = void;
};
@@ -257,12 +257,12 @@ struct TGreater: public std::greater<T> {
};
template <>
-struct TGreater<TString>: public TGreater<TStringBuf> {
+struct TGreater<TString>: public TGreater<TStringBuf> {
using is_transparent = void;
};
template <>
-struct TGreater<TUtf16String>: public TGreater<TWtringBuf> {
+struct TGreater<TUtf16String>: public TGreater<TWtringBuf> {
using is_transparent = void;
};
diff --git a/util/stream/aligned.cpp b/util/stream/aligned.cpp
index f25d78c719..2fd12d15b7 100644
--- a/util/stream/aligned.cpp
+++ b/util/stream/aligned.cpp
@@ -12,7 +12,7 @@ size_t TAlignedInput::DoSkip(size_t len) {
return ret;
}
-size_t TAlignedInput::DoReadTo(TString& st, char ch) {
+size_t TAlignedInput::DoReadTo(TString& st, char ch) {
size_t ret = Stream_->ReadTo(st, ch);
Position_ += ret;
return ret;
diff --git a/util/stream/aligned.h b/util/stream/aligned.h
index 48262d8061..70e7be05a9 100644
--- a/util/stream/aligned.h
+++ b/util/stream/aligned.h
@@ -44,7 +44,7 @@ public:
private:
size_t DoRead(void* ptr, size_t len) override;
size_t DoSkip(size_t len) override;
- size_t DoReadTo(TString& st, char ch) override;
+ size_t DoReadTo(TString& st, char ch) override;
ui64 DoReadAll(IOutputStream& out) override;
private:
@@ -64,9 +64,9 @@ public:
{
}
- TAlignedOutput(TAlignedOutput&&) noexcept = default;
- TAlignedOutput& operator=(TAlignedOutput&&) noexcept = default;
-
+ TAlignedOutput(TAlignedOutput&&) noexcept = default;
+ TAlignedOutput& operator=(TAlignedOutput&&) noexcept = default;
+
size_t GetCurrentOffset() const {
return Position_;
}
diff --git a/util/stream/buffer.cpp b/util/stream/buffer.cpp
index 38c1012738..2facece4ea 100644
--- a/util/stream/buffer.cpp
+++ b/util/stream/buffer.cpp
@@ -34,7 +34,7 @@ public:
Data_.Append(c);
}
- inline TBuffer& Buffer() const noexcept {
+ inline TBuffer& Buffer() const noexcept {
return Data_;
}
@@ -71,7 +71,7 @@ TBufferOutput& TBufferOutput::operator=(TBufferOutput&&) noexcept = default;
TBufferOutput::~TBufferOutput() = default;
-TBuffer& TBufferOutput::Buffer() const noexcept {
+TBuffer& TBufferOutput::Buffer() const noexcept {
return Impl_->Buffer();
}
@@ -99,11 +99,11 @@ TBufferInput::TBufferInput(const TBuffer& buffer)
TBufferInput::~TBufferInput() = default;
-const TBuffer& TBufferInput::Buffer() const noexcept {
+const TBuffer& TBufferInput::Buffer() const noexcept {
return Buf_;
}
-void TBufferInput::Rewind() noexcept {
+void TBufferInput::Rewind() noexcept {
Readed_ = 0;
}
diff --git a/util/stream/buffer.h b/util/stream/buffer.h
index feba91cc21..9dc99dbe49 100644
--- a/util/stream/buffer.h
+++ b/util/stream/buffer.h
@@ -37,13 +37,13 @@ public:
TBufferOutput(TBufferOutput&&) noexcept;
TBufferOutput& operator=(TBufferOutput&&) noexcept;
-
- ~TBufferOutput() override;
+
+ ~TBufferOutput() override;
/**
* @returns Buffer that this stream writes into.
*/
- TBuffer& Buffer() const noexcept;
+ TBuffer& Buffer() const noexcept;
private:
size_t DoNext(void** ptr) override;
@@ -69,11 +69,11 @@ public:
*/
TBufferInput(const TBuffer& buffer);
- ~TBufferInput() override;
+ ~TBufferInput() override;
- const TBuffer& Buffer() const noexcept;
+ const TBuffer& Buffer() const noexcept;
- void Rewind() noexcept;
+ void Rewind() noexcept;
protected:
size_t DoNext(const void** ptr, size_t len) override;
diff --git a/util/stream/buffer_ut.cpp b/util/stream/buffer_ut.cpp
index 217af94161..3494696190 100644
--- a/util/stream/buffer_ut.cpp
+++ b/util/stream/buffer_ut.cpp
@@ -25,7 +25,7 @@ Y_UNIT_TEST_SUITE(TBufferTest) {
TBuffer buffer("1234567890", 10);
TBufferInput input(buffer);
- TString tmp;
+ TString tmp;
UNIT_ASSERT_VALUES_EQUAL(input.ReadTo(tmp, '3'), 3);
UNIT_ASSERT_VALUES_EQUAL(tmp, "12");
diff --git a/util/stream/buffered.cpp b/util/stream/buffered.cpp
index 289ff3d1a5..a00e592e1c 100644
--- a/util/stream/buffered.cpp
+++ b/util/stream/buffered.cpp
@@ -62,10 +62,10 @@ public:
return MemInput_.Skip(len);
}
- inline size_t ReadTo(TString& st, char to) {
+ inline size_t ReadTo(TString& st, char to) {
st.clear();
- TString s_tmp;
+ TString s_tmp;
size_t ret = 0;
@@ -104,11 +104,11 @@ public:
}
private:
- inline size_t BufLen() const noexcept {
+ inline size_t BufLen() const noexcept {
return AdditionalDataLength();
}
- inline void* Buf() const noexcept {
+ inline void* Buf() const noexcept {
return AdditionalData();
}
@@ -139,7 +139,7 @@ size_t TBufferedInput::DoNext(const void** ptr, size_t len) {
return Impl_->Next(ptr, len);
}
-size_t TBufferedInput::DoReadTo(TString& st, char ch) {
+size_t TBufferedInput::DoReadTo(TString& st, char ch) {
return Impl_->ReadTo(st, ch);
}
@@ -227,11 +227,11 @@ public:
MemOut_.Write(c);
}
- inline void SetFlushPropagateMode(bool mode) noexcept {
+ inline void SetFlushPropagateMode(bool mode) noexcept {
PropagateFlush_ = mode;
}
- inline void SetFinishPropagateMode(bool mode) noexcept {
+ inline void SetFinishPropagateMode(bool mode) noexcept {
PropagateFinish_ = mode;
}
@@ -269,17 +269,17 @@ private:
}
}
- inline size_t Stored() const noexcept {
+ inline size_t Stored() const noexcept {
return Len() - MemOut_.Avail();
}
- inline size_t DownToBufferGranularity(size_t l) const noexcept {
+ inline size_t DownToBufferGranularity(size_t l) const noexcept {
return l - (l % Len());
}
virtual void OnBufferExhausted() = 0;
- virtual void* Buf() const noexcept = 0;
- virtual size_t Len() const noexcept = 0;
+ virtual void* Buf() const noexcept = 0;
+ virtual size_t Len() const noexcept = 0;
private:
IOutputStream* Slave_;
@@ -301,11 +301,11 @@ namespace {
void OnBufferExhausted() final {
}
- void* Buf() const noexcept override {
+ void* Buf() const noexcept override {
return AdditionalData();
}
- size_t Len() const noexcept override {
+ size_t Len() const noexcept override {
return AdditionalDataLength();
}
};
@@ -333,11 +333,11 @@ namespace {
}
}
- void* Buf() const noexcept override {
+ void* Buf() const noexcept override {
return (void*)B_.Data();
}
- size_t Len() const noexcept override {
+ size_t Len() const noexcept override {
return B_.Capacity();
}
@@ -359,7 +359,7 @@ TBufferedOutputBase::TBufferedOutputBase(IOutputStream* slave, size_t buflen)
TBufferedOutputBase::TBufferedOutputBase(TBufferedOutputBase&&) noexcept = default;
TBufferedOutputBase& TBufferedOutputBase::operator=(TBufferedOutputBase&&) noexcept = default;
-TBufferedOutputBase::~TBufferedOutputBase() {
+TBufferedOutputBase::~TBufferedOutputBase() {
try {
Finish();
} catch (...) {
@@ -401,13 +401,13 @@ void TBufferedOutputBase::DoFinish() {
}
}
-void TBufferedOutputBase::SetFlushPropagateMode(bool propagate) noexcept {
+void TBufferedOutputBase::SetFlushPropagateMode(bool propagate) noexcept {
if (Impl_.Get()) {
Impl_->SetFlushPropagateMode(propagate);
}
}
-void TBufferedOutputBase::SetFinishPropagateMode(bool propagate) noexcept {
+void TBufferedOutputBase::SetFinishPropagateMode(bool propagate) noexcept {
if (Impl_.Get()) {
Impl_->SetFinishPropagateMode(propagate);
}
diff --git a/util/stream/buffered.h b/util/stream/buffered.h
index 93798e5eca..0847186141 100644
--- a/util/stream/buffered.h
+++ b/util/stream/buffered.h
@@ -27,7 +27,7 @@ public:
TBufferedInput(TBufferedInput&&) noexcept;
TBufferedInput& operator=(TBufferedInput&&) noexcept;
- ~TBufferedInput() override;
+ ~TBufferedInput() override;
/**
* Switches the underlying stream to the one provided. Does not clear the
@@ -39,7 +39,7 @@ public:
protected:
size_t DoRead(void* buf, size_t len) override;
- size_t DoReadTo(TString& st, char ch) override;
+ size_t DoReadTo(TString& st, char ch) override;
size_t DoSkip(size_t len) override;
size_t DoNext(const void** ptr, size_t len) override;
@@ -81,15 +81,15 @@ public:
TBufferedOutputBase(TBufferedOutputBase&&) noexcept;
TBufferedOutputBase& operator=(TBufferedOutputBase&&) noexcept;
-
- ~TBufferedOutputBase() override;
+
+ ~TBufferedOutputBase() override;
/**
* @param propagate Whether `Flush` and `Finish` calls should
* be propagated to the underlying stream.
* By default they are not.
*/
- inline void SetPropagateMode(bool propagate) noexcept {
+ inline void SetPropagateMode(bool propagate) noexcept {
SetFlushPropagateMode(propagate);
SetFinishPropagateMode(propagate);
}
@@ -99,14 +99,14 @@ public:
* to the underlying stream. By default they
* are not.
*/
- void SetFlushPropagateMode(bool propagate) noexcept;
+ void SetFlushPropagateMode(bool propagate) noexcept;
/**
* @param propagate Whether `Finish` calls should be propagated
* to the underlying stream. By default they
* are not.
*/
- void SetFinishPropagateMode(bool propagate) noexcept;
+ void SetFinishPropagateMode(bool propagate) noexcept;
class TImpl;
@@ -130,10 +130,10 @@ private:
class TBufferedOutput: public TBufferedOutputBase {
public:
TBufferedOutput(IOutputStream* slave, size_t buflen = 8192);
- ~TBufferedOutput() override;
-
- TBufferedOutput(TBufferedOutput&&) noexcept = default;
- TBufferedOutput& operator=(TBufferedOutput&&) noexcept = default;
+ ~TBufferedOutput() override;
+
+ TBufferedOutput(TBufferedOutput&&) noexcept = default;
+ TBufferedOutput& operator=(TBufferedOutput&&) noexcept = default;
};
/**
@@ -145,10 +145,10 @@ public:
class TAdaptiveBufferedOutput: public TBufferedOutputBase {
public:
TAdaptiveBufferedOutput(IOutputStream* slave);
- ~TAdaptiveBufferedOutput() override;
-
- TAdaptiveBufferedOutput(TAdaptiveBufferedOutput&&) noexcept = default;
- TAdaptiveBufferedOutput& operator=(TAdaptiveBufferedOutput&&) noexcept = default;
+ ~TAdaptiveBufferedOutput() override;
+
+ TAdaptiveBufferedOutput(TAdaptiveBufferedOutput&&) noexcept = default;
+ TAdaptiveBufferedOutput& operator=(TAdaptiveBufferedOutput&&) noexcept = default;
};
namespace NPrivate {
@@ -170,13 +170,13 @@ namespace NPrivate {
* A mixin class that turns unbuffered stream into a buffered one.
*
* Note that using this mixin with a stream that is already buffered won't
- * result in double buffering, e.g. `TBuffered<TBuffered<TUnbufferedFileInput>>` and
- * `TBuffered<TUnbufferedFileInput>` are basically the same types.
+ * result in double buffering, e.g. `TBuffered<TBuffered<TUnbufferedFileInput>>` and
+ * `TBuffered<TUnbufferedFileInput>` are basically the same types.
*
* Example usage:
* @code
- * TBuffered<TUnbufferedFileInput> file_input(1024, "/path/to/file");
- * TBuffered<TUnbufferedFileOutput> file_output(1024, "/path/to/file");
+ * TBuffered<TUnbufferedFileInput> file_input(1024, "/path/to/file");
+ * TBuffered<TUnbufferedFileOutput> file_output(1024, "/path/to/file");
* @endcode
* Here 1024 is the size of the buffer.
*/
@@ -211,7 +211,7 @@ public:
*
* Example usage:
* @code
- * TAdaptivelyBuffered<TUnbufferedFileOutput> file_output("/path/to/file");
+ * TAdaptivelyBuffered<TUnbufferedFileOutput> file_output("/path/to/file");
* @endcode
*/
template <class TSlave>
diff --git a/util/stream/buffered_ut.cpp b/util/stream/buffered_ut.cpp
index d6e33fc3d7..41d2fc3030 100644
--- a/util/stream/buffered_ut.cpp
+++ b/util/stream/buffered_ut.cpp
@@ -2,7 +2,7 @@
#include <library/cpp/testing/unittest/registar.h>
-#include <util/generic/string.h>
+#include <util/generic/string.h>
#include <util/random/mersenne.h>
Y_UNIT_TEST_SUITE(TestBufferedIO) {
@@ -12,7 +12,7 @@ Y_UNIT_TEST_SUITE(TestBufferedIO) {
for (size_t i = 0; i < 1000; ++i) {
const size_t c = r.GenRand() % 10000;
- TString s;
+ TString s;
for (size_t j = 0; j < c; ++j) {
s.append('A' + (r.GenRand() % 10));
@@ -23,8 +23,8 @@ Y_UNIT_TEST_SUITE(TestBufferedIO) {
}
Y_UNIT_TEST(TestEqual) {
- TString s1;
- TString s2;
+ TString s1;
+ TString s2;
Run(TBuffered<TStringOutput>(8000, s1));
Run(TAdaptivelyBuffered<TStringOutput>(s2));
@@ -33,7 +33,7 @@ Y_UNIT_TEST_SUITE(TestBufferedIO) {
}
Y_UNIT_TEST(Test1) {
- TString s;
+ TString s;
TBuffered<TStringOutput>(100, s).Write("1", 1);
@@ -41,7 +41,7 @@ Y_UNIT_TEST_SUITE(TestBufferedIO) {
}
Y_UNIT_TEST(Test2) {
- TString s;
+ TString s;
TBuffered<TStringOutput>(1, s).Write("12", 2);
@@ -49,7 +49,7 @@ Y_UNIT_TEST_SUITE(TestBufferedIO) {
}
Y_UNIT_TEST(Test3) {
- TString s;
+ TString s;
auto&& b = TBuffered<TStringOutput>(1, s);
@@ -108,7 +108,7 @@ Y_UNIT_TEST_SUITE(TestBufferedIO) {
}
Y_UNIT_TEST(TestInput) {
- TString s("0123456789abcdefghijklmn");
+ TString s("0123456789abcdefghijklmn");
TBuffered<TStringInput> in(5, s);
char c;
UNIT_ASSERT_VALUES_EQUAL(in.Read(&c, 1), 1); //1
@@ -129,9 +129,9 @@ Y_UNIT_TEST_SUITE(TestBufferedIO) {
}
Y_UNIT_TEST(TestReadTo) {
- TString s("0123456789abc");
+ TString s("0123456789abc");
TBuffered<TStringInput> in(2, s);
- TString t;
+ TString t;
UNIT_ASSERT_VALUES_EQUAL(in.ReadTo(t, '7'), 8);
UNIT_ASSERT_VALUES_EQUAL(t, "0123456");
UNIT_ASSERT_VALUES_EQUAL(in.ReadTo(t, '8'), 1);
diff --git a/util/stream/debug.cpp b/util/stream/debug.cpp
index b9255b7a85..afd5b3e1c7 100644
--- a/util/stream/debug.cpp
+++ b/util/stream/debug.cpp
@@ -45,6 +45,6 @@ IOutputStream& StdDbgStream() noexcept {
return *(Singleton<TDbgSelector>()->Out);
}
-int StdDbgLevel() noexcept {
+int StdDbgLevel() noexcept {
return Singleton<TDbgSelector>()->Level;
}
diff --git a/util/stream/debug.h b/util/stream/debug.h
index 86601ea0ba..92d6d4b42d 100644
--- a/util/stream/debug.h
+++ b/util/stream/debug.h
@@ -12,12 +12,12 @@
*/
class TDebugOutput: public IOutputStream {
public:
- inline TDebugOutput() noexcept = default;
+ inline TDebugOutput() noexcept = default;
~TDebugOutput() override = default;
- TDebugOutput(TDebugOutput&&) noexcept = default;
- TDebugOutput& operator=(TDebugOutput&&) noexcept = default;
-
+ TDebugOutput(TDebugOutput&&) noexcept = default;
+ TDebugOutput& operator=(TDebugOutput&&) noexcept = default;
+
private:
void DoWrite(const void* buf, size_t len) override;
};
@@ -39,7 +39,7 @@ IOutputStream& StdDbgStream() noexcept;
* @see ETraceLevel
* @see DBGTRACE
*/
-int StdDbgLevel() noexcept;
+int StdDbgLevel() noexcept;
/**
* Standard debug stream.
diff --git a/util/stream/direct_io.cpp b/util/stream/direct_io.cpp
index c759d32b8e..649033af34 100644
--- a/util/stream/direct_io.cpp
+++ b/util/stream/direct_io.cpp
@@ -33,7 +33,7 @@ void TRandomAccessFileOutput::DoFlush() {
File->FlushData();
}
-TBufferedFileOutputEx::TBufferedFileOutputEx(const TString& path, EOpenMode oMode, size_t buflen)
+TBufferedFileOutputEx::TBufferedFileOutputEx(const TString& path, EOpenMode oMode, size_t buflen)
: TRandomAccessFileOutput(*(new TDirectIOBufferedFile(path, oMode, buflen)))
, FileHolder(File)
{
diff --git a/util/stream/direct_io.h b/util/stream/direct_io.h
index f7dc39d4a0..2e1f2e07dd 100644
--- a/util/stream/direct_io.h
+++ b/util/stream/direct_io.h
@@ -21,9 +21,9 @@ class TRandomAccessFileOutput: public IOutputStream {
public:
TRandomAccessFileOutput(TDirectIOBufferedFile& file);
- TRandomAccessFileOutput(TRandomAccessFileOutput&&) noexcept = default;
- TRandomAccessFileOutput& operator=(TRandomAccessFileOutput&&) noexcept = default;
-
+ TRandomAccessFileOutput(TRandomAccessFileOutput&&) noexcept = default;
+ TRandomAccessFileOutput& operator=(TRandomAccessFileOutput&&) noexcept = default;
+
protected:
TDirectIOBufferedFile* File;
@@ -34,7 +34,7 @@ private:
class TBufferedFileOutputEx: public TRandomAccessFileOutput {
public:
- TBufferedFileOutputEx(const TString& path, EOpenMode oMode, size_t buflen = 1 << 17);
+ TBufferedFileOutputEx(const TString& path, EOpenMode oMode, size_t buflen = 1 << 17);
private:
void DoFlush() override;
diff --git a/util/stream/direct_io_ut.cpp b/util/stream/direct_io_ut.cpp
index 00567f6ed1..01d09db232 100644
--- a/util/stream/direct_io_ut.cpp
+++ b/util/stream/direct_io_ut.cpp
@@ -1,6 +1,6 @@
#include <library/cpp/testing/unittest/registar.h>
-#include <util/generic/string.h>
+#include <util/generic/string.h>
#include <util/generic/array_size.h>
#include <util/system/env.h>
@@ -29,7 +29,7 @@ Y_UNIT_TEST_SUITE(TDirectIOTests) {
// filling file
// TEMPLATE|TEMPLATE|TEMPLATE|...
- const auto fileName = TString("test.file");
+ const auto fileName = TString("test.file");
auto&& directIOBuffer = TDirectIOBufferedFile{fileName, RdWr | CreateAlways | mode};
{
auto&& output = TRandomAccessFileOutput{directIOBuffer};
diff --git a/util/stream/file.cpp b/util/stream/file.cpp
index dfce45c002..dc5d2f6311 100644
--- a/util/stream/file.cpp
+++ b/util/stream/file.cpp
@@ -3,7 +3,7 @@
#include <util/memory/blob.h>
#include <util/generic/yexception.h>
-TUnbufferedFileInput::TUnbufferedFileInput(const TString& path)
+TUnbufferedFileInput::TUnbufferedFileInput(const TString& path)
: File_(path, OpenExisting | RdOnly | Seq)
{
if (!File_.IsOpen()) {
@@ -11,7 +11,7 @@ TUnbufferedFileInput::TUnbufferedFileInput(const TString& path)
}
}
-TUnbufferedFileInput::TUnbufferedFileInput(const TFile& file)
+TUnbufferedFileInput::TUnbufferedFileInput(const TFile& file)
: File_(file)
{
if (!File_.IsOpen()) {
@@ -19,11 +19,11 @@ TUnbufferedFileInput::TUnbufferedFileInput(const TFile& file)
}
}
-size_t TUnbufferedFileInput::DoRead(void* buf, size_t len) {
+size_t TUnbufferedFileInput::DoRead(void* buf, size_t len) {
return File_.ReadOrFail(buf, len);
}
-size_t TUnbufferedFileInput::DoSkip(size_t len) {
+size_t TUnbufferedFileInput::DoSkip(size_t len) {
if (len < 384) {
/* Base implementation calls DoRead, which results in one system call
* instead of three as in fair skip implementation. For small sizes
@@ -42,7 +42,7 @@ size_t TUnbufferedFileInput::DoSkip(size_t len) {
return newPos - oldPos;
}
-TUnbufferedFileOutput::TUnbufferedFileOutput(const TString& path)
+TUnbufferedFileOutput::TUnbufferedFileOutput(const TString& path)
: File_(path, CreateAlways | WrOnly | Seq)
{
if (!File_.IsOpen()) {
@@ -50,7 +50,7 @@ TUnbufferedFileOutput::TUnbufferedFileOutput(const TString& path)
}
}
-TUnbufferedFileOutput::TUnbufferedFileOutput(const TFile& file)
+TUnbufferedFileOutput::TUnbufferedFileOutput(const TFile& file)
: File_(file)
{
if (!File_.IsOpen()) {
@@ -58,13 +58,13 @@ TUnbufferedFileOutput::TUnbufferedFileOutput(const TFile& file)
}
}
-TUnbufferedFileOutput::~TUnbufferedFileOutput() = default;
+TUnbufferedFileOutput::~TUnbufferedFileOutput() = default;
-void TUnbufferedFileOutput::DoWrite(const void* buf, size_t len) {
+void TUnbufferedFileOutput::DoWrite(const void* buf, size_t len) {
File_.Write(buf, len);
}
-void TUnbufferedFileOutput::DoFlush() {
+void TUnbufferedFileOutput::DoFlush() {
if (File_.IsOpen()) {
File_.Flush();
}
@@ -87,7 +87,7 @@ TMappedFileInput::TMappedFileInput(const TFile& file)
Reset(Impl_->Data(), Impl_->Size());
}
-TMappedFileInput::TMappedFileInput(const TString& path)
+TMappedFileInput::TMappedFileInput(const TString& path)
: TMemoryInput(nullptr, 0)
, Impl_(new TImpl(TFile(path, OpenExisting | RdOnly)))
{
diff --git a/util/stream/file.h b/util/stream/file.h
index 11b2ee7ff2..c1cf4f591d 100644
--- a/util/stream/file.h
+++ b/util/stream/file.h
@@ -15,15 +15,15 @@
*/
/**
- * Unbuffered file input stream.
+ * Unbuffered file input stream.
*
* Note that the input is not buffered, which means that `ReadLine` calls will
* be _very_ slow.
*/
-class TUnbufferedFileInput: public IInputStream {
+class TUnbufferedFileInput: public IInputStream {
public:
- TUnbufferedFileInput(const TFile& file);
- TUnbufferedFileInput(const TString& path);
+ TUnbufferedFileInput(const TFile& file);
+ TUnbufferedFileInput(const TString& path);
private:
size_t DoRead(void* buf, size_t len) override;
@@ -39,8 +39,8 @@ private:
class TMappedFileInput: public TMemoryInput {
public:
TMappedFileInput(const TFile& file);
- TMappedFileInput(const TString& path);
- ~TMappedFileInput() override;
+ TMappedFileInput(const TString& path);
+ ~TMappedFileInput() override;
private:
class TImpl;
@@ -53,15 +53,15 @@ private:
* Note that the output is unbuffered, thus writing in many small chunks is
* likely to be quite slow.
*/
-class TUnbufferedFileOutput: public IOutputStream {
+class TUnbufferedFileOutput: public IOutputStream {
public:
- TUnbufferedFileOutput(const TString& path);
- TUnbufferedFileOutput(const TFile& file);
- ~TUnbufferedFileOutput() override;
+ TUnbufferedFileOutput(const TString& path);
+ TUnbufferedFileOutput(const TFile& file);
+ ~TUnbufferedFileOutput() override;
+
+ TUnbufferedFileOutput(TUnbufferedFileOutput&&) noexcept = default;
+ TUnbufferedFileOutput& operator=(TUnbufferedFileOutput&&) noexcept = default;
- TUnbufferedFileOutput(TUnbufferedFileOutput&&) noexcept = default;
- TUnbufferedFileOutput& operator=(TUnbufferedFileOutput&&) noexcept = default;
-
private:
void DoWrite(const void* buf, size_t len) override;
void DoFlush() override;
@@ -75,34 +75,34 @@ private:
*
* @see TBuffered
*/
-class TFileInput: public TBuffered<TUnbufferedFileInput> {
+class TFileInput: public TBuffered<TUnbufferedFileInput> {
public:
template <class T>
- inline TFileInput(T&& t, size_t buf = 1 << 13)
- : TBuffered<TUnbufferedFileInput>(buf, std::forward<T>(t))
+ inline TFileInput(T&& t, size_t buf = 1 << 13)
+ : TBuffered<TUnbufferedFileInput>(buf, std::forward<T>(t))
{
}
- ~TFileInput() override = default;
+ ~TFileInput() override = default;
};
/**
* Buffered file output stream.
*
- * Currently deprecated, please use TFileOutput in new code.
+ * Currently deprecated, please use TFileOutput in new code.
*
* @deprecated
* @see TBuffered
*/
-class TFixedBufferFileOutput: public TBuffered<TUnbufferedFileOutput> {
+class TFixedBufferFileOutput: public TBuffered<TUnbufferedFileOutput> {
public:
template <class T>
- inline TFixedBufferFileOutput(T&& t, size_t buf = 1 << 13)
- : TBuffered<TUnbufferedFileOutput>(buf, std::forward<T>(t))
+ inline TFixedBufferFileOutput(T&& t, size_t buf = 1 << 13)
+ : TBuffered<TUnbufferedFileOutput>(buf, std::forward<T>(t))
{
}
- ~TFixedBufferFileOutput() override = default;
+ ~TFixedBufferFileOutput() override = default;
};
/** @} */
diff --git a/util/stream/file_ut.cpp b/util/stream/file_ut.cpp
index f6d4315564..ac0f09796e 100644
--- a/util/stream/file_ut.cpp
+++ b/util/stream/file_ut.cpp
@@ -13,32 +13,32 @@ Y_UNIT_TEST_SUITE(TFileTest) {
TTempFile tmp(TmpFileName);
{
- TUnbufferedFileOutput output(TmpFileName);
+ TUnbufferedFileOutput output(TmpFileName);
output.Write(TmpFileContents, strlen(TmpFileContents));
}
{
- TUnbufferedFileInput input(TmpFileName);
- TString s = input.ReadAll();
+ TUnbufferedFileInput input(TmpFileName);
+ TString s = input.ReadAll();
UNIT_ASSERT_VALUES_EQUAL(s, TmpFileContents);
}
{
- TUnbufferedFileInput input(TmpFileName);
+ TUnbufferedFileInput input(TmpFileName);
input.Skip(TmpFileSubstring - TmpFileContents);
- TString s = input.ReadAll();
+ TString s = input.ReadAll();
UNIT_ASSERT_VALUES_EQUAL(s, "chivalrous plan");
}
{
- TUnbufferedFileOutput output(TFile::ForAppend(TmpFileName));
+ TUnbufferedFileOutput output(TFile::ForAppend(TmpFileName));
output.Write(TmpFileContents, strlen(TmpFileContents));
}
{
- TUnbufferedFileInput input(TmpFileName);
- TString s = input.ReadAll();
- UNIT_ASSERT_VALUES_EQUAL(s, TString::Join(TmpFileContents, TmpFileContents));
+ TUnbufferedFileInput input(TmpFileName);
+ TString s = input.ReadAll();
+ UNIT_ASSERT_VALUES_EQUAL(s, TString::Join(TmpFileContents, TmpFileContents));
}
}
@@ -46,13 +46,13 @@ Y_UNIT_TEST_SUITE(TFileTest) {
TTempFile tmp(TmpFileName);
{
- TUnbufferedFileOutput output(TmpFileName);
+ TUnbufferedFileOutput output(TmpFileName);
/* Write nothing. */
}
{
TMappedFileInput input(TmpFileName);
- TString s = input.ReadAll();
+ TString s = input.ReadAll();
UNIT_ASSERT(s.empty());
}
}
diff --git a/util/stream/format.h b/util/stream/format.h
index 830516991f..b033208a1b 100644
--- a/util/stream/format.h
+++ b/util/stream/format.h
@@ -113,7 +113,7 @@ namespace NFormatPrivate {
if (str[0] == '-') {
stream << '-';
- str.Skip(1);
+ str.Skip(1);
}
if (value.Flags & HF_ADDX) {
diff --git a/util/stream/format_ut.cpp b/util/stream/format_ut.cpp
index 3c83bce4a4..43245aeb48 100644
--- a/util/stream/format_ut.cpp
+++ b/util/stream/format_ut.cpp
@@ -54,7 +54,7 @@ Y_UNIT_TEST_SUITE(TOutputStreamFormattingTest) {
}
{
TStringStream ss;
- TUtf16String w = UTF8ToWide("abcи");
+ TUtf16String w = UTF8ToWide("abcи");
ss << HexText<wchar16>(w);
UNIT_ASSERT_VALUES_EQUAL("0061 0062 0063 0438", ss.Str());
}
diff --git a/util/stream/hex_ut.cpp b/util/stream/hex_ut.cpp
index c1b80ef5f7..5074a0b616 100644
--- a/util/stream/hex_ut.cpp
+++ b/util/stream/hex_ut.cpp
@@ -4,14 +4,14 @@
#include "str.h"
Y_UNIT_TEST_SUITE(THexCodingTest) {
- void TestImpl(const TString& data) {
- TString encoded;
+ void TestImpl(const TString& data) {
+ TString encoded;
TStringOutput encodedOut(encoded);
HexEncode(data.data(), data.size(), encodedOut);
UNIT_ASSERT_EQUAL(encoded.size(), data.size() * 2);
- TString decoded;
+ TString decoded;
TStringOutput decodedOut(decoded);
HexDecode(encoded.data(), encoded.size(), decodedOut);
@@ -19,7 +19,7 @@ Y_UNIT_TEST_SUITE(THexCodingTest) {
}
Y_UNIT_TEST(TestEncodeDecodeToStream) {
- TString data = "100ABAcaba500,$%0987123456 \n\t\x01\x02\x03.";
+ TString data = "100ABAcaba500,$%0987123456 \n\t\x01\x02\x03.";
TestImpl(data);
}
diff --git a/util/stream/input.cpp b/util/stream/input.cpp
index eb99b10809..6e8170f2f9 100644
--- a/util/stream/input.cpp
+++ b/util/stream/input.cpp
@@ -4,7 +4,7 @@
#include <util/charset/wide.h>
#include <util/memory/tempbuf.h>
-#include <util/generic/string.h>
+#include <util/generic/string.h>
#include <util/generic/yexception.h>
#include <util/generic/singleton.h>
#include <util/string/cast.h>
@@ -89,7 +89,7 @@ size_t IInputStream::ReadLine(TString& st) {
}
size_t IInputStream::ReadLine(TUtf16String& w) {
- TString s;
+ TString s;
size_t result = ReadLine(s);
if (result) {
@@ -100,7 +100,7 @@ size_t IInputStream::ReadLine(TUtf16String& w) {
}
TString IInputStream::ReadLine() {
- TString ret;
+ TString ret;
if (!ReadLine(ret)) {
ythrow yexception() << "can not read line from stream";
@@ -110,7 +110,7 @@ TString IInputStream::ReadLine() {
}
TString IInputStream::ReadTo(char ch) {
- TString ret;
+ TString ret;
if (!ReadTo(ret, ch)) {
ythrow yexception() << "can not read from stream";
@@ -146,7 +146,7 @@ size_t IInputStream::DoSkip(size_t sz) {
}
TString IInputStream::ReadAll() {
- TString result;
+ TString result;
TStringOutput stream(result);
DoReadAll(stream);
@@ -190,7 +190,7 @@ namespace {
free(B_);
}
- size_t DoReadTo(TString& st, char ch) override {
+ size_t DoReadTo(TString& st, char ch) override {
auto&& guard = Guard(M_);
(void)guard;
@@ -227,7 +227,7 @@ namespace {
using TGetLine = TGetLineBase;
#else
struct TGetLine: public TGetLineBase {
- size_t DoReadTo(TString& st, char ch) override {
+ size_t DoReadTo(TString& st, char ch) override {
if (ch == '\n') {
size_t len = 0;
auto r = fgetln(F_, &len);
@@ -285,7 +285,7 @@ void In<TString>(IInputStream& i, TString& s) {
template <>
void In<TUtf16String>(IInputStream& i, TUtf16String& w) {
- TString s;
+ TString s;
ReadUpToDelimiter(i, s);
if (s.empty()) {
diff --git a/util/stream/input.h b/util/stream/input.h
index f4432f7553..f0d5807ed2 100644
--- a/util/stream/input.h
+++ b/util/stream/input.h
@@ -1,7 +1,7 @@
#pragma once
#include <util/generic/fwd.h>
-#include <util/generic/noncopyable.h>
+#include <util/generic/noncopyable.h>
#include <util/system/defaults.h>
class IOutputStream;
@@ -21,11 +21,11 @@ public:
IInputStream(IInputStream&&) noexcept {
}
-
+
IInputStream& operator=(IInputStream&&) noexcept {
- return *this;
+ return *this;
}
-
+
/**
* Reads some data from the stream. Note that this function might read less
* data than what was requested. Use `Load` function if you want to read as
@@ -66,7 +66,7 @@ public:
* @returns Total number of characters read from the stream.
* A return value of zero signals end of stream.
*/
- inline size_t ReadTo(TString& st, char ch) {
+ inline size_t ReadTo(TString& st, char ch) {
return DoReadTo(st, ch);
}
@@ -98,7 +98,7 @@ public:
*
* @returns Contents of this stream as a string.
*/
- TString ReadAll();
+ TString ReadAll();
/**
* Reads all data from this stream and writes it into a provided output
@@ -119,7 +119,7 @@ public:
* because end of stream has already been
* reached.
*/
- TString ReadLine();
+ TString ReadLine();
/**
* Reads all characters from the stream until the given character is
@@ -132,7 +132,7 @@ public:
* because end of stream has already been
* reached.
*/
- TString ReadTo(char ch);
+ TString ReadTo(char ch);
/**
* Reads all data from the stream until the first occurrence of '\n' and
@@ -143,7 +143,7 @@ public:
* @returns Total number of characters read from the stream.
* A return value of zero signals end of stream.
*/
- size_t ReadLine(TString& st);
+ size_t ReadLine(TString& st);
/**
* Reads UTF8 encoded characters from the stream the first occurrence of '\n',
@@ -155,7 +155,7 @@ public:
* @returns Total number of characters read from the stream.
* A return value of zero signals end of stream.
*/
- size_t ReadLine(TUtf16String& w);
+ size_t ReadLine(TUtf16String& w);
/**
* Skips some data from the stream without reading / copying it. Note that
@@ -204,7 +204,7 @@ protected:
* A return value of zero signals end of stream.
* @throws yexception If IO error occurs.
*/
- virtual size_t DoReadTo(TString& st, char ch);
+ virtual size_t DoReadTo(TString& st, char ch);
/**
* Reads all data from this stream and writes it into a provided output
diff --git a/util/stream/input_ut.cpp b/util/stream/input_ut.cpp
index dddb657def..4a93f5458e 100644
--- a/util/stream/input_ut.cpp
+++ b/util/stream/input_ut.cpp
@@ -61,7 +61,7 @@ private:
class TNoOutput: public IOutputStream {
public:
- TNoOutput() = default;
+ TNoOutput() = default;
protected:
void DoWrite(const void*, size_t) override {
@@ -70,7 +70,7 @@ protected:
class TSimpleStringInput: public IInputStream {
public:
- TSimpleStringInput(const TString& string)
+ TSimpleStringInput(const TString& string)
: String_(string)
{
}
@@ -89,7 +89,7 @@ protected:
}
private:
- TString String_;
+ TString String_;
};
Y_UNIT_TEST_SUITE(TInputTest) {
@@ -108,7 +108,7 @@ Y_UNIT_TEST_SUITE(TInputTest) {
TSimpleStringInput in("0123456789abc");
- TString t;
+ TString t;
UNIT_ASSERT_VALUES_EQUAL(in.ReadTo(t, '7'), 8);
UNIT_ASSERT_VALUES_EQUAL(t, "0123456");
UNIT_ASSERT_VALUES_EQUAL(in.ReadTo(t, 'z'), 5);
@@ -120,7 +120,7 @@ Y_UNIT_TEST_SUITE(TInputTest) {
Y_UNIT_TEST(TestReadLine) {
TSimpleStringInput in("1\n22\n333");
- TString t;
+ TString t;
UNIT_ASSERT_VALUES_EQUAL(in.ReadLine(t), 2);
UNIT_ASSERT_VALUES_EQUAL(t, "1");
UNIT_ASSERT_VALUES_EQUAL(in.ReadLine(t), 3);
@@ -148,7 +148,7 @@ Y_UNIT_TEST_SUITE(TInputTest) {
stdIn.ForInput(text,
[=] {
- TString value;
+ TString value;
Cin.ReadTo(value, delim);
UNIT_ASSERT_VALUES_EQUAL(value, expectedValue);
});
diff --git a/util/stream/ios_ut.cpp b/util/stream/ios_ut.cpp
index 3785c1d727..139f4296e5 100644
--- a/util/stream/ios_ut.cpp
+++ b/util/stream/ios_ut.cpp
@@ -53,14 +53,14 @@ public:
UNIT_TEST_SUITE_REGISTRATION(TStreamsTest);
void TStreamsTest::TestIStreamOperators() {
- TString data("first line\r\nsecond\t\xd1\x82\xd0\xb5\xd1\x81\xd1\x82 line\r\n 1 -4 59 4320000000009999999 c\n -1.5 1e-110");
+ TString data("first line\r\nsecond\t\xd1\x82\xd0\xb5\xd1\x81\xd1\x82 line\r\n 1 -4 59 4320000000009999999 c\n -1.5 1e-110");
TStringInput si(data);
- TString l1;
- TString l2;
- TString l3;
- TUtf16String w1;
- TString l4;
+ TString l1;
+ TString l2;
+ TString l3;
+ TUtf16String w1;
+ TString l4;
ui16 i1;
i16 i2;
i32 i3;
@@ -120,7 +120,7 @@ void TStreamsTest::TestStringStream() {
}
void TStreamsTest::TestGenericRead() {
- TString s("1234567890");
+ TString s("1234567890");
TStringInput si(s);
char buf[1024];
@@ -131,7 +131,7 @@ void TStreamsTest::TestGenericRead() {
}
void TStreamsTest::TestGenericWrite() {
- TString s;
+ TString s;
TStringOutput so(s);
so.Write("123456", 6);
@@ -141,7 +141,7 @@ void TStreamsTest::TestGenericWrite() {
}
void TStreamsTest::TestReadLine() {
- TString data("1234\r\n5678\nqw");
+ TString data("1234\r\n5678\nqw");
TStringInput si(data);
UNIT_ASSERT_EQUAL(si.ReadLine(), "1234");
@@ -171,7 +171,7 @@ void TStreamsTest::TestMemoryStream() {
class TMyStringOutput: public IOutputStream {
public:
- inline TMyStringOutput(TString& s, size_t buflen) noexcept
+ inline TMyStringOutput(TString& s, size_t buflen) noexcept
: S_(s)
, BufLen_(buflen)
{
@@ -185,7 +185,7 @@ public:
}
void DoWriteV(const TPart* p, size_t count) override {
- TString s;
+ TString s;
for (size_t i = 0; i < count; ++i) {
s.append((const char*)p[i].buf, p[i].len);
@@ -200,14 +200,14 @@ private:
};
void TStreamsTest::TestBufferedIO() {
- TString s;
+ TString s;
{
const size_t buflen = 7;
TBuffered<TMyStringOutput> bo(buflen, s, buflen);
for (size_t i = 0; i < 1000; ++i) {
- TString str(" ");
+ TString str(" ");
str += ToString(i % 10);
bo.Write(str.data(), str.size());
@@ -223,7 +223,7 @@ void TStreamsTest::TestBufferedIO() {
TBuffered<TStringInput> bi(buflen, s);
for (size_t i = 0; i < 1000; ++i) {
- TString str(" ");
+ TString str(" ");
str += ToString(i % 10);
char buf[3];
@@ -241,7 +241,7 @@ void TStreamsTest::TestBufferedIO() {
{
const size_t buflen = 13;
TBuffered<TMyStringOutput> bo(buflen, s, buflen);
- TString f = "1234567890";
+ TString f = "1234567890";
for (size_t i = 0; i < 10; ++i) {
f += f;
@@ -257,7 +257,7 @@ void TStreamsTest::TestBufferedIO() {
void TStreamsTest::TestBufferStream() {
TBufferStream stream;
- TString s = "test";
+ TString s = "test";
stream.Write(s.data(), s.size());
char buf[5];
@@ -281,7 +281,7 @@ void TStreamsTest::TestBufferStream() {
namespace {
class TStringListInput: public IWalkInput {
public:
- TStringListInput(const TVector<TString>& data)
+ TStringListInput(const TVector<TString>& data)
: Data_(data)
, Index_(0)
{
@@ -293,14 +293,14 @@ namespace {
return 0;
}
- const TString& string = Data_[Index_++];
+ const TString& string = Data_[Index_++];
*ptr = string.data();
return string.size();
}
private:
- const TVector<TString>& Data_;
+ const TVector<TString>& Data_;
size_t Index_;
};
@@ -332,7 +332,7 @@ namespace {
"123",
"\t\r "};
void TestStreamReadTo1(IInputStream& input, const char* comment) {
- TString tmp;
+ TString tmp;
input.ReadTo(tmp, 'c');
UNIT_ASSERT_VALUES_EQUAL_C(tmp, "111a222b333", comment);
@@ -348,7 +348,7 @@ namespace {
}
void TestStreamReadTo2(IInputStream& input, const char* comment) {
- TString s;
+ TString s;
size_t i = 0;
while (input.ReadLine(s)) {
UNIT_ASSERT_C(i < Y_ARRAY_SIZE(Expected), comment);
@@ -368,7 +368,7 @@ namespace {
}
void TestStrokaInput(IInputStream& input, const char* comment) {
- TString line;
+ TString line;
ui32 i = 0;
TInstant start = Now();
while (input.ReadLine(line)) {
@@ -379,7 +379,7 @@ namespace {
}
template <class T>
- void TestStreamReadTo(const TString& text, T test) {
+ void TestStreamReadTo(const TString& text, T test) {
TStringInput is(text);
test(is, "TStringInput");
TMemoryInput mi(text.data(), text.size());
@@ -390,7 +390,7 @@ namespace {
TStringInput slave(text);
TBufferedInput bdi(&slave);
test(bdi, "TBufferedInput");
- TVector<TString> lst(1, text);
+ TVector<TString> lst(1, text);
TStringListInput sli(lst);
test(sli, "IWalkInput");
}
@@ -400,15 +400,15 @@ void TStreamsTest::TestReadTo() {
TestStreamReadTo("111a222b333c444d555e666f", TestStreamReadTo1);
TestStreamReadTo(Text, TestStreamReadTo2);
TestStreamReadTo("111a222b333c444d555e666f", TestStreamReadTo3);
- TString withZero = "one";
+ TString withZero = "one";
withZero.append('\0').append("two").append('\0').append("three");
TestStreamReadTo(withZero, TestStreamReadTo4);
}
void TStreamsTest::TestStrokaInput() {
- TString s;
+ TString s;
for (ui32 i = 0; i < 100000; ++i) {
- TVector<char> d(i % 1000, 'a');
+ TVector<char> d(i % 1000, 'a');
s.append(d.data(), d.size());
s.append('\n');
}
@@ -416,9 +416,9 @@ void TStreamsTest::TestStrokaInput() {
}
void TStreamsTest::TestWtrokaInput() {
- const TString s(Text);
+ const TString s(Text);
TStringInput is(s);
- TUtf16String w;
+ TUtf16String w;
size_t i = 0;
while (is.ReadLine(w)) {
@@ -430,12 +430,12 @@ void TStreamsTest::TestWtrokaInput() {
}
void TStreamsTest::TestWtrokaOutput() {
- TString s;
+ TString s;
TStringOutput os(s);
const size_t n = sizeof(Expected) / sizeof(Expected[0]);
for (size_t i = 0; i < n; ++i) {
- TUtf16String w = UTF8ToWide(Expected[i]);
+ TUtf16String w = UTF8ToWide(Expected[i]);
os << w;
diff --git a/util/stream/length.cpp b/util/stream/length.cpp
index 7358d01c9a..9907fe2ac9 100644
--- a/util/stream/length.cpp
+++ b/util/stream/length.cpp
@@ -28,7 +28,7 @@ size_t TCountingInput::DoSkip(size_t len) {
return ret;
}
-size_t TCountingInput::DoReadTo(TString& st, char ch) {
+size_t TCountingInput::DoReadTo(TString& st, char ch) {
const size_t ret = Slave_->ReadTo(st, ch);
Count_ += ret;
return ret;
diff --git a/util/stream/length.h b/util/stream/length.h
index fd7aa18799..4d508ae24d 100644
--- a/util/stream/length.h
+++ b/util/stream/length.h
@@ -22,7 +22,7 @@ public:
~TLengthLimitedInput() override = default;
- inline ui64 Left() const noexcept {
+ inline ui64 Left() const noexcept {
return Length_;
}
@@ -52,14 +52,14 @@ public:
* \returns The total number of characters read from
* this stream.
*/
- inline ui64 Counter() const noexcept {
+ inline ui64 Counter() const noexcept {
return Count_;
}
private:
size_t DoRead(void* buf, size_t len) override;
size_t DoSkip(size_t len) override;
- size_t DoReadTo(TString& st, char ch) override;
+ size_t DoReadTo(TString& st, char ch) override;
ui64 DoReadAll(IOutputStream& out) override;
private:
@@ -80,14 +80,14 @@ public:
~TCountingOutput() override = default;
- TCountingOutput(TCountingOutput&&) noexcept = default;
- TCountingOutput& operator=(TCountingOutput&&) noexcept = default;
-
+ TCountingOutput(TCountingOutput&&) noexcept = default;
+ TCountingOutput& operator=(TCountingOutput&&) noexcept = default;
+
/**
* \returns The total number of characters written
* into this stream.
*/
- inline ui64 Counter() const noexcept {
+ inline ui64 Counter() const noexcept {
return Count_;
}
diff --git a/util/stream/length_ut.cpp b/util/stream/length_ut.cpp
index 3dd7f44abc..8968448954 100644
--- a/util/stream/length_ut.cpp
+++ b/util/stream/length_ut.cpp
@@ -2,7 +2,7 @@
#include <library/cpp/testing/unittest/registar.h>
-#include <util/generic/string.h>
+#include <util/generic/string.h>
Y_UNIT_TEST_SUITE(TestLengthIO) {
Y_UNIT_TEST(TestLengthLimitedInput) {
@@ -20,7 +20,7 @@ Y_UNIT_TEST_SUITE(TestLengthIO) {
TStringStream s1("abc\ndef\n");
TCountingInput l1(&s1);
- TString s;
+ TString s;
l1.ReadLine(s);
UNIT_ASSERT_VALUES_EQUAL(l1.Counter(), 4);
@@ -41,10 +41,10 @@ Y_UNIT_TEST_SUITE(TestLengthIO) {
l1.Write('1');
UNIT_ASSERT_VALUES_EQUAL(l1.Counter(), 1);
- l1.Write(TString("abcd"));
+ l1.Write(TString("abcd"));
UNIT_ASSERT_VALUES_EQUAL(l1.Counter(), 5);
- TString buf("aaa");
+ TString buf("aaa");
IOutputStream::TPart parts[] = {{buf.data(), buf.size()}, {buf.data(), buf.size()}, {buf.data(), buf.size()}};
l1.Write(parts, 3);
UNIT_ASSERT_VALUES_EQUAL(l1.Counter(), 14);
diff --git a/util/stream/mem.cpp b/util/stream/mem.cpp
index ac6cefd36c..22a3339e27 100644
--- a/util/stream/mem.cpp
+++ b/util/stream/mem.cpp
@@ -2,13 +2,13 @@
#include <util/generic/yexception.h>
-TMemoryInput::TMemoryInput() noexcept
+TMemoryInput::TMemoryInput() noexcept
: Buf_(nullptr)
, Len_(0)
{
}
-TMemoryInput::TMemoryInput(const void* buf, size_t len) noexcept
+TMemoryInput::TMemoryInput(const void* buf, size_t len) noexcept
: Buf_((const char*)buf)
, Len_(len)
{
diff --git a/util/stream/mem.h b/util/stream/mem.h
index 771d13d067..18a5d46772 100644
--- a/util/stream/mem.h
+++ b/util/stream/mem.h
@@ -15,7 +15,7 @@
*/
class TMemoryInput: public IZeroCopyInputFastReadTo {
public:
- TMemoryInput() noexcept;
+ TMemoryInput() noexcept;
/**
* Constructs a stream that reads from the provided memory block. It's up
@@ -25,29 +25,29 @@ public:
* @param buf Memory block to use.
* @param len Size of the memory block.
*/
- TMemoryInput(const void* buf, size_t len) noexcept;
+ TMemoryInput(const void* buf, size_t len) noexcept;
explicit TMemoryInput(const TStringBuf buf) noexcept;
- ~TMemoryInput() override;
+ ~TMemoryInput() override;
- TMemoryInput(const TMemoryInput& other) noexcept
+ TMemoryInput(const TMemoryInput& other) noexcept
: IZeroCopyInputFastReadTo()
- , Buf_(other.Buf_)
- , Len_(other.Len_)
- {
- }
-
- TMemoryInput& operator=(const TMemoryInput& other) noexcept {
- if (this != &other) {
- Buf_ = other.Buf_;
- Len_ = other.Len_;
- }
-
- return *this;
- }
-
- TMemoryInput(TMemoryInput&&) noexcept = default;
- TMemoryInput& operator=(TMemoryInput&&) noexcept = default;
-
+ , Buf_(other.Buf_)
+ , Len_(other.Len_)
+ {
+ }
+
+ TMemoryInput& operator=(const TMemoryInput& other) noexcept {
+ if (this != &other) {
+ Buf_ = other.Buf_;
+ Len_ = other.Len_;
+ }
+
+ return *this;
+ }
+
+ TMemoryInput(TMemoryInput&&) noexcept = default;
+ TMemoryInput& operator=(TMemoryInput&&) noexcept = default;
+
/**
* Initializes this stream with a new memory block. It's up to the
* user to make sure that the memory block doesn't get freed while this
@@ -56,7 +56,7 @@ public:
* @param buf New memory block to use.
* @param len Size of the new memory block.
*/
- void Reset(const void* buf, size_t len) noexcept {
+ void Reset(const void* buf, size_t len) noexcept {
Buf_ = (const char*)buf;
Len_ = len;
}
@@ -64,14 +64,14 @@ public:
/**
* @returns Whether there is more data in the stream.
*/
- bool Exhausted() const noexcept {
+ bool Exhausted() const noexcept {
return !Avail();
}
/**
* @returns Number of bytes available in the stream.
*/
- size_t Avail() const noexcept {
+ size_t Avail() const noexcept {
return Len_;
}
@@ -79,7 +79,7 @@ public:
* @returns Current read position in the memory block
* used by this stream.
*/
- const char* Buf() const noexcept {
+ const char* Buf() const noexcept {
return Buf_;
}
@@ -118,16 +118,16 @@ public:
* @param buf Memory block to use.
* @param len Size of the memory block.
*/
- TMemoryOutput(void* buf, size_t len) noexcept
+ TMemoryOutput(void* buf, size_t len) noexcept
: Buf_(static_cast<char*>(buf))
, End_(Buf_ + len)
{
}
- ~TMemoryOutput() override;
+ ~TMemoryOutput() override;
+
+ TMemoryOutput(TMemoryOutput&&) noexcept = default;
+ TMemoryOutput& operator=(TMemoryOutput&&) noexcept = default;
- TMemoryOutput(TMemoryOutput&&) noexcept = default;
- TMemoryOutput& operator=(TMemoryOutput&&) noexcept = default;
-
/**
* Initializes this stream with a new memory block. It's up to the
* user to make sure that the memory block doesn't get freed while this
@@ -136,7 +136,7 @@ public:
* @param buf New memory block to use.
* @param len Size of the new memory block.
*/
- inline void Reset(void* buf, size_t len) noexcept {
+ inline void Reset(void* buf, size_t len) noexcept {
Buf_ = static_cast<char*>(buf);
End_ = Buf_ + len;
}
@@ -145,7 +145,7 @@ public:
* @returns Whether there is more space in the
* stream for writing.
*/
- inline bool Exhausted() const noexcept {
+ inline bool Exhausted() const noexcept {
return !Avail();
}
@@ -153,7 +153,7 @@ public:
* @returns Number of bytes available for writing
* in the stream.
*/
- inline size_t Avail() const noexcept {
+ inline size_t Avail() const noexcept {
return End_ - Buf_;
}
@@ -161,7 +161,7 @@ public:
* @returns Current write position in the memory block
* used by this stream.
*/
- inline char* Buf() const noexcept {
+ inline char* Buf() const noexcept {
return Buf_;
}
diff --git a/util/stream/mem_ut.cpp b/util/stream/mem_ut.cpp
index 5bc35d73bc..f388ae66ac 100644
--- a/util/stream/mem_ut.cpp
+++ b/util/stream/mem_ut.cpp
@@ -4,10 +4,10 @@
Y_UNIT_TEST_SUITE(TestMemIO) {
Y_UNIT_TEST(TestReadTo) {
- TString s("0123456789abc");
+ TString s("0123456789abc");
TMemoryInput in(s);
- TString t;
+ TString t;
UNIT_ASSERT_VALUES_EQUAL(in.ReadTo(t, '7'), 8);
UNIT_ASSERT_VALUES_EQUAL(t, "0123456");
UNIT_ASSERT_VALUES_EQUAL(in.ReadTo(t, 'z'), 5);
diff --git a/util/stream/multi.cpp b/util/stream/multi.cpp
index 23ebb23e7f..b2354298a0 100644
--- a/util/stream/multi.cpp
+++ b/util/stream/multi.cpp
@@ -22,7 +22,7 @@ size_t TMultiInput::DoRead(void* buf, size_t len) {
return C_->Read(buf, len);
}
-size_t TMultiInput::DoReadTo(TString& st, char ch) {
+size_t TMultiInput::DoReadTo(TString& st, char ch) {
size_t ret = C_->ReadTo(st, ch);
if (ret == st.size() + 1) { // found a symbol, not eof
return ret;
@@ -34,7 +34,7 @@ size_t TMultiInput::DoReadTo(TString& st, char ch) {
if (ret == 0) {
ret += C_->ReadTo(st, ch);
} else {
- TString tmp;
+ TString tmp;
ret += C_->ReadTo(tmp, ch);
st += tmp;
}
diff --git a/util/stream/multi.h b/util/stream/multi.h
index 2098b2732f..8bfd462d99 100644
--- a/util/stream/multi.h
+++ b/util/stream/multi.h
@@ -13,12 +13,12 @@
class TMultiInput: public IInputStream {
public:
TMultiInput(IInputStream* f, IInputStream* s) noexcept;
- ~TMultiInput() override;
+ ~TMultiInput() override;
private:
size_t DoRead(void* buf, size_t len) override;
size_t DoSkip(size_t len) override;
- size_t DoReadTo(TString& st, char ch) override;
+ size_t DoReadTo(TString& st, char ch) override;
private:
IInputStream* C_;
diff --git a/util/stream/multi_ut.cpp b/util/stream/multi_ut.cpp
index 46611639bc..fc2553b533 100644
--- a/util/stream/multi_ut.cpp
+++ b/util/stream/multi_ut.cpp
@@ -15,16 +15,16 @@ Y_UNIT_TEST_SUITE(TestMultiInput) {
{
}
void TestReadToResult(char c, size_t expectedRetval,
- const TString& expectedValue,
- const TString& initValue = "") {
- TString t = initValue;
+ const TString& expectedValue,
+ const TString& initValue = "") {
+ TString t = initValue;
UNIT_ASSERT_VALUES_EQUAL(MultiInput.ReadTo(t, c), expectedRetval);
UNIT_ASSERT_VALUES_EQUAL(t, expectedValue);
}
};
Y_UNIT_TEST(TestReadTo) {
- TString t;
+ TString t;
TTestCase simpleCase("0123456789abc", "defghijk");
simpleCase.TestReadToResult('7', 8, "0123456");
diff --git a/util/stream/null.cpp b/util/stream/null.cpp
index 54ae12e894..4e8b298145 100644
--- a/util/stream/null.cpp
+++ b/util/stream/null.cpp
@@ -2,11 +2,11 @@
#include <util/generic/singleton.h>
-TNullIO& NPrivate::StdNullStream() noexcept {
+TNullIO& NPrivate::StdNullStream() noexcept {
return *SingletonWithPriority<TNullIO, 4>();
}
-TNullInput::TNullInput() noexcept {
+TNullInput::TNullInput() noexcept {
}
TNullInput::~TNullInput() = default;
@@ -23,14 +23,14 @@ size_t TNullInput::DoNext(const void**, size_t) {
return 0;
}
-TNullOutput::TNullOutput() noexcept = default;
+TNullOutput::TNullOutput() noexcept = default;
TNullOutput::~TNullOutput() = default;
void TNullOutput::DoWrite(const void* /*buf*/, size_t /*len*/) {
}
-TNullIO::TNullIO() noexcept {
+TNullIO::TNullIO() noexcept {
}
TNullIO::~TNullIO() = default;
diff --git a/util/stream/null.h b/util/stream/null.h
index efccfaab4c..8c335a9a78 100644
--- a/util/stream/null.h
+++ b/util/stream/null.h
@@ -13,8 +13,8 @@
*/
class TNullInput: public IZeroCopyInput {
public:
- TNullInput() noexcept;
- ~TNullInput() override;
+ TNullInput() noexcept;
+ ~TNullInput() override;
private:
size_t DoRead(void* buf, size_t len) override;
@@ -27,12 +27,12 @@ private:
*/
class TNullOutput: public IOutputStream {
public:
- TNullOutput() noexcept;
- ~TNullOutput() override;
+ TNullOutput() noexcept;
+ ~TNullOutput() override;
+
+ TNullOutput(TNullOutput&&) noexcept = default;
+ TNullOutput& operator=(TNullOutput&&) noexcept = default;
- TNullOutput(TNullOutput&&) noexcept = default;
- TNullOutput& operator=(TNullOutput&&) noexcept = default;
-
private:
void DoWrite(const void* buf, size_t len) override;
};
@@ -45,12 +45,12 @@ private:
*/
class TNullIO: public TNullInput, public TNullOutput {
public:
- TNullIO() noexcept;
- ~TNullIO() override;
+ TNullIO() noexcept;
+ ~TNullIO() override;
};
namespace NPrivate {
- TNullIO& StdNullStream() noexcept;
+ TNullIO& StdNullStream() noexcept;
}
/**
diff --git a/util/stream/output.cpp b/util/stream/output.cpp
index 6ca2952f7f..db81b81b70 100644
--- a/util/stream/output.cpp
+++ b/util/stream/output.cpp
@@ -23,7 +23,7 @@
#if defined(_win_)
#include <io.h>
#endif
-
+
constexpr size_t MAX_UTF8_BYTES = 4; // UTF-8-encoded code point takes between 1 and 4 bytes
IOutputStream::IOutputStream() noexcept = default;
@@ -260,13 +260,13 @@ namespace {
class TAndroidStdOutput: public IOutputStream {
public:
- inline TAndroidStdOutput(TLogFuncPtr logFuncPtr) noexcept
+ inline TAndroidStdOutput(TLogFuncPtr logFuncPtr) noexcept
: Buffer()
, LogFuncPtr(logFuncPtr)
{
}
- virtual ~TAndroidStdOutput() {
+ virtual ~TAndroidStdOutput() {
}
private:
@@ -298,7 +298,7 @@ namespace {
{
}
- virtual ~TStdErr() {
+ virtual ~TStdErr() {
}
private:
@@ -314,7 +314,7 @@ namespace {
{
}
- virtual ~TStdOut() {
+ virtual ~TStdOut() {
}
private:
@@ -341,7 +341,7 @@ namespace {
namespace {
class TStdOutput: public IOutputStream {
public:
- inline TStdOutput(FILE* f) noexcept
+ inline TStdOutput(FILE* f) noexcept
: F_(f)
{
}
diff --git a/util/stream/output.h b/util/stream/output.h
index 0dc723e6f0..00eef50b95 100644
--- a/util/stream/output.h
+++ b/util/stream/output.h
@@ -3,8 +3,8 @@
#include "fwd.h"
#include "labeled.h"
-#include <util/generic/noncopyable.h>
-#include <util/generic/string.h>
+#include <util/generic/noncopyable.h>
+#include <util/generic/string.h>
#include <util/generic/strbuf.h>
#include <util/generic/typetraits.h>
@@ -24,7 +24,7 @@ public:
* Data block for output.
*/
struct TPart {
- inline TPart(const void* Buf, size_t Len) noexcept
+ inline TPart(const void* Buf, size_t Len) noexcept
: buf(Buf)
, len(Len)
{
@@ -36,7 +36,7 @@ public:
{
}
- inline TPart() noexcept
+ inline TPart() noexcept
: buf(nullptr)
, len(0)
{
@@ -44,7 +44,7 @@ public:
inline ~TPart() = default;
- static inline TPart CrLf() noexcept {
+ static inline TPart CrLf() noexcept {
return TPart("\r\n", 2);
}
@@ -57,11 +57,11 @@ public:
IOutputStream(IOutputStream&&) noexcept {
}
-
+
IOutputStream& operator=(IOutputStream&&) noexcept {
- return *this;
- };
-
+ return *this;
+ };
+
/**
* Writes into this stream.
*
diff --git a/util/stream/pipe.cpp b/util/stream/pipe.cpp
index 0fc2d721f4..51be1934a7 100644
--- a/util/stream/pipe.cpp
+++ b/util/stream/pipe.cpp
@@ -7,7 +7,7 @@
class TPipeBase::TImpl {
public:
- inline TImpl(const TString& command, const char* mode)
+ inline TImpl(const TString& command, const char* mode)
: Pipe_(nullptr)
{
#ifndef _freebsd_
@@ -21,7 +21,7 @@ public:
}
}
- inline ~TImpl() {
+ inline ~TImpl() {
if (Pipe_ != nullptr) {
::pclose(Pipe_);
}
@@ -31,14 +31,14 @@ public:
FILE* Pipe_;
};
-TPipeBase::TPipeBase(const TString& command, const char* mode)
+TPipeBase::TPipeBase(const TString& command, const char* mode)
: Impl_(new TImpl(command, mode))
{
}
TPipeBase::~TPipeBase() = default;
-TPipeInput::TPipeInput(const TString& command)
+TPipeInput::TPipeInput(const TString& command)
: TPipeBase(command, "r")
{
}
@@ -61,7 +61,7 @@ size_t TPipeInput::DoRead(void* buf, size_t len) {
return bytesRead;
}
-TPipeOutput::TPipeOutput(const TString& command)
+TPipeOutput::TPipeOutput(const TString& command)
: TPipeBase(command, "w")
{
}
@@ -87,7 +87,7 @@ TPipedBase::TPipedBase(PIPEHANDLE fd)
{
}
-TPipedBase::~TPipedBase() {
+TPipedBase::~TPipedBase() {
if (Handle_.IsOpen()) {
Handle_.Close();
}
diff --git a/util/stream/pipe.h b/util/stream/pipe.h
index 8ffdbd1bdc..18525b9517 100644
--- a/util/stream/pipe.h
+++ b/util/stream/pipe.h
@@ -5,7 +5,7 @@
#include <util/system/pipe.h>
#include <util/generic/ptr.h>
-#include <util/generic/string.h>
+#include <util/generic/string.h>
/**
* @addtogroup Streams_Pipes
@@ -24,8 +24,8 @@ protected:
* @param mode Data transfer mode for the pipe. Use
* "r" for reading and "w" for writing.
*/
- TPipeBase(const TString& command, const char* mode);
- virtual ~TPipeBase();
+ TPipeBase(const TString& command, const char* mode);
+ virtual ~TPipeBase();
protected:
class TImpl;
@@ -45,7 +45,7 @@ public:
*
* @param command Command line to start a process with.
*/
- TPipeInput(const TString& command);
+ TPipeInput(const TString& command);
private:
size_t DoRead(void* buf, size_t len) override;
@@ -64,7 +64,7 @@ public:
*
* @param command Command line to start a process with.
*/
- TPipeOutput(const TString& command);
+ TPipeOutput(const TString& command);
/**
* Waits for the process to terminate and throws an exception if it ended
@@ -79,7 +79,7 @@ private:
class TPipedBase {
protected:
TPipedBase(PIPEHANDLE fd);
- virtual ~TPipedBase();
+ virtual ~TPipedBase();
protected:
TPipeHandle Handle_;
@@ -91,7 +91,7 @@ protected:
class TPipedInput: public TPipedBase, public IInputStream {
public:
TPipedInput(PIPEHANDLE fd);
- ~TPipedInput() override;
+ ~TPipedInput() override;
private:
size_t DoRead(void* buf, size_t len) override;
@@ -103,7 +103,7 @@ private:
class TPipedOutput: public TPipedBase, public IOutputStream {
public:
TPipedOutput(PIPEHANDLE fd);
- ~TPipedOutput() override;
+ ~TPipedOutput() override;
private:
void DoWrite(const void* buf, size_t len) override;
diff --git a/util/stream/printf_ut.cpp b/util/stream/printf_ut.cpp
index d96789e96a..0eab167062 100644
--- a/util/stream/printf_ut.cpp
+++ b/util/stream/printf_ut.cpp
@@ -2,7 +2,7 @@
#include "printf.h"
#include "str.h"
-#include <util/generic/string.h>
+#include <util/generic/string.h>
#include <library/cpp/testing/unittest/registar.h>
@@ -23,7 +23,7 @@ Y_UNIT_TEST_SUITE(TStreamPrintfTest) {
}
Y_UNIT_TEST(TestLargePrintf) {
- TString s = NUnitTest::RandomString(1000000);
+ TString s = NUnitTest::RandomString(1000000);
TStringStream ss;
Printf(ss, "%s", s.data());
diff --git a/util/stream/str.h b/util/stream/str.h
index a3695b6840..028bd572c0 100644
--- a/util/stream/str.h
+++ b/util/stream/str.h
@@ -3,7 +3,7 @@
#include "zerocopy.h"
#include "zerocopy_output.h"
-#include <util/generic/string.h>
+#include <util/generic/string.h>
#include <util/generic/noncopyable.h>
#include <util/generic/store_policy.h>
@@ -29,19 +29,19 @@ public:
*
* @param s String to read from.
*/
- inline TStringInput(const TString& s) noexcept
+ inline TStringInput(const TString& s) noexcept
: S_(&s)
, Pos_(0)
{
}
- TStringInput(const TString&&) = delete;
+ TStringInput(const TString&&) = delete;
- ~TStringInput() override;
+ ~TStringInput() override;
+
+ TStringInput(TStringInput&&) noexcept = default;
+ TStringInput& operator=(TStringInput&&) noexcept = default;
- TStringInput(TStringInput&&) noexcept = default;
- TStringInput& operator=(TStringInput&&) noexcept = default;
-
inline void Swap(TStringInput& s) noexcept {
DoSwap(S_, s.S_);
DoSwap(Pos_, s.Pos_);
@@ -73,14 +73,14 @@ public:
*
* @param s String to append to.
*/
- inline TStringOutput(TString& s) noexcept
+ inline TStringOutput(TString& s) noexcept
: S_(&s)
{
}
TStringOutput(TStringOutput&& s) noexcept = default;
- ~TStringOutput() override;
+ ~TStringOutput() override;
/**
* @param size Number of additional characters to
@@ -107,7 +107,7 @@ private:
/**
* String input/output stream, similar to `std::stringstream`.
*/
-class TStringStream: private TEmbedPolicy<TString>, public TStringInput, public TStringOutput {
+class TStringStream: private TEmbedPolicy<TString>, public TStringInput, public TStringOutput {
using TEmbeddedString = TEmbedPolicy<TString>;
public:
@@ -118,7 +118,7 @@ public:
{
}
- inline TStringStream(const TString& string)
+ inline TStringStream(const TString& string)
: TEmbeddedString(string)
, TStringInput(*TEmbeddedString::Ptr())
, TStringOutput(*TEmbeddedString::Ptr())
@@ -140,7 +140,7 @@ public:
return *this;
}
- ~TStringStream() override;
+ ~TStringStream() override;
/**
* @returns Whether @c this contains any data
@@ -152,14 +152,14 @@ public:
/**
* @returns String that this stream is writing into.
*/
- inline TString& Str() noexcept {
+ inline TString& Str() noexcept {
return *Ptr();
}
/**
* @returns String that this stream is writing into.
*/
- inline const TString& Str() const noexcept {
+ inline const TString& Str() const noexcept {
return *Ptr();
}
@@ -168,7 +168,7 @@ public:
* in this stream. The data is guaranteed
* to be null-terminated.
*/
- inline const char* Data() const noexcept {
+ inline const char* Data() const noexcept {
return Ptr()->data();
}
@@ -178,7 +178,7 @@ public:
* as the total number of characters
* available for reading.
*/
- inline size_t Size() const noexcept {
+ inline size_t Size() const noexcept {
return Ptr()->size();
}
diff --git a/util/stream/str_ut.cpp b/util/stream/str_ut.cpp
index 416c924b30..fc6b46c31a 100644
--- a/util/stream/str_ut.cpp
+++ b/util/stream/str_ut.cpp
@@ -8,39 +8,39 @@ const T ReturnConstTemp();
Y_UNIT_TEST_SUITE(TStringInputOutputTest) {
Y_UNIT_TEST(Lvalue) {
- TString str = "Hello, World!";
+ TString str = "Hello, World!";
TStringInput input(str);
- TString result = input.ReadAll();
+ TString result = input.ReadAll();
UNIT_ASSERT_VALUES_EQUAL(result, str);
}
Y_UNIT_TEST(ConstRef) {
- TString str = "Hello, World!";
- const TString& r = str;
+ TString str = "Hello, World!";
+ const TString& r = str;
TStringInput input(r);
- TString result = input.ReadAll();
+ TString result = input.ReadAll();
UNIT_ASSERT_VALUES_EQUAL(result, str);
}
Y_UNIT_TEST(NonConstRef) {
- TString str = "Hello, World!";
- TString& r = str;
+ TString str = "Hello, World!";
+ TString& r = str;
TStringInput input(r);
- TString result = input.ReadAll();
+ TString result = input.ReadAll();
UNIT_ASSERT_VALUES_EQUAL(result, str);
}
Y_UNIT_TEST(Transfer) {
- TString inputString = "some_string";
+ TString inputString = "some_string";
TStringInput input(inputString);
- TString outputString;
+ TString outputString;
TStringOutput output(outputString);
TransferData(&input, &output);
@@ -49,9 +49,9 @@ Y_UNIT_TEST_SUITE(TStringInputOutputTest) {
}
Y_UNIT_TEST(SkipReadAll) {
- TString string0 = "All animals are equal, but some animals are more equal than others.";
+ TString string0 = "All animals are equal, but some animals are more equal than others.";
- TString string1;
+ TString string1;
for (size_t i = 1; i <= string0.size(); i++) {
string1 += string0.substr(0, i);
}
@@ -63,7 +63,7 @@ Y_UNIT_TEST_SUITE(TStringInputOutputTest) {
left -= input0.Skip(left);
}
- TString string2 = input0.ReadAll();
+ TString string2 = input0.ReadAll();
UNIT_ASSERT_VALUES_EQUAL(string2, string1.substr(5));
}
@@ -78,8 +78,8 @@ Y_UNIT_TEST_SUITE(TStringInputOutputTest) {
}
Y_UNIT_TEST(TestReadTo) {
- TString s("0123456789abc");
- TString t;
+ TString s("0123456789abc");
+ TString t;
TStringInput in0(s);
UNIT_ASSERT_VALUES_EQUAL(in0.ReadTo(t, '7'), 8);
diff --git a/util/stream/tee.h b/util/stream/tee.h
index 197d242ff5..c69e232fb9 100644
--- a/util/stream/tee.h
+++ b/util/stream/tee.h
@@ -13,7 +13,7 @@
class TTeeOutput: public IOutputStream {
public:
TTeeOutput(IOutputStream* l, IOutputStream* r) noexcept;
- ~TTeeOutput() override;
+ ~TTeeOutput() override;
private:
void DoWrite(const void* buf, size_t len) override;
diff --git a/util/stream/tempbuf.cpp b/util/stream/tempbuf.cpp
index 1f00c22dd3..801a1fabb0 100644
--- a/util/stream/tempbuf.cpp
+++ b/util/stream/tempbuf.cpp
@@ -1,7 +1,7 @@
#include "tempbuf.h"
namespace {
- static inline size_t Next(size_t size) noexcept {
+ static inline size_t Next(size_t size) noexcept {
return size * 2;
}
}
diff --git a/util/stream/tempbuf.h b/util/stream/tempbuf.h
index 71a2a08d84..a6dc001025 100644
--- a/util/stream/tempbuf.h
+++ b/util/stream/tempbuf.h
@@ -5,9 +5,9 @@
#include <util/memory/tempbuf.h>
class TTempBufOutput: public IOutputStream, public TTempBuf {
-public:
+public:
inline TTempBufOutput() = default;
-
+
explicit TTempBufOutput(size_t size)
: TTempBuf(size)
{
@@ -15,7 +15,7 @@ public:
TTempBufOutput(TTempBufOutput&&) noexcept = default;
TTempBufOutput& operator=(TTempBufOutput&&) noexcept = default;
-
+
protected:
void DoWrite(const void* data, size_t len) override;
};
diff --git a/util/stream/tokenizer.h b/util/stream/tokenizer.h
index 944aada3a5..b2398efdd1 100644
--- a/util/stream/tokenizer.h
+++ b/util/stream/tokenizer.h
@@ -31,7 +31,7 @@ public:
{
}
- inline TIterator() noexcept
+ inline TIterator() noexcept
: Parent_(nullptr)
, Data_(nullptr)
, Len_(0)
@@ -45,11 +45,11 @@ public:
Next();
}
- inline bool operator==(const TIterator& l) const noexcept {
+ inline bool operator==(const TIterator& l) const noexcept {
return AtEnd_ == l.AtEnd_;
}
- inline bool operator!=(const TIterator& l) const noexcept {
+ inline bool operator!=(const TIterator& l) const noexcept {
return !(*this == l);
}
@@ -57,7 +57,7 @@ public:
* @return Return null-terminated character array with current token.
* The pointer may be invalid after iterator increment.
*/
- inline const char* Data() const noexcept {
+ inline const char* Data() const noexcept {
Y_ASSERT(!AtEnd_);
return Data_;
@@ -66,17 +66,17 @@ public:
/**
* @return Length of current token.
*/
- inline size_t Length() const noexcept {
+ inline size_t Length() const noexcept {
Y_ASSERT(!AtEnd_);
return Len_;
}
- inline TIterator* operator->() noexcept {
+ inline TIterator* operator->() noexcept {
return this;
}
- inline TStringBuf operator*() noexcept {
+ inline TStringBuf operator*() noexcept {
return TStringBuf{Data_, Len_};
}
@@ -166,7 +166,7 @@ public:
return TIterator{this};
}
- inline TIterator end() noexcept {
+ inline TIterator end() noexcept {
return {};
}
@@ -180,11 +180,11 @@ private:
return bytesRead;
}
- inline char* BufBegin() noexcept {
+ inline char* BufBegin() noexcept {
return Buf_.Data();
}
- inline char* BufEnd() noexcept {
+ inline char* BufEnd() noexcept {
return Buf_.Data() + Buf_.Capacity();
}
@@ -206,7 +206,7 @@ private:
* Predicate for `TStreamTokenizer` that uses '\\n' as a delimiter.
*/
struct TEol {
- inline bool operator()(char ch) const noexcept {
+ inline bool operator()(char ch) const noexcept {
return ch == '\n';
}
};
diff --git a/util/stream/tokenizer_ut.cpp b/util/stream/tokenizer_ut.cpp
index 957b8cc3e0..afc566da86 100644
--- a/util/stream/tokenizer_ut.cpp
+++ b/util/stream/tokenizer_ut.cpp
@@ -108,7 +108,7 @@ Y_UNIT_TEST_SUITE(TStreamTokenizerTests) {
Y_UNIT_TEST(CustomPredicateTest) {
struct TIsVerticalBar {
- inline bool operator()(const char ch) const noexcept {
+ inline bool operator()(const char ch) const noexcept {
return '|' == ch;
}
};
@@ -132,7 +132,7 @@ Y_UNIT_TEST_SUITE(TStreamTokenizerTests) {
Y_UNIT_TEST(CustomPredicateSecondTest) {
struct TIsVerticalBar {
- inline bool operator()(const char ch) const noexcept {
+ inline bool operator()(const char ch) const noexcept {
return '|' == ch || ',' == ch;
}
};
@@ -157,7 +157,7 @@ Y_UNIT_TEST_SUITE(TStreamTokenizerTests) {
Y_UNIT_TEST(FalsePredicateTest) {
struct TAlwaysFalse {
- inline bool operator()(const char) const noexcept {
+ inline bool operator()(const char) const noexcept {
return false;
}
};
@@ -178,7 +178,7 @@ Y_UNIT_TEST_SUITE(TStreamTokenizerTests) {
Y_UNIT_TEST(TruePredicateTest) {
struct TAlwaysTrue {
- inline bool operator()(const char) const noexcept {
+ inline bool operator()(const char) const noexcept {
return true;
}
};
diff --git a/util/stream/walk.cpp b/util/stream/walk.cpp
index 280f7e9f10..57dc9ab036 100644
--- a/util/stream/walk.cpp
+++ b/util/stream/walk.cpp
@@ -1,6 +1,6 @@
#include "walk.h"
-#include <util/generic/string.h>
+#include <util/generic/string.h>
void IWalkInput::DoUndo(size_t len) {
Len_ += len;
diff --git a/util/stream/walk_ut.cpp b/util/stream/walk_ut.cpp
index ed75b4e2ba..e0a783799f 100644
--- a/util/stream/walk_ut.cpp
+++ b/util/stream/walk_ut.cpp
@@ -4,7 +4,7 @@
class TStringListInput: public IWalkInput {
public:
- TStringListInput(const TVector<TString>& data)
+ TStringListInput(const TVector<TString>& data)
: Data_(data)
, Index_(0)
{
@@ -16,20 +16,20 @@ protected:
return 0;
}
- const TString& string = Data_[Index_++];
+ const TString& string = Data_[Index_++];
*ptr = string.data();
return string.size();
}
private:
- const TVector<TString>& Data_;
+ const TVector<TString>& Data_;
size_t Index_;
};
Y_UNIT_TEST_SUITE(TWalkTest) {
Y_UNIT_TEST(ReadTo) {
- TVector<TString> data;
+ TVector<TString> data;
data.push_back("111a");
data.push_back("222b");
data.push_back("333c");
@@ -39,17 +39,17 @@ Y_UNIT_TEST_SUITE(TWalkTest) {
TStringListInput input(data);
- TString tmp1 = input.ReadTo('c');
+ TString tmp1 = input.ReadTo('c');
UNIT_ASSERT_VALUES_EQUAL(tmp1, "111a222b333");
char tmp2;
input.Read(&tmp2, 1);
UNIT_ASSERT_VALUES_EQUAL(tmp2, '4');
- TString tmp3 = input.ReadTo('6');
+ TString tmp3 = input.ReadTo('6');
UNIT_ASSERT_VALUES_EQUAL(tmp3, "44d555e");
- TString tmp4 = input.ReadAll();
+ TString tmp4 = input.ReadAll();
UNIT_ASSERT_VALUES_EQUAL(tmp4, "66f");
}
}
diff --git a/util/stream/zerocopy.h b/util/stream/zerocopy.h
index 583985f57f..3315aa3a51 100644
--- a/util/stream/zerocopy.h
+++ b/util/stream/zerocopy.h
@@ -25,7 +25,7 @@ public:
IZeroCopyInput(IZeroCopyInput&&) noexcept = default;
IZeroCopyInput& operator=(IZeroCopyInput&&) noexcept = default;
-
+
/**
* Returns the next data chunk from this input stream.
*
@@ -70,7 +70,7 @@ public:
IZeroCopyInputFastReadTo& operator=(IZeroCopyInputFastReadTo&&) noexcept = default;
protected:
- size_t DoReadTo(TString& st, char ch) override;
+ size_t DoReadTo(TString& st, char ch) override;
private:
/**
diff --git a/util/stream/zlib.cpp b/util/stream/zlib.cpp
index 7e065aab61..60f4e9439f 100644
--- a/util/stream/zlib.cpp
+++ b/util/stream/zlib.cpp
@@ -22,17 +22,17 @@ namespace {
class TZLibCommon {
public:
- inline TZLibCommon() noexcept {
+ inline TZLibCommon() noexcept {
memset(Z(), 0, sizeof(*Z()));
}
inline ~TZLibCommon() = default;
- inline const char* GetErrMsg() const noexcept {
+ inline const char* GetErrMsg() const noexcept {
return Z()->msg != nullptr ? Z()->msg : "unknown error";
}
- inline z_stream* Z() const noexcept {
+ inline z_stream* Z() const noexcept {
return (z_stream*)(&Z_);
}
@@ -40,7 +40,7 @@ namespace {
z_stream Z_;
};
- static inline ui32 MaxPortion(size_t s) noexcept {
+ static inline ui32 MaxPortion(size_t s) noexcept {
return (ui32)Min<size_t>(Max<ui32>(), s);
}
@@ -225,7 +225,7 @@ public:
Z()->avail_out = TmpBufLen();
}
- inline ~TImpl() {
+ inline ~TImpl() {
deflateEnd(Z());
}
@@ -305,11 +305,11 @@ public:
}
private:
- inline unsigned char* TmpBuf() noexcept {
+ inline unsigned char* TmpBuf() noexcept {
return (unsigned char*)AdditionalData();
}
- inline size_t TmpBufLen() const noexcept {
+ inline size_t TmpBufLen() const noexcept {
return AdditionalDataLength();
}
@@ -347,7 +347,7 @@ void TZLibCompress::TDestruct::Destroy(TImpl* impl) {
delete impl;
}
-TZLibCompress::~TZLibCompress() {
+TZLibCompress::~TZLibCompress() {
try {
Finish();
} catch (...) {
diff --git a/util/stream/zlib.h b/util/stream/zlib.h
index c571d98251..e7de7c81b7 100644
--- a/util/stream/zlib.h
+++ b/util/stream/zlib.h
@@ -62,7 +62,7 @@ public:
*/
void SetAllowMultipleStreams(bool allowMultipleStreams);
- ~TZLibDecompress() override;
+ ~TZLibDecompress() override;
protected:
size_t DoRead(void* buf, size_t size) override;
@@ -86,19 +86,19 @@ public:
{
}
- inline TParams& SetType(ZLib::StreamType type) noexcept {
+ inline TParams& SetType(ZLib::StreamType type) noexcept {
Type = type;
return *this;
}
- inline TParams& SetCompressionLevel(size_t level) noexcept {
+ inline TParams& SetCompressionLevel(size_t level) noexcept {
CompressionLevel = level;
return *this;
}
- inline TParams& SetBufLen(size_t buflen) noexcept {
+ inline TParams& SetBufLen(size_t buflen) noexcept {
BufLen = buflen;
return *this;
@@ -133,7 +133,7 @@ public:
Init(TParams(out).SetType(type).SetCompressionLevel(compression_level).SetBufLen(buflen));
}
- ~TZLibCompress() override;
+ ~TZLibCompress() override;
private:
void Init(const TParams& opts);
@@ -167,7 +167,7 @@ public:
{
}
- ~TBufferedZLibDecompress() override;
+ ~TBufferedZLibDecompress() override;
};
/** @} */
diff --git a/util/stream/zlib_ut.cpp b/util/stream/zlib_ut.cpp
index 022bca5f3f..2290b4a9de 100644
--- a/util/stream/zlib_ut.cpp
+++ b/util/stream/zlib_ut.cpp
@@ -56,7 +56,7 @@ Y_UNIT_TEST_SUITE(TZLibTest) {
static const TString DATA2 = "cn8wk2bd9vb3vdfif83g1ks94bfiovtwv";
Y_UNIT_TEST(Compress) {
- TUnbufferedFileOutput o(ZDATA);
+ TUnbufferedFileOutput o(ZDATA);
TZLibCompress c(&o, ZLib::ZLib);
c.Write(DATA.data(), DATA.size());
@@ -68,7 +68,7 @@ Y_UNIT_TEST_SUITE(TZLibTest) {
TTempFile tmpFile(ZDATA);
{
- TUnbufferedFileInput i(ZDATA);
+ TUnbufferedFileInput i(ZDATA);
TZLibDecompress d(&i);
UNIT_ASSERT_EQUAL(d.ReadAll(), DATA);
@@ -94,7 +94,7 @@ Y_UNIT_TEST_SUITE(TZLibTest) {
// Check that Decompress(Compress(X) + Compress(Y)) == X + Y
TTempFile tmpFile(ZDATA);
{
- TUnbufferedFileOutput o(ZDATA);
+ TUnbufferedFileOutput o(ZDATA);
TZLibCompress c1(&o, ZLib::ZLib);
c1.Write(DATA.data(), DATA.size());
c1.Finish();
@@ -104,7 +104,7 @@ Y_UNIT_TEST_SUITE(TZLibTest) {
o.Finish();
}
{
- TUnbufferedFileInput i(ZDATA);
+ TUnbufferedFileInput i(ZDATA);
TZLibDecompress d(&i);
UNIT_ASSERT_EQUAL(d.ReadAll(), DATA + DATA2);
@@ -130,7 +130,7 @@ Y_UNIT_TEST_SUITE(TZLibTest) {
// Check that Decompress(Compress(X) + Compress(Y)) == X when single stream is allowed
TTempFile tmpFile(ZDATA);
{
- TUnbufferedFileOutput o(ZDATA);
+ TUnbufferedFileOutput o(ZDATA);
TZLibCompress c1(&o, ZLib::ZLib);
c1.Write(DATA.data(), DATA.size());
c1.Finish();
@@ -140,7 +140,7 @@ Y_UNIT_TEST_SUITE(TZLibTest) {
o.Finish();
}
{
- TUnbufferedFileInput i(ZDATA);
+ TUnbufferedFileInput i(ZDATA);
TZLibDecompress d(&i);
d.SetAllowMultipleStreams(false);
diff --git a/util/string/ascii.h b/util/string/ascii.h
index 67c4e35a71..10344384d3 100644
--- a/util/string/ascii.h
+++ b/util/string/ascii.h
@@ -2,7 +2,7 @@
#include <util/system/defaults.h>
#include <util/system/compat.h>
-#include <util/generic/string.h>
+#include <util/generic/string.h>
// ctype.h-like functions, locale-independent:
// IsAscii{Upper,Lower,Digit,Alpha,Alnum,Space} and
diff --git a/util/string/ascii_ut.cpp b/util/string/ascii_ut.cpp
index 5b0617a8b5..89069fee50 100644
--- a/util/string/ascii_ut.cpp
+++ b/util/string/ascii_ut.cpp
@@ -65,15 +65,15 @@ Y_UNIT_TEST_SUITE(TAsciiTest) {
Y_UNIT_TEST(CompareTest) {
UNIT_ASSERT(AsciiEqualsIgnoreCase("qqq", "qQq"));
UNIT_ASSERT(AsciiEqualsIgnoreCase("qqq", TStringBuf("qQq")));
- TString qq = "qq";
- TString qQ = "qQ";
+ TString qq = "qq";
+ TString qQ = "qQ";
UNIT_ASSERT(AsciiEqualsIgnoreCase(qq, qQ));
- TString x = "qqqA";
- TString y = "qQqB";
- TString z = "qQnB";
- TString zz = "qQqq";
- TString zzz = "qQqqq";
+ TString x = "qqqA";
+ TString y = "qQqB";
+ TString z = "qQnB";
+ TString zz = "qQqq";
+ TString zzz = "qQqqq";
TStringBuf xs = TStringBuf(x.data(), 3);
TStringBuf ys = TStringBuf(y.data(), 3);
TStringBuf zs = TStringBuf(z.data(), 3);
diff --git a/util/string/benchmark/float_to_string/main.cpp b/util/string/benchmark/float_to_string/main.cpp
index b52a5e5ab1..1c7c0684a3 100644
--- a/util/string/benchmark/float_to_string/main.cpp
+++ b/util/string/benchmark/float_to_string/main.cpp
@@ -34,7 +34,7 @@ namespace {
template <typename T, size_t N>
struct TExamplesHolder {
- TVector<TExample<T>> Examples;
+ TVector<TExample<T>> Examples;
TExamplesHolder()
: Examples(N)
@@ -49,7 +49,7 @@ namespace {
template <typename T, size_t N>
struct TNearZeroExamplesHolder {
- TVector<TExample<T>> Examples;
+ TVector<TExample<T>> Examples;
TNearZeroExamplesHolder()
: Examples(N)
diff --git a/util/string/benchmark/join/main.cpp b/util/string/benchmark/join/main.cpp
index cca2331a33..1a8633d3a8 100644
--- a/util/string/benchmark/join/main.cpp
+++ b/util/string/benchmark/join/main.cpp
@@ -46,7 +46,7 @@ namespace {
template <size_t N, typename... T>
struct TExamplesHolder {
- using TExamples = TVector<std::tuple<T...>>;
+ using TExamples = TVector<std::tuple<T...>>;
TExamples Examples;
TExamplesHolder()
diff --git a/util/string/benchmark/subst_global/main.cpp b/util/string/benchmark/subst_global/main.cpp
index 0cce508f08..e0decfa042 100644
--- a/util/string/benchmark/subst_global/main.cpp
+++ b/util/string/benchmark/subst_global/main.cpp
@@ -2,7 +2,7 @@
#include <util/generic/cast.h>
#include <util/generic/singleton.h>
-#include <util/generic/string.h>
+#include <util/generic/string.h>
#include <util/generic/xrange.h>
#include <util/random/fast.h>
#include <util/string/cast.h>
@@ -15,7 +15,7 @@ namespace {
WHAT = What,
WITH = With
};
- TString Str;
+ TString Str;
TNoMatches() {
for (const auto dummy : xrange(N)) {
@@ -31,7 +31,7 @@ namespace {
WHAT = What,
WITH = With
};
- TString Str;
+ TString Str;
TOneMatchInTheBeginning() {
if (!N) {
@@ -54,7 +54,7 @@ namespace {
WHAT = What,
WITH = With
};
- TString Str;
+ TString Str;
TOneMatchInTheEnd() {
if (!N) {
@@ -77,7 +77,7 @@ namespace {
WHAT = What,
WITH = With
};
- TString Str;
+ TString Str;
TOneMatchInTheMiddle() {
if (!N) {
@@ -100,7 +100,7 @@ namespace {
WHAT = What,
WITH = With
};
- TString Str;
+ TString Str;
TFirstHalfMatches() {
for (size_t i = 0; i < N / 2; ++i) {
@@ -118,7 +118,7 @@ namespace {
WHAT = What,
WITH = With
};
- TString Str;
+ TString Str;
TSecondHalfMatches() {
for (size_t i = 0; i < N / 2; ++i) {
@@ -136,7 +136,7 @@ namespace {
WHAT = What,
WITH = With
};
- TString Str;
+ TString Str;
TEveryKth() {
TFastRng<ui64> prng{N * K * 101};
diff --git a/util/string/builder.cpp b/util/string/builder.cpp
index 205b4475f9..a3821d3399 100644
--- a/util/string/builder.cpp
+++ b/util/string/builder.cpp
@@ -4,5 +4,5 @@
template <>
void Out<TStringBuilder>(IOutputStream& os, const TStringBuilder& sb) {
- os << static_cast<const TString&>(sb);
+ os << static_cast<const TString&>(sb);
}
diff --git a/util/string/builder.h b/util/string/builder.h
index eb800b807f..7b54821151 100644
--- a/util/string/builder.h
+++ b/util/string/builder.h
@@ -2,10 +2,10 @@
#include <util/stream/str.h>
#include <utility>
-#include <util/generic/string.h>
+#include <util/generic/string.h>
namespace NPrivateStringBuilder {
- class TStringBuilder: public TString {
+ class TStringBuilder: public TString {
public:
inline TStringBuilder()
: Out(*this)
diff --git a/util/string/builder_ut.cpp b/util/string/builder_ut.cpp
index ff6395ca22..22def683ec 100644
--- a/util/string/builder_ut.cpp
+++ b/util/string/builder_ut.cpp
@@ -2,15 +2,15 @@
#include <library/cpp/testing/unittest/registar.h>
-static void TestEquals(const TString& expected, const TString& actual) {
+static void TestEquals(const TString& expected, const TString& actual) {
UNIT_ASSERT_VALUES_EQUAL(expected, actual);
}
struct TClassWithStreamOperator {
ui32 Id;
- TString Name;
+ TString Name;
- TClassWithStreamOperator(ui32 id, const TString& name)
+ TClassWithStreamOperator(ui32 id, const TString& name)
: Id(id)
, Name(name)
{
@@ -30,7 +30,7 @@ Y_UNIT_TEST_SUITE(TStringBuilderTest) {
}
Y_UNIT_TEST(TestStringBuilderOut) {
- TString s;
+ TString s;
TStringOutput out(s);
TStringBuilder sb;
sb << "a";
@@ -40,11 +40,11 @@ Y_UNIT_TEST_SUITE(TStringBuilderTest) {
Y_UNIT_TEST(TestStringBuilderRValue) {
struct TRValueAcceptTester {
- static bool IsRValue(const TString&) {
+ static bool IsRValue(const TString&) {
return false;
}
- static bool IsRValue(TString&&) {
+ static bool IsRValue(TString&&) {
return true;
}
};
diff --git a/util/string/cast.cpp b/util/string/cast.cpp
index 21f4a35157..aa1e65a8e9 100644
--- a/util/string/cast.cpp
+++ b/util/string/cast.cpp
@@ -14,7 +14,7 @@
#include <contrib/libs/double-conversion/double-conversion.h>
-#include <util/generic/string.h>
+#include <util/generic/string.h>
#include <util/system/yassert.h>
#include <util/generic/yexception.h>
#include <util/generic/typetraits.h>
@@ -517,8 +517,8 @@ bool FromStringImpl<bool>(const char* data, size_t len) {
}
template <>
-TString FromStringImpl<TString>(const char* data, size_t len) {
- return TString(data, len);
+TString FromStringImpl<TString>(const char* data, size_t len) {
+ return TString(data, len);
}
template <>
@@ -532,8 +532,8 @@ std::string FromStringImpl<std::string>(const char* data, size_t len) {
}
template <>
-TUtf16String FromStringImpl<TUtf16String>(const wchar16* data, size_t len) {
- return TUtf16String(data, len);
+TUtf16String FromStringImpl<TUtf16String>(const wchar16* data, size_t len) {
+ return TUtf16String(data, len);
}
template <>
@@ -549,8 +549,8 @@ bool TryFromStringImpl<TStringBuf>(const char* data, size_t len, TStringBuf& res
}
template <>
-bool TryFromStringImpl<TString>(const char* data, size_t len, TString& result) {
- result = TString(data, len);
+bool TryFromStringImpl<TString>(const char* data, size_t len, TString& result) {
+ result = TString(data, len);
return true;
}
@@ -567,8 +567,8 @@ bool TryFromStringImpl<TWtringBuf>(const wchar16* data, size_t len, TWtringBuf&
}
template <>
-bool TryFromStringImpl<TUtf16String>(const wchar16* data, size_t len, TUtf16String& result) {
- result = TUtf16String(data, len);
+bool TryFromStringImpl<TUtf16String>(const wchar16* data, size_t len, TUtf16String& result) {
+ result = TUtf16String(data, len);
return true;
}
diff --git a/util/string/cast.h b/util/string/cast.h
index b6c78b5f48..90e925c194 100644
--- a/util/string/cast.h
+++ b/util/string/cast.h
@@ -2,7 +2,7 @@
#include <util/system/defaults.h>
#include <util/stream/str.h>
-#include <util/generic/string.h>
+#include <util/generic/string.h>
#include <util/generic/strbuf.h>
#include <util/generic/typetraits.h>
#include <util/generic/yexception.h>
@@ -40,35 +40,35 @@ enum EFloatToStringMode {
/** "%f" mode, writes the given number of digits after decimal point:
* 0.1f -> "0.100000", 1.2e-06f -> "0.000001" for ndigits=6 */
PREC_POINT_DIGITS = 3,
-
- /** same as PREC_POINT_DIGITS, but stripping trailing zeroes:
- * 0.1f for ndgigits=6 -> "0.1" */
- PREC_POINT_DIGITS_STRIP_ZEROES = 4
+
+ /** same as PREC_POINT_DIGITS, but stripping trailing zeroes:
+ * 0.1f for ndgigits=6 -> "0.1" */
+ PREC_POINT_DIGITS_STRIP_ZEROES = 4
};
size_t FloatToString(float t, char* buf, size_t len, EFloatToStringMode mode = PREC_AUTO, int ndigits = 0);
size_t FloatToString(double t, char* buf, size_t len, EFloatToStringMode mode = PREC_AUTO, int ndigits = 0);
template <typename T>
-inline TString FloatToString(const T& t, EFloatToStringMode mode = PREC_AUTO, int ndigits = 0) {
+inline TString FloatToString(const T& t, EFloatToStringMode mode = PREC_AUTO, int ndigits = 0) {
char buf[512]; // Max<double>() with mode = PREC_POINT_DIGITS has 309 digits before the decimal point
size_t count = FloatToString(t, buf, sizeof(buf), mode, ndigits);
- return TString(buf, count);
+ return TString(buf, count);
}
namespace NPrivate {
template <class T, bool isSimple>
struct TToString {
- static inline TString Cvt(const T& t) {
+ static inline TString Cvt(const T& t) {
char buf[512];
- return TString(buf, ToString<T>(t, buf, sizeof(buf)));
+ return TString(buf, ToString<T>(t, buf, sizeof(buf)));
}
};
template <class T>
struct TToString<T, false> {
- static inline TString Cvt(const T& t) {
+ static inline TString Cvt(const T& t) {
TString s;
TStringOutput o(s);
o << t;
@@ -81,25 +81,25 @@ namespace NPrivate {
* some clever implementations...
*/
template <class T>
-inline TString ToString(const T& t) {
+inline TString ToString(const T& t) {
using TR = std::remove_cv_t<T>;
return ::NPrivate::TToString<TR, std::is_arithmetic<TR>::value>::Cvt((const TR&)t);
}
-inline const TString& ToString(const TString& s) noexcept {
+inline const TString& ToString(const TString& s) noexcept {
return s;
}
-inline const TString& ToString(TString& s) noexcept {
+inline const TString& ToString(TString& s) noexcept {
return s;
}
-inline TString ToString(const char* s) {
+inline TString ToString(const char* s) {
return s;
}
-inline TString ToString(char* s) {
+inline TString ToString(char* s) {
return s;
}
@@ -107,15 +107,15 @@ inline TString ToString(char* s) {
* Wrapper for wide strings.
*/
template <class T>
-inline TUtf16String ToWtring(const T& t) {
- return TUtf16String::FromAscii(ToString(t));
+inline TUtf16String ToWtring(const T& t) {
+ return TUtf16String::FromAscii(ToString(t));
}
-inline const TUtf16String& ToWtring(const TUtf16String& w) {
+inline const TUtf16String& ToWtring(const TUtf16String& w) {
return w;
}
-inline const TUtf16String& ToWtring(TUtf16String& w) {
+inline const TUtf16String& ToWtring(TUtf16String& w) {
return w;
}
@@ -156,7 +156,7 @@ inline T FromString(const TStringBuf& s) {
}
template <class T>
-inline T FromString(const TString& s) {
+inline T FromString(const TString& s) {
return ::FromString<T>(s.data(), s.size());
}
@@ -166,7 +166,7 @@ inline T FromString(const std::string& s) {
}
template <>
-inline TString FromString<TString>(const TString& s) {
+inline TString FromString<TString>(const TString& s) {
return s;
}
@@ -176,7 +176,7 @@ inline T FromString(const TWtringBuf& s) {
}
template <class T>
-inline T FromString(const TUtf16String& s) {
+inline T FromString(const TUtf16String& s) {
return ::FromString<T, wchar16>(s.data(), s.size());
}
@@ -251,7 +251,7 @@ inline bool TryFromString(const TStringBuf& s, T& result) {
}
template <class T>
-inline bool TryFromString(const TString& s, T& result) {
+inline bool TryFromString(const TString& s, T& result) {
return TryFromString<T>(s.data(), s.size(), result);
}
@@ -266,12 +266,12 @@ inline bool TryFromString(const TWtringBuf& s, T& result) {
}
template <class T>
-inline bool TryFromString(const TUtf16String& s, T& result) {
+inline bool TryFromString(const TUtf16String& s, T& result) {
return TryFromString<T>(s.data(), s.size(), result);
}
-template <class T, class TStringType>
-inline bool TryFromStringWithDefault(const TStringType& s, T& result, const T& def) {
+template <class T, class TStringType>
+inline bool TryFromStringWithDefault(const TStringType& s, T& result, const T& def) {
return TryFromString<T>(s.data(), s.size(), result, def);
}
@@ -280,8 +280,8 @@ inline bool TryFromStringWithDefault(const char* s, T& result, const T& def) {
return TryFromStringWithDefault<T>(TStringBuf(s), result, def);
}
-template <class T, class TStringType>
-inline bool TryFromStringWithDefault(const TStringType& s, T& result) {
+template <class T, class TStringType>
+inline bool TryFromStringWithDefault(const TStringType& s, T& result) {
return TryFromStringWithDefault<T>(s, result, T());
}
@@ -293,8 +293,8 @@ inline T FromString(const TChar* data, const size_t len, const T& def) {
return result;
}
-template <class T, class TStringType>
-inline T FromStringWithDefault(const TStringType& s, const T& def) {
+template <class T, class TStringType>
+inline T FromStringWithDefault(const TStringType& s, const T& def) {
return FromString<T>(s.data(), s.size(), def);
}
@@ -303,8 +303,8 @@ inline T FromStringWithDefault(const char* s, const T& def) {
return FromStringWithDefault<T>(TStringBuf(s), def);
}
-template <class T, class TStringType>
-inline T FromStringWithDefault(const TStringType& s) {
+template <class T, class TStringType>
+inline T FromStringWithDefault(const TStringType& s) {
return FromStringWithDefault<T>(s, T());
}
@@ -315,19 +315,19 @@ template <int base, class T>
size_t IntToString(T t, char* buf, size_t len);
template <int base, class T>
-inline TString IntToString(T t) {
+inline TString IntToString(T t) {
static_assert(std::is_arithmetic<std::remove_cv_t<T>>::value, "expect std::is_arithmetic<std::remove_cv_t<T>>::value");
char buf[256];
- return TString(buf, IntToString<base>(t, buf, sizeof(buf)));
+ return TString(buf, IntToString<base>(t, buf, sizeof(buf)));
}
template <int base, class TInt, class TChar>
bool TryIntFromString(const TChar* data, size_t len, TInt& result);
-template <int base, class TInt, class TStringType>
-inline bool TryIntFromString(const TStringType& s, TInt& result) {
+template <int base, class TInt, class TStringType>
+inline bool TryIntFromString(const TStringType& s, TInt& result) {
return TryIntFromString<base>(s.data(), s.size(), result);
}
diff --git a/util/string/cast_ut.cpp b/util/string/cast_ut.cpp
index 31212fff12..033450c38c 100644
--- a/util/string/cast_ut.cpp
+++ b/util/string/cast_ut.cpp
@@ -43,12 +43,12 @@
template <class A>
struct TRet {
template <int base>
- inline A IntFromStringForCheck(const TString& str) {
+ inline A IntFromStringForCheck(const TString& str) {
return IntFromString<A, base>(str);
}
template <int base>
- inline bool TryIntFromStringForCheck(const TString& str, A& result) {
+ inline bool TryIntFromStringForCheck(const TString& str, A& result) {
return TryIntFromString<base>(str, result);
}
@@ -126,7 +126,7 @@ inline TRet<A> F() {
#if 0
template <class T>
-inline void CheckConvertToBuffer(const T& value, const size_t size, const TString& canonValue) {
+inline void CheckConvertToBuffer(const T& value, const size_t size, const TString& canonValue) {
const size_t maxSize = 256;
char buffer[maxSize];
const char magic = 0x7F;
@@ -262,7 +262,7 @@ Y_UNIT_TEST_SUITE(TCastTest) {
UNIT_ASSERT_VALUES_EQUAL(FloatToString(0.12345678f, PREC_POINT_DIGITS, 6), "0.123457");
UNIT_ASSERT_VALUES_EQUAL(FloatToString(1e-20f, PREC_POINT_DIGITS, 6), "0.000000");
UNIT_ASSERT_VALUES_EQUAL(FloatToString(12.34f, PREC_POINT_DIGITS, 0), "12"); // rounding to integers drops '.'
- // strip trailing zeroes
+ // strip trailing zeroes
UNIT_ASSERT_VALUES_EQUAL(FloatToString(0.1f, PREC_POINT_DIGITS_STRIP_ZEROES, 6), "0.1");
UNIT_ASSERT_VALUES_EQUAL(FloatToString(0.12345678f, PREC_POINT_DIGITS_STRIP_ZEROES, 6), "0.123457");
UNIT_ASSERT_VALUES_EQUAL(FloatToString(1e-20f, PREC_POINT_DIGITS_STRIP_ZEROES, 6), "0");
@@ -321,7 +321,7 @@ Y_UNIT_TEST_SUITE(TCastTest) {
}
Y_UNIT_TEST(TestFromStringStringBuf) {
- TString a = "xyz";
+ TString a = "xyz";
TStringBuf b = FromString<TStringBuf>(a);
UNIT_ASSERT_VALUES_EQUAL(a, b);
UNIT_ASSERT_VALUES_EQUAL((void*)a.data(), (void*)b.data());
@@ -375,7 +375,7 @@ Y_UNIT_TEST_SUITE(TCastTest) {
size_t res = 0;
const size_t def1 = 42;
- TString s1("100500");
+ TString s1("100500");
UNIT_ASSERT_VALUES_EQUAL(TryFromStringWithDefault(s1, res, def1), true);
UNIT_ASSERT_VALUES_EQUAL(res, 100500);
@@ -390,7 +390,7 @@ Y_UNIT_TEST_SUITE(TCastTest) {
UNIT_ASSERT_VALUES_EQUAL(FromStringWithDefault<size_t>(s1), 100500);
UNIT_ASSERT_VALUES_EQUAL(FromStringWithDefault("100500", def1), 100500);
- TString s2("100q500");
+ TString s2("100q500");
UNIT_ASSERT_VALUES_EQUAL(TryFromStringWithDefault(s2, res), false);
UNIT_ASSERT_VALUES_EQUAL(res, size_t());
@@ -453,7 +453,7 @@ Y_UNIT_TEST_SUITE(TCastTest) {
UNIT_ASSERT_DOUBLES_EQUAL((float)FromString("0.0001"), 0.0001, EPS);
UNIT_ASSERT_DOUBLES_EQUAL((double)FromString("0.0015", sizeof("0.0015") - 2), 0.001, EPS);
UNIT_ASSERT_DOUBLES_EQUAL((long double)FromString(TStringBuf("0.0001")), 0.0001, EPS);
- UNIT_ASSERT_DOUBLES_EQUAL((float)FromString(TString("10E-5")), 10E-5, EPS);
+ UNIT_ASSERT_DOUBLES_EQUAL((float)FromString(TString("10E-5")), 10E-5, EPS);
UNIT_ASSERT_VALUES_EQUAL((bool)FromString("da"), true);
UNIT_ASSERT_VALUES_EQUAL((bool)FromString("no"), false);
UNIT_ASSERT_VALUES_EQUAL((short)FromString(u"9000"), 9000);
@@ -465,7 +465,7 @@ Y_UNIT_TEST_SUITE(TCastTest) {
}
static void CheckMessage(TFromStringException& exc, const TString& phrase) {
- TString message = exc.what();
+ TString message = exc.what();
if (!message.Contains(phrase)) {
Cerr << message << Endl;
UNIT_ASSERT(false);
@@ -536,7 +536,7 @@ Y_UNIT_TEST_SUITE(TCastTest) {
UNIT_ASSERT_VALUES_EQUAL(hello, out);
}
{
- const TUtf16String empty;
+ const TUtf16String empty;
TWtringBuf out;
UNIT_ASSERT(TryFromString(empty, out));
UNIT_ASSERT_VALUES_EQUAL(empty, out);
diff --git a/util/string/escape.cpp b/util/string/escape.cpp
index 92a28b63ec..cd09a7dbd0 100644
--- a/util/string/escape.cpp
+++ b/util/string/escape.cpp
@@ -174,8 +174,8 @@ TBasicString<TChar>& EscapeCImpl(const TChar* str, size_t len, TBasicString<TCha
return r;
}
-template TString& EscapeCImpl<TString::TChar>(const TString::TChar* str, size_t len, TString& r);
-template TUtf16String& EscapeCImpl<TUtf16String::TChar>(const TUtf16String::TChar* str, size_t len, TUtf16String& r);
+template TString& EscapeCImpl<TString::TChar>(const TString::TChar* str, size_t len, TString& r);
+template TUtf16String& EscapeCImpl<TUtf16String::TChar>(const TUtf16String::TChar* str, size_t len, TUtf16String& r);
namespace {
template <class TStr>
@@ -358,8 +358,8 @@ TChar* UnescapeC(const TChar* str, size_t len, TChar* buf) {
return DoUnescapeC(str, len, bufbuf).P;
}
-template TString& UnescapeCImpl<TString::TChar>(const TString::TChar* str, size_t len, TString& r);
-template TUtf16String& UnescapeCImpl<TUtf16String::TChar>(const TUtf16String::TChar* str, size_t len, TUtf16String& r);
+template TString& UnescapeCImpl<TString::TChar>(const TString::TChar* str, size_t len, TString& r);
+template TUtf16String& UnescapeCImpl<TUtf16String::TChar>(const TUtf16String::TChar* str, size_t len, TUtf16String& r);
template char* UnescapeC<char>(const char* str, size_t len, char* buf);
@@ -398,36 +398,36 @@ size_t UnescapeCCharLen(const TChar* begin, const TChar* end) {
}
template size_t UnescapeCCharLen<char>(const char* begin, const char* end);
-template size_t UnescapeCCharLen<TUtf16String::TChar>(const TUtf16String::TChar* begin, const TUtf16String::TChar* end);
+template size_t UnescapeCCharLen<TUtf16String::TChar>(const TUtf16String::TChar* begin, const TUtf16String::TChar* end);
-TString& EscapeC(const TStringBuf str, TString& s) {
+TString& EscapeC(const TStringBuf str, TString& s) {
return EscapeC(str.data(), str.size(), s);
}
-TUtf16String& EscapeC(const TWtringBuf str, TUtf16String& w) {
+TUtf16String& EscapeC(const TWtringBuf str, TUtf16String& w) {
return EscapeC(str.data(), str.size(), w);
}
-TString EscapeC(const TString& str) {
+TString EscapeC(const TString& str) {
return EscapeC(str.data(), str.size());
}
-TUtf16String EscapeC(const TUtf16String& str) {
+TUtf16String EscapeC(const TUtf16String& str) {
return EscapeC(str.data(), str.size());
}
-TString& UnescapeC(const TStringBuf str, TString& s) {
+TString& UnescapeC(const TStringBuf str, TString& s) {
return UnescapeC(str.data(), str.size(), s);
}
-TUtf16String& UnescapeC(const TWtringBuf str, TUtf16String& w) {
+TUtf16String& UnescapeC(const TWtringBuf str, TUtf16String& w) {
return UnescapeC(str.data(), str.size(), w);
}
-TString UnescapeC(const TStringBuf str) {
+TString UnescapeC(const TStringBuf str) {
return UnescapeC(str.data(), str.size());
}
-TUtf16String UnescapeC(const TWtringBuf str) {
+TUtf16String UnescapeC(const TWtringBuf str) {
return UnescapeC(str.data(), str.size());
}
diff --git a/util/string/escape.h b/util/string/escape.h
index 47f3c7447b..b01be65b0e 100644
--- a/util/string/escape.h
+++ b/util/string/escape.h
@@ -1,6 +1,6 @@
#pragma once
-#include <util/generic/string.h>
+#include <util/generic/string.h>
#include <util/generic/strbuf.h>
template <class TChar>
@@ -49,18 +49,18 @@ static inline TBasicString<TChar> EscapeC(const TChar* str) {
return EscapeC(str, std::char_traits<TChar>::length(str));
}
-TString& EscapeC(const TStringBuf str, TString& res);
-TUtf16String& EscapeC(const TWtringBuf str, TUtf16String& res);
+TString& EscapeC(const TStringBuf str, TString& res);
+TUtf16String& EscapeC(const TWtringBuf str, TUtf16String& res);
// these two need to be methods, because of TBasicString::Quote implementation
-TString EscapeC(const TString& str);
-TUtf16String EscapeC(const TUtf16String& str);
+TString EscapeC(const TString& str);
+TUtf16String EscapeC(const TUtf16String& str);
-TString& UnescapeC(const TStringBuf str, TString& res);
-TUtf16String& UnescapeC(const TWtringBuf str, TUtf16String& res);
+TString& UnescapeC(const TStringBuf str, TString& res);
+TUtf16String& UnescapeC(const TWtringBuf str, TUtf16String& res);
-TString UnescapeC(const TStringBuf str);
-TUtf16String UnescapeC(const TWtringBuf wtr);
+TString UnescapeC(const TStringBuf str);
+TUtf16String UnescapeC(const TWtringBuf wtr);
/// Returns number of chars in escape sequence.
/// - 0, if begin >= end
diff --git a/util/string/escape_ut.cpp b/util/string/escape_ut.cpp
index b2a9fdd807..cd38ecffd3 100644
--- a/util/string/escape_ut.cpp
+++ b/util/string/escape_ut.cpp
@@ -2,15 +2,15 @@
#include <library/cpp/testing/unittest/registar.h>
-#include <util/generic/string.h>
+#include <util/generic/string.h>
#include <util/charset/wide.h>
using namespace std::string_view_literals;
namespace {
struct TExample {
- TString Expected;
- TString Source;
+ TString Expected;
+ TString Source;
TExample(const TStringBuf expected, const TStringBuf source)
: Expected{expected}
@@ -49,42 +49,42 @@ static const TExample CommonTestData[] = {
Y_UNIT_TEST_SUITE(TEscapeCTest) {
Y_UNIT_TEST(TestStrokaEscapeC) {
for (const auto& e : CommonTestData) {
- TString expected(e.Expected);
- TString source(e.Source);
- TString actual(EscapeC(e.Source));
- TString actual2(UnescapeC(e.Expected));
+ TString expected(e.Expected);
+ TString source(e.Source);
+ TString actual(EscapeC(e.Source));
+ TString actual2(UnescapeC(e.Expected));
UNIT_ASSERT_VALUES_EQUAL(e.Expected, actual);
UNIT_ASSERT_VALUES_EQUAL(e.Source, actual2);
}
- UNIT_ASSERT_VALUES_EQUAL("http://ya.ru/\\x17\\n\\xAB", EscapeC(TString("http://ya.ru/\x17\n\xab")));
- UNIT_ASSERT_VALUES_EQUAL("http://ya.ru/\x17\n\xab", UnescapeC(TString("http://ya.ru/\\x17\\n\\xAB")));
+ UNIT_ASSERT_VALUES_EQUAL("http://ya.ru/\\x17\\n\\xAB", EscapeC(TString("http://ya.ru/\x17\n\xab")));
+ UNIT_ASSERT_VALUES_EQUAL("http://ya.ru/\x17\n\xab", UnescapeC(TString("http://ya.ru/\\x17\\n\\xAB")));
UNIT_ASSERT_VALUES_EQUAL("h", EscapeC('h'));
- UNIT_ASSERT_VALUES_EQUAL("h", UnescapeC(TString("h")));
+ UNIT_ASSERT_VALUES_EQUAL("h", UnescapeC(TString("h")));
UNIT_ASSERT_VALUES_EQUAL("\\xFF", EscapeC('\xFF'));
- UNIT_ASSERT_VALUES_EQUAL("\xFF", UnescapeC(TString("\\xFF")));
+ UNIT_ASSERT_VALUES_EQUAL("\xFF", UnescapeC(TString("\\xFF")));
- UNIT_ASSERT_VALUES_EQUAL("\\377f", EscapeC(TString("\xff"
+ UNIT_ASSERT_VALUES_EQUAL("\\377f", EscapeC(TString("\xff"
"f")));
UNIT_ASSERT_VALUES_EQUAL("\xff"
"f",
- UnescapeC(TString("\\377f")));
- UNIT_ASSERT_VALUES_EQUAL("\\xFFg", EscapeC(TString("\xff"
+ UnescapeC(TString("\\377f")));
+ UNIT_ASSERT_VALUES_EQUAL("\\xFFg", EscapeC(TString("\xff"
"g")));
UNIT_ASSERT_VALUES_EQUAL("\xff"
"g",
- UnescapeC(TString("\\xFFg")));
- UNIT_ASSERT_VALUES_EQUAL("\xEA\x9A\x96", UnescapeC(TString("\\uA696")));
- UNIT_ASSERT_VALUES_EQUAL("Странный компроматтест", UnescapeC(TString("\\u0421\\u0442\\u0440\\u0430\\u043d\\u043d\\u044b\\u0439 \\u043a\\u043e\\u043c\\u043f\\u0440\\u043e\\u043c\\u0430\\u0442тест")));
+ UnescapeC(TString("\\xFFg")));
+ UNIT_ASSERT_VALUES_EQUAL("\xEA\x9A\x96", UnescapeC(TString("\\uA696")));
+ UNIT_ASSERT_VALUES_EQUAL("Странный компроматтест", UnescapeC(TString("\\u0421\\u0442\\u0440\\u0430\\u043d\\u043d\\u044b\\u0439 \\u043a\\u043e\\u043c\\u043f\\u0440\\u043e\\u043c\\u0430\\u0442тест")));
}
Y_UNIT_TEST(TestWtrokaEscapeC) {
for (const auto& e : CommonTestData) {
- TUtf16String expected(UTF8ToWide(e.Expected));
- TUtf16String source(UTF8ToWide(e.Source));
- TUtf16String actual(EscapeC(source));
- TUtf16String actual2(UnescapeC(expected));
+ TUtf16String expected(UTF8ToWide(e.Expected));
+ TUtf16String source(UTF8ToWide(e.Source));
+ TUtf16String actual(EscapeC(source));
+ TUtf16String actual2(UnescapeC(expected));
UNIT_ASSERT_VALUES_EQUAL(expected, actual);
UNIT_ASSERT_VALUES_EQUAL(source, actual2);
@@ -96,12 +96,12 @@ Y_UNIT_TEST_SUITE(TEscapeCTest) {
}
Y_UNIT_TEST(TestEscapeTrigraphs) {
- UNIT_ASSERT_VALUES_EQUAL("?", EscapeC(TString("?")));
- UNIT_ASSERT_VALUES_EQUAL("\\x3F?", EscapeC(TString("??")));
- UNIT_ASSERT_VALUES_EQUAL("\\x3F\\x3F?", EscapeC(TString("???")));
+ UNIT_ASSERT_VALUES_EQUAL("?", EscapeC(TString("?")));
+ UNIT_ASSERT_VALUES_EQUAL("\\x3F?", EscapeC(TString("??")));
+ UNIT_ASSERT_VALUES_EQUAL("\\x3F\\x3F?", EscapeC(TString("???")));
// ok but may cause warning about trigraphs
- // UNIT_ASSERT_VALUES_EQUAL("[x]?z", EscapeC(TString("??(x??)?z")));
- UNIT_ASSERT_VALUES_EQUAL("\\x3F?x\\x3F\\x3F?z", EscapeC(TString("??x???z")));
+ // UNIT_ASSERT_VALUES_EQUAL("[x]?z", EscapeC(TString("??(x??)?z")));
+ UNIT_ASSERT_VALUES_EQUAL("\\x3F?x\\x3F\\x3F?z", EscapeC(TString("??x???z")));
}
Y_UNIT_TEST(TestUnescapeCCharLen) {
diff --git a/util/string/fuzzing/collapse/main.cpp b/util/string/fuzzing/collapse/main.cpp
index f2c2b2d5d6..e7b09f0f55 100644
--- a/util/string/fuzzing/collapse/main.cpp
+++ b/util/string/fuzzing/collapse/main.cpp
@@ -2,10 +2,10 @@
#include <util/charset/wide.h>
extern "C" int LLVMFuzzerTestOneInput(const ui8* data, size_t size) {
- TUtf16String w((const wchar16*)data, size / 2);
+ TUtf16String w((const wchar16*)data, size / 2);
Collapse(w);
- TString s((const char*)data, size);
+ TString s((const char*)data, size);
CollapseInPlace(s);
return 0; // Non-zero return values are reserved for future use.
diff --git a/util/string/hex.cpp b/util/string/hex.cpp
index 71eec149a0..667397987f 100644
--- a/util/string/hex.cpp
+++ b/util/string/hex.cpp
@@ -44,8 +44,8 @@ void* HexDecode(const void* in, size_t len, void* ptr) {
return out;
}
-TString HexEncode(const void* in, size_t len) {
- TString ret;
+TString HexEncode(const void* in, size_t len) {
+ TString ret;
ret.ReserveAndResize(len << 1);
HexEncode(in, len, ret.begin());
@@ -53,8 +53,8 @@ TString HexEncode(const void* in, size_t len) {
return ret;
}
-TString HexDecode(const void* in, size_t len) {
- TString ret;
+TString HexDecode(const void* in, size_t len) {
+ TString ret;
ret.ReserveAndResize(len >> 1);
HexDecode(in, len, ret.begin());
diff --git a/util/string/hex.h b/util/string/hex.h
index 07d2de8578..af3d2d528f 100644
--- a/util/string/hex.h
+++ b/util/string/hex.h
@@ -1,6 +1,6 @@
#pragma once
-#include <util/generic/string.h>
+#include <util/generic/string.h>
#include <util/generic/yexception.h>
#include <util/system/yassert.h>
@@ -28,9 +28,9 @@ inline static int String2Byte(const char* s) {
char* HexEncode(const void* in, size_t len, char* out);
-TString HexEncode(const void* in, size_t len);
+TString HexEncode(const void* in, size_t len);
-inline TString HexEncode(const TStringBuf h) {
+inline TString HexEncode(const TStringBuf h) {
return HexEncode(h.data(), h.size());
}
@@ -51,9 +51,9 @@ void* HexDecode(const void* in, size_t len, void* ptr);
*
* @example HexDecode("beef", 4) => {190, 239}
*/
-TString HexDecode(const void* in, size_t len);
+TString HexDecode(const void* in, size_t len);
//! Convert an ASCII hex-string (case-insensitive) to the binary form. Note that h.Size() must be even (+h % 2 == 0).
-inline TString HexDecode(const TStringBuf h) {
+inline TString HexDecode(const TStringBuf h) {
return HexDecode(h.data(), h.size());
}
diff --git a/util/string/join.h b/util/string/join.h
index 6cb09a9251..b166fad1f3 100644
--- a/util/string/join.h
+++ b/util/string/join.h
@@ -1,6 +1,6 @@
#pragma once
-#include <util/generic/string.h>
+#include <util/generic/string.h>
#include <util/generic/typetraits.h>
#include <util/string/cast.h>
#include "cast.h"
@@ -96,8 +96,8 @@ inline void AppendJoin(TString& dst, const TStringBuf delim, const TValues&... v
}
template <typename TFirst, typename... TRest>
-inline TString Join(const TStringBuf delim, const TFirst& f, const TRest&... r) {
- TString ret = ToString(f);
+inline TString Join(const TStringBuf delim, const TFirst& f, const TRest&... r) {
+ TString ret = ToString(f);
AppendJoin(ret, delim, r...);
return ret;
}
@@ -106,7 +106,7 @@ inline TString Join(const TStringBuf delim, const TFirst& f, const TRest&... r)
// but any char value @v will be printed as corresponding numeric code.
// For example, Join('a', 'a', 'a') will print "97a97" (see unit-test).
template <typename... TValues>
-inline TString Join(char cdelim, const TValues&... v) {
+inline TString Join(char cdelim, const TValues&... v) {
return Join(TStringBuf(&cdelim, 1), v...);
}
diff --git a/util/string/join_ut.cpp b/util/string/join_ut.cpp
index 011b5eecbd..3ed2b2459c 100644
--- a/util/string/join_ut.cpp
+++ b/util/string/join_ut.cpp
@@ -6,10 +6,10 @@
#include <util/stream/output.h>
struct TCustomData {
- TVector<int> Ints;
+ TVector<int> Ints;
};
-TString ToString(const TCustomData& d) {
+TString ToString(const TCustomData& d) {
return JoinSeq("__", d.Ints);
}
@@ -17,7 +17,7 @@ Y_UNIT_TEST_SUITE(JoinStringTest) {
Y_UNIT_TEST(ScalarItems) {
UNIT_ASSERT_EQUAL(Join(',', 10, 11.1, "foobar"), "10,11.1,foobar");
UNIT_ASSERT_EQUAL(Join(", ", 10, 11.1, "foobar"), "10, 11.1, foobar");
- UNIT_ASSERT_EQUAL(Join(", ", 10, 11.1, TString("foobar")), "10, 11.1, foobar");
+ UNIT_ASSERT_EQUAL(Join(", ", 10, 11.1, TString("foobar")), "10, 11.1, foobar");
UNIT_ASSERT_EQUAL(Join('#', 0, "a", "foobar", -1.4, TStringBuf("aaa")), "0#a#foobar#-1.4#aaa");
UNIT_ASSERT_EQUAL(Join("", "", ""), "");
@@ -28,7 +28,7 @@ Y_UNIT_TEST_SUITE(JoinStringTest) {
Y_UNIT_TEST(IntContainerItems) {
int v[] = {1, 2, 3};
- TVector<int> vv(v, v + 3);
+ TVector<int> vv(v, v + 3);
UNIT_ASSERT_EQUAL(JoinSeq(" ", vv), "1 2 3");
UNIT_ASSERT_EQUAL(JoinSeq(" ", vv), JoinRange(" ", vv.begin(), vv.end()));
UNIT_ASSERT_EQUAL(JoinRange(" ", v, v + 2), "1 2");
@@ -42,9 +42,9 @@ Y_UNIT_TEST_SUITE(JoinStringTest) {
// try various overloads and template type arguments
static const char* const result = "1 22 333";
static const char* const v[] = {"1", "22", "333"};
- TVector<const char*> vchar(v, v + sizeof(v) / sizeof(v[0]));
- TVector<TStringBuf> vbuf(v, v + sizeof(v) / sizeof(v[0]));
- TVector<TString> vstring(v, v + sizeof(v) / sizeof(v[0]));
+ TVector<const char*> vchar(v, v + sizeof(v) / sizeof(v[0]));
+ TVector<TStringBuf> vbuf(v, v + sizeof(v) / sizeof(v[0]));
+ TVector<TString> vstring(v, v + sizeof(v) / sizeof(v[0]));
// ranges
UNIT_ASSERT_EQUAL(JoinRange(" ", v, v + 3), result);
diff --git a/util/string/printf.cpp b/util/string/printf.cpp
index 8f90329950..5b7c34d4e1 100644
--- a/util/string/printf.cpp
+++ b/util/string/printf.cpp
@@ -3,13 +3,13 @@
#include <util/stream/printf.h>
#include <util/stream/str.h>
-int vsprintf(TString& s, const char* c, va_list params) {
+int vsprintf(TString& s, const char* c, va_list params) {
TStringOutput so(s.remove());
return Printf(so, c, params);
}
-int sprintf(TString& s, const char* c, ...) {
+int sprintf(TString& s, const char* c, ...) {
va_list params;
va_start(params, c);
const int k = vsprintf(s, c, params);
@@ -17,8 +17,8 @@ int sprintf(TString& s, const char* c, ...) {
return k;
}
-TString Sprintf(const char* c, ...) {
- TString s;
+TString Sprintf(const char* c, ...) {
+ TString s;
va_list params;
va_start(params, c);
vsprintf(s, c, params);
@@ -26,7 +26,7 @@ TString Sprintf(const char* c, ...) {
return s;
}
-int fcat(TString& s, const char* c, ...) {
+int fcat(TString& s, const char* c, ...) {
TStringOutput so(s);
va_list params;
diff --git a/util/string/printf.h b/util/string/printf.h
index 1cd482ed2f..925c6edaff 100644
--- a/util/string/printf.h
+++ b/util/string/printf.h
@@ -6,8 +6,8 @@
#include <cstdarg>
/// formatted print. return printed length:
-int Y_PRINTF_FORMAT(2, 0) vsprintf(TString& s, const char* c, va_list params);
+int Y_PRINTF_FORMAT(2, 0) vsprintf(TString& s, const char* c, va_list params);
/// formatted print. return printed length:
-int Y_PRINTF_FORMAT(2, 3) sprintf(TString& s, const char* c, ...);
-TString Y_PRINTF_FORMAT(1, 2) Sprintf(const char* c, ...);
-int Y_PRINTF_FORMAT(2, 3) fcat(TString& s, const char* c, ...);
+int Y_PRINTF_FORMAT(2, 3) sprintf(TString& s, const char* c, ...);
+TString Y_PRINTF_FORMAT(1, 2) Sprintf(const char* c, ...);
+int Y_PRINTF_FORMAT(2, 3) fcat(TString& s, const char* c, ...);
diff --git a/util/string/printf_ut.cpp b/util/string/printf_ut.cpp
index 49f02b3da1..2b2f980b70 100644
--- a/util/string/printf_ut.cpp
+++ b/util/string/printf_ut.cpp
@@ -4,19 +4,19 @@
Y_UNIT_TEST_SUITE(TStringPrintf) {
Y_UNIT_TEST(TestSprintf) {
- TString s;
+ TString s;
int len = sprintf(s, "Hello %s", "world");
- UNIT_ASSERT_EQUAL(s, TString("Hello world"));
+ UNIT_ASSERT_EQUAL(s, TString("Hello world"));
UNIT_ASSERT_EQUAL(len, 11);
}
Y_UNIT_TEST(TestFcat) {
- TString s;
+ TString s;
int len = sprintf(s, "Hello %s", "world");
- UNIT_ASSERT_EQUAL(s, TString("Hello world"));
+ UNIT_ASSERT_EQUAL(s, TString("Hello world"));
UNIT_ASSERT_EQUAL(len, 11);
len = fcat(s, " qwqw%s", "as");
- UNIT_ASSERT_EQUAL(s, TString("Hello world qwqwas"));
+ UNIT_ASSERT_EQUAL(s, TString("Hello world qwqwas"));
UNIT_ASSERT_EQUAL(len, 7);
}
diff --git a/util/string/split.cpp b/util/string/split.cpp
index 50099db18b..7d26857cc7 100644
--- a/util/string/split.cpp
+++ b/util/string/split.cpp
@@ -1,7 +1,7 @@
#include "split.h"
template <class TValue>
-inline size_t Split(const char* ptr, const char* delim, TVector<TValue>& values) {
+inline size_t Split(const char* ptr, const char* delim, TVector<TValue>& values) {
values.erase(values.begin(), values.end());
while (ptr && *ptr) {
ptr += strspn(ptr, delim);
@@ -15,10 +15,10 @@ inline size_t Split(const char* ptr, const char* delim, TVector<TValue>& values)
return values.size();
}
-size_t Split(const char* ptr, const char* delim, TVector<TString>& values) {
- return Split<TString>(ptr, delim, values);
+size_t Split(const char* ptr, const char* delim, TVector<TString>& values) {
+ return Split<TString>(ptr, delim, values);
}
-size_t Split(const TString& in, const TString& delim, TVector<TString>& res) {
+size_t Split(const TString& in, const TString& delim, TVector<TString>& res) {
return Split(in.data(), delim.data(), res);
}
diff --git a/util/string/split.h b/util/string/split.h
index fd516336e1..bc46d9e64c 100644
--- a/util/string/split.h
+++ b/util/string/split.h
@@ -9,7 +9,7 @@
#include <util/generic/iterator_range.h>
#include <util/generic/store_policy.h>
#include <util/generic/strbuf.h>
-#include <util/generic/string.h>
+#include <util/generic/string.h>
#include <util/generic/typetraits.h>
#include <util/generic/vector.h>
#include <util/generic/ylimits.h>
@@ -72,7 +72,7 @@ SplitString(I b, const TDelim& d, TConsumer&& c) {
}
template <class I1, class I2>
-static inline I1* FastStrChr(I1* str, I2 f) noexcept {
+static inline I1* FastStrChr(I1* str, I2 f) noexcept {
I1* ret = NStringSplitPrivate::Find(str, f);
if (!ret) {
@@ -83,7 +83,7 @@ static inline I1* FastStrChr(I1* str, I2 f) noexcept {
}
template <class I>
-static inline I* FastStrStr(I* str, I* f, size_t l) noexcept {
+static inline I* FastStrStr(I* str, I* f, size_t l) noexcept {
std::basic_string_view<I> strView(str);
const auto ret = strView.find(*f);
@@ -283,7 +283,7 @@ struct TConsumerBackInserter<T, std::enable_if_t<!NSplitTargetHasPushBack::TClas
template <class T>
struct TContainerConsumer {
- inline TContainerConsumer(T* c) noexcept
+ inline TContainerConsumer(T* c) noexcept
: C(c)
{
}
@@ -300,7 +300,7 @@ struct TContainerConsumer {
template <class T>
struct TContainerConvertingConsumer {
- inline TContainerConvertingConsumer(T* c) noexcept
+ inline TContainerConvertingConsumer(T* c) noexcept
: C(c)
{
}
@@ -317,7 +317,7 @@ struct TContainerConvertingConsumer {
template <class S, class I>
struct TLimitingConsumer {
- inline TLimitingConsumer(size_t cnt, S* slave) noexcept
+ inline TLimitingConsumer(size_t cnt, S* slave) noexcept
: Cnt(cnt ? cnt - 1 : Max<size_t>())
, Slave(slave)
, Last(nullptr)
@@ -343,7 +343,7 @@ struct TLimitingConsumer {
template <class S>
struct TSkipEmptyTokens {
- inline TSkipEmptyTokens(S* slave) noexcept
+ inline TSkipEmptyTokens(S* slave) noexcept
: Slave(slave)
{
}
@@ -362,7 +362,7 @@ struct TSkipEmptyTokens {
template <class S>
struct TKeepDelimiters {
- inline TKeepDelimiters(S* slave) noexcept
+ inline TKeepDelimiters(S* slave) noexcept
: Slave(slave)
{
}
@@ -411,15 +411,15 @@ static inline void Split(char* buf, char ch, T* res) {
/// Old good slow split function.
/// Field delimter is any number of symbols specified in delim (no empty strings in res vector)
/// @return number of elements created
-size_t Split(const char* in, const char* delim, TVector<TString>& res);
-size_t Split(const TString& in, const TString& delim, TVector<TString>& res);
+size_t Split(const char* in, const char* delim, TVector<TString>& res);
+size_t Split(const TString& in, const TString& delim, TVector<TString>& res);
/// Old split reimplemented for TStringBuf using the new code
/// Note that delim can be constructed from char* automatically (it is not cheap though)
-inline size_t Split(const TStringBuf s, const TSetDelimiter<const char>& delim, TVector<TStringBuf>& res) {
+inline size_t Split(const TStringBuf s, const TSetDelimiter<const char>& delim, TVector<TStringBuf>& res) {
res.clear();
- TContainerConsumer<TVector<TStringBuf>> res1(&res);
- TSkipEmptyTokens<TContainerConsumer<TVector<TStringBuf>>> consumer(&res1);
+ TContainerConsumer<TVector<TStringBuf>> res1(&res);
+ TSkipEmptyTokens<TContainerConsumer<TVector<TStringBuf>>> consumer(&res1);
SplitString(s.data(), s.data() + s.size(), delim, consumer);
return res.size();
}
diff --git a/util/string/split_ut.cpp b/util/string/split_ut.cpp
index 01996e621b..43e59f2d75 100644
--- a/util/string/split_ut.cpp
+++ b/util/string/split_ut.cpp
@@ -95,35 +95,35 @@ void TestConsumerOnRange(TResult& good, I* b, I* e, I* d) {
UNIT_ASSERT_EQUAL(good, test);
}
-using TStrokaConsumer = TContainerConsumer<TVector<TString>>;
+using TStrokaConsumer = TContainerConsumer<TVector<TString>>;
-void TestLimitingConsumerOnString(TVector<TString>& good, const char* str, const char* d, size_t n, const char* last) {
- TVector<TString> test;
+void TestLimitingConsumerOnString(TVector<TString>& good, const char* str, const char* d, size_t n, const char* last) {
+ TVector<TString> test;
TStrokaConsumer consumer(&test);
TLimitingConsumer<TStrokaConsumer, const char> limits(n, &consumer);
TCharDelimiter<const char> delim(*d);
SplitString(str, delim, limits);
Cmp(good, test);
UNIT_ASSERT_EQUAL(good, test);
- UNIT_ASSERT_EQUAL(TString(limits.Last), TString(last)); // Quite unobvious behaviour. Why the last token is not added to slave consumer?
+ UNIT_ASSERT_EQUAL(TString(limits.Last), TString(last)); // Quite unobvious behaviour. Why the last token is not added to slave consumer?
}
-void TestLimitingConsumerOnRange(TVector<TString>& good, const char* b, const char* e, const char* d, size_t n, const char* last) {
- TVector<TString> test;
+void TestLimitingConsumerOnRange(TVector<TString>& good, const char* b, const char* e, const char* d, size_t n, const char* last) {
+ TVector<TString> test;
TStrokaConsumer consumer(&test);
TLimitingConsumer<TStrokaConsumer, const char> limits(n, &consumer);
TCharDelimiter<const char> delim(*d);
SplitString(b, e, delim, limits);
Cmp(good, test);
UNIT_ASSERT_EQUAL(good, test);
- UNIT_ASSERT_EQUAL(TString(limits.Last), TString(last));
+ UNIT_ASSERT_EQUAL(TString(limits.Last), TString(last));
}
Y_UNIT_TEST_SUITE(SplitStringTest) {
Y_UNIT_TEST(TestCharSingleDelimiter) {
- TString data("qw ab qwabcab");
- TString canonic[] = {"qw", "ab", "", "qwabcab"};
- TVector<TString> good(canonic, canonic + 4);
+ TString data("qw ab qwabcab");
+ TString canonic[] = {"qw", "ab", "", "qwabcab"};
+ TVector<TString> good(canonic, canonic + 4);
TCharDelimiter<const char> delim(' ');
TestDelimiterOnString<TContainerConsumer>(good, data.data(), delim);
@@ -133,7 +133,7 @@ Y_UNIT_TEST_SUITE(SplitStringTest) {
Y_UNIT_TEST(TestWideSingleDelimiter) {
TUtf16String data(u"qw ab qwabcab");
TUtf16String canonic[] = {u"qw", u"ab", TUtf16String(), u"qwabcab"};
- TVector<TUtf16String> good(canonic, canonic + 4);
+ TVector<TUtf16String> good(canonic, canonic + 4);
TCharDelimiter<const wchar16> delim(' ');
TestDelimiterOnString<TContainerConsumer>(good, data.data(), delim);
@@ -141,9 +141,9 @@ Y_UNIT_TEST_SUITE(SplitStringTest) {
}
Y_UNIT_TEST(TestConvertToIntCharSingleDelimiter) {
- TString data("42 4242 -12345 0");
+ TString data("42 4242 -12345 0");
i32 canonic[] = {42, 4242, -12345, 0};
- TVector<i32> good(canonic, canonic + 4);
+ TVector<i32> good(canonic, canonic + 4);
TCharDelimiter<const char> delim(' ');
TestDelimiterOnString<TContainerConvertingConsumer>(good, data.data(), delim);
@@ -151,36 +151,36 @@ Y_UNIT_TEST_SUITE(SplitStringTest) {
}
Y_UNIT_TEST(TestCharSkipEmpty) {
- TString data("qw ab qwabcab ");
- TString canonic[] = {"qw", "ab", "qwabcab"};
- TVector<TString> good(canonic, canonic + 3);
+ TString data("qw ab qwabcab ");
+ TString canonic[] = {"qw", "ab", "qwabcab"};
+ TVector<TString> good(canonic, canonic + 3);
TestConsumerOnString<TSkipEmptyTokens<TStrokaConsumer>>(good, data.data(), " ");
TestConsumerOnRange<TSkipEmptyTokens<TStrokaConsumer>>(good, data.data(), data.end(), " ");
}
Y_UNIT_TEST(TestCharKeepDelimiters) {
- TString data("qw ab qwabcab ");
- TString canonic[] = {"qw", " ", "ab", " ", "", " ", "qwabcab", " ", ""};
- TVector<TString> good(canonic, canonic + 9);
+ TString data("qw ab qwabcab ");
+ TString canonic[] = {"qw", " ", "ab", " ", "", " ", "qwabcab", " ", ""};
+ TVector<TString> good(canonic, canonic + 9);
TestConsumerOnString<TKeepDelimiters<TStrokaConsumer>>(good, data.data(), " ");
TestConsumerOnRange<TKeepDelimiters<TStrokaConsumer>>(good, data.data(), data.end(), " ");
}
Y_UNIT_TEST(TestCharLimit) {
- TString data("qw ab qwabcab ");
- TString canonic[] = {"qw", "ab"};
- TVector<TString> good(canonic, canonic + 2);
+ TString data("qw ab qwabcab ");
+ TString canonic[] = {"qw", "ab"};
+ TVector<TString> good(canonic, canonic + 2);
TestLimitingConsumerOnString(good, data.data(), " ", 3, " qwabcab ");
TestLimitingConsumerOnRange(good, data.data(), data.end(), " ", 3, " qwabcab ");
}
Y_UNIT_TEST(TestCharStringDelimiter) {
- TString data("qw ab qwababcab");
- TString canonic[] = {"qw ", " qw", "", "c", ""};
- TVector<TString> good(canonic, canonic + 5);
+ TString data("qw ab qwababcab");
+ TString canonic[] = {"qw ", " qw", "", "c", ""};
+ TVector<TString> good(canonic, canonic + 5);
TStringDelimiter<const char> delim("ab");
TestDelimiterOnString<TContainerConsumer>(good, data.data(), delim);
@@ -190,7 +190,7 @@ Y_UNIT_TEST_SUITE(SplitStringTest) {
Y_UNIT_TEST(TestWideStringDelimiter) {
TUtf16String data(u"qw ab qwababcab");
TUtf16String canonic[] = {u"qw ", u" qw", TUtf16String(), u"c", TUtf16String()};
- TVector<TUtf16String> good(canonic, canonic + 5);
+ TVector<TUtf16String> good(canonic, canonic + 5);
TUtf16String wideDelim(u"ab");
TStringDelimiter<const wchar16> delim(wideDelim.data());
@@ -199,9 +199,9 @@ Y_UNIT_TEST_SUITE(SplitStringTest) {
}
Y_UNIT_TEST(TestCharSetDelimiter) {
- TString data("qw ab qwababccab");
- TString canonic[] = {"q", " ab q", "abab", "", "ab"};
- TVector<TString> good(canonic, canonic + 5);
+ TString data("qw ab qwababccab");
+ TString canonic[] = {"q", " ab q", "abab", "", "ab"};
+ TVector<TString> good(canonic, canonic + 5);
TSetDelimiter<const char> delim("wc");
TestDelimiterOnString<TContainerConsumer>(good, data.data(), delim);
@@ -211,7 +211,7 @@ Y_UNIT_TEST_SUITE(SplitStringTest) {
Y_UNIT_TEST(TestWideSetDelimiter) {
TUtf16String data(u"qw ab qwababccab");
TUtf16String canonic[] = {u"q", u" ab q", u"abab", TUtf16String(), u"ab"};
- TVector<TUtf16String> good(canonic, canonic + 5);
+ TVector<TUtf16String> good(canonic, canonic + 5);
TUtf16String wideDelim(u"wc");
TSetDelimiter<const wchar16> delim(wideDelim.data());
@@ -221,17 +221,17 @@ Y_UNIT_TEST_SUITE(SplitStringTest) {
Y_UNIT_TEST(TestWideSetDelimiterRange) {
TUtf16String data(u"qw ab qwababccab");
TUtf16String canonic[] = {u"q", u" ab q", u"abab", TUtf16String(), u"ab"};
- TVector<TUtf16String> good(1);
+ TVector<TUtf16String> good(1);
TUtf16String wideDelim(u"wc");
TSetDelimiter<const wchar16> delim(wideDelim.data());
- TVector<TUtf16String> test;
- TContainerConsumer<TVector<TUtf16String>> consumer(&test);
+ TVector<TUtf16String> test;
+ TContainerConsumer<TVector<TUtf16String>> consumer(&test);
SplitString(data.data(), data.data(), delim, consumer); // Empty string is still inserted into consumer
Cmp(good, test);
good.assign(canonic, canonic + 4);
- good.push_back(TUtf16String());
+ good.push_back(TUtf16String());
test.clear();
SplitString(data.data(), data.end() - 2, delim, consumer);
Cmp(good, test);
@@ -239,21 +239,21 @@ Y_UNIT_TEST_SUITE(SplitStringTest) {
Y_UNIT_TEST(TestSplit) {
TString data("qw ab qwababcba");
- TString canonic[] = {"qw ", " qw", "c"};
- TVector<TString> good(canonic, canonic + 3);
- TString delim = "ab";
- TVector<TString> test;
+ TString canonic[] = {"qw ", " qw", "c"};
+ TVector<TString> good(canonic, canonic + 3);
+ TString delim = "ab";
+ TVector<TString> test;
Split(data, delim, test);
Cmp(good, test);
- TVector<TStringBuf> test1;
+ TVector<TStringBuf> test1;
Split(data, delim.data(), test1);
Cmp(good, test1);
}
Y_UNIT_TEST(ConvenientSplitTest) {
- TString data("abc 22 33.5 xyz");
- TString str;
+ TString data("abc 22 33.5 xyz");
+ TString str;
int num1 = 0;
double num2 = 0;
TStringBuf strBuf;
@@ -265,8 +265,8 @@ Y_UNIT_TEST_SUITE(SplitStringTest) {
}
Y_UNIT_TEST(ConvenientSplitTestWithMaybe) {
- TString data("abc 42");
- TString str;
+ TString data("abc 42");
+ TString str;
TMaybe<double> num2 = 1;
TMaybe<double> maybe = 1;
@@ -278,8 +278,8 @@ Y_UNIT_TEST_SUITE(SplitStringTest) {
}
Y_UNIT_TEST(ConvenientSplitTestExceptions) {
- TString data("abc 22 33");
- TString s1, s2, s3, s4;
+ TString data("abc 22 33");
+ TString s1, s2, s3, s4;
UNIT_ASSERT_EXCEPTION(Split(data, ' ', s1, s2), yexception);
UNIT_ASSERT_NO_EXCEPTION(Split(data, ' ', s1, s2, s3));
@@ -287,9 +287,9 @@ Y_UNIT_TEST_SUITE(SplitStringTest) {
}
Y_UNIT_TEST(ConvenientSplitTestMaybeExceptions) {
- TString data("abc 22 33");
- TString s1, s2;
- TMaybe<TString> m1, m2;
+ TString data("abc 22 33");
+ TString s1, s2;
+ TMaybe<TString> m1, m2;
UNIT_ASSERT_EXCEPTION(Split(data, ' ', s1, m1), yexception);
UNIT_ASSERT_EXCEPTION(Split(data, ' ', m1, m2), yexception);
diff --git a/util/string/strip.cpp b/util/string/strip.cpp
index 0765806359..c921571cf0 100644
--- a/util/string/strip.cpp
+++ b/util/string/strip.cpp
@@ -3,11 +3,11 @@
#include <util/string/reverse.h>
-bool Collapse(const TString& from, TString& to, size_t maxLen) {
- return CollapseImpl<TString, bool (*)(unsigned char)>(from, to, maxLen, IsAsciiSpace);
+bool Collapse(const TString& from, TString& to, size_t maxLen) {
+ return CollapseImpl<TString, bool (*)(unsigned char)>(from, to, maxLen, IsAsciiSpace);
}
-void CollapseText(const TString& from, TString& to, size_t maxLen) {
+void CollapseText(const TString& from, TString& to, size_t maxLen) {
Collapse(from, to, maxLen);
StripInPlace(to);
if (to.size() >= maxLen) {
diff --git a/util/string/strip.h b/util/string/strip.h
index 6b9e179b70..d5ef6da96d 100644
--- a/util/string/strip.h
+++ b/util/string/strip.h
@@ -2,13 +2,13 @@
#include "ascii.h"
-#include <util/generic/string.h>
+#include <util/generic/string.h>
#include <util/generic/strbuf.h>
#include <utility>
template <class It>
struct TIsAsciiSpaceAdapter {
- bool operator()(const It& it) const noexcept {
+ bool operator()(const It& it) const noexcept {
return IsAsciiSpace(*it);
}
};
@@ -26,7 +26,7 @@ struct TEqualsStripAdapter {
}
template <class It>
- bool operator()(const It& it) const noexcept {
+ bool operator()(const It& it) const noexcept {
return *it == Ch;
}
@@ -39,33 +39,33 @@ TEqualsStripAdapter<TChar> EqualsStripAdapter(TChar ch) {
}
template <class It, class TStripCriterion>
-inline void StripRangeBegin(It& b, const It& e, TStripCriterion&& criterion) noexcept {
+inline void StripRangeBegin(It& b, const It& e, TStripCriterion&& criterion) noexcept {
while (b < e && criterion(b)) {
++b;
}
}
template <class It>
-inline void StripRangeBegin(It& b, const It& e) noexcept {
+inline void StripRangeBegin(It& b, const It& e) noexcept {
StripRangeBegin(b, e, IsAsciiSpaceAdapter(b));
}
template <class It, class TStripCriterion>
-inline void StripRangeEnd(const It& b, It& e, TStripCriterion&& criterion) noexcept {
+inline void StripRangeEnd(const It& b, It& e, TStripCriterion&& criterion) noexcept {
while (b < e && criterion(e - 1)) {
--e;
}
}
template <class It>
-inline void StripRangeEnd(const It& b, It& e) noexcept {
+inline void StripRangeEnd(const It& b, It& e) noexcept {
StripRangeEnd(b, e, IsAsciiSpaceAdapter(b));
}
template <bool stripBeg, bool stripEnd>
struct TStripImpl {
template <class It, class TStripCriterion>
- static inline bool StripRange(It& b, It& e, TStripCriterion&& criterion) noexcept {
+ static inline bool StripRange(It& b, It& e, TStripCriterion&& criterion) noexcept {
const size_t oldLen = e - b;
if (stripBeg) {
@@ -110,17 +110,17 @@ struct TStripImpl {
};
template <class It, class TStripCriterion>
-inline bool StripRange(It& b, It& e, TStripCriterion&& criterion) noexcept {
+inline bool StripRange(It& b, It& e, TStripCriterion&& criterion) noexcept {
return TStripImpl<true, true>::StripRange(b, e, criterion);
}
template <class It>
-inline bool StripRange(It& b, It& e) noexcept {
+inline bool StripRange(It& b, It& e) noexcept {
return StripRange(b, e, IsAsciiSpaceAdapter(b));
}
template <class It, class TStripCriterion>
-inline bool Strip(It& b, size_t& len, TStripCriterion&& criterion) noexcept {
+inline bool Strip(It& b, size_t& len, TStripCriterion&& criterion) noexcept {
It e = b + len;
if (StripRange(b, e, criterion)) {
@@ -133,7 +133,7 @@ inline bool Strip(It& b, size_t& len, TStripCriterion&& criterion) noexcept {
}
template <class It>
-inline bool Strip(It& b, size_t& len) noexcept {
+inline bool Strip(It& b, size_t& len) noexcept {
return Strip(b, len, IsAsciiSpaceAdapter(b));
}
@@ -178,7 +178,7 @@ static inline T StripStringRight(const T& from, TStripCriterion&& criterion) {
}
/// Copies the given string removing leading and trailing spaces.
-static inline bool Strip(const TString& from, TString& to) {
+static inline bool Strip(const TString& from, TString& to) {
return StripString(from, to);
}
@@ -189,9 +189,9 @@ inline TString& StripInPlace(TString& s) {
}
/// Returns a copy of the given string with removed leading and trailing spaces.
-inline TString Strip(const TString& s) Y_WARN_UNUSED_RESULT;
-inline TString Strip(const TString& s) {
- TString ret = s;
+inline TString Strip(const TString& s) Y_WARN_UNUSED_RESULT;
+inline TString Strip(const TString& s) {
+ TString ret = s;
Strip(ret, ret);
return ret;
}
@@ -215,8 +215,8 @@ size_t CollapseImpl(TChar* s, size_t n, const TWhitespaceFunc& isWhitespace) {
return newLen;
}
-template <class TStringType, class TWhitespaceFunc>
-bool CollapseImpl(const TStringType& from, TStringType& to, size_t maxLen, const TWhitespaceFunc& isWhitespace) {
+template <class TStringType, class TWhitespaceFunc>
+bool CollapseImpl(const TStringType& from, TStringType& to, size_t maxLen, const TWhitespaceFunc& isWhitespace) {
to = from;
maxLen = maxLen ? Min(maxLen, to.size()) : to.size();
for (size_t i = 0; i < maxLen; ++i) {
@@ -230,7 +230,7 @@ bool CollapseImpl(const TStringType& from, TStringType& to, size_t maxLen, const
return false;
}
-bool Collapse(const TString& from, TString& to, size_t maxLen = 0);
+bool Collapse(const TString& from, TString& to, size_t maxLen = 0);
/// Replaces several consequtive space symbols with one (processing is limited to maxLen bytes)
inline TString& CollapseInPlace(TString& s, size_t maxLen = 0) {
@@ -241,17 +241,17 @@ inline TString& CollapseInPlace(TString& s, size_t maxLen = 0) {
/// Replaces several consequtive space symbols with one (processing is limited to maxLen bytes)
inline TString Collapse(const TString& s, size_t maxLen = 0) Y_WARN_UNUSED_RESULT;
inline TString Collapse(const TString& s, size_t maxLen) {
- TString ret;
+ TString ret;
Collapse(s, ret, maxLen);
return ret;
}
-void CollapseText(const TString& from, TString& to, size_t maxLen);
+void CollapseText(const TString& from, TString& to, size_t maxLen);
/// The same as Collapse() + truncates the string to maxLen.
/// @details An ellipsis is inserted at the end of the truncated line.
-inline void CollapseText(TString& s, size_t maxLen) {
- TString to;
+inline void CollapseText(TString& s, size_t maxLen) {
+ TString to;
CollapseText(s, to, maxLen);
s = to;
}
diff --git a/util/string/strip_ut.cpp b/util/string/strip_ut.cpp
index 83bfe73a87..d1029d1498 100644
--- a/util/string/strip_ut.cpp
+++ b/util/string/strip_ut.cpp
@@ -27,9 +27,9 @@ Y_UNIT_TEST_SUITE(TStripStringTest) {
};
for (const auto& test : tests) {
- TString inputStr(test.Str);
+ TString inputStr(test.Str);
- TString s;
+ TString s;
Strip(inputStr, s);
UNIT_ASSERT_EQUAL(s, test.StripRes);
@@ -58,7 +58,7 @@ Y_UNIT_TEST_SUITE(TStripStringTest) {
for (auto test : tests) {
UNIT_ASSERT_EQUAL(
- StripString(TString(test.Str), EqualsStripAdapter('/')),
+ StripString(TString(test.Str), EqualsStripAdapter('/')),
test.Result);
};
}
@@ -78,10 +78,10 @@ Y_UNIT_TEST_SUITE(TStripStringTest) {
for (const auto& test : tests) {
UNIT_ASSERT_EQUAL(
- StripStringLeft(TString(test.Str), EqualsStripAdapter('/')),
+ StripStringLeft(TString(test.Str), EqualsStripAdapter('/')),
test.ResultLeft);
UNIT_ASSERT_EQUAL(
- StripStringRight(TString(test.Str), EqualsStripAdapter('/')),
+ StripStringRight(TString(test.Str), EqualsStripAdapter('/')),
test.ResultRight);
};
}
@@ -90,7 +90,7 @@ Y_UNIT_TEST_SUITE(TStripStringTest) {
TStringBuf nullString(nullptr, nullptr);
UNIT_ASSERT_EQUAL(
StripString(nullString),
- TString());
+ TString());
}
Y_UNIT_TEST(TestWtrokaStrip) {
@@ -108,14 +108,14 @@ Y_UNIT_TEST_SUITE(TStripStringTest) {
}
Y_UNIT_TEST(TestCollapse) {
- TString s;
- Collapse(TString(" 123 456 "), s);
+ TString s;
+ Collapse(TString(" 123 456 "), s);
UNIT_ASSERT(s == " 123 456 ");
- Collapse(TString(" 123 456 "), s, 10);
+ Collapse(TString(" 123 456 "), s, 10);
UNIT_ASSERT(s == " 123 456 ");
- s = TString(" a b c ");
- TString s2 = s;
+ s = TString(" a b c ");
+ TString s2 = s;
CollapseInPlace(s2);
UNIT_ASSERT(s == s2);
@@ -125,9 +125,9 @@ Y_UNIT_TEST_SUITE(TStripStringTest) {
}
Y_UNIT_TEST(TestCollapseText) {
- TString abs1("Very long description string written in unknown language.");
- TString abs2(abs1);
- TString abs3(abs1);
+ TString abs1("Very long description string written in unknown language.");
+ TString abs2(abs1);
+ TString abs3(abs1);
CollapseText(abs1, 204);
CollapseText(abs2, 54);
CollapseText(abs3, 49);
diff --git a/util/string/strspn.h b/util/string/strspn.h
index c5bce7be46..8229e74a9c 100644
--- a/util/string/strspn.h
+++ b/util/string/strspn.h
@@ -4,7 +4,7 @@
#include <util/generic/bitmap.h>
-template <class TSetType>
+template <class TSetType>
class TStrSpnImpl {
public:
inline TStrSpnImpl(const char* b, const char* e) {
@@ -17,33 +17,33 @@ public:
//FirstOf
template <class It>
- inline It FindFirstOf(It b, const char* e) const noexcept {
+ inline It FindFirstOf(It b, const char* e) const noexcept {
return FindFirst<false>(b, e);
}
template <class It>
- inline It FindFirstOf(It s) const noexcept {
+ inline It FindFirstOf(It s) const noexcept {
return FindFirst<false>(s, TCStringEndIterator());
}
//FirstNotOf
template <class It>
- inline It FindFirstNotOf(It b, const char* e) const noexcept {
+ inline It FindFirstNotOf(It b, const char* e) const noexcept {
return FindFirst<true>(b, e);
}
template <class It>
- inline It FindFirstNotOf(It s) const noexcept {
+ inline It FindFirstNotOf(It s) const noexcept {
return FindFirst<true>(s, TCStringEndIterator());
}
- inline void Set(ui8 b) noexcept {
+ inline void Set(ui8 b) noexcept {
S_.Set(b);
}
private:
template <bool Result, class It1, class It2>
- inline It1 FindFirst(It1 b, It2 e) const noexcept {
+ inline It1 FindFirst(It1 b, It2 e) const noexcept {
while (b != e && (S_.Get((ui8)*b) == Result)) {
++b;
}
@@ -59,7 +59,7 @@ private:
}
private:
- TSetType S_;
+ TSetType S_;
};
using TCompactStrSpn = TStrSpnImpl<TBitMap<256>>;
diff --git a/util/string/subst.h b/util/string/subst.h
index 8855e818fa..45b622fbef 100644
--- a/util/string/subst.h
+++ b/util/string/subst.h
@@ -36,21 +36,21 @@ size_t SubstGlobal(TUtf32String& text, wchar32 what, wchar32 with, size_t from =
// TODO(yazevnul):
// - rename `SubstGlobal` to `ReplaceAll` for convenience
-// - add `SubstGlobalCopy(TStringBuf)` for convenience
+// - add `SubstGlobalCopy(TStringBuf)` for convenience
// - add `RemoveAll(text, what, from)` as a shortcut for `SubstGlobal(text, what, "", from)`
// - rename file to `replace.h`
-
-/* Replace all occurences of substring or character `what` with string or character `with` starting from position `from`, and return result string.
- *
- * @param text String to modify.
- * @param what Substring/character to replace.
- * @param with Substring/character to use as replacement.
- * @param from Position at with to start replacement.
- *
- * @return Result string
- */
-template <class TStringType, class TPatternType>
+
+/* Replace all occurences of substring or character `what` with string or character `with` starting from position `from`, and return result string.
+ *
+ * @param text String to modify.
+ * @param what Substring/character to replace.
+ * @param with Substring/character to use as replacement.
+ * @param from Position at with to start replacement.
+ *
+ * @return Result string
+ */
+template <class TStringType, class TPatternType>
Y_WARN_UNUSED_RESULT TStringType SubstGlobalCopy(TStringType result, TPatternType what, TPatternType with, size_t from = 0) {
- SubstGlobal(result, what, with, from);
- return result;
-}
+ SubstGlobal(result, what, with, from);
+ return result;
+}
diff --git a/util/string/subst_ut.cpp b/util/string/subst_ut.cpp
index e1e76a82fe..21eccef779 100644
--- a/util/string/subst_ut.cpp
+++ b/util/string/subst_ut.cpp
@@ -6,11 +6,11 @@
Y_UNIT_TEST_SUITE(TStringSubst) {
static const size_t MIN_FROM_CTX = 4;
- static const TVector<TString> ALL_FROM{TString("F"), TString("FF")};
- static const TVector<TString> ALL_TO{TString(""), TString("T"), TString("TT"), TString("TTT")};
+ static const TVector<TString> ALL_FROM{TString("F"), TString("FF")};
+ static const TVector<TString> ALL_TO{TString(""), TString("T"), TString("TT"), TString("TTT")};
- static void AssertSubstGlobal(const TString& sFrom, const TString& sTo, const TString& from, const TString& to, const size_t fromPos, const size_t numSubst) {
- TString s = sFrom;
+ static void AssertSubstGlobal(const TString& sFrom, const TString& sTo, const TString& from, const TString& to, const size_t fromPos, const size_t numSubst) {
+ TString s = sFrom;
size_t res = SubstGlobal(s, from, to, fromPos);
UNIT_ASSERT_VALUES_EQUAL_C(res, numSubst,
TStringBuilder() << "numSubst=" << numSubst << ", fromPos=" << fromPos << ", " << sFrom << " -> " << sTo);
@@ -31,7 +31,7 @@ Y_UNIT_TEST_SUITE(TStringSubst) {
const size_t maxSz = fromSz + MIN_FROM_CTX;
for (size_t sz = minSz; sz <= maxSz; ++sz) {
for (size_t fromPos = 0; fromPos < sz; ++fromPos) {
- TString s{sz, '.'};
+ TString s{sz, '.'};
for (const auto& to : ALL_TO) {
AssertSubstGlobal(s, s, from, to, fromPos, 0);
}
@@ -49,9 +49,9 @@ Y_UNIT_TEST_SUITE(TStringSubst) {
for (size_t fromPos = 0; fromPos <= sz - fromSz; ++fromPos) {
for (size_t fromBeg = 0; fromBeg < fromPos; ++fromBeg) {
const auto parts = {
- TString{fromBeg, '.'},
- TString{sz - fromSz - fromBeg, '.'}};
- TString s = JoinSeq(from, parts);
+ TString{fromBeg, '.'},
+ TString{sz - fromSz - fromBeg, '.'}};
+ TString s = JoinSeq(from, parts);
for (const auto& to : ALL_TO) {
AssertSubstGlobal(s, s, from, to, fromPos, 0);
}
@@ -62,7 +62,7 @@ Y_UNIT_TEST_SUITE(TStringSubst) {
}
static void DoTestSubstGlobal(TVector<TString>& parts, const size_t minBeg, const size_t sz,
- const TString& from, const size_t fromPos, const size_t numSubst) {
+ const TString& from, const size_t fromPos, const size_t numSubst) {
const size_t numLeft = numSubst - parts.size();
for (size_t fromBeg = minBeg; fromBeg <= sz - numLeft * from.size(); ++fromBeg) {
if (parts.empty()) {
@@ -73,10 +73,10 @@ Y_UNIT_TEST_SUITE(TStringSubst) {
if (numLeft == 1) {
parts.emplace_back(sz - fromBeg - from.size(), '.');
- TString sFrom = JoinSeq(from, parts);
+ TString sFrom = JoinSeq(from, parts);
UNIT_ASSERT_VALUES_EQUAL_C(sFrom.size(), sz, sFrom);
for (const auto& to : ALL_TO) {
- TString sTo = JoinSeq(to, parts);
+ TString sTo = JoinSeq(to, parts);
AssertSubstGlobal(sFrom, sTo, from, to, fromPos, numSubst);
}
parts.pop_back();
@@ -89,7 +89,7 @@ Y_UNIT_TEST_SUITE(TStringSubst) {
}
static void DoTestSubstGlobal(size_t numSubst) {
- TVector<TString> parts;
+ TVector<TString> parts;
for (const auto& from : ALL_FROM) {
const size_t fromSz = from.size();
const size_t minSz = numSubst * fromSz;
@@ -120,132 +120,132 @@ Y_UNIT_TEST_SUITE(TStringSubst) {
}
Y_UNIT_TEST(TestSubstGlobalOld) {
- TString s;
+ TString s;
s = "aaa";
SubstGlobal(s, "a", "bb");
- UNIT_ASSERT_EQUAL(s, TString("bbbbbb"));
+ UNIT_ASSERT_EQUAL(s, TString("bbbbbb"));
s = "aaa";
SubstGlobal(s, "a", "b");
- UNIT_ASSERT_EQUAL(s, TString("bbb"));
+ UNIT_ASSERT_EQUAL(s, TString("bbb"));
s = "aaa";
SubstGlobal(s, "a", "");
- UNIT_ASSERT_EQUAL(s, TString(""));
+ UNIT_ASSERT_EQUAL(s, TString(""));
s = "abcdefbcbcdfb";
SubstGlobal(s, "bc", "bbc", 2);
- UNIT_ASSERT_EQUAL(s, TString("abcdefbbcbbcdfb"));
+ UNIT_ASSERT_EQUAL(s, TString("abcdefbbcbbcdfb"));
s = "Москва ~ Париж";
SubstGlobal(s, " ~ ", " ");
UNIT_ASSERT_EQUAL(s, TString("Москва Париж"));
}
- Y_UNIT_TEST(TestSubstGlobalOldRet) {
- const TString s1 = "aaa";
- const TString s2 = SubstGlobalCopy(s1, "a", "bb");
- UNIT_ASSERT_EQUAL(s2, TString("bbbbbb"));
-
- const TString s3 = "aaa";
- const TString s4 = SubstGlobalCopy(s3, "a", "b");
- UNIT_ASSERT_EQUAL(s4, TString("bbb"));
-
- const TString s5 = "aaa";
- const TString s6 = SubstGlobalCopy(s5, "a", "");
- UNIT_ASSERT_EQUAL(s6, TString(""));
-
- const TString s7 = "abcdefbcbcdfb";
- const TString s8 = SubstGlobalCopy(s7, "bc", "bbc", 2);
- UNIT_ASSERT_EQUAL(s8, TString("abcdefbbcbbcdfb"));
-
- const TString s9 = "Москва ~ Париж";
- const TString s10 = SubstGlobalCopy(s9, " ~ ", " ");
- UNIT_ASSERT_EQUAL(s10, TString("Москва Париж"));
- }
-
+ Y_UNIT_TEST(TestSubstGlobalOldRet) {
+ const TString s1 = "aaa";
+ const TString s2 = SubstGlobalCopy(s1, "a", "bb");
+ UNIT_ASSERT_EQUAL(s2, TString("bbbbbb"));
+
+ const TString s3 = "aaa";
+ const TString s4 = SubstGlobalCopy(s3, "a", "b");
+ UNIT_ASSERT_EQUAL(s4, TString("bbb"));
+
+ const TString s5 = "aaa";
+ const TString s6 = SubstGlobalCopy(s5, "a", "");
+ UNIT_ASSERT_EQUAL(s6, TString(""));
+
+ const TString s7 = "abcdefbcbcdfb";
+ const TString s8 = SubstGlobalCopy(s7, "bc", "bbc", 2);
+ UNIT_ASSERT_EQUAL(s8, TString("abcdefbbcbbcdfb"));
+
+ const TString s9 = "Москва ~ Париж";
+ const TString s10 = SubstGlobalCopy(s9, " ~ ", " ");
+ UNIT_ASSERT_EQUAL(s10, TString("Москва Париж"));
+ }
+
Y_UNIT_TEST(TestSubstCharGlobal) {
TUtf16String w = u"abcdabcd";
SubstGlobal(w, wchar16('b'), wchar16('B'), 3);
UNIT_ASSERT_EQUAL(w, u"abcdaBcd");
- TString s = "aaa";
+ TString s = "aaa";
SubstGlobal(s, 'a', 'b', 1);
- UNIT_ASSERT_EQUAL(s, TString("abb"));
+ UNIT_ASSERT_EQUAL(s, TString("abb"));
}
- Y_UNIT_TEST(TestSubstCharGlobalRet) {
+ Y_UNIT_TEST(TestSubstCharGlobalRet) {
const TUtf16String w1 = u"abcdabcd";
const TUtf16String w2 = SubstGlobalCopy(w1, wchar16('b'), wchar16('B'), 3);
UNIT_ASSERT_EQUAL(w2, u"abcdaBcd");
-
- const TString s1 = "aaa";
- const TString s2 = SubstGlobalCopy(s1, 'a', 'b', 1);
- UNIT_ASSERT_EQUAL(s2, TString("abb"));
- }
-
+
+ const TString s1 = "aaa";
+ const TString s2 = SubstGlobalCopy(s1, 'a', 'b', 1);
+ UNIT_ASSERT_EQUAL(s2, TString("abb"));
+ }
+
Y_UNIT_TEST(TestSubstStdString) {
std::string s = "aaa";
SubstGlobal(s, "a", "b", 1);
UNIT_ASSERT_EQUAL(s, "abb");
}
- Y_UNIT_TEST(TestSubstStdStringRet) {
- const std::string s1 = "aaa";
- const std::string s2 = SubstGlobalCopy(s1, "a", "b", 1);
- UNIT_ASSERT_EQUAL(s2, "abb");
- }
-
+ Y_UNIT_TEST(TestSubstStdStringRet) {
+ const std::string s1 = "aaa";
+ const std::string s2 = SubstGlobalCopy(s1, "a", "b", 1);
+ UNIT_ASSERT_EQUAL(s2, "abb");
+ }
+
Y_UNIT_TEST(TestSubstGlobalChar) {
{
- const TString s = "a";
- const TString st = "b";
- TString ss = s;
+ const TString s = "a";
+ const TString st = "b";
+ TString ss = s;
UNIT_ASSERT_VALUES_EQUAL(s.size(), SubstGlobal(ss, 'a', 'b'));
UNIT_ASSERT_VALUES_EQUAL(st, ss);
}
{
- const TString s = "aa";
- const TString st = "bb";
- TString ss = s;
+ const TString s = "aa";
+ const TString st = "bb";
+ TString ss = s;
UNIT_ASSERT_VALUES_EQUAL(s.size(), SubstGlobal(ss, 'a', 'b'));
UNIT_ASSERT_VALUES_EQUAL(st, ss);
}
{
- const TString s = "aaa";
- const TString st = "bbb";
- TString ss = s;
+ const TString s = "aaa";
+ const TString st = "bbb";
+ TString ss = s;
UNIT_ASSERT_VALUES_EQUAL(s.size(), SubstGlobal(ss, 'a', 'b'));
UNIT_ASSERT_VALUES_EQUAL(st, ss);
}
{
- const TString s = "aaaa";
- const TString st = "bbbb";
- TString ss = s;
+ const TString s = "aaaa";
+ const TString st = "bbbb";
+ TString ss = s;
UNIT_ASSERT_VALUES_EQUAL(s.size(), SubstGlobal(ss, 'a', 'b'));
UNIT_ASSERT_VALUES_EQUAL(st, ss);
}
{
- const TString s = "aaaaa";
- const TString st = "bbbbb";
- TString ss = s;
+ const TString s = "aaaaa";
+ const TString st = "bbbbb";
+ TString ss = s;
UNIT_ASSERT_VALUES_EQUAL(s.size(), SubstGlobal(ss, 'a', 'b'));
UNIT_ASSERT_VALUES_EQUAL(st, ss);
}
{
- const TString s = "aaaaaa";
- const TString st = "bbbbbb";
- TString ss = s;
+ const TString s = "aaaaaa";
+ const TString st = "bbbbbb";
+ TString ss = s;
UNIT_ASSERT_VALUES_EQUAL(s.size(), SubstGlobal(ss, 'a', 'b'));
UNIT_ASSERT_VALUES_EQUAL(st, ss);
}
{
- const TString s = "aaaaaaa";
- const TString st = "bbbbbbb";
- TString ss = s;
+ const TString s = "aaaaaaa";
+ const TString st = "bbbbbbb";
+ TString ss = s;
UNIT_ASSERT_VALUES_EQUAL(s.size(), SubstGlobal(ss, 'a', 'b'));
UNIT_ASSERT_VALUES_EQUAL(st, ss);
}
{
- const TString s = "aaaaaaaa";
- const TString st = "bbbbbbbb";
- TString ss = s;
+ const TString s = "aaaaaaaa";
+ const TString st = "bbbbbbbb";
+ TString ss = s;
UNIT_ASSERT_VALUES_EQUAL(s.size(), SubstGlobal(ss, 'a', 'b'));
UNIT_ASSERT_VALUES_EQUAL(st, ss);
}
diff --git a/util/string/type.cpp b/util/string/type.cpp
index b5a660008b..49671c02c2 100644
--- a/util/string/type.cpp
+++ b/util/string/type.cpp
@@ -3,7 +3,7 @@
#include <array>
-bool IsSpace(const char* s, size_t len) noexcept {
+bool IsSpace(const char* s, size_t len) noexcept {
if (len == 0) {
return false;
}
diff --git a/util/string/type_ut.cpp b/util/string/type_ut.cpp
index 9356282119..03e7af62bd 100644
--- a/util/string/type_ut.cpp
+++ b/util/string/type_ut.cpp
@@ -62,7 +62,7 @@ Y_UNIT_TEST_SUITE(TStringClassify) {
UNIT_ASSERT(IsHexNumber("1234567890a"));
UNIT_ASSERT(!IsHexNumber("12345xx67890a"));
UNIT_ASSERT(!IsHexNumber("foobar"));
- UNIT_ASSERT(!IsHexNumber(TString()));
+ UNIT_ASSERT(!IsHexNumber(TString()));
UNIT_ASSERT(IsHexNumber(u"0"));
UNIT_ASSERT(IsHexNumber(u"aaaadddAAAAA"));
@@ -71,6 +71,6 @@ Y_UNIT_TEST_SUITE(TStringClassify) {
UNIT_ASSERT(IsHexNumber(u"1234567890a"));
UNIT_ASSERT(!IsHexNumber(u"12345xx67890a"));
UNIT_ASSERT(!IsHexNumber(u"foobar"));
- UNIT_ASSERT(!IsHexNumber(TUtf16String()));
+ UNIT_ASSERT(!IsHexNumber(TUtf16String()));
}
}
diff --git a/util/string/util.cpp b/util/string/util.cpp
index a528489b9b..b14f20bf75 100644
--- a/util/string/util.cpp
+++ b/util/string/util.cpp
@@ -6,7 +6,7 @@
#include <cstdarg>
#include <cstdlib>
-int a2i(const TString& s) {
+int a2i(const TString& s) {
return atoi(s.c_str());
}
@@ -49,20 +49,20 @@ Tr::Tr(const char* from, const char* to) {
}
}
-size_t Tr::FindFirstChangePosition(const TString& str) const {
+size_t Tr::FindFirstChangePosition(const TString& str) const {
for (auto it = str.begin(); it != str.end(); ++it) {
if (ConvertChar(*it) != *it) {
return it - str.begin();
}
}
- return TString::npos;
+ return TString::npos;
}
-void Tr::Do(TString& str) const {
+void Tr::Do(TString& str) const {
const size_t changePosition = FindFirstChangePosition(str);
- if (changePosition == TString::npos) {
+ if (changePosition == TString::npos) {
return;
}
diff --git a/util/string/util.h b/util/string/util.h
index 4108a1389a..0d77a5042b 100644
--- a/util/string/util.h
+++ b/util/string/util.h
@@ -7,12 +7,12 @@
#include <algorithm>
#include <util/system/defaults.h>
-#include <util/generic/string.h>
+#include <util/generic/string.h>
#include <util/generic/strbuf.h>
/// @addtogroup Strings_Miscellaneous
/// @{
-int a2i(const TString& s);
+int a2i(const TString& s);
/// Removes the last character if it is equal to c.
template <class T>
@@ -23,7 +23,7 @@ inline void RemoveIfLast(T& s, int c) {
}
/// Adds lastCh symbol to the the of the string if it is not already there.
-inline void addIfNotLast(TString& s, int lastCh) {
+inline void addIfNotLast(TString& s, int lastCh) {
size_t len = s.length();
if (!len || s[len - 1] != lastCh) {
s.append(char(lastCh));
@@ -33,9 +33,9 @@ inline void addIfNotLast(TString& s, int lastCh) {
/// @details Finishes the string with lastCh1 if lastCh2 is not present in the string and lastCh1 is not already at the end of the string.
/// Else, if lastCh2 is not equal to the symbol before the last, it finishes the string with lastCh2.
/// @todo ?? Define, when to apply the function. Is in use several times for URLs parsing.
-inline void addIfAbsent(TString& s, char lastCh1, char lastCh2) {
+inline void addIfAbsent(TString& s, char lastCh1, char lastCh2) {
size_t pos = s.find(lastCh2);
- if (pos == TString::npos) {
+ if (pos == TString::npos) {
//s.append((char)lastCh1);
addIfNotLast(s, lastCh1);
} else if (pos < s.length() - 1) {
@@ -173,18 +173,18 @@ public:
for (size_t i = 0; i < l && s[i]; i++)
s[i] = ConvertChar(s[i]);
}
- void Do(TString& str) const;
+ void Do(TString& str) const;
private:
char Map[256];
- size_t FindFirstChangePosition(const TString& str) const;
+ size_t FindFirstChangePosition(const TString& str) const;
};
// Removes all occurrences of given character from string
template <typename TStringType>
void RemoveAll(TStringType& str, typename TStringType::char_type ch) {
- size_t pos = str.find(ch); // 'find' to avoid cloning of string in 'TString.begin()'
+ size_t pos = str.find(ch); // 'find' to avoid cloning of string in 'TString.begin()'
if (pos == TStringType::npos)
return;
diff --git a/util/string/util_ut.cpp b/util/string/util_ut.cpp
index 2d9f5f3579..18a2d8e195 100644
--- a/util/string/util_ut.cpp
+++ b/util/string/util_ut.cpp
@@ -36,7 +36,7 @@ public:
};
for (const T* t = tests; t != std::end(tests); ++t) {
- TString str(t->Str);
+ TString str(t->Str);
RemoveAll(str, t->Ch);
UNIT_ASSERT_EQUAL(t->Result, str);
}
diff --git a/util/string/vector.cpp b/util/string/vector.cpp
index eb24bfcf27..9ba401f0a2 100644
--- a/util/string/vector.cpp
+++ b/util/string/vector.cpp
@@ -22,7 +22,7 @@ static inline void DoSplit1(TConsumer& cc, TDelim& d, const TBasicStringBuf<TChr
template <class C, class TDelim, typename TChr>
static inline void DoSplit0(C* res, const TBasicStringBuf<TChr> str, TDelim& d, size_t maxFields, int options) {
- using TStringType = std::conditional_t<std::is_same<TChr, wchar16>::value, TUtf16String, TString>;
+ using TStringType = std::conditional_t<std::is_same<TChr, wchar16>::value, TUtf16String, TString>;
res->clear();
if (!str.data()) {
@@ -79,13 +79,13 @@ void ::NPrivate::SplitStringImpl(TVector<TUtf16String>* res, const wchar16* ptr,
return SplitStringImplT<wchar16>(res, TWtringBuf(ptr, len), delimiter, maxFields, options);
}
-TUtf16String JoinStrings(const TVector<TUtf16String>& v, const TWtringBuf delim) {
- return JoinStrings(v.begin(), v.end(), delim);
+TUtf16String JoinStrings(const TVector<TUtf16String>& v, const TWtringBuf delim) {
+ return JoinStrings(v.begin(), v.end(), delim);
}
-TUtf16String JoinStrings(const TVector<TUtf16String>& v, size_t index, size_t count, const TWtringBuf delim) {
+TUtf16String JoinStrings(const TVector<TUtf16String>& v, size_t index, size_t count, const TWtringBuf delim) {
const size_t f = Min(index, v.size());
const size_t l = f + Min(count, v.size() - f);
- return JoinStrings(v.begin() + f, v.begin() + l, delim);
+ return JoinStrings(v.begin() + f, v.begin() + l, delim);
}
diff --git a/util/string/vector.h b/util/string/vector.h
index 08f2d7e489..e36c348bbe 100644
--- a/util/string/vector.h
+++ b/util/string/vector.h
@@ -5,7 +5,7 @@
#include <util/generic/map.h>
#include <util/generic/strbuf.h>
-#include <util/generic/string.h>
+#include <util/generic/string.h>
#include <util/generic/vector.h>
#include <util/string/cast.h>
#include <util/system/yassert.h>
@@ -67,11 +67,11 @@ SplitString(const typename ::NPrivate::TStringDeducer<C>::type& str, const C* de
}
template <class TIter>
-inline TString JoinStrings(TIter begin, TIter end, const TStringBuf delim) {
+inline TString JoinStrings(TIter begin, TIter end, const TStringBuf delim) {
if (begin == end)
- return TString();
+ return TString();
- TString result = ToString(*begin);
+ TString result = ToString(*begin);
for (++begin; begin != end; ++begin) {
result.append(delim);
@@ -82,11 +82,11 @@ inline TString JoinStrings(TIter begin, TIter end, const TStringBuf delim) {
}
template <class TIter>
-inline TUtf16String JoinStrings(TIter begin, TIter end, const TWtringBuf delim) {
+inline TUtf16String JoinStrings(TIter begin, TIter end, const TWtringBuf delim) {
if (begin == end)
- return TUtf16String();
+ return TUtf16String();
- TUtf16String result = ToWtring(*begin);
+ TUtf16String result = ToWtring(*begin);
for (++begin; begin != end; ++begin) {
result.append(delim);
@@ -96,34 +96,34 @@ inline TUtf16String JoinStrings(TIter begin, TIter end, const TWtringBuf delim)
return result;
}
-/// Concatenates elements of given TVector<TString>.
-inline TString JoinStrings(const TVector<TString>& v, const TStringBuf delim) {
- return JoinStrings(v.begin(), v.end(), delim);
+/// Concatenates elements of given TVector<TString>.
+inline TString JoinStrings(const TVector<TString>& v, const TStringBuf delim) {
+ return JoinStrings(v.begin(), v.end(), delim);
}
-inline TString JoinStrings(const TVector<TString>& v, size_t index, size_t count, const TStringBuf delim) {
- Y_ASSERT(index + count <= v.size() && "JoinStrings(): index or count out of range");
- return JoinStrings(v.begin() + index, v.begin() + index + count, delim);
+inline TString JoinStrings(const TVector<TString>& v, size_t index, size_t count, const TStringBuf delim) {
+ Y_ASSERT(index + count <= v.size() && "JoinStrings(): index or count out of range");
+ return JoinStrings(v.begin() + index, v.begin() + index + count, delim);
}
template <typename T>
-inline TString JoinVectorIntoString(const TVector<T>& v, const TStringBuf delim) {
- return JoinStrings(v.begin(), v.end(), delim);
+inline TString JoinVectorIntoString(const TVector<T>& v, const TStringBuf delim) {
+ return JoinStrings(v.begin(), v.end(), delim);
}
template <typename T>
-inline TString JoinVectorIntoString(const TVector<T>& v, size_t index, size_t count, const TStringBuf delim) {
+inline TString JoinVectorIntoString(const TVector<T>& v, size_t index, size_t count, const TStringBuf delim) {
Y_ASSERT(index + count <= v.size() && "JoinVectorIntoString(): index or count out of range");
- return JoinStrings(v.begin() + index, v.begin() + index + count, delim);
+ return JoinStrings(v.begin() + index, v.begin() + index + count, delim);
}
-TUtf16String JoinStrings(const TVector<TUtf16String>& v, const TWtringBuf delim);
-TUtf16String JoinStrings(const TVector<TUtf16String>& v, size_t index, size_t count, const TWtringBuf delim);
+TUtf16String JoinStrings(const TVector<TUtf16String>& v, const TWtringBuf delim);
+TUtf16String JoinStrings(const TVector<TUtf16String>& v, size_t index, size_t count, const TWtringBuf delim);
//! Converts vector of strings to vector of type T variables
template <typename T, typename TStringType>
-TVector<T> Scan(const TVector<TStringType>& input) {
- TVector<T> output;
+TVector<T> Scan(const TVector<TStringType>& input) {
+ TVector<T> output;
output.reserve(input.size());
for (int i = 0; i < input.ysize(); ++i) {
output.push_back(FromString<T>(input[i]));
diff --git a/util/string/vector_ut.cpp b/util/string/vector_ut.cpp
index b6b22a8cf4..817120f268 100644
--- a/util/string/vector_ut.cpp
+++ b/util/string/vector_ut.cpp
@@ -6,33 +6,33 @@
Y_UNIT_TEST_SUITE(TStringJoinTest) {
Y_UNIT_TEST(Test1) {
- TVector<TUtf16String> v;
+ TVector<TUtf16String> v;
- UNIT_ASSERT_EQUAL(JoinStrings(v, ToWtring("")), ToWtring(""));
+ UNIT_ASSERT_EQUAL(JoinStrings(v, ToWtring("")), ToWtring(""));
}
Y_UNIT_TEST(Test2) {
- TVector<TUtf16String> v;
+ TVector<TUtf16String> v;
v.push_back(ToWtring("1"));
v.push_back(ToWtring("2"));
- UNIT_ASSERT_EQUAL(JoinStrings(v, ToWtring(" ")), ToWtring("1 2"));
+ UNIT_ASSERT_EQUAL(JoinStrings(v, ToWtring(" ")), ToWtring("1 2"));
}
Y_UNIT_TEST(Test3) {
- TVector<TUtf16String> v;
+ TVector<TUtf16String> v;
v.push_back(ToWtring("1"));
v.push_back(ToWtring("2"));
- UNIT_ASSERT_EQUAL(JoinStrings(v, 1, 10, ToWtring(" ")), ToWtring("2"));
+ UNIT_ASSERT_EQUAL(JoinStrings(v, 1, 10, ToWtring(" ")), ToWtring("2"));
}
Y_UNIT_TEST(TestJoinWStrings) {
const TUtf16String str = u"Яндекс";
- const TVector<TUtf16String> v(1, str);
+ const TVector<TUtf16String> v(1, str);
- UNIT_ASSERT_EQUAL(JoinStrings(v, TUtf16String()), str);
+ UNIT_ASSERT_EQUAL(JoinStrings(v, TUtf16String()), str);
}
}
diff --git a/util/system/align.h b/util/system/align.h
index 0261b6848e..ea0bbc5b46 100644
--- a/util/system/align.h
+++ b/util/system/align.h
@@ -5,45 +5,45 @@
#include <util/generic/bitops.h>
template <class T>
-static inline T AlignDown(T len, T align) noexcept {
+static inline T AlignDown(T len, T align) noexcept {
Y_ASSERT(IsPowerOf2(align)); // align should be power of 2
return len & ~(align - 1);
}
template <class T>
-static inline T AlignUp(T len, T align) noexcept {
+static inline T AlignUp(T len, T align) noexcept {
const T alignedResult = AlignDown(len + (align - 1), align);
Y_ASSERT(alignedResult >= len); // check for overflow
return alignedResult;
}
template <class T>
-static inline T AlignUpSpace(T len, T align) noexcept {
+static inline T AlignUpSpace(T len, T align) noexcept {
Y_ASSERT(IsPowerOf2(align)); // align should be power of 2
return ((T)0 - len) & (align - 1); // AlignUp(len, align) - len;
}
template <class T>
-static inline T* AlignUp(T* ptr, size_t align) noexcept {
+static inline T* AlignUp(T* ptr, size_t align) noexcept {
return (T*)AlignUp((uintptr_t)ptr, align);
}
template <class T>
-static inline T* AlignDown(T* ptr, size_t align) noexcept {
+static inline T* AlignDown(T* ptr, size_t align) noexcept {
return (T*)AlignDown((uintptr_t)ptr, align);
}
template <class T>
-static inline T AlignUp(T t) noexcept {
+static inline T AlignUp(T t) noexcept {
return AlignUp(t, (size_t)PLATFORM_DATA_ALIGN);
}
template <class T>
-static inline T AlignDown(T t) noexcept {
+static inline T AlignDown(T t) noexcept {
return AlignDown(t, (size_t)PLATFORM_DATA_ALIGN);
}
template <class T>
-static inline T Align(T t) noexcept {
+static inline T Align(T t) noexcept {
return AlignUp(t);
}
diff --git a/util/system/atexit.cpp b/util/system/atexit.cpp
index 4ae0d9c3e7..74fb10b6b1 100644
--- a/util/system/atexit.cpp
+++ b/util/system/atexit.cpp
@@ -34,7 +34,7 @@ namespace {
{
}
- inline void Finish() noexcept {
+ inline void Finish() noexcept {
AtomicSet(FinishStarted_, 1);
auto guard = Guard(Lock_);
@@ -72,8 +72,8 @@ namespace {
private:
TAdaptiveLock Lock_;
TAtomic FinishStarted_;
- TDeque<TFunc> Store_;
- TPriorityQueue<TFunc*, TVector<TFunc*>, TCmp> Items_;
+ TDeque<TFunc> Store_;
+ TPriorityQueue<TFunc*, TVector<TFunc*>, TCmp> Items_;
};
static TAtomic atExitLock = 0;
diff --git a/util/system/atomic_ut.cpp b/util/system/atomic_ut.cpp
index 0265f57c60..07211ffba7 100644
--- a/util/system/atomic_ut.cpp
+++ b/util/system/atomic_ut.cpp
@@ -213,11 +213,11 @@ using TAltAtomic = volatile TChooser<TAtomicBase, long, long long>::TdType;
class TTTest: public TAtomicTest<TAltAtomic> {
public:
- TString Name() const noexcept override {
+ TString Name() const noexcept override {
return "TAtomicTest<TAltAtomic>";
}
- static TString StaticName() noexcept {
+ static TString StaticName() noexcept {
return "TAtomicTest<TAltAtomic>";
}
};
diff --git a/util/system/backtrace.cpp b/util/system/backtrace.cpp
index 3e6e05a61f..b77fe58fb1 100644
--- a/util/system/backtrace.cpp
+++ b/util/system/backtrace.cpp
@@ -6,7 +6,7 @@
#include <util/stream/output.h>
#include <util/stream/format.h>
#include <util/generic/array_ref.h>
-#include <util/generic/string.h>
+#include <util/generic/string.h>
#ifdef _win_
#include "mutex.h"
@@ -278,7 +278,7 @@ void TBackTrace::PrintTo(IOutputStream& out) const {
FormatBackTraceFn(&out, Data, Size);
}
-TString TBackTrace::PrintToString() const {
+TString TBackTrace::PrintToString() const {
TStringStream ss;
PrintTo(ss);
return ss.Str();
diff --git a/util/system/backtrace.h b/util/system/backtrace.h
index 0f91f96951..2fce7585c3 100644
--- a/util/system/backtrace.h
+++ b/util/system/backtrace.h
@@ -35,7 +35,7 @@ public:
TBackTrace();
void Capture();
void PrintTo(IOutputStream&) const;
- TString PrintToString() const;
+ TString PrintToString() const;
size_t size() const;
const void* const* data() const;
operator TBackTraceView() const;
diff --git a/util/system/backtrace_ut.cpp b/util/system/backtrace_ut.cpp
index 766e6bbfa2..9b5ead71bc 100644
--- a/util/system/backtrace_ut.cpp
+++ b/util/system/backtrace_ut.cpp
@@ -31,7 +31,7 @@ void SomeMethod() {
return;
#endif
- UNIT_ASSERT(out.Empty() || out.Str().find("SomeMethod") != TString::npos);
+ UNIT_ASSERT(out.Empty() || out.Str().find("SomeMethod") != TString::npos);
}
class TBackTraceTest: public TTestBase {
diff --git a/util/system/byteorder.h b/util/system/byteorder.h
index 56dc3943a7..94b9fea515 100644
--- a/util/system/byteorder.h
+++ b/util/system/byteorder.h
@@ -33,7 +33,7 @@
#endif
#ifndef SwapBytes16
-inline ui16 SwapBytes16(ui16 val) noexcept {
+inline ui16 SwapBytes16(ui16 val) noexcept {
#define byte_n(__val, __n) ((((unsigned char*)(&__val))[__n]))
DoSwap(byte_n(val, 0), byte_n(val, 1));
return val;
@@ -42,7 +42,7 @@ inline ui16 SwapBytes16(ui16 val) noexcept {
#endif
#ifndef SwapBytes32
-inline ui32 SwapBytes32(ui32 val) noexcept {
+inline ui32 SwapBytes32(ui32 val) noexcept {
#define byte_n(__val, __n) ((((unsigned char*)(&__val))[__n]))
DoSwap(byte_n(val, 0), byte_n(val, 3));
DoSwap(byte_n(val, 1), byte_n(val, 2));
@@ -52,7 +52,7 @@ inline ui32 SwapBytes32(ui32 val) noexcept {
#endif
#ifndef SwapBytes64
-inline ui64 SwapBytes64(ui64 val) noexcept {
+inline ui64 SwapBytes64(ui64 val) noexcept {
union {
ui64 val;
ui32 p[2];
@@ -66,8 +66,8 @@ inline ui64 SwapBytes64(ui64 val) noexcept {
}
#endif
-//for convenience
-static inline ui8 SwapBytes8(ui8 v) noexcept {
+//for convenience
+static inline ui8 SwapBytes8(ui8 v) noexcept {
return v;
}
@@ -94,22 +94,22 @@ namespace NSwapBytes {
}
template <class T>
-inline T SwapBytes(T val) noexcept {
+inline T SwapBytes(T val) noexcept {
return NSwapBytes::TSwapBytesHelper<sizeof(T) * 8>::Swap(val);
}
template <class T>
-inline T LittleToBig(T val) noexcept {
+inline T LittleToBig(T val) noexcept {
return SwapBytes(val);
}
template <class T>
-inline T BigToLittle(T val) noexcept {
+inline T BigToLittle(T val) noexcept {
return LittleToBig(val);
}
template <class T>
-inline T HostToInet(T val) noexcept {
+inline T HostToInet(T val) noexcept {
#if defined(_big_endian_)
return val;
#elif defined(_little_endian_)
@@ -120,12 +120,12 @@ inline T HostToInet(T val) noexcept {
}
template <class T>
-inline T InetToHost(T val) noexcept {
+inline T InetToHost(T val) noexcept {
return HostToInet(val);
}
template <class T>
-inline T HostToLittle(T val) noexcept {
+inline T HostToLittle(T val) noexcept {
#if defined(_big_endian_)
return BigToLittle(val);
#elif defined(_little_endian_)
@@ -136,6 +136,6 @@ inline T HostToLittle(T val) noexcept {
}
template <class T>
-inline T LittleToHost(T val) noexcept {
+inline T LittleToHost(T val) noexcept {
return HostToLittle(val);
}
diff --git a/util/system/compiler.h b/util/system/compiler.h
index 7782564207..b373edcc46 100644
--- a/util/system/compiler.h
+++ b/util/system/compiler.h
@@ -24,7 +24,7 @@
* int main() {
* Hi(); // void Hi()
* Do<int>(); // void Do() [T = int]
- * Do<TString>(); // void Do() [T = TString]
+ * Do<TString>(); // void Do() [T = TString]
* }
* @endcode
*/
@@ -216,8 +216,8 @@ constexpr Y_FORCE_INLINE int Y_UNUSED(Types&&...) {
*
* // we know that xs and ys are non-negative from domain knowledge,
* // but we can't change the types of xs and ys because of API constrains
- * int Foo(const TVector<int>& xs, const TVector<int>& ys) {
- * TVector<int> avgs;
+ * int Foo(const TVector<int>& xs, const TVector<int>& ys) {
+ * TVector<int> avgs;
* avgs.resize(xs.size());
* for (size_t i = 0; i < xs.size(); ++i) {
* auto x = xs[i];
@@ -313,12 +313,12 @@ _YandexAbort();
#else
#define Y_WEAK
#endif
-
+
#if defined(__CUDACC_VER_MAJOR__)
#define Y_CUDA_AT_LEAST(x, y) (__CUDACC_VER_MAJOR__ > x || (__CUDACC_VER_MAJOR__ == x && __CUDACC_VER_MINOR__ >= y))
#else
#define Y_CUDA_AT_LEAST(x, y) 0
-#endif
+#endif
// NVidia CUDA C++ Compiler did not know about noexcept keyword until version 9.0
#if !Y_CUDA_AT_LEAST(9, 0)
@@ -336,145 +336,145 @@ _YandexAbort();
#define Y_LEAF
#define Y_WRAPPER
#endif
-
-/**
- * @def Y_PRAGMA
- *
- * Macro for use in other macros to define compiler pragma
- * See below for other usage examples
- *
- * @code
- * #if defined(__clang__) || defined(__GNUC__)
- * #define Y_PRAGMA_NO_WSHADOW \
- * Y_PRAGMA("GCC diagnostic ignored \"-Wshadow\"")
- * #elif defined(_MSC_VER)
- * #define Y_PRAGMA_NO_WSHADOW \
- * Y_PRAGMA("warning(disable:4456 4457")
- * #else
- * #define Y_PRAGMA_NO_WSHADOW
- * #endif
- * @endcode
- */
-#if defined(__clang__) || defined(__GNUC__)
+
+/**
+ * @def Y_PRAGMA
+ *
+ * Macro for use in other macros to define compiler pragma
+ * See below for other usage examples
+ *
+ * @code
+ * #if defined(__clang__) || defined(__GNUC__)
+ * #define Y_PRAGMA_NO_WSHADOW \
+ * Y_PRAGMA("GCC diagnostic ignored \"-Wshadow\"")
+ * #elif defined(_MSC_VER)
+ * #define Y_PRAGMA_NO_WSHADOW \
+ * Y_PRAGMA("warning(disable:4456 4457")
+ * #else
+ * #define Y_PRAGMA_NO_WSHADOW
+ * #endif
+ * @endcode
+ */
+#if defined(__clang__) || defined(__GNUC__)
#define Y_PRAGMA(x) _Pragma(x)
#elif defined(_MSC_VER)
#define Y_PRAGMA(x) __pragma(x)
-#else
+#else
#define Y_PRAGMA(x)
-#endif
-
-/**
- * @def Y_PRAGMA_DIAGNOSTIC_PUSH
- *
- * Cross-compiler pragma to save diagnostic settings
- *
- * @see
- * GCC: https://gcc.gnu.org/onlinedocs/gcc/Diagnostic-Pragmas.html
- * MSVC: https://msdn.microsoft.com/en-us/library/2c8f766e.aspx
- * Clang: https://clang.llvm.org/docs/UsersManual.html#controlling-diagnostics-via-pragmas
- *
- * @code
- * Y_PRAGMA_DIAGNOSTIC_PUSH
- * @endcode
- */
-#if defined(__clang__) || defined(__GNUC__)
+#endif
+
+/**
+ * @def Y_PRAGMA_DIAGNOSTIC_PUSH
+ *
+ * Cross-compiler pragma to save diagnostic settings
+ *
+ * @see
+ * GCC: https://gcc.gnu.org/onlinedocs/gcc/Diagnostic-Pragmas.html
+ * MSVC: https://msdn.microsoft.com/en-us/library/2c8f766e.aspx
+ * Clang: https://clang.llvm.org/docs/UsersManual.html#controlling-diagnostics-via-pragmas
+ *
+ * @code
+ * Y_PRAGMA_DIAGNOSTIC_PUSH
+ * @endcode
+ */
+#if defined(__clang__) || defined(__GNUC__)
#define Y_PRAGMA_DIAGNOSTIC_PUSH \
Y_PRAGMA("GCC diagnostic push")
-#elif defined(_MSC_VER)
+#elif defined(_MSC_VER)
#define Y_PRAGMA_DIAGNOSTIC_PUSH \
Y_PRAGMA(warning(push))
-#else
+#else
#define Y_PRAGMA_DIAGNOSTIC_PUSH
-#endif
-
-/**
- * @def Y_PRAGMA_DIAGNOSTIC_POP
- *
- * Cross-compiler pragma to restore diagnostic settings
- *
- * @see
- * GCC: https://gcc.gnu.org/onlinedocs/gcc/Diagnostic-Pragmas.html
- * MSVC: https://msdn.microsoft.com/en-us/library/2c8f766e.aspx
- * Clang: https://clang.llvm.org/docs/UsersManual.html#controlling-diagnostics-via-pragmas
- *
- * @code
- * Y_PRAGMA_DIAGNOSTIC_POP
- * @endcode
- */
-#if defined(__clang__) || defined(__GNUC__)
+#endif
+
+/**
+ * @def Y_PRAGMA_DIAGNOSTIC_POP
+ *
+ * Cross-compiler pragma to restore diagnostic settings
+ *
+ * @see
+ * GCC: https://gcc.gnu.org/onlinedocs/gcc/Diagnostic-Pragmas.html
+ * MSVC: https://msdn.microsoft.com/en-us/library/2c8f766e.aspx
+ * Clang: https://clang.llvm.org/docs/UsersManual.html#controlling-diagnostics-via-pragmas
+ *
+ * @code
+ * Y_PRAGMA_DIAGNOSTIC_POP
+ * @endcode
+ */
+#if defined(__clang__) || defined(__GNUC__)
#define Y_PRAGMA_DIAGNOSTIC_POP \
Y_PRAGMA("GCC diagnostic pop")
-#elif defined(_MSC_VER)
+#elif defined(_MSC_VER)
#define Y_PRAGMA_DIAGNOSTIC_POP \
Y_PRAGMA(warning(pop))
-#else
+#else
#define Y_PRAGMA_DIAGNOSTIC_POP
-#endif
-
-/**
- * @def Y_PRAGMA_NO_WSHADOW
- *
- * Cross-compiler pragma to disable warnings about shadowing variables
- *
- * @code
- * Y_PRAGMA_DIAGNOSTIC_PUSH
- * Y_PRAGMA_NO_WSHADOW
- *
- * // some code which use variable shadowing, e.g.:
- *
- * for (int i = 0; i < 100; ++i) {
- * Use(i);
- *
- * for (int i = 42; i < 100500; ++i) { // this i is shadowing previous i
- * AnotherUse(i);
- * }
- * }
- *
- * Y_PRAGMA_DIAGNOSTIC_POP
- * @endcode
- */
-#if defined(__clang__) || defined(__GNUC__)
+#endif
+
+/**
+ * @def Y_PRAGMA_NO_WSHADOW
+ *
+ * Cross-compiler pragma to disable warnings about shadowing variables
+ *
+ * @code
+ * Y_PRAGMA_DIAGNOSTIC_PUSH
+ * Y_PRAGMA_NO_WSHADOW
+ *
+ * // some code which use variable shadowing, e.g.:
+ *
+ * for (int i = 0; i < 100; ++i) {
+ * Use(i);
+ *
+ * for (int i = 42; i < 100500; ++i) { // this i is shadowing previous i
+ * AnotherUse(i);
+ * }
+ * }
+ *
+ * Y_PRAGMA_DIAGNOSTIC_POP
+ * @endcode
+ */
+#if defined(__clang__) || defined(__GNUC__)
#define Y_PRAGMA_NO_WSHADOW \
Y_PRAGMA("GCC diagnostic ignored \"-Wshadow\"")
-#elif defined(_MSC_VER)
+#elif defined(_MSC_VER)
#define Y_PRAGMA_NO_WSHADOW \
Y_PRAGMA(warning(disable : 4456 4457))
-#else
+#else
#define Y_PRAGMA_NO_WSHADOW
-#endif
-
-/**
- * @ def Y_PRAGMA_NO_UNUSED_FUNCTION
- *
- * Cross-compiler pragma to disable warnings about unused functions
- *
- * @see
- * GCC: https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html
- * Clang: https://clang.llvm.org/docs/DiagnosticsReference.html#wunused-function
- * MSVC: there is no such warning
- *
- * @code
- * Y_PRAGMA_DIAGNOSTIC_PUSH
- * Y_PRAGMA_NO_UNUSED_FUNCTION
- *
- * // some code which introduces a function which later will not be used, e.g.:
- *
- * void Foo() {
- * }
- *
- * int main() {
- * return 0; // Foo() never called
- * }
- *
- * Y_PRAGMA_DIAGNOSTIC_POP
- * @endcode
- */
-#if defined(__clang__) || defined(__GNUC__)
+#endif
+
+/**
+ * @ def Y_PRAGMA_NO_UNUSED_FUNCTION
+ *
+ * Cross-compiler pragma to disable warnings about unused functions
+ *
+ * @see
+ * GCC: https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html
+ * Clang: https://clang.llvm.org/docs/DiagnosticsReference.html#wunused-function
+ * MSVC: there is no such warning
+ *
+ * @code
+ * Y_PRAGMA_DIAGNOSTIC_PUSH
+ * Y_PRAGMA_NO_UNUSED_FUNCTION
+ *
+ * // some code which introduces a function which later will not be used, e.g.:
+ *
+ * void Foo() {
+ * }
+ *
+ * int main() {
+ * return 0; // Foo() never called
+ * }
+ *
+ * Y_PRAGMA_DIAGNOSTIC_POP
+ * @endcode
+ */
+#if defined(__clang__) || defined(__GNUC__)
#define Y_PRAGMA_NO_UNUSED_FUNCTION \
Y_PRAGMA("GCC diagnostic ignored \"-Wunused-function\"")
-#else
+#else
#define Y_PRAGMA_NO_UNUSED_FUNCTION
-#endif
+#endif
/**
* @ def Y_PRAGMA_NO_UNUSED_PARAMETER
@@ -514,42 +514,42 @@ _YandexAbort();
#define Y_PRAGMA_NO_UNUSED_PARAMETER
#endif
-/**
- * @def Y_PRAGMA_NO_DEPRECATED
- *
- * Cross compiler pragma to disable warnings and errors about deprecated
- *
- * @see
- * GCC: https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html
- * Clang: https://clang.llvm.org/docs/DiagnosticsReference.html#wdeprecated
- * MSVC: https://docs.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warning-level-3-c4996?view=vs-2017
- *
- * @code
- * Y_PRAGMA_DIAGNOSTIC_PUSH
- * Y_PRAGMA_NO_DEPRECATED
- *
- * [deprecated] void foo() {
- * // ...
- * }
- *
- * int main() {
- * foo();
- * return 0;
- * }
- *
- * Y_PRAGMA_DIAGNOSTIC_POP
- * @endcode
- */
+/**
+ * @def Y_PRAGMA_NO_DEPRECATED
+ *
+ * Cross compiler pragma to disable warnings and errors about deprecated
+ *
+ * @see
+ * GCC: https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html
+ * Clang: https://clang.llvm.org/docs/DiagnosticsReference.html#wdeprecated
+ * MSVC: https://docs.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warning-level-3-c4996?view=vs-2017
+ *
+ * @code
+ * Y_PRAGMA_DIAGNOSTIC_PUSH
+ * Y_PRAGMA_NO_DEPRECATED
+ *
+ * [deprecated] void foo() {
+ * // ...
+ * }
+ *
+ * int main() {
+ * foo();
+ * return 0;
+ * }
+ *
+ * Y_PRAGMA_DIAGNOSTIC_POP
+ * @endcode
+ */
#if defined(__clang__) || defined(__GNUC__)
#define Y_PRAGMA_NO_DEPRECATED \
Y_PRAGMA("GCC diagnostic ignored \"-Wdeprecated\"")
-#elif defined(_MSC_VER)
+#elif defined(_MSC_VER)
#define Y_PRAGMA_NO_DEPRECATED \
Y_PRAGMA(warning(disable : 4996))
-#else
+#else
#define Y_PRAGMA_NO_DEPRECATED
-#endif
-
+#endif
+
// Memory sanitizer sometimes doesn't correctly set parameter shadow of constant functions.
#if (defined(__clang__) || defined(__GNUC__)) && !defined(_msan_enabled_)
/**
@@ -584,23 +584,23 @@ _YandexAbort();
#if !defined(Y_PURE_FUNCTION)
#define Y_PURE_FUNCTION
#endif
-
-/**
- * @ def Y_HAVE_INT128
- *
- * Defined when the compiler supports __int128 extension
- *
- * @code
- *
- * #if defined(Y_HAVE_INT128)
- * __int128 myVeryBigInt = 12345678901234567890;
- * #endif
- *
- * @endcode
- */
-#if defined(__SIZEOF_INT128__)
+
+/**
+ * @ def Y_HAVE_INT128
+ *
+ * Defined when the compiler supports __int128 extension
+ *
+ * @code
+ *
+ * #if defined(Y_HAVE_INT128)
+ * __int128 myVeryBigInt = 12345678901234567890;
+ * #endif
+ *
+ * @endcode
+ */
+#if defined(__SIZEOF_INT128__)
#define Y_HAVE_INT128 1
-#endif
+#endif
/**
* XRAY macro must be passed to compiler if XRay is enabled.
diff --git a/util/system/compiler_ut.cpp b/util/system/compiler_ut.cpp
index 5b500e9529..f93b1c0850 100644
--- a/util/system/compiler_ut.cpp
+++ b/util/system/compiler_ut.cpp
@@ -1,24 +1,24 @@
-#include "compiler.h"
-
+#include "compiler.h"
+
#include <library/cpp/testing/unittest/registar.h>
-
+
Y_UNIT_TEST_SUITE(TCompilerTest) {
Y_UNIT_TEST(TestPragmaNoWshadow) {
- Y_PRAGMA_DIAGNOSTIC_PUSH
- Y_PRAGMA_NO_WSHADOW
-
- // define two variables with similar names, latest must shadow first
- // and there will be no warning for this
-
- for (int i = 0; i < 1; ++i) {
- for (int i = 100500; i < 100501; ++i) {
- UNIT_ASSERT_EQUAL(i, 100500);
- }
- }
-
- Y_PRAGMA_DIAGNOSTIC_POP
- }
-
+ Y_PRAGMA_DIAGNOSTIC_PUSH
+ Y_PRAGMA_NO_WSHADOW
+
+ // define two variables with similar names, latest must shadow first
+ // and there will be no warning for this
+
+ for (int i = 0; i < 1; ++i) {
+ for (int i = 100500; i < 100501; ++i) {
+ UNIT_ASSERT_EQUAL(i, 100500);
+ }
+ }
+
+ Y_PRAGMA_DIAGNOSTIC_POP
+ }
+
Y_PRAGMA_DIAGNOSTIC_PUSH
Y_PRAGMA_NO_UNUSED_PARAMETER
@@ -35,38 +35,38 @@ Y_UNIT_TEST_SUITE(TCompilerTest) {
}
Y_UNIT_TEST(TestHaveInt128) {
-#ifdef Y_HAVE_INT128
- // will be compiled without errors
- unsigned __int128 a = 1;
- __int128 b = 1;
- UNIT_ASSERT_EQUAL(a, 1);
- UNIT_ASSERT_EQUAL(b, 1);
- UNIT_ASSERT_EQUAL(sizeof(a), sizeof(b));
-
- // and we can set a type alias for __int128 and unsigned __int128 without compiler errors
- using TMyInt128 = __int128;
- using TMyUnsignedInt128 = unsigned __int128;
-
- TMyInt128 i128value;
- TMyUnsignedInt128 ui128value;
- Y_UNUSED(i128value);
- Y_UNUSED(ui128value);
-
-#endif
- }
-
- // define deprecated function
+#ifdef Y_HAVE_INT128
+ // will be compiled without errors
+ unsigned __int128 a = 1;
+ __int128 b = 1;
+ UNIT_ASSERT_EQUAL(a, 1);
+ UNIT_ASSERT_EQUAL(b, 1);
+ UNIT_ASSERT_EQUAL(sizeof(a), sizeof(b));
+
+ // and we can set a type alias for __int128 and unsigned __int128 without compiler errors
+ using TMyInt128 = __int128;
+ using TMyUnsignedInt128 = unsigned __int128;
+
+ TMyInt128 i128value;
+ TMyUnsignedInt128 ui128value;
+ Y_UNUSED(i128value);
+ Y_UNUSED(ui128value);
+
+#endif
+ }
+
+ // define deprecated function
[[deprecated]] void Bar() {
- return;
- }
-
- Y_UNIT_TEST(TestNoDeprecated) {
- Y_PRAGMA_DIAGNOSTIC_PUSH
- Y_PRAGMA_NO_DEPRECATED
-
- // will be compiled without errors
+ return;
+ }
+
+ Y_UNIT_TEST(TestNoDeprecated) {
+ Y_PRAGMA_DIAGNOSTIC_PUSH
+ Y_PRAGMA_NO_DEPRECATED
+
+ // will be compiled without errors
Bar();
-
- Y_PRAGMA_DIAGNOSTIC_POP
- }
-}
+
+ Y_PRAGMA_DIAGNOSTIC_POP
+ }
+}
diff --git a/util/system/condvar.cpp b/util/system/condvar.cpp
index 707db52c0b..62f3d22356 100644
--- a/util/system/condvar.cpp
+++ b/util/system/condvar.cpp
@@ -27,11 +27,11 @@ namespace {
using TWaitEvents = TIntrusiveList<TWaitEvent>;
public:
- inline ~TCondVarImpl() {
+ inline ~TCondVarImpl() {
Y_ASSERT(Events_.Empty());
}
- inline void Signal() noexcept {
+ inline void Signal() noexcept {
with_lock (Lock_) {
if (!Events_.Empty()) {
Events_.PopFront()->Signal();
@@ -39,7 +39,7 @@ namespace {
}
}
- inline void BroadCast() noexcept {
+ inline void BroadCast() noexcept {
with_lock (Lock_) {
//TODO
while (!Events_.Empty()) {
@@ -48,7 +48,7 @@ namespace {
}
}
- inline bool WaitD(TMutex& m, TInstant deadLine) noexcept {
+ inline bool WaitD(TMutex& m, TInstant deadLine) noexcept {
TWaitEvent event;
with_lock (Lock_) {
@@ -86,17 +86,17 @@ public:
}
}
- inline ~TImpl() {
+ inline ~TImpl() {
int ret = pthread_cond_destroy(&Cond_);
Y_VERIFY(ret == 0, "pthread_cond_destroy failed: %s", LastSystemErrorText(ret));
}
- inline void Signal() noexcept {
+ inline void Signal() noexcept {
int ret = pthread_cond_signal(&Cond_);
Y_VERIFY(ret == 0, "pthread_cond_signal failed: %s", LastSystemErrorText(ret));
}
- inline bool WaitD(TMutex& lock, TInstant deadLine) noexcept {
+ inline bool WaitD(TMutex& lock, TInstant deadLine) noexcept {
if (deadLine == TInstant::Max()) {
int ret = pthread_cond_wait(&Cond_, (pthread_mutex_t*)lock.Handle());
Y_VERIFY(ret == 0, "pthread_cond_wait failed: %s", LastSystemErrorText(ret));
@@ -117,7 +117,7 @@ public:
}
}
- inline void BroadCast() noexcept {
+ inline void BroadCast() noexcept {
int ret = pthread_cond_broadcast(&Cond_);
Y_VERIFY(ret == 0, "pthread_cond_broadcast failed: %s", LastSystemErrorText(ret));
}
@@ -134,14 +134,14 @@ TCondVar::TCondVar()
TCondVar::~TCondVar() = default;
-void TCondVar::BroadCast() noexcept {
+void TCondVar::BroadCast() noexcept {
Impl_->BroadCast();
}
-void TCondVar::Signal() noexcept {
+void TCondVar::Signal() noexcept {
Impl_->Signal();
}
-bool TCondVar::WaitD(TMutex& mutex, TInstant deadLine) noexcept {
+bool TCondVar::WaitD(TMutex& mutex, TInstant deadLine) noexcept {
return Impl_->WaitD(mutex, deadLine);
}
diff --git a/util/system/condvar.h b/util/system/condvar.h
index b18e48432b..569162717c 100644
--- a/util/system/condvar.h
+++ b/util/system/condvar.h
@@ -11,10 +11,10 @@
class TCondVar {
public:
TCondVar();
- ~TCondVar();
+ ~TCondVar();
- void BroadCast() noexcept;
- void Signal() noexcept;
+ void BroadCast() noexcept;
+ void Signal() noexcept;
/*
* returns false if failed by timeout
@@ -46,7 +46,7 @@ public:
/*
* infinite wait
*/
- inline void WaitI(TMutex& m) noexcept {
+ inline void WaitI(TMutex& m) noexcept {
WaitD(m, TInstant::Max());
}
@@ -56,7 +56,7 @@ public:
}
//deprecated
- inline void Wait(TMutex& m) noexcept {
+ inline void Wait(TMutex& m) noexcept {
WaitI(m);
}
diff --git a/util/system/context.cpp b/util/system/context.cpp
index 18684e4054..ad99309088 100644
--- a/util/system/context.cpp
+++ b/util/system/context.cpp
@@ -52,7 +52,7 @@ extern "C" void __mylongjmp(__myjmp_buf env, int val) __attribute__((__noreturn_
extern "C" int __mysetjmp(__myjmp_buf env) __attribute__((__returns_twice__));
namespace {
- class TStackType {
+ class TStackType {
public:
inline TStackType(TArrayRef<char> range) noexcept
#if defined(STACK_GROW_DOWN)
@@ -64,14 +64,14 @@ namespace {
ReAlign();
}
- inline ~TStackType() = default;
+ inline ~TStackType() = default;
- inline void ReAlign() noexcept {
+ inline void ReAlign() noexcept {
Data_ = AlignStackPtr(Data_);
}
template <class T>
- inline void Push(T t) noexcept {
+ inline void Push(T t) noexcept {
#if defined(STACK_GROW_DOWN)
Data_ -= sizeof(T);
*((T*)Data_) = t;
@@ -81,12 +81,12 @@ namespace {
#endif
}
- inline char* StackPtr() noexcept {
+ inline char* StackPtr() noexcept {
return Data_;
}
private:
- static inline char* AlignStackPtr(char* ptr) noexcept {
+ static inline char* AlignStackPtr(char* ptr) noexcept {
#if defined(STACK_GROW_DOWN)
return AlignDown(ptr, STACK_ALIGN);
#else
@@ -98,15 +98,15 @@ namespace {
char* Data_;
};
- static inline void*& JmpBufReg(__myjmp_buf& buf, size_t n) noexcept {
+ static inline void*& JmpBufReg(__myjmp_buf& buf, size_t n) noexcept {
return (((void**)(void*)(buf))[n]);
}
- static inline void*& JmpBufStackReg(__myjmp_buf& buf) noexcept {
+ static inline void*& JmpBufStackReg(__myjmp_buf& buf) noexcept {
return JmpBufReg(buf, STACK_CNT);
}
- static inline void*& JmpBufProgrReg(__myjmp_buf& buf) noexcept {
+ static inline void*& JmpBufProgrReg(__myjmp_buf& buf) noexcept {
return JmpBufReg(buf, PROGR_CNT);
}
@@ -156,7 +156,7 @@ TContMachineContext::TContMachineContext(const TContClosure& c)
: San_(c)
#endif
{
- TStackType stack(c.Stack);
+ TStackType stack(c.Stack);
/*
* arg, and align data
@@ -194,7 +194,7 @@ TContMachineContext::TContMachineContext(const TContClosure& c)
JmpBufFrameReg(Buf_) = nullptr;
}
-void TContMachineContext::SwitchTo(TContMachineContext* next) noexcept {
+void TContMachineContext::SwitchTo(TContMachineContext* next) noexcept {
if (Y_LIKELY(__mysetjmp(Buf_) == 0)) {
#if defined(_asan_enabled_) || defined(_tsan_enabled_)
next->San_.BeforeSwitch(&San_);
@@ -231,7 +231,7 @@ TContMachineContext::TContMachineContext(const TContClosure& c)
Y_ENSURE(Fiber_, TStringBuf("fiber error"));
}
-TContMachineContext::~TContMachineContext() {
+TContMachineContext::~TContMachineContext() {
if (MainFiber_) {
ConvertFiberToThread();
} else {
@@ -239,7 +239,7 @@ TContMachineContext::~TContMachineContext() {
}
}
-void TContMachineContext::SwitchTo(TContMachineContext* next) noexcept {
+void TContMachineContext::SwitchTo(TContMachineContext* next) noexcept {
SwitchToFiber(next->Fiber_);
}
#endif
@@ -262,7 +262,7 @@ struct TContMachineContext::TImpl {
Thread->Start();
}
- inline ~TImpl() {
+ inline ~TImpl() {
if (Thread) {
Finish = true;
Signal();
@@ -270,7 +270,7 @@ struct TContMachineContext::TImpl {
}
}
- inline void SwitchTo(TImpl* next) noexcept {
+ inline void SwitchTo(TImpl* next) noexcept {
next->Signal();
Wait();
}
@@ -286,11 +286,11 @@ struct TContMachineContext::TImpl {
TL->DoRun();
}
- inline void Signal() noexcept {
+ inline void Signal() noexcept {
Event.Signal();
}
- inline void Wait() noexcept {
+ inline void Wait() noexcept {
Event.Wait();
if (Finish) {
@@ -315,10 +315,10 @@ TContMachineContext::TContMachineContext(const TContClosure& c)
{
}
-TContMachineContext::~TContMachineContext() {
+TContMachineContext::~TContMachineContext() {
}
-void TContMachineContext::SwitchTo(TContMachineContext* next) noexcept {
+void TContMachineContext::SwitchTo(TContMachineContext* next) noexcept {
Impl_->SwitchTo(next->Impl_.Get());
}
#endif
diff --git a/util/system/context.h b/util/system/context.h
index 9f16663f66..d2a349bfc5 100644
--- a/util/system/context.h
+++ b/util/system/context.h
@@ -78,10 +78,10 @@ public:
makecontext(&Ctx_, (ucontext_func_t)ContextTrampoLine, 1, c.TrampoLine);
}
- inline ~TContMachineContext() {
+ inline ~TContMachineContext() {
}
- inline void SwitchTo(TContMachineContext* next) noexcept {
+ inline void SwitchTo(TContMachineContext* next) noexcept {
swapcontext(&Ctx_, &next->Ctx_);
}
@@ -98,9 +98,9 @@ public:
TContMachineContext();
TContMachineContext(const TContClosure& c);
- ~TContMachineContext();
+ ~TContMachineContext();
- void SwitchTo(TContMachineContext* next) noexcept;
+ void SwitchTo(TContMachineContext* next) noexcept;
private:
THolder<TImpl> Impl_;
@@ -112,9 +112,9 @@ class TContMachineContext {
public:
TContMachineContext();
TContMachineContext(const TContClosure& c);
- ~TContMachineContext();
+ ~TContMachineContext();
- void SwitchTo(TContMachineContext* next) noexcept;
+ void SwitchTo(TContMachineContext* next) noexcept;
private:
void* Fiber_;
@@ -133,7 +133,7 @@ public:
inline ~TContMachineContext() = default;
- void SwitchTo(TContMachineContext* next) noexcept;
+ void SwitchTo(TContMachineContext* next) noexcept;
private:
__myjmp_buf Buf_;
@@ -153,7 +153,7 @@ private:
};
#endif
-static inline size_t MachineContextSize() noexcept {
+static inline size_t MachineContextSize() noexcept {
return sizeof(TContMachineContext);
}
diff --git a/util/system/context_ut.cpp b/util/system/context_ut.cpp
index 1c75718134..45cb0249f7 100644
--- a/util/system/context_ut.cpp
+++ b/util/system/context_ut.cpp
@@ -22,7 +22,7 @@ Y_UNIT_TEST_SUITE(TestContext) {
char Buf[1000000];
};
- static TDeque<TW> w;
+ static TDeque<TW> w;
auto& tw = w.emplace_back(&f);
diff --git a/util/system/direct_io.cpp b/util/system/direct_io.cpp
index 532780e835..f59c54b0cb 100644
--- a/util/system/direct_io.cpp
+++ b/util/system/direct_io.cpp
@@ -46,7 +46,7 @@ namespace {
};
}
-TDirectIOBufferedFile::TDirectIOBufferedFile(const TString& path, EOpenMode oMode, size_t buflen /*= 1 << 17*/)
+TDirectIOBufferedFile::TDirectIOBufferedFile(const TString& path, EOpenMode oMode, size_t buflen /*= 1 << 17*/)
: File(path, oMode)
, Alignment(0)
, DataLen(0)
diff --git a/util/system/direct_io.h b/util/system/direct_io.h
index 4a9e80f3c7..6a3325a960 100644
--- a/util/system/direct_io.h
+++ b/util/system/direct_io.h
@@ -11,7 +11,7 @@
// - Supports writing odd sized files by turning off direct IO for the last chunk.
class TDirectIOBufferedFile {
public:
- TDirectIOBufferedFile(const TString& path, EOpenMode oMode, size_t buflen = 1 << 17);
+ TDirectIOBufferedFile(const TString& path, EOpenMode oMode, size_t buflen = 1 << 17);
~TDirectIOBufferedFile();
void FlushData();
diff --git a/util/system/direct_io_ut.cpp b/util/system/direct_io_ut.cpp
index 8293cc3573..839c3de7ca 100644
--- a/util/system/direct_io_ut.cpp
+++ b/util/system/direct_io_ut.cpp
@@ -12,7 +12,7 @@ static const char* FileName_("./test.file");
Y_UNIT_TEST_SUITE(TDirectIoTestSuite) {
Y_UNIT_TEST(TestDirectFile) {
TDirectIOBufferedFile file(FileName_, RdWr | Direct | Seq | CreateAlways, 1 << 15);
- TVector<ui64> data((1 << 15) + 1);
+ TVector<ui64> data((1 << 15) + 1);
TVector<ui64> readResult(data.size());
for (auto& i : data) {
i = RandomNumber<ui64>();
diff --git a/util/system/dynlib.cpp b/util/system/dynlib.cpp
index 7a3a2d4a29..9d2541c25f 100644
--- a/util/system/dynlib.cpp
+++ b/util/system/dynlib.cpp
@@ -25,7 +25,7 @@ using HINSTANCE = void*;
#define DLLSYM(hndl, name) dlsym(hndl, name)
#endif
-inline TString DLLERR() {
+inline TString DLLERR() {
#ifdef _unix_
return dlerror();
#endif
@@ -38,7 +38,7 @@ inline TString DLLERR() {
return "DLLERR() unknown error";
while (cnt && isspace(msg[cnt - 1]))
--cnt;
- TString err(msg, 0, cnt);
+ TString err(msg, 0, cnt);
LocalFree(msg);
return err;
#endif
@@ -67,13 +67,13 @@ public:
return new TImpl(path, flags);
}
- inline ~TImpl() {
+ inline ~TImpl() {
if (Module && Unloadable) {
DLLCLOSE(Module);
}
}
- inline void* SymOptional(const char* name) noexcept {
+ inline void* SymOptional(const char* name) noexcept {
return (void*)DLLSYM(Module, name);
}
@@ -96,10 +96,10 @@ private:
bool Unloadable;
};
-TDynamicLibrary::TDynamicLibrary() noexcept {
+TDynamicLibrary::TDynamicLibrary() noexcept {
}
-TDynamicLibrary::TDynamicLibrary(const TString& path, int flags) {
+TDynamicLibrary::TDynamicLibrary(const TString& path, int flags) {
Open(path.data(), flags);
}
@@ -109,11 +109,11 @@ void TDynamicLibrary::Open(const char* path, int flags) {
Impl_.Reset(TImpl::SafeCreate(path, flags));
}
-void TDynamicLibrary::Close() noexcept {
+void TDynamicLibrary::Close() noexcept {
Impl_.Destroy();
}
-void* TDynamicLibrary::SymOptional(const char* name) noexcept {
+void* TDynamicLibrary::SymOptional(const char* name) noexcept {
if (!IsLoaded()) {
return nullptr;
}
@@ -129,7 +129,7 @@ void* TDynamicLibrary::Sym(const char* name) {
return Impl_->Sym(name);
}
-bool TDynamicLibrary::IsLoaded() const noexcept {
+bool TDynamicLibrary::IsLoaded() const noexcept {
return (bool)Impl_.Get();
}
diff --git a/util/system/dynlib.h b/util/system/dynlib.h
index 6c4a1b0dd5..66eaf4a5c1 100644
--- a/util/system/dynlib.h
+++ b/util/system/dynlib.h
@@ -3,7 +3,7 @@
#include "defaults.h"
#include <util/generic/ptr.h>
-#include <util/generic/string.h>
+#include <util/generic/string.h>
#define Y_GET_FUNC(dll, name) FUNC_##name((dll).Sym(#name))
#define Y_GET_FUNC_OPTIONAL(dll, name) FUNC_##name((dll).SymOptional(#name))
@@ -22,15 +22,15 @@
class TDynamicLibrary {
public:
- TDynamicLibrary() noexcept;
- TDynamicLibrary(const TString& path, int flags = DEFAULT_DLLOPEN_FLAGS);
- ~TDynamicLibrary();
+ TDynamicLibrary() noexcept;
+ TDynamicLibrary(const TString& path, int flags = DEFAULT_DLLOPEN_FLAGS);
+ ~TDynamicLibrary();
void Open(const char* path, int flags = DEFAULT_DLLOPEN_FLAGS);
- void Close() noexcept;
- void* SymOptional(const char* name) noexcept;
+ void Close() noexcept;
+ void* SymOptional(const char* name) noexcept;
void* Sym(const char* name);
- bool IsLoaded() const noexcept;
+ bool IsLoaded() const noexcept;
void SetUnloadable(bool unloadable); // Set to false to avoid unloading on destructor
private:
@@ -44,11 +44,11 @@ class TExternalSymbol {
private:
TLib* PLib;
TDynamicLibrary* DLib;
- TString lname;
- TString vname;
+ TString lname;
+ TString vname;
public:
- TExternalSymbol() noexcept {
+ TExternalSymbol() noexcept {
PLib = nullptr;
DLib = nullptr;
}
@@ -70,7 +70,7 @@ public:
}
return *this;
}
- ~TExternalSymbol() {
+ ~TExternalSymbol() {
delete DLib;
}
// set the symbol from dynamic source
@@ -90,30 +90,30 @@ public:
vname = vtbl_name;
}
// set the symbol from static source
- void SetSym(TLib* pl) noexcept {
+ void SetSym(TLib* pl) noexcept {
if (DLib == nullptr && PLib == nullptr)
PLib = pl;
}
- void Close() noexcept {
+ void Close() noexcept {
delete DLib;
DLib = 0;
PLib = 0;
lname.remove();
vname.remove();
}
- TLib* Symbol() const noexcept {
+ TLib* Symbol() const noexcept {
return PLib;
}
- const TString& LibName() const noexcept {
+ const TString& LibName() const noexcept {
return lname;
}
- const TString& VtblName() const noexcept {
+ const TString& VtblName() const noexcept {
return vname;
}
- bool IsStatic() const noexcept {
+ bool IsStatic() const noexcept {
return DLib == nullptr && PLib != nullptr;
}
- bool IsDynamic() const noexcept {
+ bool IsDynamic() const noexcept {
return DLib && DLib->IsLoaded() && PLib != nullptr;
}
};
diff --git a/util/system/env.cpp b/util/system/env.cpp
index 779aa6e4fb..ead9b566a5 100644
--- a/util/system/env.cpp
+++ b/util/system/env.cpp
@@ -1,19 +1,19 @@
#include "env.h"
-#include <util/generic/string.h>
+#include <util/generic/string.h>
#include <util/generic/yexception.h>
#ifdef _win_
#include <util/generic/vector.h>
#include "winint.h"
-#else
+#else
#include <cerrno>
#include <cstdlib>
#endif
/**
- * On Windows there may be many copies of enviroment variables, there at least two known, one is
- * manipulated by Win32 API, another by C runtime, so we must be consistent in the choice of
+ * On Windows there may be many copies of enviroment variables, there at least two known, one is
+ * manipulated by Win32 API, another by C runtime, so we must be consistent in the choice of
* functions used to manipulate them.
*
* Relevant links:
@@ -21,35 +21,35 @@
* - https://a.yandex-team.ru/review/108892/details
*/
-TString GetEnv(const TString& key, const TString& def) {
+TString GetEnv(const TString& key, const TString& def) {
#ifdef _win_
size_t len = GetEnvironmentVariableA(key.data(), nullptr, 0);
-
- if (len == 0) {
+
+ if (len == 0) {
if (GetLastError() == ERROR_ENVVAR_NOT_FOUND) {
return def;
}
- return TString{};
- }
-
- TVector<char> buffer(len);
- size_t bufferSize;
- do {
- bufferSize = buffer.size();
+ return TString{};
+ }
+
+ TVector<char> buffer(len);
+ size_t bufferSize;
+ do {
+ bufferSize = buffer.size();
len = GetEnvironmentVariableA(key.data(), buffer.data(), static_cast<DWORD>(bufferSize));
- if (len > bufferSize) {
- buffer.resize(len);
- }
- } while (len > bufferSize);
-
- return TString(buffer.data(), len);
+ if (len > bufferSize) {
+ buffer.resize(len);
+ }
+ } while (len > bufferSize);
+
+ return TString(buffer.data(), len);
#else
const char* env = getenv(key.data());
- return env ? TString(env) : def;
+ return env ? TString(env) : def;
#endif
}
-void SetEnv(const TString& key, const TString& value) {
+void SetEnv(const TString& key, const TString& value) {
bool isOk = false;
int errorCode = 0;
#ifdef _win_
diff --git a/util/system/env.h b/util/system/env.h
index 0b77070ab7..e2ccdd1e95 100644
--- a/util/system/env.h
+++ b/util/system/env.h
@@ -1,6 +1,6 @@
#pragma once
-#include <util/generic/string.h>
+#include <util/generic/string.h>
/**
* Search the environment list provided by the host environment for associated variable.
@@ -16,7 +16,7 @@
* @note Calls to `GetEnv` and `SetEnv` from different threads must be synchronized.
* @see SetEnv
*/
-TString GetEnv(const TString& key, const TString& def = TString());
+TString GetEnv(const TString& key, const TString& def = TString());
/**
* Add or change environment variable provided by the host environment.
@@ -29,4 +29,4 @@ TString GetEnv(const TString& key, const TString& def = TString());
* @note Calls to `GetEnv` and `SetEnv` from different threads must be synchronized.
* @see GetEnv
*/
-void SetEnv(const TString& key, const TString& value);
+void SetEnv(const TString& key, const TString& value);
diff --git a/util/system/env_ut.cpp b/util/system/env_ut.cpp
index 3139394bc7..e03cc01658 100644
--- a/util/system/env_ut.cpp
+++ b/util/system/env_ut.cpp
@@ -1,31 +1,31 @@
#include <library/cpp/testing/unittest/registar.h>
-#include <util/generic/string.h>
+#include <util/generic/string.h>
#include "env.h"
Y_UNIT_TEST_SUITE(EnvTest) {
Y_UNIT_TEST(GetSetEnvTest) {
- TString key = "util_GETENV_TestVar";
- TString value = "Some value for env var";
- TString def = "Some default value for env var";
+ TString key = "util_GETENV_TestVar";
+ TString value = "Some value for env var";
+ TString def = "Some default value for env var";
// first of all, it should be clear
- UNIT_ASSERT_VALUES_EQUAL(GetEnv(key), TString());
+ UNIT_ASSERT_VALUES_EQUAL(GetEnv(key), TString());
UNIT_ASSERT_VALUES_EQUAL(GetEnv(key, def), def);
SetEnv(key, value);
// set and see what value we get here
UNIT_ASSERT_VALUES_EQUAL(GetEnv(key), value);
UNIT_ASSERT_VALUES_EQUAL(GetEnv(key, def), value);
// set empty value
- SetEnv(key, TString());
- UNIT_ASSERT_VALUES_EQUAL(GetEnv(key), TString());
-
- // check for long values, see IGNIETFERRO-214
- TString longKey = "util_GETENV_TestVarLong";
- TString longValue{1500, 't'};
- UNIT_ASSERT_VALUES_EQUAL(GetEnv(longKey), TString());
- SetEnv(longKey, longValue);
- UNIT_ASSERT_VALUES_EQUAL(GetEnv(longKey), longValue);
- SetEnv(longKey, TString());
- UNIT_ASSERT_VALUES_EQUAL(GetEnv(longKey), TString());
+ SetEnv(key, TString());
+ UNIT_ASSERT_VALUES_EQUAL(GetEnv(key), TString());
+
+ // check for long values, see IGNIETFERRO-214
+ TString longKey = "util_GETENV_TestVarLong";
+ TString longValue{1500, 't'};
+ UNIT_ASSERT_VALUES_EQUAL(GetEnv(longKey), TString());
+ SetEnv(longKey, longValue);
+ UNIT_ASSERT_VALUES_EQUAL(GetEnv(longKey), longValue);
+ SetEnv(longKey, TString());
+ UNIT_ASSERT_VALUES_EQUAL(GetEnv(longKey), TString());
}
}
diff --git a/util/system/error.cpp b/util/system/error.cpp
index eb0806fe5d..f778ec42cb 100644
--- a/util/system/error.cpp
+++ b/util/system/error.cpp
@@ -47,7 +47,7 @@ int LastSystemError() {
#if defined(_win_)
namespace {
struct TErrString {
- inline TErrString() noexcept {
+ inline TErrString() noexcept {
data[0] = 0;
}
diff --git a/util/system/event.cpp b/util/system/event.cpp
index 6f70a37e05..79b3cdb291 100644
--- a/util/system/event.cpp
+++ b/util/system/event.cpp
@@ -19,19 +19,19 @@ public:
cond = CreateEvent(nullptr, rmode == rManual ? true : false, false, nullptr);
}
- inline ~TEvImpl() {
+ inline ~TEvImpl() {
CloseHandle(cond);
}
- inline void Reset() noexcept {
+ inline void Reset() noexcept {
ResetEvent(cond);
}
- inline void Signal() noexcept {
+ inline void Signal() noexcept {
SetEvent(cond);
}
- inline bool WaitD(TInstant deadLine) noexcept {
+ inline bool WaitD(TInstant deadLine) noexcept {
if (deadLine == TInstant::Max()) {
return WaitForSingleObject(cond, INFINITE) == WAIT_OBJECT_0;
}
@@ -51,7 +51,7 @@ public:
{
}
- inline void Signal() noexcept {
+ inline void Signal() noexcept {
if (Manual && AtomicGet(Signaled)) {
return; // shortcut
}
@@ -67,11 +67,11 @@ public:
}
}
- inline void Reset() noexcept {
+ inline void Reset() noexcept {
AtomicSet(Signaled, 0);
}
- inline bool WaitD(TInstant deadLine) noexcept {
+ inline bool WaitD(TInstant deadLine) noexcept {
if (Manual && AtomicGet(Signaled)) {
return true; // shortcut
}
diff --git a/util/system/event.h b/util/system/event.h
index 3e9378fbee..cab2fc478a 100644
--- a/util/system/event.h
+++ b/util/system/event.h
@@ -24,34 +24,34 @@ public:
~TSystemEvent();
- void Reset() noexcept;
- void Signal() noexcept;
+ void Reset() noexcept;
+ void Signal() noexcept;
/*
* return true if signaled, false if timed out.
*/
- bool WaitD(TInstant deadLine) noexcept;
+ bool WaitD(TInstant deadLine) noexcept;
/*
* return true if signaled, false if timed out.
*/
- inline bool WaitT(TDuration timeOut) noexcept {
+ inline bool WaitT(TDuration timeOut) noexcept {
return WaitD(timeOut.ToDeadLine());
}
/*
* wait infinite time
*/
- inline void WaitI() noexcept {
+ inline void WaitI() noexcept {
WaitD(TInstant::Max());
}
//return true if signaled, false if timed out.
- inline bool Wait(ui32 timer) noexcept {
+ inline bool Wait(ui32 timer) noexcept {
return WaitT(TDuration::MilliSeconds(timer));
}
- inline bool Wait() noexcept {
+ inline bool Wait() noexcept {
WaitI();
return true;
diff --git a/util/system/execpath.cpp b/util/system/execpath.cpp
index 3877c912e7..33198af58b 100644
--- a/util/system/execpath.cpp
+++ b/util/system/execpath.cpp
@@ -32,8 +32,8 @@
#include "fs.h"
#if defined(_freebsd_)
-static inline bool GoodPath(const TString& path) {
- return path.find('/') != TString::npos;
+static inline bool GoodPath(const TString& path) {
+ return path.find('/') != TString::npos;
}
static inline int FreeBSDSysCtl(int* mib, size_t mibSize, TTempBuf& res) {
@@ -51,12 +51,12 @@ static inline int FreeBSDSysCtl(int* mib, size_t mibSize, TTempBuf& res) {
return errno;
}
-static inline TString FreeBSDGetExecPath() {
+static inline TString FreeBSDGetExecPath() {
int mib[] = {CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1};
TTempBuf buf;
int r = FreeBSDSysCtl(mib, Y_ARRAY_SIZE(mib), buf);
if (r == 0) {
- return TString(buf.Data(), buf.Filled() - 1);
+ return TString(buf.Data(), buf.Filled() - 1);
} else if (r == ENOTSUP) { // older FreeBSD version
/*
* BSD analogue for /proc/self is /proc/curproc.
@@ -66,24 +66,24 @@ static inline TString FreeBSDGetExecPath() {
TString path("/proc/curproc/file");
return NFs::ReadLink(path);
} else {
- return TString();
+ return TString();
}
}
-static inline TString FreeBSDGetArgv0() {
+static inline TString FreeBSDGetArgv0() {
int mib[] = {CTL_KERN, KERN_PROC, KERN_PROC_ARGS, getpid()};
TTempBuf buf;
int r = FreeBSDSysCtl(mib, Y_ARRAY_SIZE(mib), buf);
if (r == 0) {
- return TString(buf.Data());
+ return TString(buf.Data());
} else if (r == ENOTSUP) {
- return TString();
+ return TString();
} else {
ythrow yexception() << "FreeBSDGetArgv0() failed: " << LastSystemErrorText();
}
}
-static inline bool FreeBSDGuessExecPath(const TString& guessPath, TString& execPath) {
+static inline bool FreeBSDGuessExecPath(const TString& guessPath, TString& execPath) {
if (NFs::Exists(guessPath)) {
// now it should work for real
execPath = FreeBSDGetExecPath();
@@ -94,13 +94,13 @@ static inline bool FreeBSDGuessExecPath(const TString& guessPath, TString& execP
return false;
}
-static inline bool FreeBSDGuessExecBasePath(const TString& guessBasePath, TString& execPath) {
- return FreeBSDGuessExecPath(TString(guessBasePath) + "/" + getprogname(), execPath);
+static inline bool FreeBSDGuessExecBasePath(const TString& guessBasePath, TString& execPath) {
+ return FreeBSDGuessExecPath(TString(guessBasePath) + "/" + getprogname(), execPath);
}
#endif
-static TString GetExecPathImpl() {
+static TString GetExecPathImpl() {
#if defined(_solaris_)
return execname();
#elif defined(_darwin_)
@@ -132,7 +132,7 @@ static TString GetExecPathImpl() {
return NFs::ReadLink(path);
// TODO(yoda): check if the filename ends with " (deleted)"
#elif defined(_freebsd_)
- TString execPath = FreeBSDGetExecPath();
+ TString execPath = FreeBSDGetExecPath();
if (GoodPath(execPath)) {
return execPath;
}
@@ -185,12 +185,12 @@ namespace {
return SingletonWithPriority<TExecPathsHolder, 1>();
}
- TString ExecPath;
+ TString ExecPath;
TString PersistentExecPath;
};
}
-const TString& GetExecPath() {
+const TString& GetExecPath() {
return TExecPathsHolder::Instance()->ExecPath;
}
diff --git a/util/system/execpath.h b/util/system/execpath.h
index 451551ac79..4b914b8e85 100644
--- a/util/system/execpath.h
+++ b/util/system/execpath.h
@@ -3,7 +3,7 @@
#include <util/generic/fwd.h>
// NOTE: This function has rare sporadic failures (throws exceptions) on FreeBSD. See REVIEW:54297
-const TString& GetExecPath();
+const TString& GetExecPath();
/**
* Get openable path to the binary currently being executed.
diff --git a/util/system/execpath_ut.cpp b/util/system/execpath_ut.cpp
index df64d08e2f..16b01466f5 100644
--- a/util/system/execpath_ut.cpp
+++ b/util/system/execpath_ut.cpp
@@ -7,7 +7,7 @@
Y_UNIT_TEST_SUITE(TExecPathTest) {
Y_UNIT_TEST(TestIt) {
- TString execPath = GetExecPath();
+ TString execPath = GetExecPath();
TString persistentExecPath = GetPersistentExecPath();
try {
diff --git a/util/system/fasttime.cpp b/util/system/fasttime.cpp
index d885592a81..057a814f0a 100644
--- a/util/system/fasttime.cpp
+++ b/util/system/fasttime.cpp
@@ -130,35 +130,35 @@ namespace {
{
}
- inline void Add(const A& a, const B& b) noexcept {
+ inline void Add(const A& a, const B& b) noexcept {
Add(TSample(a, b));
}
- inline void Add(const TSample& s) noexcept {
+ inline void Add(const TSample& s) noexcept {
S_[(C_++) % N] = s;
if (C_ > 1) {
ReCalc();
}
}
- inline B Predict(A a) const noexcept {
+ inline B Predict(A a) const noexcept {
return A_ + a * B_;
}
- inline size_t Size() const noexcept {
+ inline size_t Size() const noexcept {
return C_;
}
- inline bool Enough() const noexcept {
+ inline bool Enough() const noexcept {
return Size() >= N;
}
- inline A LastX() const noexcept {
+ inline A LastX() const noexcept {
return S_[(C_ - 1) % N].first;
}
private:
- inline void ReCalc() noexcept {
+ inline void ReCalc() noexcept {
const size_t n = Min(N, C_);
double sx = 0;
diff --git a/util/system/file.cpp b/util/system/file.cpp
index e4af4bacde..4a261d020c 100644
--- a/util/system/file.cpp
+++ b/util/system/file.cpp
@@ -17,7 +17,7 @@
#include <util/random/random.h>
#include <util/generic/size_literals.h>
-#include <util/generic/string.h>
+#include <util/generic/string.h>
#include <util/generic/ylimits.h>
#include <util/generic/yexception.h>
@@ -63,7 +63,7 @@ static bool IsStupidFlagCombination(EOpenMode oMode) {
return (oMode & (CreateAlways | ForAppend)) == (CreateAlways | ForAppend) || (oMode & (TruncExisting | ForAppend)) == (TruncExisting | ForAppend) || (oMode & (CreateNew | ForAppend)) == (CreateNew | ForAppend);
}
-TFileHandle::TFileHandle(const TString& fName, EOpenMode oMode) noexcept {
+TFileHandle::TFileHandle(const TString& fName, EOpenMode oMode) noexcept {
ui32 fcMode = 0;
EOpenMode createMode = oMode & MaskCreation;
Y_VERIFY(!IsStupidFlagCombination(oMode), "oMode %d makes no sense", static_cast<int>(oMode));
@@ -267,7 +267,7 @@ TFileHandle::TFileHandle(const TString& fName, EOpenMode oMode) noexcept {
#endif
}
-bool TFileHandle::Close() noexcept {
+bool TFileHandle::Close() noexcept {
bool isOk = true;
#ifdef _win_
if (Fd_ != INVALID_FHANDLE) {
@@ -294,7 +294,7 @@ bool TFileHandle::Close() noexcept {
return isOk;
}
-static inline i64 DoSeek(FHANDLE h, i64 offset, SeekDir origin) noexcept {
+static inline i64 DoSeek(FHANDLE h, i64 offset, SeekDir origin) noexcept {
if (h == INVALID_FHANDLE) {
return -1L;
}
@@ -319,15 +319,15 @@ static inline i64 DoSeek(FHANDLE h, i64 offset, SeekDir origin) noexcept {
#endif
}
-i64 TFileHandle::GetPosition() const noexcept {
+i64 TFileHandle::GetPosition() const noexcept {
return DoSeek(Fd_, 0, sCur);
}
-i64 TFileHandle::Seek(i64 offset, SeekDir origin) noexcept {
+i64 TFileHandle::Seek(i64 offset, SeekDir origin) noexcept {
return DoSeek(Fd_, offset, origin);
}
-i64 TFileHandle::GetLength() const noexcept {
+i64 TFileHandle::GetLength() const noexcept {
// XXX: returns error code, but does not set errno
if (!IsOpen()) {
return -1L;
@@ -335,7 +335,7 @@ i64 TFileHandle::GetLength() const noexcept {
return GetFileLength(Fd_);
}
-bool TFileHandle::Resize(i64 length) noexcept {
+bool TFileHandle::Resize(i64 length) noexcept {
if (!IsOpen()) {
return false;
}
@@ -363,7 +363,7 @@ bool TFileHandle::Resize(i64 length) noexcept {
#endif
}
-bool TFileHandle::Reserve(i64 length) noexcept {
+bool TFileHandle::Reserve(i64 length) noexcept {
// FIXME this should reserve disk space with fallocate
if (!IsOpen()) {
return false;
@@ -412,7 +412,7 @@ bool TFileHandle::ShrinkToFit() noexcept {
#endif
}
-bool TFileHandle::Flush() noexcept {
+bool TFileHandle::Flush() noexcept {
if (!IsOpen()) {
return false;
}
@@ -443,7 +443,7 @@ bool TFileHandle::Flush() noexcept {
#endif
}
-bool TFileHandle::FlushData() noexcept {
+bool TFileHandle::FlushData() noexcept {
#if defined(_linux_)
if (!IsOpen()) {
return false;
@@ -458,7 +458,7 @@ bool TFileHandle::FlushData() noexcept {
#endif
}
-i32 TFileHandle::Read(void* buffer, ui32 byteCount) noexcept {
+i32 TFileHandle::Read(void* buffer, ui32 byteCount) noexcept {
// FIXME size and return must be 64-bit
if (!IsOpen()) {
return -1;
@@ -480,7 +480,7 @@ i32 TFileHandle::Read(void* buffer, ui32 byteCount) noexcept {
#endif
}
-i32 TFileHandle::Write(const void* buffer, ui32 byteCount) noexcept {
+i32 TFileHandle::Write(const void* buffer, ui32 byteCount) noexcept {
if (!IsOpen()) {
return -1;
}
@@ -501,7 +501,7 @@ i32 TFileHandle::Write(const void* buffer, ui32 byteCount) noexcept {
#endif
}
-i32 TFileHandle::Pread(void* buffer, ui32 byteCount, i64 offset) const noexcept {
+i32 TFileHandle::Pread(void* buffer, ui32 byteCount, i64 offset) const noexcept {
#if defined(_win_)
OVERLAPPED io;
Zero(io);
@@ -526,7 +526,7 @@ i32 TFileHandle::Pread(void* buffer, ui32 byteCount, i64 offset) const noexcept
#endif
}
-i32 TFileHandle::Pwrite(const void* buffer, ui32 byteCount, i64 offset) const noexcept {
+i32 TFileHandle::Pwrite(const void* buffer, ui32 byteCount, i64 offset) const noexcept {
#if defined(_win_)
OVERLAPPED io;
Zero(io);
@@ -548,7 +548,7 @@ i32 TFileHandle::Pwrite(const void* buffer, ui32 byteCount, i64 offset) const no
#endif
}
-FHANDLE TFileHandle::Duplicate() const noexcept {
+FHANDLE TFileHandle::Duplicate() const noexcept {
if (!IsOpen()) {
return INVALID_FHANDLE;
}
@@ -597,7 +597,7 @@ int TFileHandle::Duplicate2Posix(int dstHandle) const noexcept {
#endif
}
-bool TFileHandle::LinkTo(const TFileHandle& fh) const noexcept {
+bool TFileHandle::LinkTo(const TFileHandle& fh) const noexcept {
#if defined(_unix_)
while (dup2(fh.Fd_, Fd_) == -1) {
if (errno != EINTR) {
@@ -621,7 +621,7 @@ bool TFileHandle::LinkTo(const TFileHandle& fh) const noexcept {
#endif
}
-int TFileHandle::Flock(int op) noexcept {
+int TFileHandle::Flock(int op) noexcept {
return ::Flock(Fd_, op);
}
@@ -775,7 +775,7 @@ bool TFileHandle::FlushCache(i64 offset, i64 length, bool wait) noexcept {
#endif
}
-TString DecodeOpenMode(ui32 mode0) {
+TString DecodeOpenMode(ui32 mode0) {
ui32 mode = mode0;
TStringBuilder r;
@@ -843,13 +843,13 @@ TString DecodeOpenMode(ui32 mode0) {
class TFile::TImpl: public TAtomicRefCount<TImpl> {
public:
- inline TImpl(FHANDLE fd, const TString& fname = TString())
+ inline TImpl(FHANDLE fd, const TString& fname = TString())
: Handle_(fd)
, FileName_(fname)
{
}
- inline TImpl(const TString& fName, EOpenMode oMode)
+ inline TImpl(const TString& fName, EOpenMode oMode)
: Handle_(fName, oMode)
, FileName_(fName)
{
@@ -866,15 +866,15 @@ public:
}
}
- const TString& GetName() const noexcept {
+ const TString& GetName() const noexcept {
return FileName_;
}
- void SetName(const TString& newName) {
+ void SetName(const TString& newName) {
FileName_ = newName;
}
- const TFileHandle& GetHandle() const noexcept {
+ const TFileHandle& GetHandle() const noexcept {
return Handle_;
}
@@ -1084,7 +1084,7 @@ public:
private:
TFileHandle Handle_;
- TString FileName_;
+ TString FileName_;
};
TFile::TFile()
@@ -1097,12 +1097,12 @@ TFile::TFile(FHANDLE fd)
{
}
-TFile::TFile(FHANDLE fd, const TString& name)
+TFile::TFile(FHANDLE fd, const TString& name)
: Impl_(new TImpl(fd, name))
{
}
-TFile::TFile(const TString& fName, EOpenMode oMode)
+TFile::TFile(const TString& fName, EOpenMode oMode)
: Impl_(new TImpl(fName, oMode))
{
}
@@ -1113,23 +1113,23 @@ void TFile::Close() {
Impl_->Close();
}
-const TString& TFile::GetName() const noexcept {
+const TString& TFile::GetName() const noexcept {
return Impl_->GetName();
}
-i64 TFile::GetPosition() const noexcept {
+i64 TFile::GetPosition() const noexcept {
return Impl_->GetHandle().GetPosition();
}
-i64 TFile::GetLength() const noexcept {
+i64 TFile::GetLength() const noexcept {
return Impl_->GetHandle().GetLength();
}
-bool TFile::IsOpen() const noexcept {
+bool TFile::IsOpen() const noexcept {
return Impl_->GetHandle().IsOpen();
}
-FHANDLE TFile::GetHandle() const noexcept {
+FHANDLE TFile::GetHandle() const noexcept {
return Impl_->GetHandle();
}
@@ -1237,12 +1237,12 @@ void TFile::LinkTo(const TFile& f) const {
}
}
-TFile TFile::Temporary(const TString& prefix) {
+TFile TFile::Temporary(const TString& prefix) {
//TODO - handle impossible case of name collision
return TFile(prefix + ToString(MicroSeconds()) + "-" + ToString(RandomNumber<ui64>()), CreateNew | RdWr | Seq | Temp | Transient);
}
-TFile TFile::ForAppend(const TString& path) {
+TFile TFile::ForAppend(const TString& path) {
return TFile(path, OpenAlways | WrOnly | Seq | ::ForAppend);
}
@@ -1283,7 +1283,7 @@ TFile Duplicate(int fd) {
#endif
}
-bool PosixDisableReadAhead(FHANDLE fileHandle, void* addr) noexcept {
+bool PosixDisableReadAhead(FHANDLE fileHandle, void* addr) noexcept {
int ret = -1;
#if HAVE_POSIX_FADVISE
diff --git a/util/system/file.h b/util/system/file.h
index efe1e59b4a..9502e159b6 100644
--- a/util/system/file.h
+++ b/util/system/file.h
@@ -52,7 +52,7 @@ enum EOpenModeFlag {
Y_DECLARE_FLAGS(EOpenMode, EOpenModeFlag)
Y_DECLARE_OPERATORS_FOR_FLAGS(EOpenMode)
-TString DecodeOpenMode(ui32 openMode);
+TString DecodeOpenMode(ui32 openMode);
enum SeekDir {
sSet = 0,
@@ -62,68 +62,68 @@ enum SeekDir {
class TFileHandle: public TNonCopyable {
public:
- constexpr TFileHandle() = default;
-
+ constexpr TFileHandle() = default;
+
/// Warning: takes ownership of fd, so closes it in destructor.
- inline TFileHandle(FHANDLE fd) noexcept
+ inline TFileHandle(FHANDLE fd) noexcept
: Fd_(fd)
{
}
- inline TFileHandle(TFileHandle&& other) noexcept
+ inline TFileHandle(TFileHandle&& other) noexcept
: Fd_(other.Fd_)
{
other.Fd_ = INVALID_FHANDLE;
}
- TFileHandle(const TString& fName, EOpenMode oMode) noexcept;
+ TFileHandle(const TString& fName, EOpenMode oMode) noexcept;
- inline ~TFileHandle() {
+ inline ~TFileHandle() {
Close();
}
- bool Close() noexcept;
+ bool Close() noexcept;
- inline FHANDLE Release() noexcept {
+ inline FHANDLE Release() noexcept {
FHANDLE ret = Fd_;
Fd_ = INVALID_FHANDLE;
return ret;
}
- inline void Swap(TFileHandle& r) noexcept {
+ inline void Swap(TFileHandle& r) noexcept {
DoSwap(Fd_, r.Fd_);
}
- inline operator FHANDLE() const noexcept {
+ inline operator FHANDLE() const noexcept {
return Fd_;
}
- inline bool IsOpen() const noexcept {
+ inline bool IsOpen() const noexcept {
return Fd_ != INVALID_FHANDLE;
}
- i64 GetPosition() const noexcept;
- i64 GetLength() const noexcept;
+ i64 GetPosition() const noexcept;
+ i64 GetLength() const noexcept;
- i64 Seek(i64 offset, SeekDir origin) noexcept;
- bool Resize(i64 length) noexcept;
- bool Reserve(i64 length) noexcept;
+ i64 Seek(i64 offset, SeekDir origin) noexcept;
+ bool Resize(i64 length) noexcept;
+ bool Reserve(i64 length) noexcept;
bool FallocateNoResize(i64 length) noexcept;
bool ShrinkToFit() noexcept;
- bool Flush() noexcept;
+ bool Flush() noexcept;
//flush data only, without file metadata
- bool FlushData() noexcept;
- i32 Read(void* buffer, ui32 byteCount) noexcept;
- i32 Write(const void* buffer, ui32 byteCount) noexcept;
- i32 Pread(void* buffer, ui32 byteCount, i64 offset) const noexcept;
- i32 Pwrite(const void* buffer, ui32 byteCount, i64 offset) const noexcept;
- int Flock(int op) noexcept;
-
- FHANDLE Duplicate() const noexcept;
+ bool FlushData() noexcept;
+ i32 Read(void* buffer, ui32 byteCount) noexcept;
+ i32 Write(const void* buffer, ui32 byteCount) noexcept;
+ i32 Pread(void* buffer, ui32 byteCount, i64 offset) const noexcept;
+ i32 Pwrite(const void* buffer, ui32 byteCount, i64 offset) const noexcept;
+ int Flock(int op) noexcept;
+
+ FHANDLE Duplicate() const noexcept;
int Duplicate2Posix(int dstHandle) const noexcept;
//dup2 - like semantics, return true on success
- bool LinkTo(const TFileHandle& fh) const noexcept;
+ bool LinkTo(const TFileHandle& fh) const noexcept;
//very low-level methods
bool SetDirect();
@@ -141,7 +141,7 @@ public:
bool FlushCache(i64 offset = 0, i64 length = 0, bool wait = true) noexcept;
private:
- FHANDLE Fd_ = INVALID_FHANDLE;
+ FHANDLE Fd_ = INVALID_FHANDLE;
};
class TFile {
@@ -149,17 +149,17 @@ public:
TFile();
/// Takes ownership of handle, so closes it when the last holder of descriptor dies.
explicit TFile(FHANDLE fd);
- TFile(FHANDLE fd, const TString& fname);
- TFile(const TString& fName, EOpenMode oMode);
- ~TFile();
+ TFile(FHANDLE fd, const TString& fname);
+ TFile(const TString& fName, EOpenMode oMode);
+ ~TFile();
void Close();
- const TString& GetName() const noexcept;
- i64 GetPosition() const noexcept;
- i64 GetLength() const noexcept;
- bool IsOpen() const noexcept;
- FHANDLE GetHandle() const noexcept;
+ const TString& GetName() const noexcept;
+ i64 GetPosition() const noexcept;
+ i64 GetLength() const noexcept;
+ bool IsOpen() const noexcept;
+ FHANDLE GetHandle() const noexcept;
i64 Seek(i64 offset, SeekDir origin);
void Resize(i64 length);
@@ -211,8 +211,8 @@ public:
//flush unwritten data in this range and optionally wait for completion
void FlushCache(i64 offset = 0, i64 length = 0, bool wait = true);
- static TFile Temporary(const TString& prefix);
- static TFile ForAppend(const TString& path);
+ static TFile Temporary(const TString& prefix);
+ static TFile ForAppend(const TString& path);
private:
class TImpl;
@@ -222,4 +222,4 @@ private:
TFile Duplicate(FILE*);
TFile Duplicate(int);
-bool PosixDisableReadAhead(FHANDLE fileHandle, void* addr) noexcept;
+bool PosixDisableReadAhead(FHANDLE fileHandle, void* addr) noexcept;
diff --git a/util/system/file_ut.cpp b/util/system/file_ut.cpp
index 8681611514..941e6a50f3 100644
--- a/util/system/file_ut.cpp
+++ b/util/system/file_ut.cpp
@@ -53,7 +53,7 @@ public:
f2.Write("67890", 5);
}
- UNIT_ASSERT_EQUAL(TUnbufferedFileInput(tmp2.Name()).ReadAll(), "1234567890");
+ UNIT_ASSERT_EQUAL(TUnbufferedFileInput(tmp2.Name()).ReadAll(), "1234567890");
}
inline void TestAppend() {
@@ -72,7 +72,7 @@ public:
f.Write("89", 2);
}
- UNIT_ASSERT_EQUAL(TUnbufferedFileInput(tmp.Name()).ReadAll(), "123456786789");
+ UNIT_ASSERT_EQUAL(TUnbufferedFileInput(tmp.Name()).ReadAll(), "123456786789");
}
inline void TestReWrite() {
@@ -90,7 +90,7 @@ public:
f.Write("6789", 4);
}
- UNIT_ASSERT_EQUAL(TUnbufferedFileInput(tmp.Name()).ReadAll(), "67895678");
+ UNIT_ASSERT_EQUAL(TUnbufferedFileInput(tmp.Name()).ReadAll(), "67895678");
}
inline void TestResize() {
@@ -111,7 +111,7 @@ public:
UNIT_ASSERT_EQUAL(file.GetPosition(), 3);
}
- const TString data = TUnbufferedFileInput(tmp.Name()).ReadAll();
+ const TString data = TUnbufferedFileInput(tmp.Name()).ReadAll();
UNIT_ASSERT_EQUAL(data.length(), 12);
UNIT_ASSERT(data.StartsWith("12345"));
}
@@ -120,7 +120,7 @@ public:
UNIT_TEST_SUITE_REGISTRATION(TFileTest);
void TFileTest::TestOpen() {
- TString res;
+ TString res;
TFile f1;
try {
diff --git a/util/system/filemap.cpp b/util/system/filemap.cpp
index 2065868199..7454a4cb94 100644
--- a/util/system/filemap.cpp
+++ b/util/system/filemap.cpp
@@ -53,7 +53,7 @@ namespace {
return *Singleton<TSysInfo>();
}
- static inline size_t CalcGranularity() noexcept {
+ static inline size_t CalcGranularity() noexcept {
#if defined(_win_)
SYSTEM_INFO sysInfo;
GetSystemInfo(&sysInfo);
@@ -75,7 +75,7 @@ TString TMemoryMapCommon::UnknownFileName() {
return "Unknown_file_name";
}
-static inline i64 DownToGranularity(i64 offset) noexcept {
+static inline i64 DownToGranularity(i64 offset) noexcept {
return offset & ~((i64)(GRANULARITY - 1));
}
@@ -161,7 +161,7 @@ public:
}
}
- inline TImpl(FILE* f, EOpenMode om, TString dbgName)
+ inline TImpl(FILE* f, EOpenMode om, TString dbgName)
: File_(Duplicate(f))
, DbgName_(std::move(dbgName))
, Length_(File_.GetLength())
@@ -171,7 +171,7 @@ public:
CreateMapping();
}
- inline TImpl(const TString& name, EOpenMode om)
+ inline TImpl(const TString& name, EOpenMode om)
: File_(name, (om & oRdWr) ? OpenExisting | RdWr : OpenExisting | RdOnly)
, DbgName_(name)
, Length_(File_.GetLength())
@@ -181,7 +181,7 @@ public:
CreateMapping();
}
- inline TImpl(const TString& name, i64 length, EOpenMode om)
+ inline TImpl(const TString& name, i64 length, EOpenMode om)
: File_(name, (om & oRdWr) ? OpenExisting | RdWr : OpenExisting | RdOnly)
, DbgName_(name)
, Length_(length)
@@ -196,7 +196,7 @@ public:
CreateMapping();
}
- inline TImpl(const TFile& file, EOpenMode om, TString dbgName)
+ inline TImpl(const TFile& file, EOpenMode om, TString dbgName)
: File_(file)
, DbgName_(File_.GetName() ? File_.GetName() : std::move(dbgName))
, Length_(File_.GetLength())
@@ -206,7 +206,7 @@ public:
CreateMapping();
}
- inline bool IsOpen() const noexcept {
+ inline bool IsOpen() const noexcept {
return File_.IsOpen()
#if defined(_win_)
&& Mapping_ != nullptr
@@ -304,7 +304,7 @@ public:
#endif
}
- inline ~TImpl() {
+ inline ~TImpl() {
#if defined(_win_)
if (Mapping_) {
::CloseHandle(Mapping_); // != FALSE
@@ -317,15 +317,15 @@ public:
#endif
}
- inline i64 Length() const noexcept {
+ inline i64 Length() const noexcept {
return Length_;
}
- inline TFile GetFile() const noexcept {
+ inline TFile GetFile() const noexcept {
return File_;
}
- inline TString GetDbgName() const {
+ inline TString GetDbgName() const {
return DbgName_;
}
@@ -335,7 +335,7 @@ public:
private:
TFile File_;
- TString DbgName_; // This string is never used to actually open a file, only in exceptions
+ TString DbgName_; // This string is never used to actually open a file, only in exceptions
i64 Length_;
EOpenMode Mode_;
@@ -346,37 +346,37 @@ private:
#endif
};
-TMemoryMap::TMemoryMap(const TString& name)
+TMemoryMap::TMemoryMap(const TString& name)
: Impl_(new TImpl(name, EOpenModeFlag::oRdOnly))
{
}
-TMemoryMap::TMemoryMap(const TString& name, EOpenMode om)
+TMemoryMap::TMemoryMap(const TString& name, EOpenMode om)
: Impl_(new TImpl(name, om))
{
}
-TMemoryMap::TMemoryMap(const TString& name, i64 length, EOpenMode om)
+TMemoryMap::TMemoryMap(const TString& name, i64 length, EOpenMode om)
: Impl_(new TImpl(name, length, om))
{
}
-TMemoryMap::TMemoryMap(FILE* f, TString dbgName)
+TMemoryMap::TMemoryMap(FILE* f, TString dbgName)
: Impl_(new TImpl(f, EOpenModeFlag::oRdOnly, std::move(dbgName)))
{
}
-TMemoryMap::TMemoryMap(FILE* f, EOpenMode om, TString dbgName)
+TMemoryMap::TMemoryMap(FILE* f, EOpenMode om, TString dbgName)
: Impl_(new TImpl(f, om, std::move(dbgName)))
{
}
-TMemoryMap::TMemoryMap(const TFile& file, TString dbgName)
+TMemoryMap::TMemoryMap(const TFile& file, TString dbgName)
: Impl_(new TImpl(file, EOpenModeFlag::oRdOnly, std::move(dbgName)))
{
}
-TMemoryMap::TMemoryMap(const TFile& file, EOpenMode om, TString dbgName)
+TMemoryMap::TMemoryMap(const TFile& file, EOpenMode om, TString dbgName)
: Impl_(new TImpl(file, om, std::move(dbgName)))
{
}
@@ -419,11 +419,11 @@ void TMemoryMap::Evict() {
Impl_->Evict();
}
-i64 TMemoryMap::Length() const noexcept {
+i64 TMemoryMap::Length() const noexcept {
return Impl_->Length();
}
-bool TMemoryMap::IsOpen() const noexcept {
+bool TMemoryMap::IsOpen() const noexcept {
return Impl_->IsOpen();
}
@@ -435,41 +435,41 @@ TMemoryMap::EOpenMode TMemoryMap::GetMode() const noexcept {
return Impl_->GetMode();
}
-TFile TMemoryMap::GetFile() const noexcept {
+TFile TMemoryMap::GetFile() const noexcept {
return Impl_->GetFile();
}
-TFileMap::TFileMap(const TMemoryMap& map) noexcept
+TFileMap::TFileMap(const TMemoryMap& map) noexcept
: Map_(map)
{
}
-TFileMap::TFileMap(const TString& name)
+TFileMap::TFileMap(const TString& name)
: Map_(name)
{
}
-TFileMap::TFileMap(const TString& name, EOpenMode om)
+TFileMap::TFileMap(const TString& name, EOpenMode om)
: Map_(name, om)
{
}
-TFileMap::TFileMap(const TString& name, i64 length, EOpenMode om)
+TFileMap::TFileMap(const TString& name, i64 length, EOpenMode om)
: Map_(name, length, om)
{
}
-TFileMap::TFileMap(FILE* f, EOpenMode om, TString dbgName)
+TFileMap::TFileMap(FILE* f, EOpenMode om, TString dbgName)
: Map_(f, om, dbgName)
{
}
-TFileMap::TFileMap(const TFile& file, EOpenMode om, TString dbgName)
+TFileMap::TFileMap(const TFile& file, EOpenMode om, TString dbgName)
: Map_(file, om, dbgName)
{
}
-TFileMap::TFileMap(const TFileMap& fm) noexcept
+TFileMap::TFileMap(const TFileMap& fm) noexcept
: Map_(fm.Map_)
{
}
@@ -516,7 +516,7 @@ void TFileMap::Unmap() {
}
}
-TFileMap::~TFileMap() {
+TFileMap::~TFileMap() {
try {
// explicit Unmap() is required because in oNotGreedy mode the Map_ object doesn't own the mapped area
Unmap();
diff --git a/util/system/filemap.h b/util/system/filemap.h
index 3f80fe1ded..11be64bff4 100644
--- a/util/system/filemap.h
+++ b/util/system/filemap.h
@@ -9,7 +9,7 @@
#include <util/generic/utility.h>
#include <util/generic/yexception.h>
#include <util/generic/flags.h>
-#include <util/generic/string.h>
+#include <util/generic/string.h>
#include <new>
#include <cstdio>
@@ -21,19 +21,19 @@ namespace NPrivate {
struct TMemoryMapCommon {
struct TMapResult {
- inline size_t MappedSize() const noexcept {
+ inline size_t MappedSize() const noexcept {
return Size - Head;
}
- inline void* MappedData() const noexcept {
+ inline void* MappedData() const noexcept {
return Ptr ? (void*)((char*)Ptr + Head) : nullptr;
}
- inline bool IsMapped() const noexcept {
+ inline bool IsMapped() const noexcept {
return Ptr != nullptr;
}
- inline void Reset() noexcept {
+ inline void Reset() noexcept {
Ptr = nullptr;
Size = 0;
Head = 0;
@@ -43,7 +43,7 @@ struct TMemoryMapCommon {
size_t Size;
i32 Head;
- TMapResult(void) noexcept {
+ TMapResult(void) noexcept {
Reset();
}
};
@@ -70,15 +70,15 @@ Y_DECLARE_OPERATORS_FOR_FLAGS(TMemoryMapCommon::EOpenMode)
class TMemoryMap: public TMemoryMapCommon {
public:
- explicit TMemoryMap(const TString& name);
- explicit TMemoryMap(const TString& name, EOpenMode om);
- TMemoryMap(const TString& name, i64 length, EOpenMode om);
+ explicit TMemoryMap(const TString& name);
+ explicit TMemoryMap(const TString& name, EOpenMode om);
+ TMemoryMap(const TString& name, i64 length, EOpenMode om);
TMemoryMap(FILE* f, TString dbgName = UnknownFileName());
TMemoryMap(FILE* f, EOpenMode om, TString dbgName = UnknownFileName());
TMemoryMap(const TFile& file, TString dbgName = UnknownFileName());
TMemoryMap(const TFile& file, EOpenMode om, TString dbgName = UnknownFileName());
- ~TMemoryMap();
+ ~TMemoryMap();
TMapResult Map(i64 offset, size_t size);
bool Unmap(TMapResult region);
@@ -86,11 +86,11 @@ public:
void ResizeAndReset(i64 size);
TMapResult ResizeAndRemap(i64 offset, size_t size);
- i64 Length() const noexcept;
- bool IsOpen() const noexcept;
+ i64 Length() const noexcept;
+ bool IsOpen() const noexcept;
bool IsWritable() const noexcept;
EOpenMode GetMode() const noexcept;
- TFile GetFile() const noexcept;
+ TFile GetFile() const noexcept;
void SetSequential();
void Evict(void* ptr, size_t len);
@@ -108,15 +108,15 @@ private:
class TFileMap: public TMemoryMapCommon {
public:
- TFileMap(const TMemoryMap& map) noexcept;
- TFileMap(const TString& name);
- TFileMap(const TString& name, EOpenMode om);
- TFileMap(const TString& name, i64 length, EOpenMode om);
+ TFileMap(const TMemoryMap& map) noexcept;
+ TFileMap(const TString& name);
+ TFileMap(const TString& name, EOpenMode om);
+ TFileMap(const TString& name, i64 length, EOpenMode om);
TFileMap(FILE* f, EOpenMode om = oRdOnly, TString dbgName = UnknownFileName());
TFileMap(const TFile& file, EOpenMode om = oRdOnly, TString dbgName = UnknownFileName());
- TFileMap(const TFileMap& fm) noexcept;
+ TFileMap(const TFileMap& fm) noexcept;
- ~TFileMap();
+ ~TFileMap();
TMapResult Map(i64 offset, size_t size);
TMapResult ResizeAndRemap(i64 offset, size_t size);
@@ -138,11 +138,11 @@ public:
FlushAsync(Ptr(), MappedSize());
}
- inline i64 Length() const noexcept {
+ inline i64 Length() const noexcept {
return Map_.Length();
}
- inline bool IsOpen() const noexcept {
+ inline bool IsOpen() const noexcept {
return Map_.IsOpen();
}
@@ -154,15 +154,15 @@ public:
return Map_.GetMode();
}
- inline void* Ptr() const noexcept {
+ inline void* Ptr() const noexcept {
return Region_.MappedData();
}
- inline size_t MappedSize() const noexcept {
+ inline size_t MappedSize() const noexcept {
return Region_.MappedSize();
}
- TFile GetFile() const noexcept {
+ TFile GetFile() const noexcept {
return Map_.GetFile();
}
@@ -241,7 +241,7 @@ public:
Dummy_.Destroy();
Dummy_.Reset(new (DummyData()) T(n_Dummy));
}
- inline char* DummyData() const noexcept {
+ inline char* DummyData() const noexcept {
return AlignUp((char*)DummyData_);
}
inline const T& Dummy() const {
@@ -260,22 +260,22 @@ public:
return 0 == Size_;
}
/// for STL compatibility only, Begin() usage is recommended
- const T* begin() const noexcept {
+ const T* begin() const noexcept {
return Begin();
}
- const T* Begin() const noexcept {
+ const T* Begin() const noexcept {
return Ptr_;
}
/// for STL compatibility only, End() usage is recommended
- const T* end() const noexcept {
+ const T* end() const noexcept {
return End_;
}
- const T* End() const noexcept {
+ const T* End() const noexcept {
return End_;
}
private:
- void DoInit(const TString& fileName) {
+ void DoInit(const TString& fileName) {
DataHolder_->Map(0, DataHolder_->Length());
if (DataHolder_->Length() % sizeof(T)) {
Term();
@@ -308,10 +308,10 @@ public:
char* Data(ui32 pos = 0) const {
return (char*)(Ptr_ ? ((char*)Ptr_ + pos) : nullptr);
}
- char* Begin() const noexcept {
+ char* Begin() const noexcept {
return (char*)Ptr();
}
- char* End() const noexcept {
+ char* End() const noexcept {
return Begin() + MappedSize();
}
size_t MappedSize() const {
diff --git a/util/system/filemap_ut.cpp b/util/system/filemap_ut.cpp
index 158be2bd58..73f109dc88 100644
--- a/util/system/filemap_ut.cpp
+++ b/util/system/filemap_ut.cpp
@@ -301,7 +301,7 @@ Y_UNIT_TEST_SUITE(TFileMapTest) {
mappedMem.Map(mappedMem.Length() / 2, mappedMem.Length() + 100); // overflow
UNIT_ASSERT(0); // should not go here
} catch (yexception& exc) {
- TString text = exc.what(); // exception should contain failed file name
+ TString text = exc.what(); // exception should contain failed file name
UNIT_ASSERT(text.find(TMemoryMapCommon::UnknownFileName()) != TString::npos);
fclose(f);
}
@@ -312,8 +312,8 @@ Y_UNIT_TEST_SUITE(TFileMapTest) {
mappedMem.Map(mappedMem.Length() / 2, mappedMem.Length() + 100); // overflow
UNIT_ASSERT(0); // should not go here
} catch (yexception& exc) {
- TString text = exc.what(); // exception should contain failed file name
- UNIT_ASSERT(text.find(FileName_) != TString::npos);
+ TString text = exc.what(); // exception should contain failed file name
+ UNIT_ASSERT(text.find(FileName_) != TString::npos);
}
NFs::Remove(FileName_);
}
diff --git a/util/system/fs.cpp b/util/system/fs.cpp
index 33ff900888..d2611a8ccc 100644
--- a/util/system/fs.cpp
+++ b/util/system/fs.cpp
@@ -16,7 +16,7 @@
#include <util/system/fstat.h>
#include <util/folder/path.h>
-bool NFs::Remove(const TString& path) {
+bool NFs::Remove(const TString& path) {
#if defined(_win_)
return NFsPrivate::WinRemove(path);
#else
@@ -24,7 +24,7 @@ bool NFs::Remove(const TString& path) {
#endif
}
-void NFs::RemoveRecursive(const TString& path) {
+void NFs::RemoveRecursive(const TString& path) {
static const TStringBuf errStr = "error while removing ";
if (!NFs::Exists(path)) {
@@ -53,7 +53,7 @@ void NFs::RemoveRecursive(const TString& path) {
}
}
-bool NFs::MakeDirectory(const TString& path, EFilePermissions mode) {
+bool NFs::MakeDirectory(const TString& path, EFilePermissions mode) {
#if defined(_win_)
Y_UNUSED(mode);
return NFsPrivate::WinMakeDirectory(path);
@@ -62,7 +62,7 @@ bool NFs::MakeDirectory(const TString& path, EFilePermissions mode) {
#endif
}
-bool NFs::MakeDirectoryRecursive(const TString& path, EFilePermissions mode, bool alwaysCreate) {
+bool NFs::MakeDirectoryRecursive(const TString& path, EFilePermissions mode, bool alwaysCreate) {
if (NFs::Exists(path) && TFileStat(path).IsDir()) {
if (alwaysCreate) {
ythrow TIoException() << "path " << path << " already exists"
@@ -84,7 +84,7 @@ bool NFs::MakeDirectoryRecursive(const TString& path, EFilePermissions mode, boo
}
}
-bool NFs::Rename(const TString& oldPath, const TString& newPath) {
+bool NFs::Rename(const TString& oldPath, const TString& newPath) {
#if defined(_win_)
return NFsPrivate::WinRename(oldPath, newPath);
#else
@@ -92,13 +92,13 @@ bool NFs::Rename(const TString& oldPath, const TString& newPath) {
#endif
}
-void NFs::HardLinkOrCopy(const TString& existingPath, const TString& newPath) {
+void NFs::HardLinkOrCopy(const TString& existingPath, const TString& newPath) {
if (!NFs::HardLink(existingPath, newPath)) {
Copy(existingPath, newPath);
}
}
-bool NFs::HardLink(const TString& existingPath, const TString& newPath) {
+bool NFs::HardLink(const TString& existingPath, const TString& newPath) {
#if defined(_win_)
return NFsPrivate::WinHardLink(existingPath, newPath);
#elif defined(_unix_)
@@ -106,7 +106,7 @@ bool NFs::HardLink(const TString& existingPath, const TString& newPath) {
#endif
}
-bool NFs::SymLink(const TString& targetPath, const TString& linkPath) {
+bool NFs::SymLink(const TString& targetPath, const TString& linkPath) {
#if defined(_win_)
return NFsPrivate::WinSymLink(targetPath, linkPath);
#elif defined(_unix_)
@@ -114,7 +114,7 @@ bool NFs::SymLink(const TString& targetPath, const TString& linkPath) {
#endif
}
-TString NFs::ReadLink(const TString& path) {
+TString NFs::ReadLink(const TString& path) {
#if defined(_win_)
return NFsPrivate::WinReadLink(path);
#elif defined(_unix_)
@@ -125,28 +125,28 @@ TString NFs::ReadLink(const TString& path) {
ythrow yexception() << "can't read link " << path << ", errno = " << errno;
}
if (r < (ssize_t)buf.Size()) {
- return TString(buf.Data(), r);
+ return TString(buf.Data(), r);
}
buf = TTempBuf(buf.Size() * 2);
}
#endif
}
-void NFs::Cat(const TString& dstPath, const TString& srcPath) {
- TUnbufferedFileInput src(srcPath);
- TUnbufferedFileOutput dst(TFile(dstPath, ForAppend | WrOnly | Seq));
+void NFs::Cat(const TString& dstPath, const TString& srcPath) {
+ TUnbufferedFileInput src(srcPath);
+ TUnbufferedFileOutput dst(TFile(dstPath, ForAppend | WrOnly | Seq));
TransferData(&src, &dst);
}
-void NFs::Copy(const TString& existingPath, const TString& newPath) {
- TUnbufferedFileInput src(existingPath);
- TUnbufferedFileOutput dst(TFile(newPath, CreateAlways | WrOnly | Seq));
+void NFs::Copy(const TString& existingPath, const TString& newPath) {
+ TUnbufferedFileInput src(existingPath);
+ TUnbufferedFileOutput dst(TFile(newPath, CreateAlways | WrOnly | Seq));
TransferData(&src, &dst);
}
-bool NFs::Exists(const TString& path) {
+bool NFs::Exists(const TString& path) {
#if defined(_win_)
return NFsPrivate::WinExists(path);
#elif defined(_unix_)
@@ -154,7 +154,7 @@ bool NFs::Exists(const TString& path) {
#endif
}
-TString NFs::CurrentWorkingDirectory() {
+TString NFs::CurrentWorkingDirectory() {
#if defined(_win_)
return NFsPrivate::WinCurrentWorkingDirectory();
#elif defined(_unix_)
@@ -167,7 +167,7 @@ TString NFs::CurrentWorkingDirectory() {
#endif
}
-void NFs::SetCurrentWorkingDirectory(TString path) {
+void NFs::SetCurrentWorkingDirectory(TString path) {
#ifdef _win_
bool ok = NFsPrivate::WinSetCurrentWorkingDirectory(path);
#else
diff --git a/util/system/fs.h b/util/system/fs.h
index a412f6cb15..237daf2d2d 100644
--- a/util/system/fs.h
+++ b/util/system/fs.h
@@ -1,7 +1,7 @@
#pragma once
#include <util/generic/flags.h>
-#include <util/generic/string.h>
+#include <util/generic/string.h>
#include <util/generic/yexception.h>
namespace NFs {
@@ -28,27 +28,27 @@ namespace NFs {
/// @param[in] path Path to file or directory
/// @returns true on success or false otherwise
/// LastSystemError() is set in case of failure
- bool Remove(const TString& path);
+ bool Remove(const TString& path);
/// Remove a file or directory with contents
///
/// @param[in] path Path to file or directory
/// @throws
- void RemoveRecursive(const TString& path);
+ void RemoveRecursive(const TString& path);
/// Creates directory
///
/// @param[in] path Path to the directory
/// @param[in] mode Access permissions field; NOTE: ignored on win
/// @returns true on success or false otherwise
- bool MakeDirectory(const TString& path, EFilePermissions mode);
+ bool MakeDirectory(const TString& path, EFilePermissions mode);
/// Creates directory
///
/// @param[in] path Path to the directory
/// @returns true on success or false otherwise
/// NOTE: access permissions is set to 0777
- inline bool MakeDirectory(const TString& path) {
+ inline bool MakeDirectory(const TString& path) {
return MakeDirectory(path, FP_COMMON_FILE);
}
@@ -58,14 +58,14 @@ namespace NFs {
/// @param[in] mode Access permissions field; NOTE: ignored on win
/// @param[in] alwaysCreate Throw if path already exists or failed to create
/// @returns true if target path created or exists (and directory)
- bool MakeDirectoryRecursive(const TString& path, EFilePermissions mode, bool alwaysCreate);
+ bool MakeDirectoryRecursive(const TString& path, EFilePermissions mode, bool alwaysCreate);
/// Creates directory and all non-existings parents
///
/// @param[in] path Path to be created
/// @param[in] mode Access permissions field; NOTE: ignored on win
/// @returns true if target path created or exists (and directory)
- inline bool MakeDirectoryRecursive(const TString& path, EFilePermissions mode) {
+ inline bool MakeDirectoryRecursive(const TString& path, EFilePermissions mode) {
return MakeDirectoryRecursive(path, mode, false);
}
@@ -73,7 +73,7 @@ namespace NFs {
///
/// @param[in] path Path to be created
/// @returns true if target path created or exists (and directory)
- inline bool MakeDirectoryRecursive(const TString& path) {
+ inline bool MakeDirectoryRecursive(const TString& path) {
return MakeDirectoryRecursive(path, FP_COMMON_FILE, false);
}
@@ -84,14 +84,14 @@ namespace NFs {
/// @param[in] newPath New path of file or directory
/// @returns true on success or false otherwise
/// LastSystemError() is set in case of failure
- bool Rename(const TString& oldPath, const TString& newPath);
+ bool Rename(const TString& oldPath, const TString& newPath);
/// Creates a new directory entry for a file
/// or creates a new one with the same content
///
/// @param[in] existingPath Path to an existing file
/// @param[in] newPath New path of file
- void HardLinkOrCopy(const TString& existingPath, const TString& newPath);
+ void HardLinkOrCopy(const TString& existingPath, const TString& newPath);
/// Creates a new directory entry for a file
///
@@ -99,7 +99,7 @@ namespace NFs {
/// @param[in] newPath New path of file
/// @returns true if new link was created or false otherwise
/// LastSystemError() is set in case of failure
- bool HardLink(const TString& existingPath, const TString& newPath);
+ bool HardLink(const TString& existingPath, const TString& newPath);
/// Creates a symlink to a file
///
@@ -107,47 +107,47 @@ namespace NFs {
/// @param[in] linkPath Path of symlink
/// @returns true if new link was created or false otherwise
/// LastSystemError() is set in case of failure
- bool SymLink(const TString& targetPath, const TString& linkPath);
+ bool SymLink(const TString& targetPath, const TString& linkPath);
/// Reads value of a symbolic link
///
/// @param[in] path Path to a symlink
/// @returns File path that a symlink points to
- TString ReadLink(const TString& path);
+ TString ReadLink(const TString& path);
/// Append contents of a file to a new file
///
/// @param[in] dstPath Path to a destination file
/// @param[in] srcPath Path to a source file
- void Cat(const TString& dstPath, const TString& srcPath);
+ void Cat(const TString& dstPath, const TString& srcPath);
/// Copy contents of a file to a new file
///
/// @param[in] existingPath Path to an existing file
/// @param[in] newPath New path of file
- void Copy(const TString& existingPath, const TString& newPath);
+ void Copy(const TString& existingPath, const TString& newPath);
/// Returns path to the current working directory
///
/// Note: is not threadsafe
- TString CurrentWorkingDirectory();
+ TString CurrentWorkingDirectory();
/// Changes current working directory
///
/// @param[in] path Path for new cwd
/// Note: is not threadsafe
- void SetCurrentWorkingDirectory(TString path);
+ void SetCurrentWorkingDirectory(TString path);
/// Checks if file exists
///
/// @param[in] path Path to check
- bool Exists(const TString& path);
+ bool Exists(const TString& path);
/// Ensures that file exists
///
/// @param[in] path Path to check
/// @returns input argument
- inline const TString& EnsureExists(const TString& path) {
+ inline const TString& EnsureExists(const TString& path) {
Y_ENSURE_EX(Exists(path), TFileError{} << "Path " << path << " does not exists (checked from cwd:" << NFs::CurrentWorkingDirectory() << ")");
return path;
}
diff --git a/util/system/fs_ut.cpp b/util/system/fs_ut.cpp
index 1b3baff09f..de071ebf55 100644
--- a/util/system/fs_ut.cpp
+++ b/util/system/fs_ut.cpp
@@ -56,7 +56,7 @@ void TFsTest::TestCreateRemove() {
UNIT_ASSERT_EXCEPTION(NFs::MakeDirectoryRecursive(subdir1, NFs::FP_COMMON_FILE, true), TIoException);
TFsPath file1 = dir1 / "f1.txt";
- TFsPath file2 = subdir1 + TString("_f2.txt");
+ TFsPath file2 = subdir1 + TString("_f2.txt");
TFsPath file3 = subdir1 / "f2.txt";
Touch(file1);
Touch(file2);
@@ -70,7 +70,7 @@ void TFsTest::TestCreateRemove() {
UNIT_ASSERT(!NFs::MakeDirectoryRecursive(file1 / "subdir1" / "subdir2", NFs::FP_COMMON_FILE, false));
UNIT_ASSERT(!NFs::MakeDirectoryRecursive(file1, NFs::FP_COMMON_FILE, false));
- TString longUtf8Name = "";
+ TString longUtf8Name = "";
while (longUtf8Name.size() < 255) {
longUtf8Name = longUtf8Name + "fф";
}
@@ -191,7 +191,7 @@ void TFsTest::TestHardlink() {
RunHardlinkTest("tempfile_абвг", "hardlinkfile_абвг"); //utf-8 names
}
-static void RunSymLinkTest(TString fileLocalName, TString symLinkName) {
+static void RunSymLinkTest(TString fileLocalName, TString symLinkName) {
// if previous running was failed
TFsPath subDir = "tempsubdir";
TFsPath srcFile = subDir / fileLocalName;
@@ -222,8 +222,8 @@ static void RunSymLinkTest(TString fileLocalName, TString symLinkName) {
UNIT_ASSERT(NFs::SymLink(subDir, linkD1));
UNIT_ASSERT(NFs::SymLink("../dir2", linkD2));
UNIT_ASSERT(NFs::SymLink("../dir3", dangling));
- UNIT_ASSERT_STRINGS_EQUAL(NFs::ReadLink(linkD2), TString("..") + LOCSLASH_S "dir2");
- UNIT_ASSERT_STRINGS_EQUAL(NFs::ReadLink(dangling), TString("..") + LOCSLASH_S "dir3");
+ UNIT_ASSERT_STRINGS_EQUAL(NFs::ReadLink(linkD2), TString("..") + LOCSLASH_S "dir2");
+ UNIT_ASSERT_STRINGS_EQUAL(NFs::ReadLink(dangling), TString("..") + LOCSLASH_S "dir3");
{
TFile file(linkD1 / fileLocalName, OpenExisting | RdOnly);
UNIT_ASSERT_VALUES_EQUAL(file.GetLength(), 7);
@@ -311,7 +311,7 @@ void TFsTest::TestEnsureExists() {
UNIT_ASSERT_EXCEPTION(NFs::EnsureExists(nonExists), TFileError);
TStringBuilder expected;
- TString got;
+ TString got;
try {
NFs::EnsureExists(nonExists);
expected << __LOCATION__;
diff --git a/util/system/fs_win.cpp b/util/system/fs_win.cpp
index 79f7c43ecd..a410ccac06 100644
--- a/util/system/fs_win.cpp
+++ b/util/system/fs_win.cpp
@@ -9,7 +9,7 @@
#include <winioctl.h>
namespace NFsPrivate {
- static LPCWSTR UTF8ToWCHAR(const TStringBuf str, TUtf16String& wstr) {
+ static LPCWSTR UTF8ToWCHAR(const TStringBuf str, TUtf16String& wstr) {
wstr.resize(str.size());
size_t written = 0;
if (!UTF8ToWide(str.data(), str.size(), wstr.begin(), written))
@@ -19,14 +19,14 @@ namespace NFsPrivate {
return (const WCHAR*)wstr.data();
}
- static TString WCHARToUTF8(const LPWSTR wstr, size_t len) {
+ static TString WCHARToUTF8(const LPWSTR wstr, size_t len) {
static_assert(sizeof(WCHAR) == sizeof(wchar16), "expect sizeof(WCHAR) == sizeof(wchar16)");
return WideToUTF8((wchar16*)wstr, len);
}
HANDLE CreateFileWithUtf8Name(const TStringBuf fName, ui32 accessMode, ui32 shareMode, ui32 createMode, ui32 attributes, bool inheritHandle) {
- TUtf16String wstr;
+ TUtf16String wstr;
LPCWSTR wname = UTF8ToWCHAR(fName, wstr);
if (!wname) {
::SetLastError(ERROR_INVALID_NAME);
@@ -39,8 +39,8 @@ namespace NFsPrivate {
return ::CreateFileW(wname, accessMode, shareMode, &secAttrs, createMode, attributes, nullptr);
}
- bool WinRename(const TString& oldPath, const TString& newPath) {
- TUtf16String op, np;
+ bool WinRename(const TString& oldPath, const TString& newPath) {
+ TUtf16String op, np;
LPCWSTR opPtr = UTF8ToWCHAR(oldPath, op);
LPCWSTR npPtr = UTF8ToWCHAR(newPath, np);
if (!opPtr || !npPtr) {
@@ -51,8 +51,8 @@ namespace NFsPrivate {
return MoveFileExW(opPtr, npPtr, MOVEFILE_REPLACE_EXISTING) != 0;
}
- bool WinRemove(const TString& path) {
- TUtf16String wstr;
+ bool WinRemove(const TString& path) {
+ TUtf16String wstr;
LPCWSTR wname = UTF8ToWCHAR(path, wstr);
if (!wname) {
::SetLastError(ERROR_INVALID_NAME);
@@ -68,16 +68,16 @@ namespace NFsPrivate {
return false;
}
- bool WinSymLink(const TString& targetName, const TString& linkName) {
- TString tName(targetName);
+ bool WinSymLink(const TString& targetName, const TString& linkName) {
+ TString tName(targetName);
{
size_t pos;
- while ((pos = tName.find('/')) != TString::npos)
+ while ((pos = tName.find('/')) != TString::npos)
tName.replace(pos, 1, LOCSLASH_S);
}
- TUtf16String tstr;
+ TUtf16String tstr;
LPCWSTR wname = UTF8ToWCHAR(tName, tstr);
- TUtf16String lstr;
+ TUtf16String lstr;
LPCWSTR lname = UTF8ToWCHAR(linkName, lstr);
// we can't create a dangling link to a dir in this way
@@ -85,14 +85,14 @@ namespace NFsPrivate {
if (attr == INVALID_FILE_ATTRIBUTES) {
TTempBuf result;
if (GetFullPathNameW(lname, result.Size(), (LPWSTR)result.Data(), 0) != 0) {
- TString fullPath = WideToUTF8(TWtringBuf((const wchar16*)result.Data()));
+ TString fullPath = WideToUTF8(TWtringBuf((const wchar16*)result.Data()));
TStringBuf linkDir(fullPath);
linkDir.RNextTok('\\');
if (linkDir) {
- TString fullTarget(tName);
+ TString fullTarget(tName);
resolvepath(fullTarget, TString{linkDir});
- TUtf16String fullTargetW;
+ TUtf16String fullTargetW;
LPCWSTR ptrFullTarget = UTF8ToWCHAR(fullTarget, fullTargetW);
attr = ::GetFileAttributesW(ptrFullTarget);
}
@@ -101,8 +101,8 @@ namespace NFsPrivate {
return 0 != CreateSymbolicLinkW(lname, wname, attr != INVALID_FILE_ATTRIBUTES && (attr & FILE_ATTRIBUTE_DIRECTORY) ? SYMBOLIC_LINK_FLAG_DIRECTORY : 0);
}
- bool WinHardLink(const TString& existingPath, const TString& newPath) {
- TUtf16String ep, np;
+ bool WinHardLink(const TString& existingPath, const TString& newPath) {
+ TUtf16String ep, np;
LPCWSTR epPtr = UTF8ToWCHAR(existingPath, ep);
LPCWSTR npPtr = UTF8ToWCHAR(newPath, np);
if (!epPtr || !npPtr) {
@@ -113,13 +113,13 @@ namespace NFsPrivate {
return (CreateHardLinkW(npPtr, epPtr, nullptr) != 0);
}
- bool WinExists(const TString& path) {
- TUtf16String buf;
+ bool WinExists(const TString& path) {
+ TUtf16String buf;
LPCWSTR ptr = UTF8ToWCHAR(path, buf);
return ::GetFileAttributesW(ptr) != INVALID_FILE_ATTRIBUTES;
}
- TString WinCurrentWorkingDirectory() {
+ TString WinCurrentWorkingDirectory() {
TTempBuf result;
LPWSTR buf = reinterpret_cast<LPWSTR>(result.Data());
int r = GetCurrentDirectoryW(result.Size() / sizeof(WCHAR), buf);
@@ -128,8 +128,8 @@ namespace NFsPrivate {
return WCHARToUTF8(buf, r);
}
- bool WinSetCurrentWorkingDirectory(const TString& path) {
- TUtf16String wstr;
+ bool WinSetCurrentWorkingDirectory(const TString& path) {
+ TUtf16String wstr;
LPCWSTR wname = UTF8ToWCHAR(path, wstr);
if (!wname) {
::SetLastError(ERROR_INVALID_NAME);
@@ -138,8 +138,8 @@ namespace NFsPrivate {
return SetCurrentDirectoryW(wname);
}
- bool WinMakeDirectory(const TString path) {
- TUtf16String buf;
+ bool WinMakeDirectory(const TString path) {
+ TUtf16String buf;
LPCWSTR ptr = UTF8ToWCHAR(path, buf);
return CreateDirectoryW(ptr, (LPSECURITY_ATTRIBUTES) nullptr);
}
@@ -180,7 +180,7 @@ namespace NFsPrivate {
// the end of edited part of <Ntifs.h>
- TString WinReadLink(const TString& name) {
+ TString WinReadLink(const TString& name) {
TFileHandle h = CreateFileWithUtf8Name(name, GENERIC_READ, FILE_SHARE_READ, OPEN_EXISTING,
FILE_FLAG_OPEN_REPARSE_POINT | FILE_FLAG_BACKUP_SEMANTICS, true);
TTempBuf buf;
@@ -199,7 +199,7 @@ namespace NFsPrivate {
return WideToUTF8(str, len);
}
//this reparse point is unsupported in arcadia
- return TString();
+ return TString();
} else {
if (GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
buf = TTempBuf(buf.Size() * 2);
diff --git a/util/system/fs_win.h b/util/system/fs_win.h
index b32bb0fefe..8086129828 100644
--- a/util/system/fs_win.h
+++ b/util/system/fs_win.h
@@ -4,26 +4,26 @@
#include "defaults.h"
#include <util/generic/strbuf.h>
-#include <util/generic/string.h>
+#include <util/generic/string.h>
namespace NFsPrivate {
- bool WinRename(const TString& oldPath, const TString& newPath);
+ bool WinRename(const TString& oldPath, const TString& newPath);
- bool WinSymLink(const TString& targetName, const TString& linkName);
+ bool WinSymLink(const TString& targetName, const TString& linkName);
- bool WinHardLink(const TString& existingPath, const TString& newPath);
+ bool WinHardLink(const TString& existingPath, const TString& newPath);
- TString WinReadLink(const TString& path);
+ TString WinReadLink(const TString& path);
HANDLE CreateFileWithUtf8Name(const TStringBuf fName, ui32 accessMode, ui32 shareMode, ui32 createMode, ui32 attributes, bool inheritHandle);
- bool WinRemove(const TString& path);
+ bool WinRemove(const TString& path);
- bool WinExists(const TString& path);
+ bool WinExists(const TString& path);
- TString WinCurrentWorkingDirectory();
+ TString WinCurrentWorkingDirectory();
- bool WinSetCurrentWorkingDirectory(const TString& path);
+ bool WinSetCurrentWorkingDirectory(const TString& path);
- bool WinMakeDirectory(const TString path);
+ bool WinMakeDirectory(const TString path);
}
diff --git a/util/system/fstat.cpp b/util/system/fstat.cpp
index 1fc66b4f70..81e98cbc6b 100644
--- a/util/system/fstat.cpp
+++ b/util/system/fstat.cpp
@@ -124,7 +124,7 @@ TFileStat::TFileStat(const TFsPath& fileName, bool nofollow) {
MakeFromFileName(fileName.GetPath().data(), nofollow);
}
-TFileStat::TFileStat(const TString& fileName, bool nofollow) {
+TFileStat::TFileStat(const TString& fileName, bool nofollow) {
MakeFromFileName(fileName.data(), nofollow);
}
@@ -210,6 +210,6 @@ i64 GetFileLength(const char* name) {
#endif
}
-i64 GetFileLength(const TString& name) {
+i64 GetFileLength(const TString& name) {
return GetFileLength(name.data());
}
diff --git a/util/system/fstat.h b/util/system/fstat.h
index e1505e6041..64e79e1b55 100644
--- a/util/system/fstat.h
+++ b/util/system/fstat.h
@@ -32,7 +32,7 @@ public:
explicit TFileStat(const TFile& f);
explicit TFileStat(FHANDLE f);
TFileStat(const TFsPath& fileName, bool nofollow = false);
- TFileStat(const TString& fileName, bool nofollow = false);
+ TFileStat(const TString& fileName, bool nofollow = false);
TFileStat(const char* fileName, bool nofollow = false);
friend bool operator==(const TFileStat& l, const TFileStat& r) noexcept;
@@ -44,4 +44,4 @@ private:
i64 GetFileLength(FHANDLE fd);
i64 GetFileLength(const char* name);
-i64 GetFileLength(const TString& name);
+i64 GetFileLength(const TString& name);
diff --git a/util/system/fstat_ut.cpp b/util/system/fstat_ut.cpp
index ed126eaead..160ecd936e 100644
--- a/util/system/fstat_ut.cpp
+++ b/util/system/fstat_ut.cpp
@@ -10,7 +10,7 @@
Y_UNIT_TEST_SUITE(TestFileStat) {
Y_UNIT_TEST(FileTest) {
- TString fileName = "f1.txt";
+ TString fileName = "f1.txt";
TFileStat oFs;
{
TFile file(fileName.data(), OpenAlways | WrOnly);
diff --git a/util/system/guard.h b/util/system/guard.h
index 19c4491424..efc091d5f8 100644
--- a/util/system/guard.h
+++ b/util/system/guard.h
@@ -8,14 +8,14 @@ struct TCommonLockOps {
t->Acquire();
}
- static inline void Release(T* t) noexcept {
+ static inline void Release(T* t) noexcept {
t->Release();
}
};
template <class T>
struct TTryLockOps: public TCommonLockOps<T> {
- static inline bool TryAcquire(T* t) noexcept {
+ static inline bool TryAcquire(T* t) noexcept {
return t->TryAcquire();
}
};
@@ -24,7 +24,7 @@ struct TTryLockOps: public TCommonLockOps<T> {
template <class TOps>
struct TInverseLockOps: public TOps {
template <class T>
- static inline void Acquire(T* t) noexcept {
+ static inline void Acquire(T* t) noexcept {
TOps::Release(t);
}
@@ -45,32 +45,32 @@ public:
Init(t);
}
- inline TGuard(TGuard&& g) noexcept
+ inline TGuard(TGuard&& g) noexcept
: T_(g.T_)
{
g.T_ = nullptr;
}
- inline ~TGuard() {
+ inline ~TGuard() {
Release();
}
- inline void Release() noexcept {
+ inline void Release() noexcept {
if (WasAcquired()) {
TOps::Release(T_);
T_ = nullptr;
}
}
- explicit inline operator bool() const noexcept {
+ explicit inline operator bool() const noexcept {
return WasAcquired();
}
- inline bool WasAcquired() const noexcept {
+ inline bool WasAcquired() const noexcept {
return T_ != nullptr;
}
- inline T* GetMutex() const noexcept {
+ inline T* GetMutex() const noexcept {
return T_;
}
@@ -129,11 +129,11 @@ static inline TInverseGuard<T> Unguard(const T& mutex) {
template <class T, class TOps = TTryLockOps<T>>
class TTryGuard: public TNonCopyable {
public:
- inline TTryGuard(const T& t) noexcept {
+ inline TTryGuard(const T& t) noexcept {
Init(&t);
}
- inline TTryGuard(const T* t) noexcept {
+ inline TTryGuard(const T* t) noexcept {
Init(t);
}
@@ -143,27 +143,27 @@ public:
g.T_ = nullptr;
}
- inline ~TTryGuard() {
+ inline ~TTryGuard() {
Release();
}
- inline void Release() noexcept {
+ inline void Release() noexcept {
if (WasAcquired()) {
TOps::Release(T_);
T_ = nullptr;
}
}
- inline bool WasAcquired() const noexcept {
+ inline bool WasAcquired() const noexcept {
return T_ != nullptr;
}
- explicit inline operator bool() const noexcept {
+ explicit inline operator bool() const noexcept {
return WasAcquired();
}
private:
- inline void Init(const T* t) noexcept {
+ inline void Init(const T* t) noexcept {
T_ = nullptr;
T* tMutable = const_cast<T*>(t);
if (TOps::TryAcquire(tMutable)) {
diff --git a/util/system/hostname.cpp b/util/system/hostname.cpp
index 397f64bae9..386f646d6b 100644
--- a/util/system/hostname.cpp
+++ b/util/system/hostname.cpp
@@ -29,7 +29,7 @@ namespace {
HostName = hostNameBuf.Data();
}
- TString HostName;
+ TString HostName;
};
struct TFQDNHostNameHolder {
@@ -60,11 +60,11 @@ namespace {
FQDNHostName.to_lower();
}
- TString FQDNHostName;
+ TString FQDNHostName;
};
}
-const TString& HostName() {
+const TString& HostName() {
return (Singleton<THostNameHolder>())->HostName;
}
@@ -72,7 +72,7 @@ const char* GetHostName() {
return HostName().data();
}
-const TString& FQDNHostName() {
+const TString& FQDNHostName() {
return (Singleton<TFQDNHostNameHolder>())->FQDNHostName;
}
@@ -80,8 +80,8 @@ const char* GetFQDNHostName() {
return FQDNHostName().data();
}
-bool IsFQDN(const TString& name) {
- TString absName = name;
+bool IsFQDN(const TString& name) {
+ TString absName = name;
if (!absName.EndsWith('.')) {
absName.append(".");
}
diff --git a/util/system/hostname.h b/util/system/hostname.h
index bf8c90fac8..0839ee2b59 100644
--- a/util/system/hostname.h
+++ b/util/system/hostname.h
@@ -3,8 +3,8 @@
#include <util/generic/fwd.h>
const char* GetHostName();
-const TString& HostName();
+const TString& HostName();
const char* GetFQDNHostName();
-const TString& FQDNHostName();
-bool IsFQDN(const TString& name);
+const TString& FQDNHostName();
+bool IsFQDN(const TString& name);
diff --git a/util/system/info.cpp b/util/system/info.cpp
index 9d66c38f0c..cf6681e89a 100644
--- a/util/system/info.cpp
+++ b/util/system/info.cpp
@@ -176,7 +176,7 @@ size_t NSystemInfo::CachedNumberOfCpus() {
return NCpus;
}
-size_t NSystemInfo::GetPageSize() noexcept {
+size_t NSystemInfo::GetPageSize() noexcept {
#if defined(_win_)
SYSTEM_INFO sysInfo;
GetSystemInfo(&sysInfo);
diff --git a/util/system/info.h b/util/system/info.h
index 8894f8e6bb..73ebe48a9a 100644
--- a/util/system/info.h
+++ b/util/system/info.h
@@ -6,7 +6,7 @@ namespace NSystemInfo {
size_t NumberOfCpus();
size_t CachedNumberOfCpus();
size_t LoadAverage(double* la, size_t len);
- size_t GetPageSize() noexcept;
+ size_t GetPageSize() noexcept;
size_t TotalMemorySize();
size_t MaxOpenFiles();
}
diff --git a/util/system/madvise.cpp b/util/system/madvise.cpp
index ababb94f3f..58c894e3ef 100644
--- a/util/system/madvise.cpp
+++ b/util/system/madvise.cpp
@@ -35,7 +35,7 @@ namespace {
}
#else
if (-1 == madvise(begin, size, flag)) {
- TString err(LastSystemErrorText());
+ TString err(LastSystemErrorText());
ythrow yexception() << "madvise(" << begin << ", " << size << ", " << flag << ")"
<< " returned error: " << err;
}
diff --git a/util/system/mem_info.cpp b/util/system/mem_info.cpp
index 49e906f006..aa51ae3b16 100644
--- a/util/system/mem_info.cpp
+++ b/util/system/mem_info.cpp
@@ -115,7 +115,7 @@ namespace NMemInfo {
} else {
path = TStringBuilder() << TStringBuf("/proc/") << pid << TStringBuf("/statm");
}
- const TString stats = TUnbufferedFileInput(path).ReadAll();
+ const TString stats = TUnbufferedFileInput(path).ReadAll();
TStringBuf statsiter(stats);
@@ -136,7 +136,7 @@ namespace NMemInfo {
errno = 0;
if (sysctl((int*)mib, 4, &proc, &size, nullptr, 0) == -1) {
int err = errno;
- TString errtxt = LastSystemErrorText(err);
+ TString errtxt = LastSystemErrorText(err);
ythrow yexception() << "sysctl({CTL_KERN,KERN_PROC,KERN_PROC_PID,pid},4,proc,&size,NULL,0) returned -1, errno: " << err << " (" << errtxt << ")" << Endl;
}
@@ -151,7 +151,7 @@ namespace NMemInfo {
if (r != sizeof(taskInfo)) {
int err = errno;
- TString errtxt = LastSystemErrorText(err);
+ TString errtxt = LastSystemErrorText(err);
ythrow yexception() << "proc_pidinfo(pid, PROC_PIDTASKINFO, 0, &taskInfo, sizeof(taskInfo)) returned " << r << ", errno: " << err << " (" << errtxt << ")" << Endl;
}
result.VMS = taskInfo.pti_virtual_size;
diff --git a/util/system/mutex.cpp b/util/system/mutex.cpp
index 4b7096cd12..4041402db9 100644
--- a/util/system/mutex.cpp
+++ b/util/system/mutex.cpp
@@ -33,7 +33,7 @@ public:
}
}
- inline ~T() {
+ inline ~T() {
int result = pthread_mutexattr_destroy(&Attr);
Y_VERIFY(result == 0, "mutexattr destroy(%s)", LastSystemErrorText(result));
}
@@ -46,7 +46,7 @@ public:
#endif
}
- inline ~TImpl() {
+ inline ~TImpl() {
#if defined(_win_)
DeleteCriticalSection(&Obj);
#else
@@ -55,7 +55,7 @@ public:
#endif
}
- inline void Acquire() noexcept {
+ inline void Acquire() noexcept {
#if defined(_win_)
EnterCriticalSection(&Obj);
#else
@@ -87,7 +87,7 @@ public:
}
#endif // _win_
- inline bool TryAcquire() noexcept {
+ inline bool TryAcquire() noexcept {
#if defined(_win_)
return TryEnterCriticalSectionInt(&Obj);
#else
@@ -99,7 +99,7 @@ public:
#endif
}
- inline void Release() noexcept {
+ inline void Release() noexcept {
#if defined(_win_)
LeaveCriticalSection(&Obj);
#else
@@ -108,7 +108,7 @@ public:
#endif
}
- inline void* Handle() const noexcept {
+ inline void* Handle() const noexcept {
return (void*)&Obj;
}
diff --git a/util/system/mutex.h b/util/system/mutex.h
index 02cd05586c..032630d134 100644
--- a/util/system/mutex.h
+++ b/util/system/mutex.h
@@ -8,14 +8,14 @@
class TFakeMutex: public TNonCopyable {
public:
- inline void Acquire() noexcept {
+ inline void Acquire() noexcept {
}
- inline bool TryAcquire() noexcept {
+ inline bool TryAcquire() noexcept {
return true;
}
- inline void Release() noexcept {
+ inline void Release() noexcept {
}
inline void lock() noexcept {
@@ -39,9 +39,9 @@ public:
TMutex(TMutex&&);
~TMutex();
- void Acquire() noexcept;
- bool TryAcquire() noexcept;
- void Release() noexcept;
+ void Acquire() noexcept;
+ bool TryAcquire() noexcept;
+ void Release() noexcept;
inline void lock() noexcept {
Acquire();
@@ -56,7 +56,7 @@ public:
}
//return opaque pointer to real handler
- void* Handle() const noexcept;
+ void* Handle() const noexcept;
private:
class TImpl;
diff --git a/util/system/pipe.cpp b/util/system/pipe.cpp
index fb3d8229a0..a543bd7472 100644
--- a/util/system/pipe.cpp
+++ b/util/system/pipe.cpp
@@ -3,7 +3,7 @@
#include <util/stream/output.h>
#include <util/generic/yexception.h>
-ssize_t TPipeHandle::Read(void* buffer, size_t byteCount) const noexcept {
+ssize_t TPipeHandle::Read(void* buffer, size_t byteCount) const noexcept {
#ifdef _win_
return recv(Fd_, (char*)buffer, byteCount, 0);
#else
@@ -11,7 +11,7 @@ ssize_t TPipeHandle::Read(void* buffer, size_t byteCount) const noexcept {
#endif
}
-ssize_t TPipeHandle::Write(const void* buffer, size_t byteCount) const noexcept {
+ssize_t TPipeHandle::Write(const void* buffer, size_t byteCount) const noexcept {
#ifdef _win_
return send(Fd_, (const char*)buffer, byteCount, 0);
#else
@@ -19,7 +19,7 @@ ssize_t TPipeHandle::Write(const void* buffer, size_t byteCount) const noexcept
#endif
}
-bool TPipeHandle::Close() noexcept {
+bool TPipeHandle::Close() noexcept {
bool ok = true;
if (Fd_ != INVALID_PIPEHANDLE) {
#ifdef _win_
@@ -94,7 +94,7 @@ public:
}
}
- TPipeHandle& GetHandle() noexcept {
+ TPipeHandle& GetHandle() noexcept {
return Handle_;
}
@@ -134,11 +134,11 @@ void TPipe::Close() {
Impl_->Close();
}
-PIPEHANDLE TPipe::GetHandle() const noexcept {
+PIPEHANDLE TPipe::GetHandle() const noexcept {
return Impl_->GetHandle();
}
-bool TPipe::IsOpen() const noexcept {
+bool TPipe::IsOpen() const noexcept {
return Impl_->IsOpen();
}
diff --git a/util/system/pipe.h b/util/system/pipe.h
index 92dd33362f..75d0360049 100644
--- a/util/system/pipe.h
+++ b/util/system/pipe.h
@@ -17,42 +17,42 @@ using PIPEHANDLE = SOCKET;
/// Pipe-like object: pipe on POSIX and socket on windows
class TPipeHandle: public TNonCopyable {
public:
- inline TPipeHandle() noexcept
+ inline TPipeHandle() noexcept
: Fd_(INVALID_PIPEHANDLE)
{
}
- inline TPipeHandle(PIPEHANDLE fd) noexcept
+ inline TPipeHandle(PIPEHANDLE fd) noexcept
: Fd_(fd)
{
}
- inline ~TPipeHandle() {
+ inline ~TPipeHandle() {
Close();
}
- bool Close() noexcept;
+ bool Close() noexcept;
- inline PIPEHANDLE Release() noexcept {
+ inline PIPEHANDLE Release() noexcept {
PIPEHANDLE ret = Fd_;
Fd_ = INVALID_PIPEHANDLE;
return ret;
}
- inline void Swap(TPipeHandle& r) noexcept {
+ inline void Swap(TPipeHandle& r) noexcept {
DoSwap(Fd_, r.Fd_);
}
- inline operator PIPEHANDLE() const noexcept {
+ inline operator PIPEHANDLE() const noexcept {
return Fd_;
}
- inline bool IsOpen() const noexcept {
+ inline bool IsOpen() const noexcept {
return Fd_ != INVALID_PIPEHANDLE;
}
- ssize_t Read(void* buffer, size_t byteCount) const noexcept;
- ssize_t Write(const void* buffer, size_t byteCount) const noexcept;
+ ssize_t Read(void* buffer, size_t byteCount) const noexcept;
+ ssize_t Write(const void* buffer, size_t byteCount) const noexcept;
// Only CloseOnExec is supported
static void Pipe(TPipeHandle& reader, TPipeHandle& writer, EOpenMode mode = 0);
@@ -66,12 +66,12 @@ public:
TPipe();
/// Takes ownership of handle, so closes it when the last holder of descriptor dies.
explicit TPipe(PIPEHANDLE fd);
- ~TPipe();
+ ~TPipe();
void Close();
- bool IsOpen() const noexcept;
- PIPEHANDLE GetHandle() const noexcept;
+ bool IsOpen() const noexcept;
+ PIPEHANDLE GetHandle() const noexcept;
size_t Read(void* buf, size_t len) const;
size_t Write(const void* buf, size_t len) const;
diff --git a/util/system/progname.cpp b/util/system/progname.cpp
index 237f7e3082..2c29119320 100644
--- a/util/system/progname.cpp
+++ b/util/system/progname.cpp
@@ -13,11 +13,11 @@ namespace {
{
}
- TString ProgName;
+ TString ProgName;
};
}
-const TString& GetProgramName() {
+const TString& GetProgramName() {
return Singleton<TProgramNameHolder>()->ProgName;
}
diff --git a/util/system/progname.h b/util/system/progname.h
index b02cdf230d..e5e2a0eee2 100644
--- a/util/system/progname.h
+++ b/util/system/progname.h
@@ -9,5 +9,5 @@ void SetProgramName(const char* argv0);
SetProgramName(argv[0]); \
} while (0)
-/// guaranted return the same immutable instance of TString
-const TString& GetProgramName();
+/// guaranted return the same immutable instance of TString
+const TString& GetProgramName();
diff --git a/util/system/progname_ut.cpp b/util/system/progname_ut.cpp
index d058647fac..11f3d9308b 100644
--- a/util/system/progname_ut.cpp
+++ b/util/system/progname_ut.cpp
@@ -4,11 +4,11 @@
Y_UNIT_TEST_SUITE(TProgramNameTest) {
Y_UNIT_TEST(TestIt) {
- TString progName = GetProgramName();
+ TString progName = GetProgramName();
try {
UNIT_ASSERT(
- progName.find("ut_util") != TString::npos || progName.find("util-system_ut") != TString::npos || progName.find("util-system-ut") != TString::npos);
+ progName.find("ut_util") != TString::npos || progName.find("util-system_ut") != TString::npos || progName.find("util-system-ut") != TString::npos);
} catch (...) {
Cerr << progName << Endl;
diff --git a/util/system/protect.cpp b/util/system/protect.cpp
index 8786f00eab..bbb8d410df 100644
--- a/util/system/protect.cpp
+++ b/util/system/protect.cpp
@@ -1,7 +1,7 @@
#include "protect.h"
#include <util/generic/yexception.h>
-#include <util/generic/string.h>
+#include <util/generic/string.h>
#include <util/stream/output.h>
#include "yassert.h"
@@ -15,7 +15,7 @@
#endif
static TString ModeToString(const EProtectMemory mode) {
- TString strMode;
+ TString strMode;
if (mode == PM_NONE) {
return "PM_NONE";
}
diff --git a/util/system/rwlock.cpp b/util/system/rwlock.cpp
index 8785f006d6..bb3dcbf188 100644
--- a/util/system/rwlock.cpp
+++ b/util/system/rwlock.cpp
@@ -14,17 +14,17 @@
class TRWMutex::TImpl {
public:
TImpl();
- ~TImpl();
+ ~TImpl();
- void AcquireRead() noexcept;
- bool TryAcquireRead() noexcept;
- void ReleaseRead() noexcept;
+ void AcquireRead() noexcept;
+ bool TryAcquireRead() noexcept;
+ void ReleaseRead() noexcept;
- void AcquireWrite() noexcept;
- bool TryAcquireWrite() noexcept;
- void ReleaseWrite() noexcept;
+ void AcquireWrite() noexcept;
+ bool TryAcquireWrite() noexcept;
+ void ReleaseWrite() noexcept;
- void Release() noexcept;
+ void Release() noexcept;
private:
TMutex Lock_;
@@ -40,12 +40,12 @@ TRWMutex::TImpl::TImpl()
{
}
-TRWMutex::TImpl::~TImpl() {
+TRWMutex::TImpl::~TImpl() {
Y_VERIFY(State_ == 0, "failure, State_ != 0");
Y_VERIFY(BlockedWriters_ == 0, "failure, BlockedWriters_ != 0");
}
-void TRWMutex::TImpl::AcquireRead() noexcept {
+void TRWMutex::TImpl::AcquireRead() noexcept {
with_lock (Lock_) {
while (BlockedWriters_ || State_ < 0) {
ReadCond_.Wait(Lock_);
@@ -57,7 +57,7 @@ void TRWMutex::TImpl::AcquireRead() noexcept {
ReadCond_.Signal();
}
-bool TRWMutex::TImpl::TryAcquireRead() noexcept {
+bool TRWMutex::TImpl::TryAcquireRead() noexcept {
with_lock (Lock_) {
if (BlockedWriters_ || State_ < 0) {
return false;
@@ -69,7 +69,7 @@ bool TRWMutex::TImpl::TryAcquireRead() noexcept {
return true;
}
-void TRWMutex::TImpl::ReleaseRead() noexcept {
+void TRWMutex::TImpl::ReleaseRead() noexcept {
Lock_.Acquire();
if (--State_ > 0) {
@@ -82,7 +82,7 @@ void TRWMutex::TImpl::ReleaseRead() noexcept {
}
}
-void TRWMutex::TImpl::AcquireWrite() noexcept {
+void TRWMutex::TImpl::AcquireWrite() noexcept {
with_lock (Lock_) {
while (State_ != 0) {
++BlockedWriters_;
@@ -94,7 +94,7 @@ void TRWMutex::TImpl::AcquireWrite() noexcept {
}
}
-bool TRWMutex::TImpl::TryAcquireWrite() noexcept {
+bool TRWMutex::TImpl::TryAcquireWrite() noexcept {
with_lock (Lock_) {
if (State_ != 0) {
return false;
@@ -106,7 +106,7 @@ bool TRWMutex::TImpl::TryAcquireWrite() noexcept {
return true;
}
-void TRWMutex::TImpl::ReleaseWrite() noexcept {
+void TRWMutex::TImpl::ReleaseWrite() noexcept {
Lock_.Acquire();
State_ = 0;
@@ -119,7 +119,7 @@ void TRWMutex::TImpl::ReleaseWrite() noexcept {
}
}
-void TRWMutex::TImpl::Release() noexcept {
+void TRWMutex::TImpl::Release() noexcept {
Lock_.Acquire();
if (State_ > 0) {
@@ -147,17 +147,17 @@ void TRWMutex::TImpl::Release() noexcept {
class TRWMutex::TImpl {
public:
TImpl();
- ~TImpl();
+ ~TImpl();
- void AcquireRead() noexcept;
- bool TryAcquireRead() noexcept;
- void ReleaseRead() noexcept;
+ void AcquireRead() noexcept;
+ bool TryAcquireRead() noexcept;
+ void ReleaseRead() noexcept;
- void AcquireWrite() noexcept;
- bool TryAcquireWrite() noexcept;
- void ReleaseWrite() noexcept;
+ void AcquireWrite() noexcept;
+ bool TryAcquireWrite() noexcept;
+ void ReleaseWrite() noexcept;
- void Release() noexcept;
+ void Release() noexcept;
private:
pthread_rwlock_t Lock_;
@@ -170,44 +170,44 @@ TRWMutex::TImpl::TImpl() {
}
}
-TRWMutex::TImpl::~TImpl() {
+TRWMutex::TImpl::~TImpl() {
const int result = pthread_rwlock_destroy(&Lock_);
Y_VERIFY(result == 0, "rwlock destroy failed (%s)", LastSystemErrorText(result));
}
-void TRWMutex::TImpl::AcquireRead() noexcept {
+void TRWMutex::TImpl::AcquireRead() noexcept {
const int result = pthread_rwlock_rdlock(&Lock_);
Y_VERIFY(result == 0, "rwlock rdlock failed (%s)", LastSystemErrorText(result));
}
-bool TRWMutex::TImpl::TryAcquireRead() noexcept {
+bool TRWMutex::TImpl::TryAcquireRead() noexcept {
const int result = pthread_rwlock_tryrdlock(&Lock_);
Y_VERIFY(result == 0 || result == EBUSY, "rwlock tryrdlock failed (%s)", LastSystemErrorText(result));
return result == 0;
}
-void TRWMutex::TImpl::ReleaseRead() noexcept {
+void TRWMutex::TImpl::ReleaseRead() noexcept {
const int result = pthread_rwlock_unlock(&Lock_);
Y_VERIFY(result == 0, "rwlock (read) unlock failed (%s)", LastSystemErrorText(result));
}
-void TRWMutex::TImpl::AcquireWrite() noexcept {
+void TRWMutex::TImpl::AcquireWrite() noexcept {
const int result = pthread_rwlock_wrlock(&Lock_);
Y_VERIFY(result == 0, "rwlock wrlock failed (%s)", LastSystemErrorText(result));
}
-bool TRWMutex::TImpl::TryAcquireWrite() noexcept {
+bool TRWMutex::TImpl::TryAcquireWrite() noexcept {
const int result = pthread_rwlock_trywrlock(&Lock_);
Y_VERIFY(result == 0 || result == EBUSY, "rwlock trywrlock failed (%s)", LastSystemErrorText(result));
return result == 0;
}
-void TRWMutex::TImpl::ReleaseWrite() noexcept {
+void TRWMutex::TImpl::ReleaseWrite() noexcept {
const int result = pthread_rwlock_unlock(&Lock_);
Y_VERIFY(result == 0, "rwlock (write) unlock failed (%s)", LastSystemErrorText(result));
}
-void TRWMutex::TImpl::Release() noexcept {
+void TRWMutex::TImpl::Release() noexcept {
const int result = pthread_rwlock_unlock(&Lock_);
Y_VERIFY(result == 0, "rwlock unlock failed (%s)", LastSystemErrorText(result));
}
@@ -221,30 +221,30 @@ TRWMutex::TRWMutex()
TRWMutex::~TRWMutex() = default;
-void TRWMutex::AcquireRead() noexcept {
+void TRWMutex::AcquireRead() noexcept {
Impl_->AcquireRead();
}
-bool TRWMutex::TryAcquireRead() noexcept {
+bool TRWMutex::TryAcquireRead() noexcept {
return Impl_->TryAcquireRead();
}
-void TRWMutex::ReleaseRead() noexcept {
+void TRWMutex::ReleaseRead() noexcept {
Impl_->ReleaseRead();
}
-void TRWMutex::AcquireWrite() noexcept {
+void TRWMutex::AcquireWrite() noexcept {
Impl_->AcquireWrite();
}
-bool TRWMutex::TryAcquireWrite() noexcept {
+bool TRWMutex::TryAcquireWrite() noexcept {
return Impl_->TryAcquireWrite();
}
-void TRWMutex::ReleaseWrite() noexcept {
+void TRWMutex::ReleaseWrite() noexcept {
Impl_->ReleaseWrite();
}
-void TRWMutex::Release() noexcept {
+void TRWMutex::Release() noexcept {
Impl_->Release();
}
diff --git a/util/system/rwlock.h b/util/system/rwlock.h
index b476837c92..0bb9b3fe1c 100644
--- a/util/system/rwlock.h
+++ b/util/system/rwlock.h
@@ -8,17 +8,17 @@
class TRWMutex {
public:
TRWMutex();
- ~TRWMutex();
+ ~TRWMutex();
- void AcquireRead() noexcept;
- bool TryAcquireRead() noexcept;
- void ReleaseRead() noexcept;
+ void AcquireRead() noexcept;
+ bool TryAcquireRead() noexcept;
+ void ReleaseRead() noexcept;
- void AcquireWrite() noexcept;
- bool TryAcquireWrite() noexcept;
- void ReleaseWrite() noexcept;
+ void AcquireWrite() noexcept;
+ bool TryAcquireWrite() noexcept;
+ void ReleaseWrite() noexcept;
- void Release() noexcept;
+ void Release() noexcept;
private:
class TImpl;
@@ -27,36 +27,36 @@ private:
template <class T>
struct TReadGuardOps {
- static inline void Acquire(T* t) noexcept {
+ static inline void Acquire(T* t) noexcept {
t->AcquireRead();
}
- static inline void Release(T* t) noexcept {
+ static inline void Release(T* t) noexcept {
t->ReleaseRead();
}
};
template <class T>
struct TTryReadGuardOps: public TReadGuardOps<T> {
- static inline bool TryAcquire(T* t) noexcept {
+ static inline bool TryAcquire(T* t) noexcept {
return t->TryAcquireRead();
}
};
template <class T>
struct TWriteGuardOps {
- static inline void Acquire(T* t) noexcept {
+ static inline void Acquire(T* t) noexcept {
t->AcquireWrite();
}
- static inline void Release(T* t) noexcept {
+ static inline void Release(T* t) noexcept {
t->ReleaseWrite();
}
};
template <class T>
struct TTryWriteGuardOps: public TWriteGuardOps<T> {
- static inline bool TryAcquire(T* t) noexcept {
+ static inline bool TryAcquire(T* t) noexcept {
return t->TryAcquireWrite();
}
};
diff --git a/util/system/sem.cpp b/util/system/sem.cpp
index 885ad8a255..4a93b903b5 100644
--- a/util/system/sem.cpp
+++ b/util/system/sem.cpp
@@ -104,7 +104,7 @@ namespace {
#endif
}
- inline ~TSemaphoreImpl() {
+ inline ~TSemaphoreImpl() {
#ifdef _win_
::CloseHandle(Handle);
#else
@@ -119,7 +119,7 @@ namespace {
#endif
}
- inline void Release() noexcept {
+ inline void Release() noexcept {
#ifdef _win_
::ReleaseSemaphore(Handle, 1, 0);
#else
@@ -135,7 +135,7 @@ namespace {
//The UNIX semaphore object does not support a timed "wait", and
//hence to maintain consistancy, for win32 case we use INFINITE or 0 timeout.
- inline void Acquire() noexcept {
+ inline void Acquire() noexcept {
#ifdef _win_
Y_VERIFY(::WaitForSingleObject(Handle, INFINITE) == WAIT_OBJECT_0, "can not acquire semaphore");
#else
@@ -149,7 +149,7 @@ namespace {
#endif
}
- inline bool TryAcquire() noexcept {
+ inline bool TryAcquire() noexcept {
#ifdef _win_
// zero-second time-out interval
// WAIT_OBJECT_0: current free count > 0
@@ -169,8 +169,8 @@ namespace {
#if defined(_unix_)
/*
- Disable errors/warnings about deprecated sem_* in Darwin
-*/
+ Disable errors/warnings about deprecated sem_* in Darwin
+*/
#ifdef _darwin_
Y_PRAGMA_DIAGNOSTIC_PUSH
Y_PRAGMA_NO_DEPRECATED
@@ -182,19 +182,19 @@ namespace {
}
}
- inline ~TPosixSemaphore() {
+ inline ~TPosixSemaphore() {
Y_VERIFY(sem_destroy(&S_) == 0, "semaphore destroy failed");
}
- inline void Acquire() noexcept {
+ inline void Acquire() noexcept {
Y_VERIFY(sem_wait(&S_) == 0, "semaphore acquire failed");
}
- inline void Release() noexcept {
+ inline void Release() noexcept {
Y_VERIFY(sem_post(&S_) == 0, "semaphore release failed");
}
- inline bool TryAcquire() noexcept {
+ inline bool TryAcquire() noexcept {
if (sem_trywait(&S_)) {
Y_VERIFY(errno == EAGAIN, "semaphore try wait failed");
@@ -227,15 +227,15 @@ TSemaphore::TSemaphore(const char* name, ui32 maxFreeCount)
TSemaphore::~TSemaphore() = default;
-void TSemaphore::Release() noexcept {
+void TSemaphore::Release() noexcept {
Impl_->Release();
}
-void TSemaphore::Acquire() noexcept {
+void TSemaphore::Acquire() noexcept {
Impl_->Acquire();
}
-bool TSemaphore::TryAcquire() noexcept {
+bool TSemaphore::TryAcquire() noexcept {
return Impl_->TryAcquire();
}
@@ -248,10 +248,10 @@ public:
}
};
#else
-class TFastSemaphore::TImpl: public TString, public TSemaphoreImpl {
+class TFastSemaphore::TImpl: public TString, public TSemaphoreImpl {
public:
inline TImpl(ui32 n)
- : TString(ToString(RandomNumber<ui64>()))
+ : TString(ToString(RandomNumber<ui64>()))
, TSemaphoreImpl(c_str(), n)
{
}
@@ -265,14 +265,14 @@ TFastSemaphore::TFastSemaphore(ui32 maxFreeCount)
TFastSemaphore::~TFastSemaphore() = default;
-void TFastSemaphore::Release() noexcept {
+void TFastSemaphore::Release() noexcept {
Impl_->Release();
}
-void TFastSemaphore::Acquire() noexcept {
+void TFastSemaphore::Acquire() noexcept {
Impl_->Acquire();
}
-bool TFastSemaphore::TryAcquire() noexcept {
+bool TFastSemaphore::TryAcquire() noexcept {
return Impl_->TryAcquire();
}
diff --git a/util/system/sem.h b/util/system/sem.h
index 2dbc5e3db9..0c964ad6b6 100644
--- a/util/system/sem.h
+++ b/util/system/sem.h
@@ -8,17 +8,17 @@
class TSemaphore {
public:
TSemaphore(const char* name, ui32 maxFreeCount);
- ~TSemaphore();
+ ~TSemaphore();
//Increase the semaphore counter.
- void Release() noexcept;
+ void Release() noexcept;
//Keep a thread held while the semaphore counter is equal 0.
- void Acquire() noexcept;
+ void Acquire() noexcept;
//Try to enter the semaphore gate. A non-blocking variant of Acquire.
//Returns 'true' if the semaphore counter decreased
- bool TryAcquire() noexcept;
+ bool TryAcquire() noexcept;
private:
class TImpl;
@@ -29,11 +29,11 @@ private:
class TFastSemaphore {
public:
TFastSemaphore(ui32 maxFreeCount);
- ~TFastSemaphore();
+ ~TFastSemaphore();
- void Release() noexcept;
- void Acquire() noexcept;
- bool TryAcquire() noexcept;
+ void Release() noexcept;
+ void Acquire() noexcept;
+ bool TryAcquire() noexcept;
private:
class TImpl;
diff --git a/util/system/shellcommand.cpp b/util/system/shellcommand.cpp
index e8da24f7ef..b1989b5c8c 100644
--- a/util/system/shellcommand.cpp
+++ b/util/system/shellcommand.cpp
@@ -115,21 +115,21 @@ using REALPIPEHANDLE = HANDLE;
class TRealPipeHandle
: public TNonCopyable {
public:
- inline TRealPipeHandle() noexcept
+ inline TRealPipeHandle() noexcept
: Fd_(INVALID_REALPIPEHANDLE)
{
}
- inline TRealPipeHandle(REALPIPEHANDLE fd) noexcept
+ inline TRealPipeHandle(REALPIPEHANDLE fd) noexcept
: Fd_(fd)
{
}
- inline ~TRealPipeHandle() {
+ inline ~TRealPipeHandle() {
Close();
}
- bool Close() noexcept {
+ bool Close() noexcept {
bool ok = true;
if (Fd_ != INVALID_REALPIPEHANDLE)
ok = CloseHandle(Fd_);
@@ -137,31 +137,31 @@ public:
return ok;
}
- inline REALPIPEHANDLE Release() noexcept {
+ inline REALPIPEHANDLE Release() noexcept {
REALPIPEHANDLE ret = Fd_;
Fd_ = INVALID_REALPIPEHANDLE;
return ret;
}
- inline void Swap(TRealPipeHandle& r) noexcept {
+ inline void Swap(TRealPipeHandle& r) noexcept {
DoSwap(Fd_, r.Fd_);
}
- inline operator REALPIPEHANDLE() const noexcept {
+ inline operator REALPIPEHANDLE() const noexcept {
return Fd_;
}
- inline bool IsOpen() const noexcept {
+ inline bool IsOpen() const noexcept {
return Fd_ != INVALID_REALPIPEHANDLE;
}
- ssize_t Read(void* buffer, size_t byteCount) const noexcept {
+ ssize_t Read(void* buffer, size_t byteCount) const noexcept {
DWORD doneBytes;
if (!ReadFile(Fd_, buffer, byteCount, &doneBytes, nullptr))
return -1;
return doneBytes;
}
- ssize_t Write(const void* buffer, size_t byteCount) const noexcept {
+ ssize_t Write(const void* buffer, size_t byteCount) const noexcept {
DWORD doneBytes;
if (!WriteFile(Fd_, buffer, byteCount, &doneBytes, nullptr))
return -1;
@@ -191,17 +191,17 @@ class TShellCommand::TImpl
: public TAtomicRefCount<TShellCommand::TImpl> {
private:
TPid Pid;
- TString Command;
- TList<TString> Arguments;
- TString WorkDir;
+ TString Command;
+ TList<TString> Arguments;
+ TString WorkDir;
TAtomic ExecutionStatus; // TShellCommand::ECommandStatus
TMaybe<int> ExitCode;
IInputStream* InputStream;
IOutputStream* OutputStream;
IOutputStream* ErrorStream;
- TString CollectedOutput;
- TString CollectedError;
- TString InternalError;
+ TString CollectedOutput;
+ TString CollectedError;
+ TString InternalError;
TThread* WatchThread;
TMutex TerminateMutex;
TFileHandle InputHandle;
@@ -224,7 +224,7 @@ private:
TShellCommandOptions::EHandleMode ErrorMode = TShellCommandOptions::HANDLE_STREAM;
TShellCommandOptions::TUserOptions User;
- THashMap<TString, TString> Environment;
+ THashMap<TString, TString> Environment;
int Nice = 0;
std::function<void()> FuncAfterFork = {};
@@ -280,7 +280,7 @@ private:
#endif
public:
- inline TImpl(const TStringBuf cmd, const TList<TString>& args, const TShellCommandOptions& options, const TString& workdir)
+ inline TImpl(const TStringBuf cmd, const TList<TString>& args, const TShellCommandOptions& options, const TString& workdir)
: Pid(0)
, Command(ToString(cmd))
, Arguments(args)
@@ -337,21 +337,21 @@ public:
Arguments.push_back(ToString(argument));
}
- inline const TString& GetOutput() const {
+ inline const TString& GetOutput() const {
if (AtomicGet(ExecutionStatus) == SHELL_RUNNING) {
ythrow yexception() << "You cannot retrieve output while process is running.";
}
return CollectedOutput;
}
- inline const TString& GetError() const {
+ inline const TString& GetError() const {
if (AtomicGet(ExecutionStatus) == SHELL_RUNNING) {
ythrow yexception() << "You cannot retrieve output while process is running.";
}
return CollectedError;
}
- inline const TString& GetInternalError() const {
+ inline const TString& GetInternalError() const {
if (AtomicGet(ExecutionStatus) != SHELL_INTERNAL_ERROR) {
ythrow yexception() << "Internal error hasn't occured so can't be retrieved.";
}
@@ -555,10 +555,10 @@ void TShellCommand::TImpl::StartProcess(TShellCommand::TImpl::TPipes& pipes) {
}
PROCESS_INFORMATION process_info;
- // TString cmd = "cmd /U" + TUtf16String can be used to read unicode messages from cmd
+ // TString cmd = "cmd /U" + TUtf16String can be used to read unicode messages from cmd
// /A - ansi charset /Q - echo off, /C - command, /Q - special quotes
- TString qcmd = GetQuotedCommand();
- TString cmd = UseShell ? "cmd /A /Q /S /C \"" + qcmd + "\"" : qcmd;
+ TString qcmd = GetQuotedCommand();
+ TString cmd = UseShell ? "cmd /A /Q /S /C \"" + qcmd + "\"" : qcmd;
// winapi can modify command text, copy it
Y_ENSURE_EX(cmd.size() < MAX_COMMAND_LINE, yexception() << "Command is too long (length=" << cmd.size() << ")");
@@ -574,7 +574,7 @@ void TShellCommand::TImpl::StartProcess(TShellCommand::TImpl::TPipes& pipes) {
}
void* lpEnvironment = nullptr;
- TString env;
+ TString env;
if (!Environment.empty()) {
for (auto e = Environment.begin(); e != Environment.end(); ++e) {
env += e->first + '=' + e->second + '\0';
@@ -627,21 +627,21 @@ void TShellCommand::TImpl::StartProcess(TShellCommand::TImpl::TPipes& pipes) {
}
#endif
-void ShellQuoteArg(TString& dst, TStringBuf argument) {
+void ShellQuoteArg(TString& dst, TStringBuf argument) {
dst.append("\"");
TStringBuf l, r;
- while (argument.TrySplit('"', l, r)) {
+ while (argument.TrySplit('"', l, r)) {
dst.append(l);
dst.append("\\\"");
- argument = r;
+ argument = r;
}
- dst.append(argument);
+ dst.append(argument);
dst.append("\"");
}
-void ShellQuoteArgSp(TString& dst, TStringBuf argument) {
+void ShellQuoteArgSp(TString& dst, TStringBuf argument) {
dst.append(' ');
- ShellQuoteArg(dst, argument);
+ ShellQuoteArg(dst, argument);
}
bool ArgNeedsQuotes(TStringBuf arg) noexcept {
@@ -651,8 +651,8 @@ bool ArgNeedsQuotes(TStringBuf arg) noexcept {
return arg.find_first_of(" \"\'\t&()*<>\\`^|") != TString::npos;
}
-TString TShellCommand::TImpl::GetQuotedCommand() const {
- TString quoted = Command; /// @todo command itself should be quoted too
+TString TShellCommand::TImpl::GetQuotedCommand() const {
+ TString quoted = Command; /// @todo command itself should be quoted too
for (const auto& argument : Arguments) {
// Don't add unnecessary quotes. It's especially important for the windows with a 32k command line length limit.
if (QuoteArguments && ArgNeedsQuotes(argument)) {
@@ -783,8 +783,8 @@ void TShellCommand::TImpl::Run() {
}
/* arguments holders */
- TString shellArg;
- TVector<char*> qargv;
+ TString shellArg;
+ TVector<char*> qargv;
/*
Following "const_cast"s are safe:
http://pubs.opengroup.org/onlinepubs/9699919799/functions/exec.html
@@ -807,8 +807,8 @@ void TShellCommand::TImpl::Run() {
qargv.push_back(nullptr);
- TVector<TString> envHolder;
- TVector<char*> envp;
+ TVector<TString> envHolder;
+ TVector<char*> envp;
if (!Environment.empty()) {
for (auto& env : Environment) {
envHolder.emplace_back(env.first + '=' + env.second);
@@ -1121,14 +1121,14 @@ void TShellCommand::TImpl::Communicate(TProcessInfo* pi) {
TerminateIsRequired(pi);
}
-TShellCommand::TShellCommand(const TStringBuf cmd, const TList<TString>& args, const TShellCommandOptions& options,
- const TString& workdir)
+TShellCommand::TShellCommand(const TStringBuf cmd, const TList<TString>& args, const TShellCommandOptions& options,
+ const TString& workdir)
: Impl(new TImpl(cmd, args, options, workdir))
{
}
-TShellCommand::TShellCommand(const TStringBuf cmd, const TShellCommandOptions& options, const TString& workdir)
- : Impl(new TImpl(cmd, TList<TString>(), options, workdir))
+TShellCommand::TShellCommand(const TStringBuf cmd, const TShellCommandOptions& options, const TString& workdir)
+ : Impl(new TImpl(cmd, TList<TString>(), options, workdir))
{
}
@@ -1139,15 +1139,15 @@ TShellCommand& TShellCommand::operator<<(const TStringBuf argument) {
return *this;
}
-const TString& TShellCommand::GetOutput() const {
+const TString& TShellCommand::GetOutput() const {
return Impl->GetOutput();
}
-const TString& TShellCommand::GetError() const {
+const TString& TShellCommand::GetError() const {
return Impl->GetError();
}
-const TString& TShellCommand::GetInternalError() const {
+const TString& TShellCommand::GetInternalError() const {
return Impl->GetInternalError();
}
diff --git a/util/system/shellcommand.h b/util/system/shellcommand.h
index c2e7a4701c..8730627fe5 100644
--- a/util/system/shellcommand.h
+++ b/util/system/shellcommand.h
@@ -1,7 +1,7 @@
#pragma once
#include <util/generic/noncopyable.h>
-#include <util/generic/string.h>
+#include <util/generic/string.h>
#include <util/generic/list.h>
#include <util/generic/hash.h>
#include <util/generic/strbuf.h>
@@ -17,9 +17,9 @@
class TShellCommandOptions {
public:
struct TUserOptions {
- TString Name;
+ TString Name;
#if defined(_win_)
- TString Password;
+ TString Password;
#endif
#if defined(_unix_)
/**
@@ -38,7 +38,7 @@ public:
};
public:
- inline TShellCommandOptions() noexcept
+ inline TShellCommandOptions() noexcept
: ClearSignalMask(false)
, CloseAllFdsOnExec(false)
, AsyncMode(false)
@@ -59,7 +59,7 @@ public:
{
}
- inline TShellCommandOptions& SetNice(int value) noexcept {
+ inline TShellCommandOptions& SetNice(int value) noexcept {
Nice = value;
return *this;
@@ -318,7 +318,7 @@ public:
IOutputStream* OutputStream;
IOutputStream* ErrorStream;
TUserOptions User;
- THashMap<TString, TString> Environment;
+ THashMap<TString, TString> Environment;
int Nice = 0;
static const size_t DefaultSyncPollDelay = 1000; // ms
@@ -351,10 +351,10 @@ public:
* @param options execution options
* @todo store entire options structure
*/
- TShellCommand(const TStringBuf cmd, const TList<TString>& args, const TShellCommandOptions& options = TShellCommandOptions(),
- const TString& workdir = TString());
- TShellCommand(const TStringBuf cmd, const TShellCommandOptions& options = TShellCommandOptions(), const TString& workdir = TString());
- ~TShellCommand();
+ TShellCommand(const TStringBuf cmd, const TList<TString>& args, const TShellCommandOptions& options = TShellCommandOptions(),
+ const TString& workdir = TString());
+ TShellCommand(const TStringBuf cmd, const TShellCommandOptions& options = TShellCommandOptions(), const TString& workdir = TString());
+ ~TShellCommand();
public:
/**
@@ -372,7 +372,7 @@ public:
*
* @return collected output
*/
- const TString& GetOutput() const;
+ const TString& GetOutput() const;
/**
* @brief return the collected error output from the command.
@@ -380,7 +380,7 @@ public:
*
* @return collected error output
*/
- const TString& GetError() const;
+ const TString& GetError() const;
/**
* @brief return the internal error occured while watching
@@ -389,7 +389,7 @@ public:
*
* @return error text
*/
- const TString& GetInternalError() const;
+ const TString& GetInternalError() const;
/**
* @brief get current status of command execution
@@ -476,10 +476,10 @@ private:
};
/// Appends to dst: quoted arg
-void ShellQuoteArg(TString& dst, TStringBuf arg);
+void ShellQuoteArg(TString& dst, TStringBuf arg);
/// Appends to dst: space, quoted arg
-void ShellQuoteArgSp(TString& dst, TStringBuf arg);
+void ShellQuoteArgSp(TString& dst, TStringBuf arg);
/// Returns true if arg should be quoted
bool ArgNeedsQuotes(TStringBuf arg) noexcept;
diff --git a/util/system/shellcommand_ut.cpp b/util/system/shellcommand_ut.cpp
index 71dd2f2e4d..9d849279d2 100644
--- a/util/system/shellcommand_ut.cpp
+++ b/util/system/shellcommand_ut.cpp
@@ -33,11 +33,11 @@ public:
Stream_.Reserve(100);
}
- TString Str() const {
+ TString Str() const {
with_lock (Lock_) {
return Stream_.Str();
}
- return TString(); // line for compiler
+ return TString(); // line for compiler
}
protected:
@@ -61,7 +61,7 @@ private:
Y_UNIT_TEST_SUITE(TShellQuoteTest) {
Y_UNIT_TEST(TestQuoteArg) {
- TString cmd;
+ TString cmd;
ShellQuoteArg(cmd, "/pr f/krev/prev.exe");
ShellQuoteArgSp(cmd, "-DVal=\"W Quotes\"");
ShellQuoteArgSp(cmd, "-DVal=W Space");
@@ -170,8 +170,8 @@ Y_UNIT_TEST_SUITE(TShellCommandTest) {
}
Y_UNIT_TEST(TestQuotes) {
TShellCommandOptions options;
- TString input = TString("a\"a a");
- TString output;
+ TString input = TString("a\"a a");
+ TString output;
TStringOutput outputStream(output);
options.SetOutputStream(&outputStream);
TShellCommand cmd("echo", options);
@@ -202,7 +202,7 @@ Y_UNIT_TEST_SUITE(TShellCommandTest) {
// 'type con' and 'copy con con' want real console, not stdin, use sort
Y_UNIT_TEST(TestInput) {
TShellCommandOptions options;
- TString input = (TString("a") * 2000).append(NL) * textSize;
+ TString input = (TString("a") * 2000).append(NL) * textSize;
TStringInput inputStream(input);
options.SetInputStream(&inputStream);
TShellCommand cmd(catCommand, options);
@@ -212,10 +212,10 @@ Y_UNIT_TEST_SUITE(TShellCommandTest) {
}
Y_UNIT_TEST(TestOutput) {
TShellCommandOptions options;
- TString input = (TString("a") * 2000).append(NL) * textSize;
+ TString input = (TString("a") * 2000).append(NL) * textSize;
TStringInput inputStream(input);
options.SetInputStream(&inputStream);
- TString output;
+ TString output;
TStringOutput outputStream(output);
options.SetOutputStream(&outputStream);
TShellCommand cmd(catCommand, options);
@@ -297,7 +297,7 @@ Y_UNIT_TEST_SUITE(TShellCommandTest) {
#if !defined(_win_)
// this ut is unix-only, port to win using %TEMP%
Y_UNIT_TEST(TestInterrupt) {
- TString tmpfile = TString("shellcommand_ut.interrupt.") + ToString(RandomNumber<ui32>());
+ TString tmpfile = TString("shellcommand_ut.interrupt.") + ToString(RandomNumber<ui32>());
TShellCommandOptions options;
options.SetAsync(true);
@@ -327,7 +327,7 @@ Y_UNIT_TEST_SUITE(TShellCommandTest) {
rc = SigProcMask(SIG_SETMASK, &newmask, &oldmask);
UNIT_ASSERT(rc == 0);
- TString tmpfile = TString("shellcommand_ut.interrupt.") + ToString(RandomNumber<ui32>());
+ TString tmpfile = TString("shellcommand_ut.interrupt.") + ToString(RandomNumber<ui32>());
TShellCommandOptions options;
options.SetAsync(true);
@@ -381,7 +381,7 @@ Y_UNIT_TEST_SUITE(TShellCommandTest) {
}
#endif
Y_UNIT_TEST(TestInternalError) {
- TString input = (TString("a") * 2000).append("\n");
+ TString input = (TString("a") * 2000).append("\n");
TStringInput inputStream(input);
TMemoryOutput outputStream(nullptr, 0);
TShellCommandOptions options;
diff --git a/util/system/spin_wait.cpp b/util/system/spin_wait.cpp
index c2281a111d..e27045e74f 100644
--- a/util/system/spin_wait.cpp
+++ b/util/system/spin_wait.cpp
@@ -8,7 +8,7 @@
#include <util/generic/utility.h>
template <class T>
-static inline T RandomizeSleepTime(T t) noexcept {
+static inline T RandomizeSleepTime(T t) noexcept {
static TAtomic counter = 0;
const T rndNum = IntHash((T)AtomicIncrement(counter));
diff --git a/util/system/spinlock.h b/util/system/spinlock.h
index 85d8a281b8..af2630890a 100644
--- a/util/system/spinlock.h
+++ b/util/system/spinlock.h
@@ -14,7 +14,7 @@ public:
return AtomicGet(Val_);
}
- inline bool TryAcquire() noexcept {
+ inline bool TryAcquire() noexcept {
return AtomicTryLock(&Val_);
}
@@ -56,11 +56,11 @@ class TSpinLock: public TSpinLockBase {
public:
using TSpinLockBase::TSpinLockBase;
- inline void Release() noexcept {
+ inline void Release() noexcept {
ReleaseSpinLock(&Val_);
}
- inline void Acquire() noexcept {
+ inline void Acquire() noexcept {
AcquireSpinLock(&Val_);
}
@@ -91,11 +91,11 @@ class TAdaptiveLock: public TSpinLockBase {
public:
using TSpinLockBase::TSpinLockBase;
- inline void Release() noexcept {
+ inline void Release() noexcept {
ReleaseAdaptiveLock(&Val_);
}
- inline void Acquire() noexcept {
+ inline void Acquire() noexcept {
AcquireAdaptiveLock(&Val_);
}
@@ -112,15 +112,15 @@ public:
template <>
struct TCommonLockOps<TAtomic> {
- static inline void Acquire(TAtomic* v) noexcept {
+ static inline void Acquire(TAtomic* v) noexcept {
AcquireAdaptiveLock(v);
}
- static inline bool TryAcquire(TAtomic* v) noexcept {
+ static inline bool TryAcquire(TAtomic* v) noexcept {
return AtomicTryLock(v);
}
- static inline void Release(TAtomic* v) noexcept {
+ static inline void Release(TAtomic* v) noexcept {
ReleaseAdaptiveLock(v);
}
};
diff --git a/util/system/src_location.cpp b/util/system/src_location.cpp
index 2d051f7be6..13ff1f24b3 100644
--- a/util/system/src_location.cpp
+++ b/util/system/src_location.cpp
@@ -7,7 +7,7 @@
template <>
void Out<TSourceLocation>(IOutputStream& o, const TSourceLocation& t) {
#if defined(_win_)
- TString file(t.File);
+ TString file(t.File);
std::replace(file.begin(), file.vend(), '\\', '/');
o << file;
#else
diff --git a/util/system/src_location_ut.cpp b/util/system/src_location_ut.cpp
index 6924ce35b1..5b86cb86ef 100644
--- a/util/system/src_location_ut.cpp
+++ b/util/system/src_location_ut.cpp
@@ -4,7 +4,7 @@
#include <library/cpp/testing/unittest/registar.h>
-static inline TString GenLoc() {
+static inline TString GenLoc() {
return TStringBuilder() << __LOCATION__;
}
diff --git a/util/system/src_root_ut.cpp b/util/system/src_root_ut.cpp
index 30f3520eda..e9a675eb9a 100644
--- a/util/system/src_root_ut.cpp
+++ b/util/system/src_root_ut.cpp
@@ -6,7 +6,7 @@
Y_UNIT_TEST_SUITE(TestSourceRoot) {
Y_UNIT_TEST(TestStrip) {
// Reconstruct() converts "\" -> "/" on Windows
- const TString path = TPathSplit(__SOURCE_FILE_IMPL__.As<TStringBuf>()).Reconstruct();
+ const TString path = TPathSplit(__SOURCE_FILE_IMPL__.As<TStringBuf>()).Reconstruct();
UNIT_ASSERT_EQUAL(path, "util" LOCSLASH_S "system" LOCSLASH_S "src_root_ut.cpp");
}
diff --git a/util/system/tempfile.cpp b/util/system/tempfile.cpp
index 0e3e461102..a2e9f49eb1 100644
--- a/util/system/tempfile.cpp
+++ b/util/system/tempfile.cpp
@@ -6,7 +6,7 @@ TTempFileHandle::TTempFileHandle()
{
}
-TTempFileHandle::TTempFileHandle(const TString& fname)
+TTempFileHandle::TTempFileHandle(const TString& fname)
: TTempFile(fname)
, TFile(CreateFile())
{
diff --git a/util/system/tempfile.h b/util/system/tempfile.h
index e20f792371..de249c129d 100644
--- a/util/system/tempfile.h
+++ b/util/system/tempfile.h
@@ -4,31 +4,31 @@
#include "file.h"
#include <util/folder/path.h>
-#include <util/generic/string.h>
+#include <util/generic/string.h>
class TTempFile {
public:
- inline TTempFile(const TString& fname)
+ inline TTempFile(const TString& fname)
: Name_(fname)
{
}
- inline ~TTempFile() {
+ inline ~TTempFile() {
NFs::Remove(Name());
}
- inline const TString& Name() const noexcept {
+ inline const TString& Name() const noexcept {
return Name_;
}
private:
- const TString Name_;
+ const TString Name_;
};
class TTempFileHandle: public TTempFile, public TFile {
public:
TTempFileHandle();
- TTempFileHandle(const TString& fname);
+ TTempFileHandle(const TString& fname);
static TTempFileHandle InCurrentDir(const TString& filePrefix = "yandex", const TString& extension = "tmp");
static TTempFileHandle InDir(const TFsPath& dirPath, const TString& filePrefix = "yandex", const TString& extension = "tmp");
diff --git a/util/system/tempfile_ut.cpp b/util/system/tempfile_ut.cpp
index b5523fa788..e4a0923d0b 100644
--- a/util/system/tempfile_ut.cpp
+++ b/util/system/tempfile_ut.cpp
@@ -10,13 +10,13 @@
Y_UNIT_TEST_SUITE(TTempFileHandle) {
Y_UNIT_TEST(Create) {
- TString path;
+ TString path;
{
TTempFileHandle tmp;
path = tmp.Name();
tmp.Write("hello world\n", 12);
tmp.FlushData();
- UNIT_ASSERT_STRINGS_EQUAL(TUnbufferedFileInput(tmp.Name()).ReadAll(), "hello world\n");
+ UNIT_ASSERT_STRINGS_EQUAL(TUnbufferedFileInput(tmp.Name()).ReadAll(), "hello world\n");
}
UNIT_ASSERT(!NFs::Exists(path));
}
diff --git a/util/system/thread.cpp b/util/system/thread.cpp
index e9cb938302..6236746c2d 100644
--- a/util/system/thread.cpp
+++ b/util/system/thread.cpp
@@ -51,7 +51,7 @@ namespace {
}
}
- inline size_t StackSize(const TParams& p) noexcept {
+ inline size_t StackSize(const TParams& p) noexcept {
if (p.StackSize) {
return FastClp2(p.StackSize);
}
@@ -83,11 +83,11 @@ namespace {
{
}
- inline bool Running() const noexcept {
+ inline bool Running() const noexcept {
return Handle != 0;
}
- inline TId SystemThreadId() const noexcept {
+ inline TId SystemThreadId() const noexcept {
#if _WIN32_WINNT < 0x0502
return (TId)ThreadId;
#else
@@ -168,7 +168,7 @@ namespace {
static_assert(sizeof(H_) == sizeof(TId), "expect sizeof(H_) == sizeof(TId)");
}
- inline TId SystemThreadId() const noexcept {
+ inline TId SystemThreadId() const noexcept {
return (TId)H_;
}
@@ -183,7 +183,7 @@ namespace {
PCHECK(pthread_detach(H_), "can not detach thread");
}
- inline bool Running() const noexcept {
+ inline bool Running() const noexcept {
return (bool)H_;
}
@@ -257,7 +257,7 @@ public:
{
}
- inline TId Id() const noexcept {
+ inline TId Id() const noexcept {
return ThreadIdHashFunction(SystemThreadId());
}
@@ -285,7 +285,7 @@ TThread::TThread(TPrivateCtor, THolder<TCallableBase> callable)
{
}
-TThread::~TThread() {
+TThread::~TThread() {
Join();
}
@@ -312,11 +312,11 @@ void TThread::Detach() {
}
}
-bool TThread::Running() const noexcept {
+bool TThread::Running() const noexcept {
return Impl_ && Impl_->Running();
}
-TThread::TId TThread::Id() const noexcept {
+TThread::TId TThread::Id() const noexcept {
if (Running()) {
return Impl_->Id();
}
@@ -324,7 +324,7 @@ TThread::TId TThread::Id() const noexcept {
return ImpossibleThreadId();
}
-TThread::TId TThread::CurrentThreadId() noexcept {
+TThread::TId TThread::CurrentThreadId() noexcept {
return SystemCurrentThreadId();
}
@@ -352,7 +352,7 @@ TThread::TId TThread::CurrentThreadNumericId() noexcept {
#endif
}
-TThread::TId TThread::ImpossibleThreadId() noexcept {
+TThread::TId TThread::ImpossibleThreadId() noexcept {
return Max<TThread::TId>();
}
diff --git a/util/system/thread.h b/util/system/thread.h
index 5702b549fa..a6e8abdb5b 100644
--- a/util/system/thread.h
+++ b/util/system/thread.h
@@ -5,7 +5,7 @@
/// @see SystemThreadFactory()
#include <util/generic/ptr.h>
-#include <util/generic/string.h>
+#include <util/generic/string.h>
#include "defaults.h"
#include "progname.h"
@@ -53,19 +53,19 @@ public:
{
}
- inline TParams& SetName(const TString& name) noexcept {
+ inline TParams& SetName(const TString& name) noexcept {
Name = name;
return *this;
}
- inline TParams& SetStackSize(size_t size) noexcept {
+ inline TParams& SetStackSize(size_t size) noexcept {
StackSize = size;
return *this;
}
- inline TParams& SetStackPointer(void* ptr) noexcept {
+ inline TParams& SetStackPointer(void* ptr) noexcept {
StackPointer = ptr;
return *this;
@@ -92,17 +92,17 @@ public:
{
}
- ~TThread();
+ ~TThread();
void Start();
void* Join();
void Detach();
- bool Running() const noexcept;
- TId Id() const noexcept;
+ bool Running() const noexcept;
+ TId Id() const noexcept;
- static TId ImpossibleThreadId() noexcept;
- static TId CurrentThreadId() noexcept;
+ static TId ImpossibleThreadId() noexcept;
+ static TId CurrentThreadId() noexcept;
/*
* Returns numeric thread id, as visible in e. g. htop.
diff --git a/util/system/thread.i b/util/system/thread.i
index 086befc238..8cba505473 100644
--- a/util/system/thread.i
+++ b/util/system/thread.i
@@ -24,7 +24,7 @@
#include <util/digest/numeric.h>
-static inline size_t SystemCurrentThreadIdImpl() noexcept {
+static inline size_t SystemCurrentThreadIdImpl() noexcept {
#if defined(_unix_)
return (size_t)pthread_self();
#elif defined(_win_)
@@ -35,7 +35,7 @@ static inline size_t SystemCurrentThreadIdImpl() noexcept {
}
template <class T>
-static inline T ThreadIdHashFunction(T t) noexcept {
+static inline T ThreadIdHashFunction(T t) noexcept {
/*
* we must permute threadid bits, because some strange platforms(such Linux)
* have strange threadid numeric properties
@@ -47,6 +47,6 @@ static inline T ThreadIdHashFunction(T t) noexcept {
return IntHash(t);
}
-static inline size_t SystemCurrentThreadId() noexcept {
+static inline size_t SystemCurrentThreadId() noexcept {
return ThreadIdHashFunction(SystemCurrentThreadIdImpl());
}
diff --git a/util/system/tls.cpp b/util/system/tls.cpp
index 9fdafc5b54..c2f1a04a14 100644
--- a/util/system/tls.cpp
+++ b/util/system/tls.cpp
@@ -6,7 +6,7 @@
#include <util/generic/hash.h>
#include <util/generic/intrlist.h>
#include <util/generic/singleton.h>
-#include <util/generic/vector.h>
+#include <util/generic/vector.h>
#if defined(_unix_)
#include <pthread.h>
@@ -46,17 +46,17 @@ namespace {
{
}
- inline ~TStoredValue() {
+ inline ~TStoredValue() {
if (Dtor_ && Data_) {
Dtor_(Data_);
}
}
- inline void Set(void* ptr) noexcept {
+ inline void Set(void* ptr) noexcept {
Data_ = ptr;
}
- inline void* Get() const noexcept {
+ inline void* Get() const noexcept {
return Data_;
}
@@ -92,8 +92,8 @@ namespace {
}
private:
- TVector<TStoredValue*> Values_;
- THashMap<size_t, TStoredValue*> FarValues_;
+ TVector<TStoredValue*> Values_;
+ THashMap<size_t, TStoredValue*> FarValues_;
TIntrusiveListWithAutoDelete<TStoredValue, TDelete> Storage_;
};
@@ -126,7 +126,7 @@ namespace {
Y_VERIFY(!pthread_key_create(&Key_, Dtor), "pthread_key_create failed");
}
- inline ~TMasterTls() override {
+ inline ~TMasterTls() override {
//explicitly call dtor for main thread
Dtor(pthread_getspecific(Key_));
@@ -197,7 +197,7 @@ namespace {
}
}
- inline void Cleanup() noexcept {
+ inline void Cleanup() noexcept {
with_lock (Lock_) {
Datas_.erase(TThread::CurrentThreadId());
}
@@ -210,7 +210,7 @@ namespace {
private:
using TPTSRef = THolder<TPerThreadStorage>;
TMutex Lock_;
- THashMap<TThread::TId, TPTSRef> Datas_;
+ THashMap<TThread::TId, TPTSRef> Datas_;
};
}
@@ -255,6 +255,6 @@ void TKey::Set(void* ptr) const {
Impl_->Set(ptr);
}
-void TKey::Cleanup() noexcept {
+void TKey::Cleanup() noexcept {
TImpl::Cleanup();
}
diff --git a/util/system/tls.h b/util/system/tls.h
index 29b5e1994b..3c4f56dbeb 100644
--- a/util/system/tls.h
+++ b/util/system/tls.h
@@ -158,12 +158,12 @@ namespace NTls {
public:
TKey(TDtor dtor);
TKey(TKey&&) noexcept;
- ~TKey();
+ ~TKey();
void* Get() const;
void Set(void* ptr) const;
- static void Cleanup() noexcept;
+ static void Cleanup() noexcept;
private:
class TImpl;
@@ -171,7 +171,7 @@ namespace NTls {
};
struct TCleaner {
- inline ~TCleaner() {
+ inline ~TCleaner() {
TKey::Cleanup();
}
};
@@ -292,16 +292,16 @@ namespace NTls {
}
template <class T>
-static inline T& TlsRef(NTls::TValue<T>& v) noexcept {
+static inline T& TlsRef(NTls::TValue<T>& v) noexcept {
return v;
}
template <class T>
-static inline const T& TlsRef(const NTls::TValue<T>& v) noexcept {
+static inline const T& TlsRef(const NTls::TValue<T>& v) noexcept {
return v;
}
template <class T>
-static inline T& TlsRef(T& v) noexcept {
+static inline T& TlsRef(T& v) noexcept {
return v;
}
diff --git a/util/system/tls_ut.cpp b/util/system/tls_ut.cpp
index ad3db72a12..e84d34b42a 100644
--- a/util/system/tls_ut.cpp
+++ b/util/system/tls_ut.cpp
@@ -31,7 +31,7 @@ Y_UNIT_TEST_SUITE(TTestTLS) {
{
}
- void* ThreadProc() noexcept override {
+ void* ThreadProc() noexcept override {
for (size_t i = 0; i < 100000; ++i) {
P[i].Do();
}
diff --git a/util/system/type_name.h b/util/system/type_name.h
index 76997db26f..b6619aba3f 100644
--- a/util/system/type_name.h
+++ b/util/system/type_name.h
@@ -1,6 +1,6 @@
#pragma once
-#include <util/generic/string.h>
+#include <util/generic/string.h>
#include <util/string/subst.h>
#include <typeindex>
diff --git a/util/system/user.cpp b/util/system/user.cpp
index ac6772f458..83e89ea0a8 100644
--- a/util/system/user.cpp
+++ b/util/system/user.cpp
@@ -13,7 +13,7 @@
#include <unistd.h>
#endif
-TString GetUsername() {
+TString GetUsername() {
for (const auto& var : {"LOGNAME", "USER", "LNAME", "USERNAME"}) {
TString val = GetEnv(var);
if (val) {
@@ -32,13 +32,13 @@ TString GetUsername() {
else
ythrow TSystemError(err) << " GetUserName failed";
} else {
- return TString(nameBuf.Data(), (size_t)(len - 1));
+ return TString(nameBuf.Data(), (size_t)(len - 1));
}
#elif defined(_bionic_)
const passwd* pwd = getpwuid(geteuid());
if (pwd) {
- return TString(pwd->pw_name);
+ return TString(pwd->pw_name);
}
ythrow TSystemError() << TStringBuf(" getpwuid failed");
diff --git a/util/system/user.h b/util/system/user.h
index 6d02d7ca48..be348d1cee 100644
--- a/util/system/user.h
+++ b/util/system/user.h
@@ -2,4 +2,4 @@
#include <util/generic/fwd.h>
-TString GetUsername();
+TString GetUsername();
diff --git a/util/system/ut/ya.make b/util/system/ut/ya.make
index dc64badf1b..127e7c261e 100644
--- a/util/system/ut/ya.make
+++ b/util/system/ut/ya.make
@@ -30,7 +30,7 @@ SRCS(
system/backtrace_ut.cpp
system/byteorder_ut.cpp
system/compat_ut.cpp
- system/compiler_ut.cpp
+ system/compiler_ut.cpp
system/context_ut.cpp
system/condvar_ut.cpp
system/cpu_id_ut.cpp
@@ -66,7 +66,7 @@ SRCS(
system/spinlock_ut.cpp
system/src_root_ut.cpp
system/src_location_ut.cpp
- system/shmat_ut.cpp
+ system/shmat_ut.cpp
system/tempfile_ut.cpp
system/thread_ut.cpp
system/tls_ut.cpp
diff --git a/util/system/yassert.cpp b/util/system/yassert.cpp
index cb006eec70..0f586648b7 100644
--- a/util/system/yassert.cpp
+++ b/util/system/yassert.cpp
@@ -8,7 +8,7 @@
#include <util/datetime/base.h>
#include <util/generic/singleton.h>
#include <util/generic/strbuf.h>
-#include <util/generic/string.h>
+#include <util/generic/string.h>
#include <util/stream/output.h>
#include <util/stream/str.h>
#include <util/string/printf.h>
@@ -38,13 +38,13 @@ namespace NPrivate {
[[noreturn]] Y_NO_INLINE void InternalPanicImpl(int line, const char* function, const char* expr, int, int, int, const TStringBuf file, const char* errorMessage, size_t errorMessageSize) noexcept;
}
-void ::NPrivate::Panic(const TStaticBuf& file, int line, const char* function, const char* expr, const char* format, ...) noexcept {
+void ::NPrivate::Panic(const TStaticBuf& file, int line, const char* function, const char* expr, const char* format, ...) noexcept {
try {
// We care of panic of first failed thread only
// Otherwise stderr could contain multiple messages and stack traces shuffled
auto guard = Guard(*Singleton<TPanicLockHolder>());
- TString errorMsg;
+ TString errorMsg;
va_list args;
va_start(args, format);
// format has " " prefix to mute GCC warning on empty format
@@ -65,7 +65,7 @@ namespace NPrivate {
TStringBuf errorMsg{errorMessage, errorMessageSize};
const TString now = TInstant::Now().ToStringLocal();
- TString r;
+ TString r;
TStringOutput o(r);
if (expr) {
o << "VERIFY failed (" << now << "): " << errorMsg << Endl;
diff --git a/util/system/yield.cpp b/util/system/yield.cpp
index 0da3c2f573..b327b37b1a 100644
--- a/util/system/yield.cpp
+++ b/util/system/yield.cpp
@@ -8,7 +8,7 @@
#include <sched.h>
#endif
-void SchedYield() noexcept {
+void SchedYield() noexcept {
#if defined(_unix_)
sched_yield();
#else
@@ -16,7 +16,7 @@ void SchedYield() noexcept {
#endif
}
-void ThreadYield() noexcept {
+void ThreadYield() noexcept {
#if defined(_freebsd_)
pthread_yield();
#else
diff --git a/util/system/yield.h b/util/system/yield.h
index 7886ac0522..9965fb52b5 100644
--- a/util/system/yield.h
+++ b/util/system/yield.h
@@ -1,4 +1,4 @@
#pragma once
-void SchedYield() noexcept;
-void ThreadYield() noexcept;
+void SchedYield() noexcept;
+void ThreadYield() noexcept;
diff --git a/util/tests/cython/test_generic.py b/util/tests/cython/test_generic.py
index fbfa10a485..a0d61339cc 100644
--- a/util/tests/cython/test_generic.py
+++ b/util/tests/cython/test_generic.py
@@ -8,7 +8,7 @@ from util.generic.hash_set_ut import TestHashSet
from util.generic.list_ut import TestList
from util.generic.maybe_ut import TestMaybe
from util.generic.ptr_ut import TestHolder
-from util.generic.string_ut import TestStroka
+from util.generic.string_ut import TestStroka
from util.generic.vector_ut import TestVector
from util.string.cast_ut import TestFromString, TestToString
diff --git a/util/tests/cython/ya.make b/util/tests/cython/ya.make
index f869f2ad65..b928c19026 100644
--- a/util/tests/cython/ya.make
+++ b/util/tests/cython/ya.make
@@ -5,8 +5,8 @@ SUBSCRIBER(g:util-subscribers)
SRCDIR(util)
-NO_WSHADOW()
-
+NO_WSHADOW()
+
PY_SRCS(
NAMESPACE
util
@@ -15,7 +15,7 @@ PY_SRCS(
generic/deque_ut.pyx
generic/maybe_ut.pyx
generic/ptr_ut.pyx
- generic/string_ut.pyx
+ generic/string_ut.pyx
generic/vector_ut.pyx
generic/list_ut.pyx
generic/hash_set_ut.pyx
diff --git a/util/thread/factory.cpp b/util/thread/factory.cpp
index 463acc8b19..48e898f32d 100644
--- a/util/thread/factory.cpp
+++ b/util/thread/factory.cpp
@@ -10,7 +10,7 @@ namespace {
public:
class TPoolThread: public IThread {
public:
- ~TPoolThread() override {
+ ~TPoolThread() override {
if (Thr_) {
Thr_->Detach();
}
@@ -22,7 +22,7 @@ namespace {
Thr_->Start();
}
- void DoJoin() noexcept override {
+ void DoJoin() noexcept override {
if (!Thr_) {
return;
}
diff --git a/util/thread/factory.h b/util/thread/factory.h
index 452169e9f7..561fcbac88 100644
--- a/util/thread/factory.h
+++ b/util/thread/factory.h
@@ -27,7 +27,7 @@ public:
virtual ~IThread() = default;
- inline void Join() noexcept {
+ inline void Join() noexcept {
DoJoin();
}
@@ -39,7 +39,7 @@ public:
private:
// it's actually DoStart
virtual void DoRun(IThreadAble* func) = 0;
- virtual void DoJoin() noexcept = 0;
+ virtual void DoJoin() noexcept = 0;
};
inline IThreadFactory() noexcept = default;
diff --git a/util/thread/lfqueue.h b/util/thread/lfqueue.h
index 170ae134fe..ab523631e4 100644
--- a/util/thread/lfqueue.h
+++ b/util/thread/lfqueue.h
@@ -364,7 +364,7 @@ class TAutoLockFreeQueue {
public:
using TRef = THolder<T>;
- inline ~TAutoLockFreeQueue() {
+ inline ~TAutoLockFreeQueue() {
TRef tmp;
while (Dequeue(&tmp)) {
diff --git a/util/thread/lfqueue_ut.cpp b/util/thread/lfqueue_ut.cpp
index f68771a8c4..83bca100cf 100644
--- a/util/thread/lfqueue_ut.cpp
+++ b/util/thread/lfqueue_ut.cpp
@@ -161,7 +161,7 @@ Y_UNIT_TEST_SUITE(TLockFreeQueueTests) {
UNIT_ASSERT(!queue.Dequeue(&i));
UNIT_ASSERT_VALUES_EQUAL(i, -1);
- TVector<int> v;
+ TVector<int> v;
v.push_back(20);
v.push_back(21);
diff --git a/util/thread/lfstack.h b/util/thread/lfstack.h
index cdc9f68386..ca3d95f3c3 100644
--- a/util/thread/lfstack.h
+++ b/util/thread/lfstack.h
@@ -1,6 +1,6 @@
#pragma once
-#include <util/generic/noncopyable.h>
+#include <util/generic/noncopyable.h>
#include <util/system/atomic.h>
//////////////////////////////
diff --git a/util/thread/lfstack_ut.cpp b/util/thread/lfstack_ut.cpp
index 61edd3d632..e20a838f95 100644
--- a/util/thread/lfstack_ut.cpp
+++ b/util/thread/lfstack_ut.cpp
@@ -68,7 +68,7 @@ Y_UNIT_TEST_SUITE(TLockFreeStackTests) {
StartLatch.CountDown();
StartLatch.Await();
- TVector<int> temp;
+ TVector<int> temp;
while (AtomicGet(LeftToDequeue) > 0) {
size_t dequeued = 0;
for (size_t i = 0; i < 100; ++i) {
@@ -85,7 +85,7 @@ Y_UNIT_TEST_SUITE(TLockFreeStackTests) {
}
void Run() {
- TVector<TSimpleSharedPtr<NThreading::TLegacyFuture<>>> futures;
+ TVector<TSimpleSharedPtr<NThreading::TLegacyFuture<>>> futures;
for (size_t i = 0; i < EnqueueThreads; ++i) {
futures.push_back(new NThreading::TLegacyFuture<>(std::bind(&TDequeueAllTester<SingleConsumer>::Enqueuer, this)));
@@ -100,7 +100,7 @@ Y_UNIT_TEST_SUITE(TLockFreeStackTests) {
UNIT_ASSERT_VALUES_EQUAL(0, int(AtomicGet(LeftToDequeue)));
- TVector<int> left;
+ TVector<int> left;
Stack.DequeueAll(&left);
UNIT_ASSERT(left.empty());
}
@@ -117,7 +117,7 @@ Y_UNIT_TEST_SUITE(TLockFreeStackTests) {
Y_UNIT_TEST(TestDequeueAllEmptyStack) {
TLockFreeStack<int> stack;
- TVector<int> r;
+ TVector<int> r;
stack.DequeueAll(&r);
UNIT_ASSERT(r.empty());
@@ -130,7 +130,7 @@ Y_UNIT_TEST_SUITE(TLockFreeStackTests) {
stack.Enqueue(19);
stack.Enqueue(23);
- TVector<int> r;
+ TVector<int> r;
stack.DequeueAll(&r);
@@ -143,8 +143,8 @@ Y_UNIT_TEST_SUITE(TLockFreeStackTests) {
Y_UNIT_TEST(TestEnqueueAll) {
TLockFreeStack<int> stack;
- TVector<int> v;
- TVector<int> expected;
+ TVector<int> v;
+ TVector<int> expected;
stack.EnqueueAll(v); // add empty
@@ -165,7 +165,7 @@ Y_UNIT_TEST_SUITE(TLockFreeStackTests) {
expected.insert(expected.end(), v.begin(), v.end());
stack.EnqueueAll(v);
- TVector<int> actual;
+ TVector<int> actual;
stack.DequeueAll(&actual);
UNIT_ASSERT_VALUES_EQUAL(expected.size(), actual.size());
diff --git a/util/thread/pool.cpp b/util/thread/pool.cpp
index cb87d95e09..05fad02e9b 100644
--- a/util/thread/pool.cpp
+++ b/util/thread/pool.cpp
@@ -86,7 +86,7 @@ public:
Start(thrnum, maxqueue);
}
- inline ~TImpl() override {
+ inline ~TImpl() override {
try {
Stop();
} catch (...) {
@@ -129,17 +129,17 @@ public:
return true;
}
- inline size_t Size() const noexcept {
+ inline size_t Size() const noexcept {
auto guard = Guard(QueueMutex);
return Queue.Size();
}
- inline size_t GetMaxQueueSize() const noexcept {
+ inline size_t GetMaxQueueSize() const noexcept {
return MaxQueueSize;
}
- inline size_t GetThreadCountExpected() const noexcept {
+ inline size_t GetThreadCountExpected() const noexcept {
return ThreadCountExpected;
}
@@ -151,7 +151,7 @@ public:
Forked = true;
}
- inline bool NeedRestart() const noexcept {
+ inline bool NeedRestart() const noexcept {
return Forked;
}
@@ -189,7 +189,7 @@ private:
MaxQueueSize = 0;
}
- inline void WaitForComplete() noexcept {
+ inline void WaitForComplete() noexcept {
with_lock (StopMutex) {
while (ThreadCountReal) {
with_lock (QueueMutex) {
@@ -245,7 +245,7 @@ private:
FinishOneThread();
}
- inline void FinishOneThread() noexcept {
+ inline void FinishOneThread() noexcept {
auto guard = Guard(StopMutex);
--ThreadCountReal;
@@ -263,7 +263,7 @@ private:
TCondVar QueuePopCond;
TCondVar StopCond;
TJobQueue Queue;
- TVector<TThreadRef> Tharr;
+ TVector<TThreadRef> Tharr;
TAtomic ShouldTerminate;
size_t MaxQueueSize;
size_t ThreadCountExpected;
@@ -379,12 +379,12 @@ public:
{
}
- inline ~TThread() override {
+ inline ~TThread() override {
Impl_->DecThreadCount();
}
private:
- void DoExecute() noexcept override {
+ void DoExecute() noexcept override {
THolder<TThread> This(this);
if (Impl_->Namer) {
@@ -431,7 +431,7 @@ public:
sprintf(Name_, "[mtp queue %ld]", (long)AtomicAdd(mtp_queue_counter, 1));
}
- inline ~TImpl() {
+ inline ~TImpl() {
Stop();
}
@@ -439,7 +439,7 @@ public:
IdleTime_ = idleTime;
}
- inline const char* Name() const noexcept {
+ inline const char* Name() const noexcept {
return Name_;
}
@@ -471,16 +471,16 @@ public:
}
}
- inline size_t Size() const noexcept {
+ inline size_t Size() const noexcept {
return (size_t)ThrCount_;
}
private:
- inline void IncThreadCount() noexcept {
+ inline void IncThreadCount() noexcept {
AtomicAdd(ThrCount_, 1);
}
- inline void DecThreadCount() noexcept {
+ inline void DecThreadCount() noexcept {
AtomicAdd(ThrCount_, -1);
}
@@ -496,7 +496,7 @@ private:
}
}
- inline void Stop() noexcept {
+ inline void Stop() noexcept {
Mutex_.Acquire();
AllDone_ = true;
@@ -510,7 +510,7 @@ private:
Mutex_.Release();
}
- inline IObjectInQueue* WaitForJob() noexcept {
+ inline IObjectInQueue* WaitForJob() noexcept {
Mutex_.Acquire();
++Free_;
@@ -690,11 +690,11 @@ namespace {
~TThreadImpl() override = default;
- inline void WaitForStart() noexcept {
+ inline void WaitForStart() noexcept {
StartEvent_.Wait();
}
- inline void WaitForComplete() noexcept {
+ inline void WaitForComplete() noexcept {
CompleteEvent_.Wait();
}
@@ -729,7 +729,7 @@ namespace {
{
}
- ~TPoolThread() override {
+ ~TPoolThread() override {
if (Impl_) {
Impl_->WaitForStart();
}
@@ -743,7 +743,7 @@ namespace {
Impl_.Swap(impl);
}
- void DoJoin() noexcept override {
+ void DoJoin() noexcept override {
if (Impl_) {
Impl_->WaitForComplete();
Impl_ = nullptr;
diff --git a/util/thread/pool.h b/util/thread/pool.h
index f19c323bd0..d1ea3a67cb 100644
--- a/util/thread/pool.h
+++ b/util/thread/pool.h
@@ -176,9 +176,9 @@ public:
bool AddAndOwn(THolder<IObjectInQueue> obj) Y_WARN_UNUSED_RESULT;
virtual void Start(size_t threadCount, size_t queueSizeLimit = 0) = 0;
/** Wait for completion of all scheduled objects, and then exit */
- virtual void Stop() noexcept = 0;
+ virtual void Stop() noexcept = 0;
/** Number of tasks currently in queue */
- virtual size_t Size() const noexcept = 0;
+ virtual size_t Size() const noexcept = 0;
public:
/**
@@ -193,7 +193,7 @@ public:
{
}
- inline ~TTsr() {
+ inline ~TTsr() {
try {
Q_->DestroyThreadSpecificResource(Data_);
} catch (...) {
@@ -201,7 +201,7 @@ public:
}
}
- inline operator void*() noexcept {
+ inline operator void*() noexcept {
return Data_;
}
@@ -247,10 +247,10 @@ public:
void Start(size_t, size_t = 0) override {
}
- void Stop() noexcept override {
+ void Stop() noexcept override {
}
- size_t Size() const noexcept override {
+ size_t Size() const noexcept override {
return 0;
}
};
@@ -275,8 +275,8 @@ public:
* @param threadCount means "single thread" when = 0
*/
void Start(size_t threadCount, size_t queueSizeLimit = 0) override;
- void Stop() noexcept override;
- size_t Size() const noexcept override;
+ void Stop() noexcept override;
+ size_t Size() const noexcept override;
size_t GetThreadCountExpected() const noexcept;
size_t GetThreadCountReal() const noexcept;
size_t GetMaxQueueSize() const noexcept;
@@ -305,8 +305,8 @@ public:
bool Add(IObjectInQueue* obj) override Y_WARN_UNUSED_RESULT;
/** @param thrnum, @param maxque are ignored */
void Start(size_t thrnum = 0, size_t maxque = 0) override;
- void Stop() noexcept override;
- size_t Size() const noexcept override;
+ void Stop() noexcept override;
+ size_t Size() const noexcept override;
private:
class TImpl;
@@ -325,8 +325,8 @@ public:
* SetMaxIdleTime interval parameter. if thrnum is not 0, use non-blocking TThreadPool
*/
void Start(size_t thrnum, size_t maxque = 0) override;
- void Stop() noexcept override;
- size_t Size() const noexcept override;
+ void Stop() noexcept override;
+ size_t Size() const noexcept override;
private:
THolder<IThreadPool> Slave_;
@@ -337,7 +337,7 @@ private:
* from IThreadPool and implement them using functions with same name from
* pointer to TSlave.
*/
-template <class TQueueType, class TSlave>
+template <class TQueueType, class TSlave>
class TThreadPoolBinder: public TQueueType {
public:
inline TThreadPoolBinder(TSlave* slave)
diff --git a/util/thread/pool_ut.cpp b/util/thread/pool_ut.cpp
index 71413f4abc..893770d0c4 100644
--- a/util/thread/pool_ut.cpp
+++ b/util/thread/pool_ut.cpp
@@ -82,10 +82,10 @@ public:
void Start(size_t, size_t) override {
}
- void Stop() noexcept override {
+ void Stop() noexcept override {
}
- size_t Size() const noexcept override {
+ size_t Size() const noexcept override {
return 0;
}
};
diff --git a/util/ya.make b/util/ya.make
index d3051cb270..6ebe7e40cf 100644
--- a/util/ya.make
+++ b/util/ya.make
@@ -26,7 +26,7 @@ JOIN_SRCS(
datetime/constants.cpp
datetime/cputimer.cpp
datetime/systime.cpp
- datetime/uptime.cpp
+ datetime/uptime.cpp
)
SRCS(
@@ -85,7 +85,7 @@ JOIN_SRCS(
generic/scope.cpp
generic/adaptor.cpp
generic/algorithm.cpp
- generic/array_ref.cpp
+ generic/array_ref.cpp
generic/array_size.cpp
generic/bitmap.cpp
generic/bitops.cpp
@@ -306,7 +306,7 @@ JOIN_SRCS(
system/sanitizers.cpp
system/sem.cpp
system/shellcommand.cpp
- system/shmat.cpp
+ system/shmat.cpp
system/sigset.cpp
system/spinlock.cpp
system/spin_wait.cpp
diff --git a/util/ysafeptr.h b/util/ysafeptr.h
index 3f5829b8a0..af7dfd4bed 100644
--- a/util/ysafeptr.h
+++ b/util/ysafeptr.h
@@ -212,8 +212,8 @@ protected: \
private:
#define OBJECT_NOCOPY_METHODS(classname) OBJECT_METHODS(classname)
#define BASIC_REGISTER_CLASS(classname) \
- Y_PRAGMA_DIAGNOSTIC_PUSH \
- Y_PRAGMA_NO_UNUSED_FUNCTION \
+ Y_PRAGMA_DIAGNOSTIC_PUSH \
+ Y_PRAGMA_NO_UNUSED_FUNCTION \
template <> \
IObjectBase* CastToObjectBaseImpl<classname>(classname * p, void*) { \
return p; \
@@ -222,7 +222,7 @@ private:
classname* CastToUserObjectImpl<classname>(IObjectBase * p, classname*, void*) { \
return dynamic_cast<classname*>(p); \
} \
- Y_PRAGMA_DIAGNOSTIC_POP
+ Y_PRAGMA_DIAGNOSTIC_POP
////////////////////////////////////////////////////////////////////////////////////////////////////
template <class TUserObj>
diff --git a/util/ysaveload.h b/util/ysaveload.h
index e85fbfdc85..02efb4049b 100644
--- a/util/ysaveload.h
+++ b/util/ysaveload.h
@@ -2,7 +2,7 @@
#include <util/generic/fwd.h>
#include <util/generic/strbuf.h>
-#include <util/generic/string.h>
+#include <util/generic/string.h>
#include <util/generic/yexception.h>
#include <util/generic/typetraits.h>
#include <util/generic/algorithm.h>
@@ -347,7 +347,7 @@ public:
};
template <class T, class A>
-class TSerializer<TVector<T, A>>: public TVectorSerializer<TVector<T, A>> {
+class TSerializer<TVector<T, A>>: public TVectorSerializer<TVector<T, A>> {
};
template <class T, class A>
@@ -355,7 +355,7 @@ class TSerializer<std::vector<T, A>>: public TVectorSerializer<std::vector<T, A>
};
template <class T, class A>
-class TSerializer<TList<T, A>>: public TVectorSerializer<TList<T, A>> {
+class TSerializer<TList<T, A>>: public TVectorSerializer<TList<T, A>> {
};
template <class T, class A>
@@ -363,11 +363,11 @@ class TSerializer<std::list<T, A>>: public TVectorSerializer<std::list<T, A>> {
};
template <>
-class TSerializer<TString>: public TVectorSerializer<TString> {
+class TSerializer<TString>: public TVectorSerializer<TString> {
};
template <>
-class TSerializer<TUtf16String>: public TVectorSerializer<TUtf16String> {
+class TSerializer<TUtf16String>: public TVectorSerializer<TUtf16String> {
};
template <class TChar>
@@ -375,7 +375,7 @@ class TSerializer<std::basic_string<TChar>>: public TVectorSerializer<std::basic
};
template <class T, class A>
-class TSerializer<TDeque<T, A>>: public TVectorSerializer<TDeque<T, A>> {
+class TSerializer<TDeque<T, A>>: public TVectorSerializer<TDeque<T, A>> {
};
template <class T, class A>
@@ -482,12 +482,12 @@ public:
}
};
-template <class TSetType, class TValue>
-class TSetSerializerInserter<TSetType, TValue, true>: public TSetSerializerInserterBase<TSetType, TValue> {
- using TBase = TSetSerializerInserterBase<TSetType, TValue>;
+template <class TSetType, class TValue>
+class TSetSerializerInserter<TSetType, TValue, true>: public TSetSerializerInserterBase<TSetType, TValue> {
+ using TBase = TSetSerializerInserterBase<TSetType, TValue>;
public:
- inline TSetSerializerInserter(TSetType& s, size_t cnt)
+ inline TSetSerializerInserter(TSetType& s, size_t cnt)
: TBase(s)
{
Y_UNUSED(cnt);
@@ -499,16 +499,16 @@ public:
}
private:
- typename TSetType::iterator P_;
+ typename TSetType::iterator P_;
};
template <class T1, class T2, class T3, class T4, class T5, class TValue>
-class TSetSerializerInserter<THashMap<T1, T2, T3, T4, T5>, TValue, false>: public TSetSerializerInserterBase<THashMap<T1, T2, T3, T4, T5>, TValue> {
- using TMapType = THashMap<T1, T2, T3, T4, T5>;
- using TBase = TSetSerializerInserterBase<TMapType, TValue>;
+class TSetSerializerInserter<THashMap<T1, T2, T3, T4, T5>, TValue, false>: public TSetSerializerInserterBase<THashMap<T1, T2, T3, T4, T5>, TValue> {
+ using TMapType = THashMap<T1, T2, T3, T4, T5>;
+ using TBase = TSetSerializerInserterBase<TMapType, TValue>;
public:
- inline TSetSerializerInserter(TMapType& m, size_t cnt)
+ inline TSetSerializerInserter(TMapType& m, size_t cnt)
: TBase(m)
{
m.reserve(cnt);
@@ -516,12 +516,12 @@ public:
};
template <class T1, class T2, class T3, class T4, class T5, class TValue>
-class TSetSerializerInserter<THashMultiMap<T1, T2, T3, T4, T5>, TValue, false>: public TSetSerializerInserterBase<THashMultiMap<T1, T2, T3, T4, T5>, TValue> {
- using TMapType = THashMultiMap<T1, T2, T3, T4, T5>;
- using TBase = TSetSerializerInserterBase<TMapType, TValue>;
+class TSetSerializerInserter<THashMultiMap<T1, T2, T3, T4, T5>, TValue, false>: public TSetSerializerInserterBase<THashMultiMap<T1, T2, T3, T4, T5>, TValue> {
+ using TMapType = THashMultiMap<T1, T2, T3, T4, T5>;
+ using TBase = TSetSerializerInserterBase<TMapType, TValue>;
public:
- inline TSetSerializerInserter(TMapType& m, size_t cnt)
+ inline TSetSerializerInserter(TMapType& m, size_t cnt)
: TBase(m)
{
m.reserve(cnt);
@@ -529,29 +529,29 @@ public:
};
template <class T1, class T2, class T3, class T4, class TValue>
-class TSetSerializerInserter<THashSet<T1, T2, T3, T4>, TValue, false>: public TSetSerializerInserterBase<THashSet<T1, T2, T3, T4>, TValue> {
- using TSetType = THashSet<T1, T2, T3, T4>;
- using TBase = TSetSerializerInserterBase<TSetType, TValue>;
+class TSetSerializerInserter<THashSet<T1, T2, T3, T4>, TValue, false>: public TSetSerializerInserterBase<THashSet<T1, T2, T3, T4>, TValue> {
+ using TSetType = THashSet<T1, T2, T3, T4>;
+ using TBase = TSetSerializerInserterBase<TSetType, TValue>;
public:
- inline TSetSerializerInserter(TSetType& s, size_t cnt)
+ inline TSetSerializerInserter(TSetType& s, size_t cnt)
: TBase(s)
{
s.reserve(cnt);
}
};
-template <class TSetType, class TValue, bool sorted>
+template <class TSetType, class TValue, bool sorted>
class TSetSerializerBase {
public:
- static inline void Save(IOutputStream* rh, const TSetType& s) {
+ static inline void Save(IOutputStream* rh, const TSetType& s) {
::SaveSize(rh, s.size());
::SaveRange(rh, s.begin(), s.end());
}
- static inline void Load(IInputStream* rh, TSetType& s) {
+ static inline void Load(IInputStream* rh, TSetType& s) {
const size_t cnt = ::LoadSize(rh);
- TSetSerializerInserter<TSetType, TValue, sorted> ins(s, cnt);
+ TSetSerializerInserter<TSetType, TValue, sorted> ins(s, cnt);
TValue v;
for (size_t i = 0; i != cnt; ++i) {
@@ -561,9 +561,9 @@ public:
}
template <class TStorage>
- static inline void Load(IInputStream* rh, TSetType& s, TStorage& pool) {
+ static inline void Load(IInputStream* rh, TSetType& s, TStorage& pool) {
const size_t cnt = ::LoadSize(rh);
- TSetSerializerInserter<TSetType, TValue, sorted> ins(s, cnt);
+ TSetSerializerInserter<TSetType, TValue, sorted> ins(s, cnt);
TValue v;
for (size_t i = 0; i != cnt; ++i) {
@@ -573,16 +573,16 @@ public:
}
};
-template <class TMapType, bool sorted = false>
-struct TMapSerializer: public TSetSerializerBase<TMapType, std::pair<typename TMapType::key_type, typename TMapType::mapped_type>, sorted> {
+template <class TMapType, bool sorted = false>
+struct TMapSerializer: public TSetSerializerBase<TMapType, std::pair<typename TMapType::key_type, typename TMapType::mapped_type>, sorted> {
};
-template <class TSetType, bool sorted = false>
-struct TSetSerializer: public TSetSerializerBase<TSetType, typename TSetType::value_type, sorted> {
+template <class TSetType, bool sorted = false>
+struct TSetSerializer: public TSetSerializerBase<TSetType, typename TSetType::value_type, sorted> {
};
template <class T1, class T2, class T3, class T4>
-class TSerializer<TMap<T1, T2, T3, T4>>: public TMapSerializer<TMap<T1, T2, T3, T4>, true> {
+class TSerializer<TMap<T1, T2, T3, T4>>: public TMapSerializer<TMap<T1, T2, T3, T4>, true> {
};
template <class K, class T, class C, class A>
@@ -590,7 +590,7 @@ class TSerializer<std::map<K, T, C, A>>: public TMapSerializer<std::map<K, T, C,
};
template <class T1, class T2, class T3, class T4>
-class TSerializer<TMultiMap<T1, T2, T3, T4>>: public TMapSerializer<TMultiMap<T1, T2, T3, T4>, true> {
+class TSerializer<TMultiMap<T1, T2, T3, T4>>: public TMapSerializer<TMultiMap<T1, T2, T3, T4>, true> {
};
template <class K, class T, class C, class A>
@@ -598,15 +598,15 @@ class TSerializer<std::multimap<K, T, C, A>>: public TMapSerializer<std::multima
};
template <class T1, class T2, class T3, class T4, class T5>
-class TSerializer<THashMap<T1, T2, T3, T4, T5>>: public TMapSerializer<THashMap<T1, T2, T3, T4, T5>, false> {
+class TSerializer<THashMap<T1, T2, T3, T4, T5>>: public TMapSerializer<THashMap<T1, T2, T3, T4, T5>, false> {
};
template <class T1, class T2, class T3, class T4, class T5>
-class TSerializer<THashMultiMap<T1, T2, T3, T4, T5>>: public TMapSerializer<THashMultiMap<T1, T2, T3, T4, T5>, false> {
+class TSerializer<THashMultiMap<T1, T2, T3, T4, T5>>: public TMapSerializer<THashMultiMap<T1, T2, T3, T4, T5>, false> {
};
template <class K, class C, class A>
-class TSerializer<TSet<K, C, A>>: public TSetSerializer<TSet<K, C, A>, true> {
+class TSerializer<TSet<K, C, A>>: public TSetSerializer<TSet<K, C, A>, true> {
};
template <class K, class C, class A>
@@ -614,27 +614,27 @@ class TSerializer<std::set<K, C, A>>: public TSetSerializer<std::set<K, C, A>, t
};
template <class T1, class T2, class T3, class T4>
-class TSerializer<THashSet<T1, T2, T3, T4>>: public TSetSerializer<THashSet<T1, T2, T3, T4>, false> {
+class TSerializer<THashSet<T1, T2, T3, T4>>: public TSetSerializer<THashSet<T1, T2, T3, T4>, false> {
};
template <class T1, class T2>
-class TSerializer<TQueue<T1, T2>> {
+class TSerializer<TQueue<T1, T2>> {
public:
- static inline void Save(IOutputStream* rh, const TQueue<T1, T2>& v) {
+ static inline void Save(IOutputStream* rh, const TQueue<T1, T2>& v) {
::Save(rh, v.Container());
}
- static inline void Load(IInputStream* in, TQueue<T1, T2>& t) {
+ static inline void Load(IInputStream* in, TQueue<T1, T2>& t) {
::Load(in, t.Container());
}
};
template <class T1, class T2, class T3>
-class TSerializer<TPriorityQueue<T1, T2, T3>> {
+class TSerializer<TPriorityQueue<T1, T2, T3>> {
public:
- static inline void Save(IOutputStream* rh, const TPriorityQueue<T1, T2, T3>& v) {
+ static inline void Save(IOutputStream* rh, const TPriorityQueue<T1, T2, T3>& v) {
::Save(rh, v.Container());
}
- static inline void Load(IInputStream* in, TPriorityQueue<T1, T2, T3>& t) {
+ static inline void Load(IInputStream* in, TPriorityQueue<T1, T2, T3>& t) {
::Load(in, t.Container());
}
};
diff --git a/util/ysaveload_ut.cpp b/util/ysaveload_ut.cpp
index 11f9e665cc..723c68f391 100644
--- a/util/ysaveload_ut.cpp
+++ b/util/ysaveload_ut.cpp
@@ -10,7 +10,7 @@
#include <util/generic/set.h>
#include <util/generic/hash.h>
#include <util/generic/deque.h>
-#include <util/generic/string.h>
+#include <util/generic/string.h>
#include <util/generic/vector.h>
#include <util/generic/buffer.h>
#include <util/generic/hash_set.h>
@@ -52,11 +52,11 @@ class TSaveLoadTest: public TTestBase {
::SaveLoad(s, Str);
}
- TString Str;
+ TString Str;
};
struct TNewNewStyleHelper {
- TString Str;
+ TString Str;
ui32 Int;
Y_SAVELOAD_DEFINE(Str, Int)
@@ -64,7 +64,7 @@ class TSaveLoadTest: public TTestBase {
private:
inline void TestNewNewStyle() {
- TString ss;
+ TString ss;
{
TNewNewStyleHelper h;
@@ -89,7 +89,7 @@ private:
}
inline void TestNewStyle() {
- TString ss;
+ TString ss;
{
TNewStyleSaveHelper sh;
@@ -119,7 +119,7 @@ private:
}
{
- TVector<ui16> vec;
+ TVector<ui16> vec;
vec.push_back((ui16)1);
vec.push_back((ui16)2);
@@ -129,7 +129,7 @@ private:
}
{
- TMap<ui16, ui32> map;
+ TMap<ui16, ui32> map;
map[(ui16)1] = 2;
map[(ui16)2] = 3;
@@ -139,7 +139,7 @@ private:
}
{
- TMultiMap<ui16, ui32> multimap;
+ TMultiMap<ui16, ui32> multimap;
multimap.emplace((ui16)1, 2);
multimap.emplace((ui16)2, 3);
@@ -157,7 +157,7 @@ private:
}
{
- TString val("123456");
+ TString val("123456");
Save(&S_, val);
}
@@ -170,7 +170,7 @@ private:
}
{
- TVector<const char*> vec;
+ TVector<const char*> vec;
vec.push_back("1");
vec.push_back("123");
@@ -180,7 +180,7 @@ private:
}
{
- TDeque<ui16> deq;
+ TDeque<ui16> deq;
deq.push_back(1);
deq.push_back(2);
@@ -211,7 +211,7 @@ private:
}
{
- THashMultiMap<TString, int> mm;
+ THashMultiMap<TString, int> mm;
mm.insert({"one", 1});
mm.insert({"two", 2});
@@ -250,7 +250,7 @@ private:
}
{
- TVector<ui16> vec;
+ TVector<ui16> vec;
Load(&S_, vec);
UNIT_ASSERT_EQUAL(vec.size(), 3);
@@ -260,7 +260,7 @@ private:
}
{
- TMap<ui16, ui32> map;
+ TMap<ui16, ui32> map;
Load(&S_, map);
UNIT_ASSERT_EQUAL(map.size(), 3);
@@ -270,14 +270,14 @@ private:
}
{
- TMultiMap<ui16, ui32> multimap;
+ TMultiMap<ui16, ui32> multimap;
Load(&S_, multimap);
UNIT_ASSERT_EQUAL(multimap.size(), 5);
UNIT_ASSERT_EQUAL(multimap.find((ui16)1)->second, 2);
UNIT_ASSERT_EQUAL(multimap.find((ui16)3)->second, 6);
- THashSet<ui32> values;
+ THashSet<ui32> values;
auto range = multimap.equal_range((ui16)2);
for (auto i = range.first; i != range.second; ++i) {
values.insert(i->second);
@@ -296,7 +296,7 @@ private:
}
{
- TString val;
+ TString val;
Load(&S_, val);
UNIT_ASSERT_EQUAL(val, "123456");
@@ -311,19 +311,19 @@ private:
}
{
- TVector<const char*> vec;
+ TVector<const char*> vec;
TMemoryPool pool(1024);
Load(&S_, vec, pool);
UNIT_ASSERT_EQUAL(vec.size(), 3);
- UNIT_ASSERT_EQUAL(vec[0], TString("1"));
- UNIT_ASSERT_EQUAL(vec[1], TString("123"));
- UNIT_ASSERT_EQUAL(vec[2], TString("4567"));
+ UNIT_ASSERT_EQUAL(vec[0], TString("1"));
+ UNIT_ASSERT_EQUAL(vec[1], TString("123"));
+ UNIT_ASSERT_EQUAL(vec[2], TString("4567"));
}
{
- TDeque<ui16> deq;
+ TDeque<ui16> deq;
Load(&S_, deq);
@@ -361,7 +361,7 @@ private:
}
{
- THashMultiMap<TString, int> mm;
+ THashMultiMap<TString, int> mm;
Load(&S_, mm);
@@ -379,7 +379,7 @@ private:
void TestList() {
TBufferStream s;
- TList<int> list = {0, 1, 10};
+ TList<int> list = {0, 1, 10};
Save(&s, list);
list.clear();
@@ -421,7 +421,7 @@ private:
TestVariantImpl(v, 42);
TestVariantImpl(v, true);
TestVariantImpl(v, TString("foo"));
- TestVariantImpl(v, TVector<char>{'b', 'a', 'r'});
+ TestVariantImpl(v, TVector<char>{'b', 'a', 'r'});
v = TString("baz");
TBufferStream s;