aboutsummaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authormowgli <mowgli@yandex-team.ru>2022-02-10 16:49:25 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:49:25 +0300
commit89afbbe4ca0e02e386dd4df08f7945f190dc1b84 (patch)
treec4772201af6215d48734691b8796e4cfc77c2ac8 /util
parent7510cec1516d17cbc8d7749974e36aa45f547a26 (diff)
downloadydb-89afbbe4ca0e02e386dd4df08f7945f190dc1b84.tar.gz
Restoring authorship annotation for <mowgli@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'util')
-rw-r--r--util/charset/unidata.h28
-rw-r--r--util/charset/wide.h16
-rw-r--r--util/charset/wide_ut.cpp2
-rw-r--r--util/folder/path.cpp34
-rw-r--r--util/folder/path.h10
-rw-r--r--util/folder/path_ut.cpp38
-rw-r--r--util/generic/algorithm.h38
-rw-r--r--util/generic/buffer.cpp14
-rw-r--r--util/generic/buffer.h4
-rw-r--r--util/generic/buffer_ut.cpp22
-rw-r--r--util/generic/deque.h4
-rw-r--r--util/generic/deque_ut.cpp8
-rw-r--r--util/generic/hash_ut.cpp22
-rw-r--r--util/generic/map.h14
-rw-r--r--util/generic/map_ut.cpp6
-rw-r--r--util/generic/ptr.h92
-rw-r--r--util/generic/ptr_ut.cpp300
-rw-r--r--util/generic/queue.h16
-rw-r--r--util/generic/queue_ut.cpp8
-rw-r--r--util/generic/set.h14
-rw-r--r--util/generic/strbase.h2
-rw-r--r--util/generic/strbuf.h72
-rw-r--r--util/generic/strbuf_ut.cpp98
-rw-r--r--util/generic/string.cpp8
-rw-r--r--util/generic/string.h4
-rw-r--r--util/generic/string_transparent_hash_ut.cpp2
-rw-r--r--util/generic/string_ut.cpp90
-rw-r--r--util/generic/string_ut.h2
-rw-r--r--util/generic/vector.h6
-rw-r--r--util/stream/input.cpp2
-rw-r--r--util/string/join.h42
-rw-r--r--util/string/join_ut.cpp44
-rw-r--r--util/string/strip.h90
-rw-r--r--util/string/strip_ut.cpp14
-rw-r--r--util/string/vector.cpp4
-rw-r--r--util/ysaveload.h48
36 files changed, 609 insertions, 609 deletions
diff --git a/util/charset/unidata.h b/util/charset/unidata.h
index 400d314186..4cef3b0039 100644
--- a/util/charset/unidata.h
+++ b/util/charset/unidata.h
@@ -200,13 +200,13 @@ inline bool IsQuotation(wchar32 ch) {
SHIFT(Pf_QUOTE) | SHIFT(Po_SINGLE_QUOTE) | SHIFT(Ps_SINGLE_QUOTE) |
SHIFT(Pe_SINGLE_QUOTE) | SHIFT(Pi_SINGLE_QUOTE) | SHIFT(Pf_SINGLE_QUOTE));
}
-
-inline bool IsSingleQuotation(wchar32 ch) {
- return NUnicode::CharHasType(ch,
+
+inline bool IsSingleQuotation(wchar32 ch) {
+ return NUnicode::CharHasType(ch,
SHIFT(Po_SINGLE_QUOTE) | SHIFT(Ps_SINGLE_QUOTE) | SHIFT(Pe_SINGLE_QUOTE) |
SHIFT(Pi_SINGLE_QUOTE) | SHIFT(Pf_SINGLE_QUOTE));
-}
-
+}
+
inline bool IsTerminal(wchar32 ch) {
return NUnicode::CharHasType(ch, SHIFT(Po_TERMINAL));
}
@@ -381,15 +381,15 @@ inline bool IsXdigit(wchar32 ch) {
inline bool IsDigit(wchar32 ch) {
return IsDecdigit(ch);
}
-
-inline bool IsCommonDigit(wchar32 ch) {
- // IsDigit returns true for some exotic symbols like "VAI DIGIT TWO" (U+A622)
- // and cannot be used safely with FromString() convertors
- const wchar32 ZERO = '0';
- const wchar32 NINE = '9';
- return ch >= ZERO && ch <= NINE;
-}
-
+
+inline bool IsCommonDigit(wchar32 ch) {
+ // IsDigit returns true for some exotic symbols like "VAI DIGIT TWO" (U+A622)
+ // and cannot be used safely with FromString() convertors
+ const wchar32 ZERO = '0';
+ const wchar32 NINE = '9';
+ return ch >= ZERO && ch <= NINE;
+}
+
inline bool IsGraph(wchar32 ch) {
return IsAlnum(ch) || IsPunct(ch) || IsSymbol(ch);
}
diff --git a/util/charset/wide.h b/util/charset/wide.h
index 04e6928aab..86433fbef1 100644
--- a/util/charset/wide.h
+++ b/util/charset/wide.h
@@ -353,8 +353,8 @@ inline TWtringBuf UTF8ToWide(const TStringBuf src, TUtf16String& dst) {
UTF8ToWideImpl<robust>(src.data(), src.size(), dst.begin(), written);
dst.resize(written);
return dst;
-}
-
+}
+
//! if not robust will stop at first error position
template <bool robust>
inline TUtf32StringBuf UTF8ToUTF32(const TStringBuf src, TUtf32String& dst) {
@@ -371,8 +371,8 @@ inline TWtringBuf UTF8ToWide(const TStringBuf src, TUtf16String& dst) {
inline TUtf16String UTF8ToWide(const char* text, size_t len) {
return UTF8ToWide<false>(text, len);
-}
-
+}
+
template <bool robust>
inline TUtf16String UTF8ToWide(const TStringBuf s) {
return UTF8ToWide<robust>(s.data(), s.size());
@@ -387,8 +387,8 @@ inline TUtf32String UTF8ToUTF32(const TStringBuf s) {
inline TUtf16String UTF8ToWide(const TStringBuf s) {
return UTF8ToWide<false>(s.data(), s.size());
-}
-
+}
+
//! converts text from unicode to UTF8
//! @attention destination buffer must be long enough to fit all characters of the text,
//! @c WriteUTF8Char converts @c wchar32 into maximum 4 bytes of UTF8 so
@@ -417,8 +417,8 @@ inline TStringBuf WideToUTF8(const TWtringBuf src, TString& dst) {
Y_ASSERT(dst.size() >= written);
dst.remove(written);
return dst;
-}
-
+}
+
inline TString WideToUTF8(const wchar16* text, size_t len) {
TString s = TString::Uninitialized(WideToUTF8BufferSize(len));
size_t written = 0;
diff --git a/util/charset/wide_ut.cpp b/util/charset/wide_ut.cpp
index d8f3233e73..f7aaa64049 100644
--- a/util/charset/wide_ut.cpp
+++ b/util/charset/wide_ut.cpp
@@ -6,7 +6,7 @@
#include <util/string/reverse.h>
#include <algorithm>
-
+
namespace {
//! three UTF8 encoded russian letters (A, B, V)
const char utext[] = "\xd0\x90\xd0\x91\xd0\x92";
diff --git a/util/folder/path.cpp b/util/folder/path.cpp
index bfe0c67d68..8ee93ef621 100644
--- a/util/folder/path.cpp
+++ b/util/folder/path.cpp
@@ -26,13 +26,13 @@ bool TFsPath::IsSubpathOf(const TFsPath& that) const {
const TSplit& rsplit = that.GetSplit();
if (rsplit.IsAbsolute != split.IsAbsolute) {
- return false;
+ return false;
}
-
+
if (rsplit.Drive != split.Drive) {
- return false;
+ return false;
}
-
+
if (rsplit.size() >= split.size()) {
return false;
}
@@ -102,9 +102,9 @@ TFsPath TFsPath::RelativePath(const TFsPath& root) const {
TFsPath TFsPath::Parent() const {
if (!IsDefined()) {
- return TFsPath();
+ return TFsPath();
}
-
+
TSplit split = GetSplit();
if (split.size()) {
split.pop_back();
@@ -116,16 +116,16 @@ TFsPath TFsPath::Parent() const {
}
TFsPath& TFsPath::operator/=(const TFsPath& that) {
- if (!IsDefined()) {
- *this = that;
-
- } else if (that.IsDefined() && that.GetPath() != ".") {
+ if (!IsDefined()) {
+ *this = that;
+
+ } else if (that.IsDefined() && that.GetPath() != ".") {
if (!that.IsRelative()) {
ythrow TIoException() << "path should be relative: " << that.GetPath();
}
- TSplit split = GetSplit();
- const TSplit& rsplit = that.GetSplit();
+ TSplit split = GetSplit();
+ const TSplit& rsplit = that.GetSplit();
split.insert(split.end(), rsplit.begin(), rsplit.end());
*this = TFsPath(split.Reconstruct());
}
@@ -144,8 +144,8 @@ TString TFsPath::GetName() const {
return TString();
}
- const TSplit& split = GetSplit();
-
+ const TSplit& split = GetSplit();
+
if (split.size() > 0) {
if (split.back() != "..") {
return TString(split.back());
@@ -214,7 +214,7 @@ TFsPath TFsPath::Child(const TString& name) const {
if (!name) {
ythrow TIoException() << "child name must not be empty";
}
-
+
return *this / name;
}
@@ -353,9 +353,9 @@ bool TFsPath::IsSymlink() const {
void TFsPath::DeleteIfExists() const {
if (!IsDefined()) {
- return;
+ return;
}
-
+
::unlink(this->c_str());
::rmdir(this->c_str());
if (Exists()) {
diff --git a/util/folder/path.h b/util/folder/path.h
index 2fb4d6b4ef..9bfc5a0416 100644
--- a/util/folder/path.h
+++ b/util/folder/path.h
@@ -39,11 +39,11 @@ public:
inline bool IsDefined() const {
return Path_.length() > 0;
}
-
- inline explicit operator bool() const {
- return IsDefined();
- }
-
+
+ inline explicit operator bool() const {
+ return IsDefined();
+ }
+
inline const char* c_str() const {
return Path_.c_str();
}
diff --git a/util/folder/path_ut.cpp b/util/folder/path_ut.cpp
index e6a3451016..9931d1ddf8 100644
--- a/util/folder/path_ut.cpp
+++ b/util/folder/path_ut.cpp
@@ -1,5 +1,5 @@
#include "path.h"
-#include "pathsplit.h"
+#include "pathsplit.h"
#include "dirut.h"
#include "tempdir.h"
@@ -103,18 +103,18 @@ Y_UNIT_TEST_SUITE(TFsPathTests) {
UNIT_ASSERT_VALUES_EQUAL(TFsPath("/etc/passwd").Parent(), TFsPath("/etc"));
UNIT_ASSERT_VALUES_EQUAL(TFsPath("/etc").Parent(), TFsPath("/"));
UNIT_ASSERT_VALUES_EQUAL(TFsPath("/").Parent(), TFsPath("/"));
-
+
UNIT_ASSERT_VALUES_EQUAL(TFsPath("etc/passwd").Parent(), TFsPath("etc"));
UNIT_ASSERT_VALUES_EQUAL(TFsPath("etc").Parent(), TFsPath("."));
UNIT_ASSERT_VALUES_EQUAL(TFsPath("./etc").Parent(), TFsPath("."));
#endif
-
-#if 0
+
+#if 0
UNIT_ASSERT_VALUES_EQUAL(TFsPath("./etc/passwd").Parent(), TFsPath("./etc"));
UNIT_ASSERT_VALUES_EQUAL(TFsPath("./").Parent(), TFsPath(".."));
UNIT_ASSERT_VALUES_EQUAL(TFsPath(".").Parent(), TFsPath(".."));
UNIT_ASSERT_VALUES_EQUAL(TFsPath("..").Parent(), TFsPath("../.."));
-#endif
+#endif
}
Y_UNIT_TEST(GetName) {
@@ -269,30 +269,30 @@ Y_UNIT_TEST_SUITE(TFsPathTests) {
Y_UNIT_TEST(TestSubpathOf) {
UNIT_ASSERT(TFsPath("/a/b/c/d").IsSubpathOf("/a/b"));
-
+
UNIT_ASSERT(TFsPath("/a").IsSubpathOf("/"));
UNIT_ASSERT(!TFsPath("/").IsSubpathOf("/a"));
UNIT_ASSERT(!TFsPath("/a").IsSubpathOf("/a"));
-
+
UNIT_ASSERT(TFsPath("/a/b").IsSubpathOf("/a"));
UNIT_ASSERT(TFsPath("a/b").IsSubpathOf("a"));
UNIT_ASSERT(!TFsPath("/a/b").IsSubpathOf("/b"));
UNIT_ASSERT(!TFsPath("a/b").IsSubpathOf("b"));
-
+
// mixing absolute/relative
UNIT_ASSERT(!TFsPath("a").IsSubpathOf("/"));
UNIT_ASSERT(!TFsPath("a").IsSubpathOf("/a"));
UNIT_ASSERT(!TFsPath("/a").IsSubpathOf("a"));
UNIT_ASSERT(!TFsPath("a/b").IsSubpathOf("/a"));
UNIT_ASSERT(!TFsPath("/a/b").IsSubpathOf("a"));
-
-#ifdef _win_
+
+#ifdef _win_
UNIT_ASSERT(TFsPath("x:/a/b").IsSubpathOf("x:/a"));
UNIT_ASSERT(!TFsPath("x:/a/b").IsSubpathOf("y:/a"));
UNIT_ASSERT(!TFsPath("x:/a/b").IsSubpathOf("a"));
-#endif
+#endif
}
-
+
Y_UNIT_TEST(TestNonStrictSubpathOf) {
UNIT_ASSERT(TFsPath("/a/b/c/d").IsNonStrictSubpathOf("/a/b"));
@@ -348,7 +348,7 @@ Y_UNIT_TEST_SUITE(TFsPathTests) {
Y_UNIT_TEST(TestUndefined) {
UNIT_ASSERT_VALUES_EQUAL(TFsPath(), TFsPath(""));
UNIT_ASSERT_VALUES_EQUAL(TFsPath(), TFsPath().Fix());
-
+
UNIT_ASSERT_VALUES_EQUAL(TFsPath() / TFsPath(), TFsPath());
#ifdef _win_
UNIT_ASSERT_VALUES_EQUAL(TFsPath("a\\b"), TFsPath() / TString("a\\b"));
@@ -363,20 +363,20 @@ Y_UNIT_TEST_SUITE(TFsPathTests) {
#endif
UNIT_ASSERT_VALUES_EQUAL(TFsPath("."), TFsPath() / ".");
UNIT_ASSERT_VALUES_EQUAL(TFsPath("."), "." / TFsPath());
-
+
UNIT_ASSERT(TFsPath().PathSplit().empty());
UNIT_ASSERT(!TFsPath().PathSplit().IsAbsolute);
UNIT_ASSERT(TFsPath().IsRelative()); // undefined path is relative
-
+
UNIT_ASSERT_VALUES_EQUAL(TFsPath().GetPath(), "");
UNIT_ASSERT_VALUES_EQUAL(TFsPath().GetName(), "");
UNIT_ASSERT_VALUES_EQUAL(TFsPath().GetExtension(), "");
-
+
UNIT_ASSERT_VALUES_EQUAL(TFsPath().Parent(), TFsPath());
UNIT_ASSERT_VALUES_EQUAL(TFsPath().Child("a"), TFsPath("a"));
UNIT_ASSERT_VALUES_EQUAL(TFsPath().Basename(), "");
UNIT_ASSERT_VALUES_EQUAL(TFsPath().Dirname(), "");
-
+
UNIT_ASSERT(!TFsPath().IsSubpathOf("a/b"));
UNIT_ASSERT(TFsPath().IsContainerOf("a/b"));
UNIT_ASSERT(!TFsPath().IsContainerOf("/a/b"));
@@ -385,14 +385,14 @@ Y_UNIT_TEST_SUITE(TFsPathTests) {
#else
UNIT_ASSERT_VALUES_EQUAL(TFsPath("a/b").RelativeTo(TFsPath()), TFsPath("a/b"));
#endif
-
+
UNIT_ASSERT(!TFsPath().Exists());
UNIT_ASSERT(!TFsPath().IsFile());
UNIT_ASSERT(!TFsPath().IsDirectory());
TFileStat stat;
UNIT_ASSERT(!TFsPath().Stat(stat));
}
-
+
Y_UNIT_TEST(TestJoinFsPaths) {
#ifdef _win_
UNIT_ASSERT_VALUES_EQUAL(JoinFsPaths("a\\b", "c\\d"), "a\\b\\c\\d");
diff --git a/util/generic/algorithm.h b/util/generic/algorithm.h
index badfb88993..92fd66b8fb 100644
--- a/util/generic/algorithm.h
+++ b/util/generic/algorithm.h
@@ -637,7 +637,7 @@ template <class T, class V>
inline typename std::iterator_traits<T>::difference_type Count(T first, T last, const V& value) {
return std::count(first, last, value);
}
-
+
template <class TContainer, class TValue>
static inline auto Count(const TContainer& container, const TValue& value) {
return Count(std::cbegin(container), std::cend(container), value);
@@ -658,13 +658,13 @@ static inline auto CountIf(const C& c, P pred) {
template <class I1, class I2>
static inline std::pair<I1, I2> Mismatch(I1 b1, I1 e1, I2 b2) {
return std::mismatch(b1, e1, b2);
-}
-
+}
+
template <class I1, class I2, class P>
static inline std::pair<I1, I2> Mismatch(I1 b1, I1 e1, I2 b2, P p) {
return std::mismatch(b1, e1, b2, p);
-}
-
+}
+
template <class RandomIterator>
static inline void NthElement(RandomIterator begin, RandomIterator nth, RandomIterator end) {
std::nth_element(begin, nth, end);
@@ -675,30 +675,30 @@ static inline void NthElement(RandomIterator begin, RandomIterator nth, RandomIt
std::nth_element(begin, nth, end, compare);
}
-// no standard implementation until C++14
+// no standard implementation until C++14
template <class I1, class I2>
static inline std::pair<I1, I2> Mismatch(I1 b1, I1 e1, I2 b2, I2 e2) {
- while (b1 != e1 && b2 != e2 && *b1 == *b2) {
- ++b1;
- ++b2;
- }
+ while (b1 != e1 && b2 != e2 && *b1 == *b2) {
+ ++b1;
+ ++b2;
+ }
return std::make_pair(b1, b2);
-}
-
+}
+
template <class I1, class I2, class P>
static inline std::pair<I1, I2> Mismatch(I1 b1, I1 e1, I2 b2, I2 e2, P p) {
- while (b1 != e1 && b2 != e2 && p(*b1, *b2)) {
- ++b1;
- ++b2;
- }
+ while (b1 != e1 && b2 != e2 && p(*b1, *b2)) {
+ ++b1;
+ ++b2;
+ }
return std::make_pair(b1, b2);
-}
-
+}
+
template <class It, class Val>
static inline bool BinarySearch(It begin, It end, const Val& val) {
return std::binary_search(begin, end, val);
}
-
+
template <class It, class Val, class Comp>
static inline bool BinarySearch(It begin, It end, const Val& val, Comp comp) {
return std::binary_search(begin, end, val, comp);
diff --git a/util/generic/buffer.cpp b/util/generic/buffer.cpp
index b92697e1d0..f8d5d840fb 100644
--- a/util/generic/buffer.cpp
+++ b/util/generic/buffer.cpp
@@ -73,18 +73,18 @@ void TBuffer::Fill(char ch, size_t len) {
}
void TBuffer::DoReserve(size_t realLen) {
- // FastClp2<T>(x) returns 0 on x from [Max<T>/2 + 2, Max<T>]
- const size_t len = Max<size_t>(FastClp2(realLen), realLen);
+ // FastClp2<T>(x) returns 0 on x from [Max<T>/2 + 2, Max<T>]
+ const size_t len = Max<size_t>(FastClp2(realLen), realLen);
Y_ASSERT(realLen > Len_);
Y_ASSERT(len >= realLen);
- Realloc(len);
-}
-
-void TBuffer::Realloc(size_t len) {
+ Realloc(len);
+}
+
+void TBuffer::Realloc(size_t len) {
Y_ASSERT(Pos_ <= len);
-
+
Data_ = (char*)y_reallocate(Data_, len);
Len_ = len;
}
diff --git a/util/generic/buffer.h b/util/generic/buffer.h
index 9576467404..358566feda 100644
--- a/util/generic/buffer.h
+++ b/util/generic/buffer.h
@@ -154,9 +154,9 @@ public:
inline void ShrinkToFit() {
if (Pos_ < Len_) {
Realloc(Pos_);
- }
+ }
}
-
+
inline void Resize(size_t len) {
Reserve(len);
Pos_ = len;
diff --git a/util/generic/buffer_ut.cpp b/util/generic/buffer_ut.cpp
index 437d7122ec..af77143215 100644
--- a/util/generic/buffer_ut.cpp
+++ b/util/generic/buffer_ut.cpp
@@ -74,46 +74,46 @@ Y_UNIT_TEST_SUITE(TBufferTest) {
buf.Reserve(4);
UNIT_ASSERT_EQUAL(buf.Capacity(), 4);
-
+
buf.Reserve(6);
UNIT_ASSERT_EQUAL(buf.Capacity(), 8);
-
+
buf.Reserve(32);
UNIT_ASSERT_EQUAL(buf.Capacity(), 32);
-
+
buf.Reserve(33);
UNIT_ASSERT_EQUAL(buf.Capacity(), 64);
buf.Reserve(64);
UNIT_ASSERT_EQUAL(buf.Capacity(), 64);
-
+
buf.Resize(128);
UNIT_ASSERT_EQUAL(buf.Capacity(), 128);
-
+
buf.Append('a');
UNIT_ASSERT_EQUAL(buf.Capacity(), 256);
TString tmp1 = "abcdef";
buf.Append(tmp1.data(), tmp1.size());
UNIT_ASSERT_EQUAL(buf.Capacity(), 256);
-
+
TString tmp2 = "30498290sfokdsflj2308w";
buf.Resize(1020);
buf.Append(tmp2.data(), tmp2.size());
UNIT_ASSERT_EQUAL(buf.Capacity(), 2048);
}
-
+
Y_UNIT_TEST(TestShrinkToFit) {
TBuffer buf;
-
+
TString content = "some text";
buf.Append(content.data(), content.size());
UNIT_ASSERT_EQUAL(buf.Size(), 9);
UNIT_ASSERT_EQUAL(buf.Capacity(), 16);
-
+
buf.ShrinkToFit();
UNIT_ASSERT_EQUAL(buf.Size(), 9);
UNIT_ASSERT_EQUAL(buf.Capacity(), 9);
UNIT_ASSERT_EQUAL(TString(buf.data(), buf.size()), content);
-
+
const size_t MB = 1024 * 1024;
buf.Resize(MB);
UNIT_ASSERT_EQUAL(buf.Capacity(), MB);
@@ -124,7 +124,7 @@ Y_UNIT_TEST_SUITE(TBufferTest) {
buf.ShrinkToFit();
UNIT_ASSERT_EQUAL(buf.Capacity(), MB + 100);
}
-
+
#if 0
Y_UNIT_TEST(TestAlignUp) {
char content[] = "some text";
diff --git a/util/generic/deque.h b/util/generic/deque.h
index 2dabaf3177..52d9219c7b 100644
--- a/util/generic/deque.h
+++ b/util/generic/deque.h
@@ -20,6 +20,6 @@ public:
}
inline explicit operator bool() const noexcept {
- return !this->empty();
- }
+ return !this->empty();
+ }
};
diff --git a/util/generic/deque_ut.cpp b/util/generic/deque_ut.cpp
index 93bf50fa92..5ec55c31fc 100644
--- a/util/generic/deque_ut.cpp
+++ b/util/generic/deque_ut.cpp
@@ -67,15 +67,15 @@ void TDequeTest::TestConstructorsAndAssignments() {
void TDequeTest::TestDeque1() {
TDeque<int> d;
- UNIT_ASSERT(!d);
-
+ UNIT_ASSERT(!d);
+
d.push_back(4);
d.push_back(9);
d.push_back(16);
d.push_front(1);
- UNIT_ASSERT(d);
-
+ UNIT_ASSERT(d);
+
UNIT_ASSERT(d[0] == 1);
UNIT_ASSERT(d[1] == 4);
UNIT_ASSERT(d[2] == 9);
diff --git a/util/generic/hash_ut.cpp b/util/generic/hash_ut.cpp
index 0551d58770..ad71298e8a 100644
--- a/util/generic/hash_ut.cpp
+++ b/util/generic/hash_ut.cpp
@@ -691,20 +691,20 @@ void THashTest::TestResizeOnInsertSmartPtrBug() {
UNIT_ASSERT_EQUAL(item.Key, "key8");
UNIT_ASSERT_EQUAL(item.Value, "value8");
}
-
-template <typename T>
-static void EmptyAndInsertTest(typename T::value_type v) {
- T c;
- UNIT_ASSERT(!c);
- c.insert(v);
- UNIT_ASSERT(c);
-}
-
-void THashTest::TestEmpty() {
+
+template <typename T>
+static void EmptyAndInsertTest(typename T::value_type v) {
+ T c;
+ UNIT_ASSERT(!c);
+ c.insert(v);
+ UNIT_ASSERT(c);
+}
+
+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));
-}
+}
void THashTest::TestDefaultConstructor() {
THashSet<int> set;
diff --git a/util/generic/map.h b/util/generic/map.h
index b5001b56c0..56449b442a 100644
--- a/util/generic/map.h
+++ b/util/generic/map.h
@@ -18,10 +18,10 @@ class TMap: public std::map<K, V, Less, TReboundAllocator<A, std::pair<const K,
public:
using TBase::TBase;
- inline explicit operator bool() const noexcept {
- return !this->empty();
- }
-
+ inline explicit operator bool() const noexcept {
+ return !this->empty();
+ }
+
inline bool contains(const K& key) const {
return this->find(key) != this->end();
}
@@ -34,9 +34,9 @@ class TMultiMap: public std::multimap<K, V, Less, TReboundAllocator<A, std::pair
public:
using TBase::TBase;
- inline explicit operator bool() const noexcept {
- return !this->empty();
- }
+ inline explicit operator bool() const noexcept {
+ return !this->empty();
+ }
inline bool contains(const K& key) const {
return this->find(key) != this->end();
diff --git a/util/generic/map_ut.cpp b/util/generic/map_ut.cpp
index 79e832b024..6d57f61600 100644
--- a/util/generic/map_ut.cpp
+++ b/util/generic/map_ut.cpp
@@ -389,7 +389,7 @@ Y_UNIT_TEST_SUITE(TYMapTest) {
UNIT_ASSERT(ccont.equal_range(2) != std::make_pair(ccont.begin(), ccont.end()));
}
}
-
+
template <typename T>
static void EmptyAndInsertTest(typename T::value_type v) {
T c;
@@ -397,7 +397,7 @@ Y_UNIT_TEST_SUITE(TYMapTest) {
c.insert(v);
UNIT_ASSERT(c);
}
-
+
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));
@@ -493,4 +493,4 @@ Y_UNIT_TEST_SUITE(TYMapTest) {
UNIT_ASSERT(movedM.contains(0));
UNIT_ASSERT_VALUES_EQUAL(1, movedM[0]);
}
-}
+}
diff --git a/util/generic/ptr.h b/util/generic/ptr.h
index 19db0e3ec5..731930a2ed 100644
--- a/util/generic/ptr.h
+++ b/util/generic/ptr.h
@@ -294,7 +294,7 @@ public:
inline void Reset(TAutoPtr<T, D> t) noexcept {
Reset(t.Release());
}
-
+
inline void Reset() noexcept {
Destroy();
}
@@ -1054,50 +1054,50 @@ private:
T* T_;
};
-// Copy-on-write pointer
+// Copy-on-write pointer
template <class TPtr, class TCopy>
-class TCowPtr: public TPointerBase<TCowPtr<TPtr, TCopy>, const typename TPtr::TValueType> {
+class TCowPtr: public TPointerBase<TCowPtr<TPtr, TCopy>, const typename TPtr::TValueType> {
using T = typename TPtr::TValueType;
-public:
+public:
inline TCowPtr() = default;
-
- inline TCowPtr(const TPtr& p)
- : T_(p)
- {
- }
-
- inline TCowPtr(T* p)
- : T_(p)
- {
- }
-
+
+ inline TCowPtr(const TPtr& p)
+ : T_(p)
+ {
+ }
+
+ inline TCowPtr(T* p)
+ : T_(p)
+ {
+ }
+
inline const T* Get() const noexcept {
- return Const();
- }
-
+ return Const();
+ }
+
inline const T* Const() const noexcept {
- return T_.Get();
- }
-
+ return T_.Get();
+ }
+
inline T* Mutable() {
- Unshare();
-
- return T_.Get();
- }
-
+ Unshare();
+
+ return T_.Get();
+ }
+
inline bool Shared() const noexcept {
- return T_.RefCount() > 1;
- }
-
+ return T_.RefCount() > 1;
+ }
+
inline void Swap(TCowPtr& r) noexcept {
- T_.Swap(r.T_);
- }
-
- inline void Reset(TCowPtr p) {
- p.Swap(*this);
- }
-
+ T_.Swap(r.T_);
+ }
+
+ inline void Reset(TCowPtr p) {
+ p.Swap(*this);
+ }
+
inline void Reset() {
T_.Reset();
}
@@ -1108,17 +1108,17 @@ public:
return (p == Get());
}
#endif
-private:
+private:
inline void Unshare() {
- if (Shared()) {
- Reset(TCopy::Copy(T_.Get()));
- }
- }
-
-private:
- TPtr T_;
-};
-
+ if (Shared()) {
+ Reset(TCopy::Copy(T_.Get()));
+ }
+ }
+
+private:
+ TPtr T_;
+};
+
// saves .Get() on argument passing. Intended usage: Func(TPtrArg<X> p); ... TIntrusivePtr<X> p2; Func(p2);
template <class T>
class TPtrArg {
diff --git a/util/generic/ptr_ut.cpp b/util/generic/ptr_ut.cpp
index c2dcff23f6..3997527746 100644
--- a/util/generic/ptr_ut.cpp
+++ b/util/generic/ptr_ut.cpp
@@ -363,7 +363,7 @@ void TPointerTest::TestIntrPtr() {
}
UNIT_ASSERT_VALUES_EQUAL(TOp::Cnt, 0);
}
-
+
namespace NTestIntrusiveConvertion {
struct TA: public TSimpleRefCount<TA> {
};
@@ -429,197 +429,197 @@ void TPointerTest::TestMakeIntrusive() {
void TPointerTest::TestCopyOnWritePtr1() {
using TPtr = TCowPtr<TSimpleSharedPtr<int>>;
- TPtr p1;
- UNIT_ASSERT(!p1.Shared());
-
- p1.Reset(new int(123));
- UNIT_ASSERT(!p1.Shared());
-
- {
- TPtr pTmp = p1;
-
- UNIT_ASSERT(p1.Shared());
- UNIT_ASSERT(pTmp.Shared());
- UNIT_ASSERT_EQUAL(p1.Get(), pTmp.Get());
- }
-
- UNIT_ASSERT(!p1.Shared());
-
- TPtr p2 = p1;
- TPtr p3;
- p3 = p2;
-
- UNIT_ASSERT(p2.Shared());
- UNIT_ASSERT(p3.Shared());
- UNIT_ASSERT_EQUAL(p1.Get(), p2.Get());
- UNIT_ASSERT_EQUAL(p1.Get(), p3.Get());
-
- *(p1.Mutable()) = 456;
-
- UNIT_ASSERT(!p1.Shared());
- UNIT_ASSERT(p2.Shared());
- UNIT_ASSERT(p3.Shared());
- UNIT_ASSERT_EQUAL(*p1, 456);
- UNIT_ASSERT_EQUAL(*p2, 123);
- UNIT_ASSERT_EQUAL(*p3, 123);
- UNIT_ASSERT_UNEQUAL(p1.Get(), p2.Get());
- UNIT_ASSERT_EQUAL(p2.Get(), p3.Get());
-
- p2.Mutable();
-
- UNIT_ASSERT(!p2.Shared());
- UNIT_ASSERT(!p3.Shared());
- UNIT_ASSERT_EQUAL(*p2, 123);
- UNIT_ASSERT_EQUAL(*p3, 123);
- UNIT_ASSERT_UNEQUAL(p2.Get(), p3.Get());
-}
-
+ TPtr p1;
+ UNIT_ASSERT(!p1.Shared());
+
+ p1.Reset(new int(123));
+ UNIT_ASSERT(!p1.Shared());
+
+ {
+ TPtr pTmp = p1;
+
+ UNIT_ASSERT(p1.Shared());
+ UNIT_ASSERT(pTmp.Shared());
+ UNIT_ASSERT_EQUAL(p1.Get(), pTmp.Get());
+ }
+
+ UNIT_ASSERT(!p1.Shared());
+
+ TPtr p2 = p1;
+ TPtr p3;
+ p3 = p2;
+
+ UNIT_ASSERT(p2.Shared());
+ UNIT_ASSERT(p3.Shared());
+ UNIT_ASSERT_EQUAL(p1.Get(), p2.Get());
+ UNIT_ASSERT_EQUAL(p1.Get(), p3.Get());
+
+ *(p1.Mutable()) = 456;
+
+ UNIT_ASSERT(!p1.Shared());
+ UNIT_ASSERT(p2.Shared());
+ UNIT_ASSERT(p3.Shared());
+ UNIT_ASSERT_EQUAL(*p1, 456);
+ UNIT_ASSERT_EQUAL(*p2, 123);
+ UNIT_ASSERT_EQUAL(*p3, 123);
+ UNIT_ASSERT_UNEQUAL(p1.Get(), p2.Get());
+ UNIT_ASSERT_EQUAL(p2.Get(), p3.Get());
+
+ p2.Mutable();
+
+ UNIT_ASSERT(!p2.Shared());
+ UNIT_ASSERT(!p3.Shared());
+ UNIT_ASSERT_EQUAL(*p2, 123);
+ UNIT_ASSERT_EQUAL(*p3, 123);
+ UNIT_ASSERT_UNEQUAL(p2.Get(), p3.Get());
+}
+
struct X: public TSimpleRefCount<X> {
- inline X(int v = 0)
- : V(v)
- {
- }
-
- int V;
-};
-
+ inline X(int v = 0)
+ : V(v)
+ {
+ }
+
+ int V;
+};
+
void TPointerTest::TestCopyOnWritePtr2() {
using TPtr = TCowPtr<TIntrusivePtr<X>>;
- TPtr p1;
- UNIT_ASSERT(!p1.Shared());
-
- p1.Reset(new X(123));
- UNIT_ASSERT(!p1.Shared());
-
- {
- TPtr pTmp = p1;
-
- UNIT_ASSERT(p1.Shared());
- UNIT_ASSERT(pTmp.Shared());
- UNIT_ASSERT_EQUAL(p1.Get(), pTmp.Get());
- }
-
- UNIT_ASSERT(!p1.Shared());
-
- TPtr p2 = p1;
- TPtr p3;
- p3 = p2;
-
- UNIT_ASSERT(p2.Shared());
- UNIT_ASSERT(p3.Shared());
- UNIT_ASSERT_EQUAL(p1.Get(), p2.Get());
- UNIT_ASSERT_EQUAL(p1.Get(), p3.Get());
-
- p1.Mutable()->V = 456;
-
- UNIT_ASSERT(!p1.Shared());
- UNIT_ASSERT(p2.Shared());
- UNIT_ASSERT(p3.Shared());
- UNIT_ASSERT_EQUAL(p1->V, 456);
- UNIT_ASSERT_EQUAL(p2->V, 123);
- UNIT_ASSERT_EQUAL(p3->V, 123);
- UNIT_ASSERT_UNEQUAL(p1.Get(), p2.Get());
- UNIT_ASSERT_EQUAL(p2.Get(), p3.Get());
-
- p2.Mutable();
-
- UNIT_ASSERT(!p2.Shared());
- UNIT_ASSERT(!p3.Shared());
- UNIT_ASSERT_EQUAL(p2->V, 123);
- UNIT_ASSERT_EQUAL(p3->V, 123);
- UNIT_ASSERT_UNEQUAL(p2.Get(), p3.Get());
-}
-
-namespace {
+ TPtr p1;
+ UNIT_ASSERT(!p1.Shared());
+
+ p1.Reset(new X(123));
+ UNIT_ASSERT(!p1.Shared());
+
+ {
+ TPtr pTmp = p1;
+
+ UNIT_ASSERT(p1.Shared());
+ UNIT_ASSERT(pTmp.Shared());
+ UNIT_ASSERT_EQUAL(p1.Get(), pTmp.Get());
+ }
+
+ UNIT_ASSERT(!p1.Shared());
+
+ TPtr p2 = p1;
+ TPtr p3;
+ p3 = p2;
+
+ UNIT_ASSERT(p2.Shared());
+ UNIT_ASSERT(p3.Shared());
+ UNIT_ASSERT_EQUAL(p1.Get(), p2.Get());
+ UNIT_ASSERT_EQUAL(p1.Get(), p3.Get());
+
+ p1.Mutable()->V = 456;
+
+ UNIT_ASSERT(!p1.Shared());
+ UNIT_ASSERT(p2.Shared());
+ UNIT_ASSERT(p3.Shared());
+ UNIT_ASSERT_EQUAL(p1->V, 456);
+ UNIT_ASSERT_EQUAL(p2->V, 123);
+ UNIT_ASSERT_EQUAL(p3->V, 123);
+ UNIT_ASSERT_UNEQUAL(p1.Get(), p2.Get());
+ UNIT_ASSERT_EQUAL(p2.Get(), p3.Get());
+
+ p2.Mutable();
+
+ UNIT_ASSERT(!p2.Shared());
+ UNIT_ASSERT(!p3.Shared());
+ UNIT_ASSERT_EQUAL(p2->V, 123);
+ UNIT_ASSERT_EQUAL(p3->V, 123);
+ UNIT_ASSERT_UNEQUAL(p2.Get(), p3.Get());
+}
+
+namespace {
template <class TFrom, class TTo>
struct TImplicitlyCastable {
struct RTYes {
char t[2];
};
-
+
using RTNo = char;
-
+
static RTYes Func(TTo);
static RTNo Func(...);
static TFrom Get();
-
+
/*
- * Result == (TFrom could be converted to TTo implicitly)
- */
+ * Result == (TFrom could be converted to TTo implicitly)
+ */
enum {
Result = (sizeof(Func(Get())) != sizeof(RTNo))
};
- };
-
+ };
+
struct TImplicitlyCastableToBool {
inline operator bool() const {
return true;
}
};
-
+
}
-
+
void TPointerTest::TestOperatorBool() {
using TVec = TVector<ui32>;
-
- // to be sure TImplicitlyCastable works as expected
- UNIT_ASSERT((TImplicitlyCastable<int, bool>::Result));
- UNIT_ASSERT((TImplicitlyCastable<double, int>::Result));
- UNIT_ASSERT((TImplicitlyCastable<int*, void*>::Result));
- UNIT_ASSERT(!(TImplicitlyCastable<void*, int*>::Result));
- UNIT_ASSERT((TImplicitlyCastable<TImplicitlyCastableToBool, bool>::Result));
- UNIT_ASSERT((TImplicitlyCastable<TImplicitlyCastableToBool, int>::Result));
- UNIT_ASSERT((TImplicitlyCastable<TImplicitlyCastableToBool, ui64>::Result));
- UNIT_ASSERT(!(TImplicitlyCastable<TImplicitlyCastableToBool, void*>::Result));
-
- // pointers
+
+ // to be sure TImplicitlyCastable works as expected
+ UNIT_ASSERT((TImplicitlyCastable<int, bool>::Result));
+ UNIT_ASSERT((TImplicitlyCastable<double, int>::Result));
+ UNIT_ASSERT((TImplicitlyCastable<int*, void*>::Result));
+ UNIT_ASSERT(!(TImplicitlyCastable<void*, int*>::Result));
+ UNIT_ASSERT((TImplicitlyCastable<TImplicitlyCastableToBool, bool>::Result));
+ UNIT_ASSERT((TImplicitlyCastable<TImplicitlyCastableToBool, int>::Result));
+ UNIT_ASSERT((TImplicitlyCastable<TImplicitlyCastableToBool, ui64>::Result));
+ UNIT_ASSERT(!(TImplicitlyCastable<TImplicitlyCastableToBool, void*>::Result));
+
+ // pointers
UNIT_ASSERT(!(TImplicitlyCastable<TSimpleSharedPtr<TVec>, int>::Result));
- UNIT_ASSERT(!(TImplicitlyCastable<TAutoPtr<ui64>, ui64>::Result));
+ UNIT_ASSERT(!(TImplicitlyCastable<TAutoPtr<ui64>, ui64>::Result));
UNIT_ASSERT(!(TImplicitlyCastable<THolder<TVec>, bool>::Result)); // even this
-
- {
- // mostly a compilability test
-
- THolder<TVec> a;
- UNIT_ASSERT(!a);
- UNIT_ASSERT(!bool(a));
+
+ {
+ // mostly a compilability test
+
+ THolder<TVec> a;
+ UNIT_ASSERT(!a);
+ UNIT_ASSERT(!bool(a));
if (a) {
- UNIT_ASSERT(false);
+ UNIT_ASSERT(false);
}
if (!a) {
- UNIT_ASSERT(true);
+ UNIT_ASSERT(true);
}
-
- a.Reset(new TVec);
- UNIT_ASSERT(a);
- UNIT_ASSERT(bool(a));
+
+ a.Reset(new TVec);
+ UNIT_ASSERT(a);
+ UNIT_ASSERT(bool(a));
if (a) {
- UNIT_ASSERT(true);
+ UNIT_ASSERT(true);
}
if (!a) {
- UNIT_ASSERT(false);
+ UNIT_ASSERT(false);
}
-
- THolder<TVec> b(new TVec);
- UNIT_ASSERT(a.Get() != b.Get());
- UNIT_ASSERT(a != b);
+
+ THolder<TVec> b(new TVec);
+ UNIT_ASSERT(a.Get() != b.Get());
+ UNIT_ASSERT(a != b);
if (a == b) {
- UNIT_ASSERT(false);
+ UNIT_ASSERT(false);
}
if (a != b) {
- UNIT_ASSERT(true);
+ UNIT_ASSERT(true);
}
if (!(a && b)) {
- UNIT_ASSERT(false);
+ UNIT_ASSERT(false);
}
if (a && b) {
- UNIT_ASSERT(true);
+ UNIT_ASSERT(true);
}
-
- // int i = a; // does not compile
- // bool c = (a < b); // does not compile
- }
-}
+
+ // int i = a; // does not compile
+ // bool c = (a < b); // does not compile
+ }
+}
void TPointerTest::TestMakeShared() {
{
diff --git a/util/generic/queue.h b/util/generic/queue.h
index f5959f68f2..570d8d915d 100644
--- a/util/generic/queue.h
+++ b/util/generic/queue.h
@@ -16,10 +16,10 @@ class TQueue: public std::queue<T, S> {
public:
using TBase::TBase;
- inline explicit operator bool() const noexcept {
- return !this->empty();
- }
-
+ inline explicit operator bool() const noexcept {
+ return !this->empty();
+ }
+
inline void clear() {
this->c.clear();
}
@@ -40,10 +40,10 @@ class TPriorityQueue: public std::priority_queue<T, S, C> {
public:
using TBase::TBase;
- inline explicit operator bool() const noexcept {
- return !this->empty();
- }
-
+ inline explicit operator bool() const noexcept {
+ return !this->empty();
+ }
+
inline void clear() {
this->c.clear();
}
diff --git a/util/generic/queue_ut.cpp b/util/generic/queue_ut.cpp
index a33399e104..122d4eabd6 100644
--- a/util/generic/queue_ut.cpp
+++ b/util/generic/queue_ut.cpp
@@ -12,10 +12,10 @@ Y_UNIT_TEST_SUITE(TYQueueTest) {
using container = TQueue<int>;
container c1;
- UNIT_ASSERT(!c1);
+ UNIT_ASSERT(!c1);
c1.push(100);
c1.push(200);
- UNIT_ASSERT(c1);
+ UNIT_ASSERT(c1);
container c2(c1);
@@ -44,10 +44,10 @@ Y_UNIT_TEST_SUITE(TYQueueTest) {
using container = TPriorityQueue<int>;
container c1;
- UNIT_ASSERT(!c1);
+ UNIT_ASSERT(!c1);
c1.push(100);
c1.push(200);
- UNIT_ASSERT(c1);
+ UNIT_ASSERT(c1);
container c2(c1);
diff --git a/util/generic/set.h b/util/generic/set.h
index 4c437ca26f..c8acd6fbb8 100644
--- a/util/generic/set.h
+++ b/util/generic/set.h
@@ -15,10 +15,10 @@ public:
using TBase = std::set<K, L, TReboundAllocator<A, K>>;
using TBase::TBase;
- inline explicit operator bool() const noexcept {
- return !this->empty();
- }
-
+ inline explicit operator bool() const noexcept {
+ return !this->empty();
+ }
+
template <class TheKey>
inline bool contains(const TheKey& key) const {
return this->find(key) != this->end();
@@ -31,9 +31,9 @@ public:
using TBase = std::multiset<K, L, TReboundAllocator<A, K>>;
using TBase::TBase;
- inline explicit operator bool() const noexcept {
- return !this->empty();
- }
+ inline explicit operator bool() const noexcept {
+ return !this->empty();
+ }
template <class TheKey>
inline bool contains(const TheKey& key) const {
diff --git a/util/generic/strbase.h b/util/generic/strbase.h
index ab39fc7537..56a759548d 100644
--- a/util/generic/strbase.h
+++ b/util/generic/strbase.h
@@ -194,7 +194,7 @@ public:
}
constexpr inline explicit operator bool() const noexcept {
- return !empty();
+ return !empty();
}
public: // style-guide compliant methods
diff --git a/util/generic/strbuf.h b/util/generic/strbuf.h
index 70b9360d58..4e6956bd7e 100644
--- a/util/generic/strbuf.h
+++ b/util/generic/strbuf.h
@@ -248,76 +248,76 @@ public:
RSplitTemplate(delim, l, r);
}
-private:
+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 {
- Y_ASSERT(pos != TBase::npos);
-
+ Y_ASSERT(pos != TBase::npos);
+
// make a copy in case one of l/r is really *this
const TdSelf tok = SubStr(pos + len);
l = Head(pos);
r = tok;
}
-public:
- // In all methods below with @pos parameter, @pos is supposed to be
- // a result of string find()/rfind()/find_first() or other similiar functions,
+public:
+ // In all methods below with @pos parameter, @pos is supposed to be
+ // a result of string find()/rfind()/find_first() or other similiar functions,
// returning either position within string length [0..size()) or npos.
- // For all other @pos values (out of string index range) the behaviour isn't well defined
- // For example, for TStringBuf s("abc"):
- // s.TrySplitOn(s.find('z'), ...) is false, but s.TrySplitOn(100500, ...) is true.
-
+ // For all other @pos values (out of string index range) the behaviour isn't well defined
+ // 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 {
if (TBase::npos == pos)
return false;
-
+
DoSplitOn(pos, l, r, len);
return true;
}
void SplitOn(size_t pos, TdSelf& l, TdSelf& r, size_t len = 1) const noexcept {
- if (!TrySplitOn(pos, l, r, len)) {
+ if (!TrySplitOn(pos, l, r, len)) {
l = *this;
r = TdSelf();
}
}
bool TrySplitAt(size_t pos, TdSelf& l, TdSelf& r) const noexcept {
- return TrySplitOn(pos, l, r, 0);
+ return TrySplitOn(pos, l, r, 0);
}
void SplitAt(size_t pos, TdSelf& l, TdSelf& r) const noexcept {
- SplitOn(pos, l, r, 0);
+ SplitOn(pos, l, r, 0);
}
/*
- // Not implemented intentionally, use TrySplitOn() instead
+ // 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;
-*/
+*/
-public:
+public:
Y_PURE_FUNCTION inline TdSelf After(TCharType c) const noexcept {
TdSelf l, r;
- return TrySplit(c, l, r) ? r : *this;
+ return TrySplit(c, l, r) ? r : *this;
}
Y_PURE_FUNCTION inline TdSelf Before(TCharType c) const noexcept {
TdSelf l, r;
- return TrySplit(c, l, r) ? l : *this;
- }
+ return TrySplit(c, l, r) ? l : *this;
+ }
Y_PURE_FUNCTION inline TdSelf RAfter(TCharType c) const noexcept {
TdSelf l, r;
- return TryRSplit(c, l, r) ? r : *this;
+ return TryRSplit(c, l, r) ? r : *this;
}
Y_PURE_FUNCTION inline TdSelf RBefore(TCharType c) const noexcept {
TdSelf l, r;
- return TryRSplit(c, l, r) ? l : *this;
+ return TryRSplit(c, l, r) ? l : *this;
}
-public:
+public:
inline bool AfterPrefix(const TdSelf& prefix, TdSelf& result) const noexcept {
if (this->StartsWith(prefix)) {
result = Tail(prefix.size());
@@ -336,15 +336,15 @@ public:
// returns true if string started with `prefix`, false otherwise
inline bool SkipPrefix(const TdSelf& prefix) noexcept {
- return AfterPrefix(prefix, *this);
- }
-
+ return AfterPrefix(prefix, *this);
+ }
+
// returns true if string ended with `suffix`, false otherwise
inline bool ChopSuffix(const TdSelf& suffix) noexcept {
- return BeforeSuffix(suffix, *this);
- }
-
-public:
+ return BeforeSuffix(suffix, *this);
+ }
+
+public:
// returns tail, including pos
TdSelf SplitOffAt(size_t pos) {
const TdSelf tok = SubStr(pos);
@@ -371,12 +371,12 @@ public:
return tok;
}
/*
- // See comment on RSplitOn() above
- TdSelf RSplitOffOn(size_t pos);
- TdSelf RNextTokOn(size_t pos);
-*/
+ // See comment on RSplitOn() above
+ TdSelf RSplitOffOn(size_t pos);
+ TdSelf RNextTokOn(size_t pos);
+*/
-public:
+public:
TdSelf SplitOff(TCharType delim) {
TdSelf tok;
Split(delim, *this, tok);
@@ -513,7 +513,7 @@ private:
template <typename TDelimiterType>
bool RNextTokTemplate(TDelimiterType delim, TdSelf& tok) {
if (!empty()) {
- tok = RNextTokTemplate(delim);
+ tok = RNextTokTemplate(delim);
return true;
}
return false;
diff --git a/util/generic/strbuf_ut.cpp b/util/generic/strbuf_ut.cpp
index 69cde785af..b26a18e470 100644
--- a/util/generic/strbuf_ut.cpp
+++ b/util/generic/strbuf_ut.cpp
@@ -95,17 +95,17 @@ Y_UNIT_TEST_SUITE(TStrBufTest) {
if (str.AfterPrefix("http://", r)) {
UNIT_ASSERT_EQUAL(r, "ya.ru");
}
-
- // SkipPrefix()
- TStringBuf a = "abcdef";
+
+ // SkipPrefix()
+ TStringBuf a = "abcdef";
UNIT_ASSERT(a.SkipPrefix("a") && a == "bcdef");
UNIT_ASSERT(a.SkipPrefix("bc") && a == "def");
UNIT_ASSERT(a.SkipPrefix("") && a == "def");
- UNIT_ASSERT(!a.SkipPrefix("xyz") && a == "def");
- UNIT_ASSERT(!a.SkipPrefix("defg") && a == "def");
+ UNIT_ASSERT(!a.SkipPrefix("xyz") && a == "def");
+ UNIT_ASSERT(!a.SkipPrefix("defg") && a == "def");
UNIT_ASSERT(a.SkipPrefix("def") && a == "");
UNIT_ASSERT(a.SkipPrefix("") && a == "");
- UNIT_ASSERT(!a.SkipPrefix("def") && a == "");
+ UNIT_ASSERT(!a.SkipPrefix("def") && a == "");
}
Y_UNIT_TEST(TestBeforeSuffix) {
@@ -122,17 +122,17 @@ Y_UNIT_TEST_SUITE(TStrBufTest) {
if (str.BeforeSuffix(".ru", r)) {
UNIT_ASSERT_EQUAL(r, "maps.yandex");
}
-
- // ChopSuffix()
- TStringBuf a = "abcdef";
+
+ // ChopSuffix()
+ TStringBuf a = "abcdef";
UNIT_ASSERT(a.ChopSuffix("f") && a == "abcde");
UNIT_ASSERT(a.ChopSuffix("de") && a == "abc");
UNIT_ASSERT(a.ChopSuffix("") && a == "abc");
- UNIT_ASSERT(!a.ChopSuffix("xyz") && a == "abc");
- UNIT_ASSERT(!a.ChopSuffix("abcd") && a == "abc");
+ UNIT_ASSERT(!a.ChopSuffix("xyz") && a == "abc");
+ UNIT_ASSERT(!a.ChopSuffix("abcd") && a == "abc");
UNIT_ASSERT(a.ChopSuffix("abc") && a == "");
UNIT_ASSERT(a.ChopSuffix("") && a == "");
- UNIT_ASSERT(!a.ChopSuffix("abc") && a == "");
+ UNIT_ASSERT(!a.ChopSuffix("abc") && a == "");
}
Y_UNIT_TEST(TestEmpty) {
@@ -248,12 +248,12 @@ Y_UNIT_TEST_SUITE(TStrBufTest) {
TStringBuf buf2("a");
UNIT_ASSERT_EQUAL(buf2.RNextTok('.'), TStringBuf("a"));
UNIT_ASSERT_EQUAL(buf2, TStringBuf());
-
- TStringBuf buf3("ab cd ef"), tok;
- UNIT_ASSERT(buf3.RNextTok(' ', tok) && tok == "ef" && buf3 == "ab cd");
- UNIT_ASSERT(buf3.RNextTok(' ', tok) && tok == "cd" && buf3 == "ab");
- UNIT_ASSERT(buf3.RNextTok(' ', tok) && tok == "ab" && buf3 == "");
- UNIT_ASSERT(!buf3.RNextTok(' ', tok) && tok == "ab" && buf3 == ""); // not modified
+
+ TStringBuf buf3("ab cd ef"), tok;
+ UNIT_ASSERT(buf3.RNextTok(' ', tok) && tok == "ef" && buf3 == "ab cd");
+ UNIT_ASSERT(buf3.RNextTok(' ', tok) && tok == "cd" && buf3 == "ab");
+ UNIT_ASSERT(buf3.RNextTok(' ', tok) && tok == "ab" && buf3 == "");
+ UNIT_ASSERT(!buf3.RNextTok(' ', tok) && tok == "ab" && buf3 == ""); // not modified
}
Y_UNIT_TEST(TestRSplitOff) {
@@ -275,50 +275,50 @@ Y_UNIT_TEST_SUITE(TStrBufTest) {
UNIT_ASSERT_VALUES_EQUAL(helloThere[index], *it);
}
}
-
+
Y_UNIT_TEST(TestSplitOnAt) {
- TStringBuf s = "abcabc";
- TStringBuf l, r;
-
- size_t pos = s.find('a');
- UNIT_ASSERT(s.TrySplitOn(pos, l, r));
- UNIT_ASSERT(l == "" && r == "bcabc");
- UNIT_ASSERT(s.TrySplitAt(pos, l, r));
- UNIT_ASSERT(l == "" && r == "abcabc");
-
- pos = s.find("ca");
- UNIT_ASSERT(s.TrySplitOn(pos, l, r));
- UNIT_ASSERT(l == "ab" && r == "abc");
- UNIT_ASSERT(s.TrySplitOn(pos, l, r, 2));
- UNIT_ASSERT(l == "ab" && r == "bc");
- UNIT_ASSERT(s.TrySplitAt(pos, l, r));
- UNIT_ASSERT(l == "ab" && r == "cabc");
-
- // out of range
- pos = 100500;
+ TStringBuf s = "abcabc";
+ TStringBuf l, r;
+
+ size_t pos = s.find('a');
+ UNIT_ASSERT(s.TrySplitOn(pos, l, r));
+ UNIT_ASSERT(l == "" && r == "bcabc");
+ UNIT_ASSERT(s.TrySplitAt(pos, l, r));
+ UNIT_ASSERT(l == "" && r == "abcabc");
+
+ pos = s.find("ca");
+ UNIT_ASSERT(s.TrySplitOn(pos, l, r));
+ UNIT_ASSERT(l == "ab" && r == "abc");
+ UNIT_ASSERT(s.TrySplitOn(pos, l, r, 2));
+ UNIT_ASSERT(l == "ab" && r == "bc");
+ UNIT_ASSERT(s.TrySplitAt(pos, l, r));
+ UNIT_ASSERT(l == "ab" && r == "cabc");
+
+ // out of range
+ pos = 100500;
UNIT_ASSERT(s.TrySplitOn(pos, l, r)); // still true
- UNIT_ASSERT(l == "abcabc" && r == "");
+ UNIT_ASSERT(l == "abcabc" && r == "");
l = "111";
r = "222";
UNIT_ASSERT(s.TrySplitAt(pos, l, r)); // still true
- UNIT_ASSERT(l == "abcabc" && r == "");
-
- // npos
- pos = s.find("missing");
+ UNIT_ASSERT(l == "abcabc" && r == "");
+
+ // npos
+ pos = s.find("missing");
l = "111";
r = "222";
- UNIT_ASSERT(!s.TrySplitOn(pos, l, r));
+ UNIT_ASSERT(!s.TrySplitOn(pos, l, r));
UNIT_ASSERT(l == "111" && r == "222"); // not modified
- s.SplitOn(pos, l, r);
+ s.SplitOn(pos, l, r);
UNIT_ASSERT(l == "abcabc" && r == ""); // modified
-
+
l = "111";
r = "222";
- UNIT_ASSERT(!s.TrySplitAt(pos, l, r));
+ UNIT_ASSERT(!s.TrySplitAt(pos, l, r));
UNIT_ASSERT(l == "111" && r == "222"); // not modified
- s.SplitAt(pos, l, r);
+ s.SplitAt(pos, l, r);
UNIT_ASSERT(l == "abcabc" && r == ""); // modified
- }
+ }
template <class T>
void PassByConstReference(const T& val) {
diff --git a/util/generic/string.cpp b/util/generic/string.cpp
index 3c655f1f66..167e8ba0f9 100644
--- a/util/generic/string.cpp
+++ b/util/generic/string.cpp
@@ -45,12 +45,12 @@ TBasicString<wchar16, std::char_traits<wchar16>>::AppendAscii(const ::TStringBuf
auto dst = begin() + size() - s.size();
for (const char* src = s.data(); dst != end(); ++dst, ++src) {
- *dst = static_cast<wchar16>(*src);
- }
+ *dst = static_cast<wchar16>(*src);
+ }
return *this;
-}
-
+}
+
template <>
TUtf16String&
TBasicString<wchar16, std::char_traits<wchar16>>::AppendUtf8(const ::TStringBuf& s) {
diff --git a/util/generic/string.h b/util/generic/string.h
index 8cd8aa6917..6b59124803 100644
--- a/util/generic/string.h
+++ b/util/generic/string.h
@@ -249,7 +249,7 @@ public:
return StdStr();
#endif
}
-
+
inline const_reference operator[](size_t pos) const noexcept {
Y_ASSERT(pos <= length());
@@ -627,7 +627,7 @@ public:
}
TBasicString& assign(const TCharType* pc, size_t pos, size_t n) {
- return assign(pc + pos, n);
+ return assign(pc + pos, n);
}
TBasicString& assign(const TBasicStringBuf<TCharType, TTraits> s) {
diff --git a/util/generic/string_transparent_hash_ut.cpp b/util/generic/string_transparent_hash_ut.cpp
index b87fa2843e..85c35f7485 100644
--- a/util/generic/string_transparent_hash_ut.cpp
+++ b/util/generic/string_transparent_hash_ut.cpp
@@ -6,7 +6,7 @@
#include <library/cpp/containers/absl_flat_hash/flat_hash_set.h>
#include <util/str_stl.h>
-
+
Y_UNIT_TEST_SUITE(StringHashFunctorTests) {
Y_UNIT_TEST(TestTransparencyWithUnorderedSet) {
// Using Abseil hash set because `std::unordered_set` is transparent only from C++20 (while
diff --git a/util/generic/string_ut.cpp b/util/generic/string_ut.cpp
index ac82e9091d..d8ec49cb70 100644
--- a/util/generic/string_ut.cpp
+++ b/util/generic/string_ut.cpp
@@ -4,11 +4,11 @@
#include "vector.h"
#include "yexception.h"
-#include <util/charset/wide.h>
+#include <util/charset/wide.h>
#include <util/str_stl.h>
#include <util/stream/output.h>
#include <util/string/subst.h>
-
+
#include <string>
#include <sstream>
#include <algorithm>
@@ -813,74 +813,74 @@ public:
UNIT_TEST(TestReverseIterators);
UNIT_TEST(TestStringLiterals);
UNIT_TEST_SUITE_END();
-
-private:
+
+private:
void TestDecodingMethods() {
UNIT_ASSERT(TUtf16String::FromAscii("").empty());
UNIT_ASSERT(TUtf16String::FromAscii("abc") == ASCIIToWide("abc"));
-
- const char* text = "123kx83abcd ej)#$%ddja&%J&";
+
+ const char* text = "123kx83abcd ej)#$%ddja&%J&";
TUtf16String wtext = ASCIIToWide(text);
UNIT_ASSERT(wtext == TUtf16String::FromAscii(text));
-
+
TString strtext(text);
UNIT_ASSERT(wtext == TUtf16String::FromAscii(strtext));
-
- TStringBuf strbuftext(text);
+
+ TStringBuf strbuftext(text);
UNIT_ASSERT(wtext == TUtf16String::FromAscii(strbuftext));
UNIT_ASSERT(wtext.substr(5) == TUtf16String::FromAscii(text + 5));
-
- const wchar16 wideCyrillicAlphabet[] = {
+
+ const wchar16 wideCyrillicAlphabet[] = {
0x0410, 0x0411, 0x0412, 0x0413, 0x0414, 0x0415, 0x0416, 0x0417, 0x0418, 0x0419, 0x041A, 0x041B, 0x041C, 0x041D, 0x041E, 0x041F,
0x0420, 0x0421, 0x0422, 0x0423, 0x0424, 0x0425, 0x0426, 0x0427, 0x0428, 0x0429, 0x042A, 0x042B, 0x042C, 0x042D, 0x042E, 0x042F,
0x0430, 0x0431, 0x0432, 0x0433, 0x0434, 0x0435, 0x0436, 0x0437, 0x0438, 0x0439, 0x043A, 0x043B, 0x043C, 0x043D, 0x043E, 0x043F,
0x0440, 0x0441, 0x0442, 0x0443, 0x0444, 0x0445, 0x0446, 0x0447, 0x0448, 0x0449, 0x044A, 0x044B, 0x044C, 0x044D, 0x044E, 0x044F,
0x00};
-
+
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)));
-
- // assign
-
+
+ // assign
+
TUtf16String s1;
- s1.AssignAscii("1234");
- UNIT_ASSERT(s1 == ASCIIToWide("1234"));
-
- s1.AssignUtf8(strUtf8);
- UNIT_ASSERT(s1 == strWide);
-
- s1.AssignAscii(text);
- UNIT_ASSERT(s1 == wtext);
-
- // append
+ s1.AssignAscii("1234");
+ UNIT_ASSERT(s1 == ASCIIToWide("1234"));
+
+ s1.AssignUtf8(strUtf8);
+ UNIT_ASSERT(s1 == strWide);
+
+ s1.AssignAscii(text);
+ UNIT_ASSERT(s1 == wtext);
+
+ // append
TUtf16String s2;
TUtf16String testAppend = strWide;
- s2.AppendUtf8(strUtf8);
- UNIT_ASSERT(testAppend == s2);
-
- testAppend += ' ';
- s2.AppendAscii(" ");
- UNIT_ASSERT(testAppend == s2);
-
- testAppend += '_';
- s2.AppendUtf8("_");
- UNIT_ASSERT(testAppend == s2);
-
- testAppend += wtext;
- s2.AppendAscii(text);
- UNIT_ASSERT(testAppend == s2);
-
- testAppend += wtext;
- s2.AppendUtf8(text);
- UNIT_ASSERT(testAppend == s2);
- }
+ s2.AppendUtf8(strUtf8);
+ UNIT_ASSERT(testAppend == s2);
+
+ testAppend += ' ';
+ s2.AppendAscii(" ");
+ UNIT_ASSERT(testAppend == s2);
+
+ testAppend += '_';
+ s2.AppendUtf8("_");
+ UNIT_ASSERT(testAppend == s2);
+
+ testAppend += wtext;
+ s2.AppendAscii(text);
+ UNIT_ASSERT(testAppend == s2);
+
+ testAppend += wtext;
+ s2.AppendUtf8(text);
+ UNIT_ASSERT(testAppend == s2);
+ }
void TestLetOperator() {
TUtf16String str;
diff --git a/util/generic/string_ut.h b/util/generic/string_ut.h
index 44bb10bdeb..52f7277e49 100644
--- a/util/generic/string_ut.h
+++ b/util/generic/string_ut.h
@@ -21,7 +21,7 @@ struct TCharBuffer {
return Data;
}
};
-
+
template <>
struct TCharBuffer<char, 0> {
const char* Data;
diff --git a/util/generic/vector.h b/util/generic/vector.h
index a5b258955a..751fd13577 100644
--- a/util/generic/vector.h
+++ b/util/generic/vector.h
@@ -99,9 +99,9 @@ public:
}
inline explicit operator bool() const noexcept {
- return !this->empty();
- }
-
+ return !this->empty();
+ }
+
Y_PURE_FUNCTION inline bool empty() const noexcept {
return TBase::empty();
}
diff --git a/util/stream/input.cpp b/util/stream/input.cpp
index 6e8170f2f9..43c68cf9be 100644
--- a/util/stream/input.cpp
+++ b/util/stream/input.cpp
@@ -91,7 +91,7 @@ size_t IInputStream::ReadLine(TString& st) {
size_t IInputStream::ReadLine(TUtf16String& w) {
TString s;
size_t result = ReadLine(s);
-
+
if (result) {
UTF8ToWide(s, w);
}
diff --git a/util/string/join.h b/util/string/join.h
index b166fad1f3..02f2d95544 100644
--- a/util/string/join.h
+++ b/util/string/join.h
@@ -22,9 +22,9 @@
template <typename TCharType, typename T>
inline std::enable_if_t<!std::is_arithmetic<std::remove_cv_t<T>>::value, void>
AppendToString(TBasicString<TCharType>& dst, const T& t) {
- dst.AppendNoAlias(ToString(t));
+ dst.AppendNoAlias(ToString(t));
}
-
+
template <typename TCharType, typename T>
inline std::enable_if_t<std::is_arithmetic<std::remove_cv_t<T>>::value, void>
AppendToString(TBasicString<TCharType>& dst, const T& t) {
@@ -34,12 +34,12 @@ AppendToString(TBasicString<TCharType>& dst, const T& t) {
template <typename TCharType>
inline void AppendToString(TBasicString<TCharType>& dst, const TCharType* t) {
- dst.append(t);
+ dst.append(t);
}
template <typename TCharType>
inline void AppendToString(TBasicString<TCharType>& dst, TBasicStringBuf<TCharType> t) {
- dst.append(t);
+ dst.append(t);
}
namespace NPrivate {
@@ -81,11 +81,11 @@ inline void AppendJoinNoReserve(TBasicString<TCharType>&, TBasicStringBuf<TCharT
template <typename TCharType, typename TFirst, typename... TRest>
inline void AppendJoinNoReserve(TBasicString<TCharType>& dst, TBasicStringBuf<TCharType> delim, const TFirst& f, const TRest&... r) {
- AppendToString(dst, delim);
- AppendToString(dst, f);
+ AppendToString(dst, delim);
+ AppendToString(dst, f);
AppendJoinNoReserve(dst, delim, r...);
-}
-
+}
+
template <typename... TValues>
inline void AppendJoin(TString& dst, const TStringBuf delim, const TValues&... values) {
const size_t appendLength = ::NPrivate::GetAppendLength(delim, values...);
@@ -95,21 +95,21 @@ inline void AppendJoin(TString& dst, const TStringBuf delim, const TValues&... v
AppendJoinNoReserve(dst, delim, values...);
}
-template <typename TFirst, typename... TRest>
+template <typename TFirst, typename... TRest>
inline TString Join(const TStringBuf delim, const TFirst& f, const TRest&... r) {
TString ret = ToString(f);
- AppendJoin(ret, delim, r...);
- return ret;
-}
-
-// Note that char delimeter @cdelim will be printed as single char string,
-// 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>
+ AppendJoin(ret, delim, r...);
+ return ret;
+}
+
+// Note that char delimeter @cdelim will be printed as single char string,
+// 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) {
- return Join(TStringBuf(&cdelim, 1), v...);
-}
-
+ return Join(TStringBuf(&cdelim, 1), v...);
+}
+
namespace NPrivate {
template <typename TCharType, typename TIter>
inline TBasicString<TCharType> JoinRange(TBasicStringBuf<TCharType> delim, const TIter beg, const TIter end) {
@@ -131,7 +131,7 @@ namespace NPrivate {
return out;
}
-
+
} // namespace NPrivate
template <typename TIter>
diff --git a/util/string/join_ut.cpp b/util/string/join_ut.cpp
index 3ed2b2459c..8bd7545b2a 100644
--- a/util/string/join_ut.cpp
+++ b/util/string/join_ut.cpp
@@ -5,27 +5,27 @@
#include <util/stream/output.h>
-struct TCustomData {
+struct TCustomData {
TVector<int> Ints;
-};
-
+};
+
TString ToString(const TCustomData& d) {
- return JoinSeq("__", d.Ints);
-}
-
+ return JoinSeq("__", d.Ints);
+}
+
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, "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("", "", ""), "");
- UNIT_ASSERT_EQUAL(Join("", "a", "b", "c"), "abc");
- UNIT_ASSERT_EQUAL(Join("", "a", "b", "", "c"), "abc");
- UNIT_ASSERT_EQUAL(Join(" ", "a", "b", "", "c"), "a b c");
+ UNIT_ASSERT_EQUAL(Join("", "", ""), "");
+ UNIT_ASSERT_EQUAL(Join("", "a", "b", "c"), "abc");
+ UNIT_ASSERT_EQUAL(Join("", "a", "b", "", "c"), "abc");
+ UNIT_ASSERT_EQUAL(Join(" ", "a", "b", "", "c"), "a b c");
}
-
+
Y_UNIT_TEST(IntContainerItems) {
int v[] = {1, 2, 3};
TVector<int> vv(v, v + 3);
@@ -37,7 +37,7 @@ Y_UNIT_TEST_SUITE(JoinStringTest) {
UNIT_ASSERT_EQUAL(JoinSeq(" ", {1, 2, 3}), "1 2 3");
UNIT_ASSERT_VALUES_EQUAL(JoinSeq(" ", v), "1 2 3");
}
-
+
Y_UNIT_TEST(StrContainerItems) {
// try various overloads and template type arguments
static const char* const result = "1 22 333";
@@ -151,13 +151,13 @@ Y_UNIT_TEST_SUITE(JoinStringTest) {
Y_UNIT_TEST(CustomToString) {
TCustomData d1{{1, 2, 3, 4, 5}};
TCustomData d2{{0, -1, -2}};
- UNIT_ASSERT_EQUAL(Join(" ", d1, d2), "1__2__3__4__5 0__-1__-2");
- }
-
+ UNIT_ASSERT_EQUAL(Join(" ", d1, d2), "1__2__3__4__5 0__-1__-2");
+ }
+
Y_UNIT_TEST(JoinChars) {
- // Note that char delimeter is printed as single char string,
- // but joined char values are printed as their numeric codes! O_o
- UNIT_ASSERT_EQUAL(Join('a', 'a', 'a'), "97a97");
- UNIT_ASSERT_EQUAL(Join("a", "a", "a"), "aaa");
- }
+ // Note that char delimeter is printed as single char string,
+ // but joined char values are printed as their numeric codes! O_o
+ UNIT_ASSERT_EQUAL(Join('a', 'a', 'a'), "97a97");
+ UNIT_ASSERT_EQUAL(Join("a", "a", "a"), "aaa");
+ }
}
diff --git a/util/string/strip.h b/util/string/strip.h
index d5ef6da96d..b2097bf4e3 100644
--- a/util/string/strip.h
+++ b/util/string/strip.h
@@ -62,53 +62,53 @@ inline void StripRangeEnd(const It& b, It& e) noexcept {
StripRangeEnd(b, e, IsAsciiSpaceAdapter(b));
}
-template <bool stripBeg, bool stripEnd>
-struct TStripImpl {
+template <bool stripBeg, bool stripEnd>
+struct TStripImpl {
template <class It, class TStripCriterion>
static inline bool StripRange(It& b, It& e, TStripCriterion&& criterion) noexcept {
- const size_t oldLen = e - b;
-
- if (stripBeg) {
+ const size_t oldLen = e - b;
+
+ if (stripBeg) {
StripRangeBegin(b, e, criterion);
- }
-
- if (stripEnd) {
+ }
+
+ if (stripEnd) {
StripRangeEnd(b, e, criterion);
- }
-
- const size_t newLen = e - b;
- return newLen != oldLen;
- }
-
+ }
+
+ const size_t newLen = e - b;
+ return newLen != oldLen;
+ }
+
template <class T, class TStripCriterion>
static inline bool StripString(const T& from, T& to, TStripCriterion&& criterion) {
auto b = from.begin();
auto e = from.end();
-
+
if (StripRange(b, e, criterion)) {
to = T(b, e - b);
-
- return true;
- }
-
- to = from;
-
- return false;
- }
-
+
+ return true;
+ }
+
+ to = from;
+
+ return false;
+ }
+
template <class T, class TStripCriterion>
static inline T StripString(const T& from, TStripCriterion&& criterion) {
- T ret;
+ T ret;
StripString(from, ret, criterion);
- return ret;
- }
-
- template <class T>
- static inline T StripString(const T& from) {
- return StripString(from, IsAsciiSpaceAdapter(from.begin()));
- }
-};
-
+ return ret;
+ }
+
+ template <class T>
+ static inline T StripString(const T& from) {
+ return StripString(from, IsAsciiSpaceAdapter(from.begin()));
+ }
+};
+
template <class It, class TStripCriterion>
inline bool StripRange(It& b, It& e, TStripCriterion&& criterion) noexcept {
return TStripImpl<true, true>::StripRange(b, e, criterion);
@@ -154,19 +154,19 @@ static inline T StripString(const T& from, TStripCriterion&& criterion) {
template <class T>
static inline T StripString(const T& from) {
- return TStripImpl<true, true>::StripString(from);
-}
-
-template <class T>
-static inline T StripStringLeft(const T& from) {
- return TStripImpl<true, false>::StripString(from);
-}
-
-template <class T>
-static inline T StripStringRight(const T& from) {
- return TStripImpl<false, true>::StripString(from);
+ return TStripImpl<true, true>::StripString(from);
}
+template <class T>
+static inline T StripStringLeft(const T& from) {
+ return TStripImpl<true, false>::StripString(from);
+}
+
+template <class T>
+static inline T StripStringRight(const T& from) {
+ return TStripImpl<false, true>::StripString(from);
+}
+
template <class T, class TStripCriterion>
static inline T StripStringLeft(const T& from, TStripCriterion&& criterion) {
return TStripImpl<true, false>::StripString(from, criterion);
diff --git a/util/string/strip_ut.cpp b/util/string/strip_ut.cpp
index d1029d1498..5f3ec0a032 100644
--- a/util/string/strip_ut.cpp
+++ b/util/string/strip_ut.cpp
@@ -8,9 +8,9 @@ Y_UNIT_TEST_SUITE(TStripStringTest) {
Y_UNIT_TEST(TestStrip) {
struct TTest {
const char* Str;
- const char* StripLeftRes;
- const char* StripRightRes;
- const char* StripRes;
+ const char* StripLeftRes;
+ const char* StripRightRes;
+ const char* StripRes;
};
static const TTest tests[] = {
{" 012 ", "012 ", " 012", "012"},
@@ -28,15 +28,15 @@ Y_UNIT_TEST_SUITE(TStripStringTest) {
for (const auto& test : tests) {
TString inputStr(test.Str);
-
+
TString s;
- Strip(inputStr, s);
+ Strip(inputStr, s);
UNIT_ASSERT_EQUAL(s, test.StripRes);
-
+
UNIT_ASSERT_EQUAL(StripString(inputStr), test.StripRes);
UNIT_ASSERT_EQUAL(StripStringLeft(inputStr), test.StripLeftRes);
UNIT_ASSERT_EQUAL(StripStringRight(inputStr), test.StripRightRes);
-
+
TStringBuf inputStrBuf(test.Str);
UNIT_ASSERT_EQUAL(StripString(inputStrBuf), test.StripRes);
UNIT_ASSERT_EQUAL(StripStringLeft(inputStrBuf), test.StripLeftRes);
diff --git a/util/string/vector.cpp b/util/string/vector.cpp
index 9ba401f0a2..e57691a7d4 100644
--- a/util/string/vector.cpp
+++ b/util/string/vector.cpp
@@ -81,8 +81,8 @@ void ::NPrivate::SplitStringImpl(TVector<TUtf16String>* res, const wchar16* ptr,
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) {
const size_t f = Min(index, v.size());
const size_t l = f + Min(count, v.size() - f);
diff --git a/util/ysaveload.h b/util/ysaveload.h
index 02efb4049b..afde429f2f 100644
--- a/util/ysaveload.h
+++ b/util/ysaveload.h
@@ -455,21 +455,21 @@ public:
template <class TSetOrMap, class TValue>
class TSetSerializerInserterBase {
-public:
+public:
inline TSetSerializerInserterBase(TSetOrMap& s)
- : S_(s)
- {
- S_.clear();
- }
-
- inline void Insert(const TValue& v) {
- S_.insert(v);
- }
-
+ : S_(s)
+ {
+ S_.clear();
+ }
+
+ inline void Insert(const TValue& v) {
+ S_.insert(v);
+ }
+
protected:
TSetOrMap& S_;
-};
-
+};
+
template <class TSetOrMap, class TValue, bool sorted>
class TSetSerializerInserter: public TSetSerializerInserterBase<TSetOrMap, TValue> {
using TBase = TSetSerializerInserterBase<TSetOrMap, TValue>;
@@ -486,22 +486,22 @@ template <class TSetType, class TValue>
class TSetSerializerInserter<TSetType, TValue, true>: public TSetSerializerInserterBase<TSetType, TValue> {
using TBase = TSetSerializerInserterBase<TSetType, TValue>;
-public:
+public:
inline TSetSerializerInserter(TSetType& s, size_t cnt)
: TBase(s)
- {
+ {
Y_UNUSED(cnt);
P_ = this->S_.begin();
- }
+ }
- inline void Insert(const TValue& v) {
+ inline void Insert(const TValue& v) {
P_ = this->S_.insert(P_, v);
- }
-
-private:
+ }
+
+private:
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>;
@@ -605,17 +605,17 @@ 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> {
};
-template <class K, class C, class A>
+template <class K, class C, class A>
class TSerializer<TSet<K, C, A>>: public TSetSerializer<TSet<K, C, A>, true> {
};
-
+
template <class K, class C, class A>
class TSerializer<std::set<K, C, A>>: public TSetSerializer<std::set<K, C, A>, true> {
};
template <class T1, class T2, class T3, class T4>
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>> {