aboutsummaryrefslogtreecommitdiffstats
path: root/util/generic
diff options
context:
space:
mode:
authorArslan Urtashev <urtashev@gmail.com>2022-02-10 16:48:55 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:48:55 +0300
commit1136f2ce7cce7bcc84e695272c0d92d4eb900c2b (patch)
tree5d5cb817648f650d76cf1076100726fd9b8448e8 /util/generic
parentb97740540e7302cec9efa181e106ae1990a0cc1c (diff)
downloadydb-1136f2ce7cce7bcc84e695272c0d92d4eb900c2b.tar.gz
Restoring authorship annotation for Arslan Urtashev <urtashev@gmail.com>. Commit 2 of 2.
Diffstat (limited to 'util/generic')
-rw-r--r--util/generic/serialized_enum.h18
-rw-r--r--util/generic/string.h46
-rw-r--r--util/generic/string_ut.cpp4
-rw-r--r--util/generic/string_ut.h44
4 files changed, 56 insertions, 56 deletions
diff --git a/util/generic/serialized_enum.h b/util/generic/serialized_enum.h
index d67ec655b8..79df2bac22 100644
--- a/util/generic/serialized_enum.h
+++ b/util/generic/serialized_enum.h
@@ -1,9 +1,9 @@
#pragma once
-#include <util/generic/fwd.h>
+#include <util/generic/fwd.h>
#include <util/generic/vector.h>
#include <util/generic/map.h>
-
+
#include <cstddef>
#include <type_traits>
@@ -30,7 +30,7 @@ in your ya.make
*/
template <typename EnumT>
Y_CONST_FUNCTION constexpr size_t GetEnumItemsCount();
-
+
namespace NEnumSerializationRuntime {
namespace NDetail {
template <typename EEnum>
@@ -83,12 +83,12 @@ namespace NEnumSerializationRuntime {
const TVector<TString>& GetEnumAllCppNamesImpl();
}
-/**
- * Returns names for items in enum or enum class
- *
- * @tparam EnumT enum type
- */
-template <typename EnumT>
+/**
+ * Returns names for items in enum or enum class
+ *
+ * @tparam EnumT enum type
+ */
+template <typename EnumT>
Y_CONST_FUNCTION ::NEnumSerializationRuntime::TMappedDictView<EnumT, TString> GetEnumNames() {
return ::NEnumSerializationRuntime::GetEnumNamesImpl<EnumT>();
}
diff --git a/util/generic/string.h b/util/generic/string.h
index e3e2a4912a..8cd8aa6917 100644
--- a/util/generic/string.h
+++ b/util/generic/string.h
@@ -104,20 +104,20 @@ private:
};
template <class TStringType>
-class TBasicCharRef {
-public:
+class TBasicCharRef {
+public:
using TChar = typename TStringType::TChar;
-
+
TBasicCharRef(TStringType& s, size_t pos)
: S_(s)
, Pos_(pos)
{
}
-
- operator TChar() const {
- return S_.at(Pos_);
- }
-
+
+ operator TChar() const {
+ return S_.at(Pos_);
+ }
+
TChar* operator&() {
return S_.begin() + Pos_;
}
@@ -126,14 +126,14 @@ public:
return S_.cbegin() + Pos_;
}
- TBasicCharRef& operator=(TChar c) {
+ TBasicCharRef& operator=(TChar c) {
Y_ASSERT(Pos_ < S_.size() || (Pos_ == S_.size() && !c));
-
+
S_.Detach()[Pos_] = c;
-
- return *this;
- }
-
+
+ return *this;
+ }
+
TBasicCharRef& operator=(const TBasicCharRef& other) {
return this->operator=(static_cast<TChar>(other));
}
@@ -149,12 +149,12 @@ public:
*/
TBasicCharRef(const TBasicCharRef&) = default;
-private:
+private:
TStringType& S_;
- size_t Pos_;
-};
+ size_t Pos_;
+};
#endif
-
+
template <typename TCharType, typename TTraits>
class TBasicString: public TStringBase<TBasicString<TCharType, TTraits>, TCharType, TTraits> {
public:
@@ -252,7 +252,7 @@ public:
inline const_reference operator[](size_t pos) const noexcept {
Y_ASSERT(pos <= length());
-
+
return this->data()[pos];
}
@@ -264,8 +264,8 @@ public:
#else
return reference(*this, pos);
#endif
- }
-
+ }
+
using TBase::back;
inline reference back() noexcept {
@@ -468,9 +468,9 @@ public:
explicit TBasicString(const reference& c)
: TBasicString(&c, 1)
{
- }
+ }
#endif
-
+
TBasicString(size_t n, TCharType c)
#ifdef TSTRING_IS_STD_STRING
: Storage_(n, c)
diff --git a/util/generic/string_ut.cpp b/util/generic/string_ut.cpp
index c2623acc17..ac82e9091d 100644
--- a/util/generic/string_ut.cpp
+++ b/util/generic/string_ut.cpp
@@ -742,7 +742,7 @@ public:
UNIT_TEST(TestStrCpy);
UNIT_TEST(TestPrefixSuffix);
#ifndef TSTRING_IS_STD_STRING
- UNIT_TEST(TestCharRef);
+ UNIT_TEST(TestCharRef);
#endif
UNIT_TEST(TestBack)
UNIT_TEST(TestFront)
@@ -804,7 +804,7 @@ public:
UNIT_TEST(TestStrCpy);
UNIT_TEST(TestPrefixSuffix);
#ifndef TSTRING_IS_STD_STRING
- UNIT_TEST(TestCharRef);
+ UNIT_TEST(TestCharRef);
#endif
UNIT_TEST(TestBack);
UNIT_TEST(TestFront)
diff --git a/util/generic/string_ut.h b/util/generic/string_ut.h
index 99ce4999db..44bb10bdeb 100644
--- a/util/generic/string_ut.h
+++ b/util/generic/string_ut.h
@@ -997,37 +997,37 @@ public:
UNIT_ASSERT_EQUAL(str.StartsWith(emptyStr), true);
UNIT_ASSERT_EQUAL(str.EndsWith(emptyStr), true);
}
-
+
#ifndef TSTRING_IS_STD_STRING
- void TestCharRef() {
+ void TestCharRef() {
const char_type abc[] = {'a', 'b', 'c', 0};
const char_type bbc[] = {'b', 'b', 'c', 0};
const char_type cbc[] = {'c', 'b', 'c', 0};
-
+
TStringType s0 = abc;
TStringType s1 = s0;
-
- UNIT_ASSERT(!s0.IsDetached());
- UNIT_ASSERT(!s1.IsDetached());
-
- /* Read access shouldn't detach. */
+
+ UNIT_ASSERT(!s0.IsDetached());
+ UNIT_ASSERT(!s1.IsDetached());
+
+ /* Read access shouldn't detach. */
UNIT_ASSERT_VALUES_EQUAL(s0[0], (ui8)'a');
- UNIT_ASSERT(!s0.IsDetached());
- UNIT_ASSERT(!s1.IsDetached());
-
- /* Writing should detach. */
+ UNIT_ASSERT(!s0.IsDetached());
+ UNIT_ASSERT(!s1.IsDetached());
+
+ /* Writing should detach. */
s1[0] = (ui8)'b';
TStringType s2 = s0;
s0[0] = (ui8)'c';
-
- UNIT_ASSERT_VALUES_EQUAL(s0, cbc);
- UNIT_ASSERT_VALUES_EQUAL(s1, bbc);
- UNIT_ASSERT_VALUES_EQUAL(s2, abc);
- UNIT_ASSERT(s0.IsDetached());
- UNIT_ASSERT(s1.IsDetached());
- UNIT_ASSERT(s2.IsDetached());
-
- /* Accessing null terminator is OK. Note that writing into it is UB. */
+
+ UNIT_ASSERT_VALUES_EQUAL(s0, cbc);
+ UNIT_ASSERT_VALUES_EQUAL(s1, bbc);
+ UNIT_ASSERT_VALUES_EQUAL(s2, abc);
+ UNIT_ASSERT(s0.IsDetached());
+ UNIT_ASSERT(s1.IsDetached());
+ UNIT_ASSERT(s2.IsDetached());
+
+ /* Accessing null terminator is OK. Note that writing into it is UB. */
UNIT_ASSERT_VALUES_EQUAL(s0[3], (ui8)'\0');
UNIT_ASSERT_VALUES_EQUAL(s1[3], (ui8)'\0');
UNIT_ASSERT_VALUES_EQUAL(s2[3], (ui8)'\0');
@@ -1044,7 +1044,7 @@ public:
}
UNIT_ASSERT_VALUES_EQUAL(s1, red_eared);
}
- }
+ }
#endif
void TestBack() {