diff options
author | kartynnik <kartynnik@yandex-team.ru> | 2022-02-10 16:48:07 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:48:07 +0300 |
commit | ca2a705e6e39e85df30054d7e806e572de9cfe23 (patch) | |
tree | fb7cc52bc2579366b2796a24f91f6df7a223f9ab /library/cpp | |
parent | e20e2b362f0232ed5a389db887e6e27e7763af18 (diff) | |
download | ydb-ca2a705e6e39e85df30054d7e806e572de9cfe23.tar.gz |
Restoring authorship annotation for <kartynnik@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp')
28 files changed, 343 insertions, 343 deletions
diff --git a/library/cpp/binsaver/class_factory.h b/library/cpp/binsaver/class_factory.h index e83512331b..7b95a974fc 100644 --- a/library/cpp/binsaver/class_factory.h +++ b/library/cpp/binsaver/class_factory.h @@ -63,15 +63,15 @@ public: (void)p; return VFT2TypeID(&typeid(TT)); } - + void GetAllTypeIDs(TVector<int>& typeIds) const { - typeIds.clear(); + typeIds.clear(); for (typename CTypeNewHash::const_iterator iter = typeInfo.begin(); iter != typeInfo.end(); ++iter) { typeIds.push_back(iter->first); - } - } + } + } }; //////////////////////////////////////////////////////////////////////////////////////////////////// template <class T> diff --git a/library/cpp/colorizer/ut/colorizer_ut.cpp b/library/cpp/colorizer/ut/colorizer_ut.cpp index 20341440af..a7b1c14f4f 100644 --- a/library/cpp/colorizer/ut/colorizer_ut.cpp +++ b/library/cpp/colorizer/ut/colorizer_ut.cpp @@ -1,29 +1,29 @@ #include <library/cpp/colorizer/colors.h> - + #include <library/cpp/testing/unittest/registar.h> #include <util/stream/str.h> - -#include <util/string/escape.h> - + +#include <util/string/escape.h> + Y_UNIT_TEST_SUITE(ColorizerTest) { Y_UNIT_TEST(BasicTest) { - NColorizer::TColors colors; - colors.Enable(); + NColorizer::TColors colors; + colors.Enable(); UNIT_ASSERT_STRINGS_EQUAL(EscapeC(colors.BlueColor()), "\\x1B[22;34m"); UNIT_ASSERT_STRINGS_EQUAL(EscapeC(colors.ForeBlue()), "\\x1B[34m"); - colors.Disable(); - UNIT_ASSERT(colors.BlueColor().Empty()); - } - + colors.Disable(); + UNIT_ASSERT(colors.BlueColor().Empty()); + } + Y_UNIT_TEST(ResettingTest) { - NColorizer::TColors colors; - colors.Enable(); - // 22;39, not 0, should be used so that only foreground changes + NColorizer::TColors colors; + colors.Enable(); + // 22;39, not 0, should be used so that only foreground changes UNIT_ASSERT_STRINGS_EQUAL(EscapeC(colors.OldColor()), "\\x1B[22;39m"); UNIT_ASSERT_STRINGS_EQUAL(EscapeC(colors.Reset()), "\\x1B[0m"); - // 22, not 0, should be used to reset boldness + // 22, not 0, should be used to reset boldness UNIT_ASSERT_STRINGS_EQUAL(EscapeC(colors.PurpleColor()), "\\x1B[22;35m"); - } + } Y_UNIT_TEST(PrintAnsi) { UNIT_ASSERT_STRINGS_EQUAL(EscapeC(ToString(NColorizer::BLUE)), "\\x1B[0m\\x1B[0;34m"); @@ -60,4 +60,4 @@ Y_UNIT_TEST_SUITE(ColorizerTest) { UNIT_ASSERT_VALUES_EQUAL(NColorizer::TotalAnsiEscapeCodeLen("some [0;1;2;3m text"), 0); UNIT_ASSERT_VALUES_EQUAL(NColorizer::TotalAnsiEscapeCodeLen("some\033[m text"), 3); } -} +} diff --git a/library/cpp/colorizer/ut/ya.make b/library/cpp/colorizer/ut/ya.make index 8a28c189af..65f2b4fed8 100644 --- a/library/cpp/colorizer/ut/ya.make +++ b/library/cpp/colorizer/ut/ya.make @@ -1,9 +1,9 @@ UNITTEST_FOR(library/cpp/colorizer) - + OWNER(pg) - -SRCS( - colorizer_ut.cpp -) - -END() + +SRCS( + colorizer_ut.cpp +) + +END() diff --git a/library/cpp/containers/compact_vector/compact_vector.cpp b/library/cpp/containers/compact_vector/compact_vector.cpp index cca77643e9..5be2899957 100644 --- a/library/cpp/containers/compact_vector/compact_vector.cpp +++ b/library/cpp/containers/compact_vector/compact_vector.cpp @@ -1 +1 @@ -#include "compact_vector.h" +#include "compact_vector.h" diff --git a/library/cpp/containers/compact_vector/compact_vector.h b/library/cpp/containers/compact_vector/compact_vector.h index dbe7473f0c..a06009653c 100644 --- a/library/cpp/containers/compact_vector/compact_vector.h +++ b/library/cpp/containers/compact_vector/compact_vector.h @@ -2,12 +2,12 @@ #include <util/generic/yexception.h> #include <util/generic/utility.h> -#include <util/memory/alloc.h> -#include <util/stream/output.h> +#include <util/memory/alloc.h> +#include <util/stream/output.h> #include <util/system/yassert.h> #include <cstdlib> - + // vector that is 8 bytes when empty (TVector is 24 bytes) template <typename T> @@ -102,7 +102,7 @@ public: void Reserve(size_t newCapacity) { if (newCapacity <= Capacity()) { } else if (Ptr == nullptr) { - void* mem = ::malloc(sizeof(THeader) + newCapacity * sizeof(T)); + void* mem = ::malloc(sizeof(THeader) + newCapacity * sizeof(T)); if (mem == nullptr) ythrow yexception() << "out of memory"; Ptr = (T*)(((THeader*)mem) + 1); diff --git a/library/cpp/containers/compact_vector/ut/ya.make b/library/cpp/containers/compact_vector/ut/ya.make index 5e655bc619..9be40910b0 100644 --- a/library/cpp/containers/compact_vector/ut/ya.make +++ b/library/cpp/containers/compact_vector/ut/ya.make @@ -1,11 +1,11 @@ -UNITTEST() - -OWNER(nga) - +UNITTEST() + +OWNER(nga) + SRCDIR(library/cpp/containers/compact_vector) - -SRCS( - compact_vector_ut.cpp -) - -END() + +SRCS( + compact_vector_ut.cpp +) + +END() diff --git a/library/cpp/containers/compact_vector/ya.make b/library/cpp/containers/compact_vector/ya.make index 6c23e8d0c1..ec25bce8f8 100644 --- a/library/cpp/containers/compact_vector/ya.make +++ b/library/cpp/containers/compact_vector/ya.make @@ -1,9 +1,9 @@ -LIBRARY() - -OWNER(nga) - -SRCS( - compact_vector.cpp -) - -END() +LIBRARY() + +OWNER(nga) + +SRCS( + compact_vector.cpp +) + +END() diff --git a/library/cpp/containers/stack_vector/stack_vec.cpp b/library/cpp/containers/stack_vector/stack_vec.cpp index 21c0ab3f11..aa84285b9a 100644 --- a/library/cpp/containers/stack_vector/stack_vec.cpp +++ b/library/cpp/containers/stack_vector/stack_vec.cpp @@ -1 +1 @@ -#include "stack_vec.h" +#include "stack_vec.h" diff --git a/library/cpp/containers/stack_vector/stack_vec.h b/library/cpp/containers/stack_vector/stack_vec.h index fcc5d9a2a5..1cefef2c73 100644 --- a/library/cpp/containers/stack_vector/stack_vec.h +++ b/library/cpp/containers/stack_vector/stack_vec.h @@ -1,22 +1,22 @@ -#pragma once - -#include <util/generic/vector.h> +#pragma once + +#include <util/generic/vector.h> #include <util/ysaveload.h> - + #include <type_traits> -// A vector preallocated on the stack. -// After exceeding the preconfigured stack space falls back to the heap. +// A vector preallocated on the stack. +// After exceeding the preconfigured stack space falls back to the heap. // Publicly inherits TVector, but disallows swap (and hence shrink_to_fit, also operator= is reimplemented via copying). -// -// Inspired by: http://qt-project.org/doc/qt-4.8/qvarlengtharray.html#details - +// +// Inspired by: http://qt-project.org/doc/qt-4.8/qvarlengtharray.html#details + template <typename T, size_t CountOnStack = 256, bool UseFallbackAlloc = true, class Alloc = std::allocator<T>> -class TStackVec; - +class TStackVec; + template <typename T, class Alloc = std::allocator<T>> using TSmallVec = TStackVec<T, 16, true, Alloc>; - + template <typename T, size_t CountOnStack = 256> using TStackOnlyVec = TStackVec<T, CountOnStack, false>; @@ -24,27 +24,27 @@ namespace NPrivate { template <class Alloc, class StackAlloc, typename T, typename U> struct TRebind { typedef TReboundAllocator<Alloc, U> other; - }; - + }; + template <class Alloc, class StackAlloc, typename T> struct TRebind<Alloc, StackAlloc, T, T> { - typedef StackAlloc other; - }; - + typedef StackAlloc other; + }; + template <typename T, size_t CountOnStack, bool UseFallbackAlloc, class Alloc = std::allocator<T>> class TStackBasedAllocator: public Alloc { - public: + public: typedef TStackBasedAllocator<T, CountOnStack, UseFallbackAlloc, Alloc> TSelf; - + using typename Alloc::difference_type; - using typename Alloc::size_type; + using typename Alloc::size_type; using typename Alloc::value_type; - + template <class U> struct rebind: public ::NPrivate::TRebind<Alloc, TSelf, T, U> { - }; - - public: + }; + + public: TStackBasedAllocator() = default; template < @@ -61,26 +61,26 @@ namespace NPrivate { if (!IsStorageUsed && CountOnStack >= n) { IsStorageUsed = true; return reinterpret_cast<T*>(&StackBasedStorage[0]); - } else { + } else { if constexpr (!UseFallbackAlloc) { Y_FAIL( "Stack storage overflow. Capacity: %d, requested: %d", (int)CountOnStack, int(n)); } return FallbackAllocator().allocate(n); - } - } - + } + } + void deallocate(T* p, size_type n) { if (p >= reinterpret_cast<T*>(&StackBasedStorage[0]) && p < reinterpret_cast<T*>(&StackBasedStorage[CountOnStack])) { Y_VERIFY(IsStorageUsed); IsStorageUsed = false; - } else { + } else { FallbackAllocator().deallocate(p, n); - } - } - - private: + } + } + + private: std::aligned_storage_t<sizeof(T), alignof(T)> StackBasedStorage[CountOnStack]; bool IsStorageUsed = false; @@ -88,53 +88,53 @@ namespace NPrivate { Alloc& FallbackAllocator() noexcept { return static_cast<Alloc&>(*this); } - }; + }; } - + template <typename T, size_t CountOnStack, bool UseFallbackAlloc, class Alloc> class TStackVec: public TVector<T, ::NPrivate::TStackBasedAllocator<T, CountOnStack, UseFallbackAlloc, TReboundAllocator<Alloc, T>>> { private: using TBase = TVector<T, ::NPrivate::TStackBasedAllocator<T, CountOnStack, UseFallbackAlloc, TReboundAllocator<Alloc, T>>>; using TAllocator = typename TBase::allocator_type; -public: +public: using typename TBase::const_iterator; using typename TBase::const_reverse_iterator; - using typename TBase::iterator; - using typename TBase::reverse_iterator; + using typename TBase::iterator; + using typename TBase::reverse_iterator; using typename TBase::size_type; - using typename TBase::value_type; - -public: + using typename TBase::value_type; + +public: TStackVec(const TAllocator& alloc = TAllocator()) : TBase(alloc) - { - TBase::reserve(CountOnStack); - } - + { + TBase::reserve(CountOnStack); + } + explicit TStackVec(size_type count, const TAllocator& alloc = TAllocator()) : TBase(alloc) - { - if (count <= CountOnStack) { - TBase::reserve(CountOnStack); - } - TBase::resize(count); - } - + { + if (count <= CountOnStack) { + TBase::reserve(CountOnStack); + } + TBase::resize(count); + } + TStackVec(size_type count, const T& val, const TAllocator& alloc = TAllocator()) : TBase(alloc) - { - if (count <= CountOnStack) { - TBase::reserve(CountOnStack); - } - TBase::assign(count, val); - } - + { + if (count <= CountOnStack) { + TBase::reserve(CountOnStack); + } + TBase::assign(count, val); + } + TStackVec(const TStackVec& src) : TStackVec(src.begin(), src.end()) - { - } - + { + } + template <class A> TStackVec(const TVector<T, A>& src) : TStackVec(src.begin(), src.end()) @@ -166,14 +166,14 @@ public: } } -public: +public: void swap(TStackVec&) = delete; - void shrink_to_fit() = delete; - + void shrink_to_fit() = delete; + TStackVec& operator=(const TStackVec& src) { TBase::assign(src.begin(), src.end()); - return *this; - } + return *this; + } template <class A> TStackVec& operator=(const TVector<T, A>& src) { @@ -185,7 +185,7 @@ public: TBase::assign(il.begin(), il.end()); return *this; } -}; +}; template <typename T, size_t CountOnStack, class Alloc> class TSerializer<TStackVec<T, CountOnStack, true, Alloc>>: public TVectorSerializer<TStackVec<T, CountOnStack, true, Alloc>> { diff --git a/library/cpp/containers/stack_vector/stack_vec_ut.cpp b/library/cpp/containers/stack_vector/stack_vec_ut.cpp index 19f9677781..0325b614c0 100644 --- a/library/cpp/containers/stack_vector/stack_vec_ut.cpp +++ b/library/cpp/containers/stack_vector/stack_vec_ut.cpp @@ -1,7 +1,7 @@ -#include "stack_vec.h" - +#include "stack_vec.h" + #include <library/cpp/testing/unittest/registar.h> - + namespace { struct TNotCopyAssignable { const int Value; @@ -45,19 +45,19 @@ namespace { Y_UNIT_TEST_SUITE(TStackBasedVectorTest) { Y_UNIT_TEST(TestCreateEmpty) { - TStackVec<int> ints; - UNIT_ASSERT_EQUAL(ints.size(), 0); - } - + TStackVec<int> ints; + UNIT_ASSERT_EQUAL(ints.size(), 0); + } + Y_UNIT_TEST(TestCreateNonEmpty) { - TStackVec<int> ints(5); - UNIT_ASSERT_EQUAL(ints.size(), 5); - - for (size_t i = 0; i < ints.size(); ++i) { - UNIT_ASSERT_EQUAL(ints[i], 0); - } - } - + TStackVec<int> ints(5); + UNIT_ASSERT_EQUAL(ints.size(), 5); + + for (size_t i = 0; i < ints.size(); ++i) { + UNIT_ASSERT_EQUAL(ints[i], 0); + } + } + Y_UNIT_TEST(TestReallyOnStack) { const TStackVec<int> vec(5); @@ -65,39 +65,39 @@ Y_UNIT_TEST_SUITE(TStackBasedVectorTest) { (const char*)&vec <= (const char*)&vec[0] && (const char*)&vec[0] <= (const char*)&vec + sizeof(vec) ); - } - + } + Y_UNIT_TEST(TestFallback) { - TSmallVec<int> ints; - for (int i = 0; i < 14; ++i) { - ints.push_back(i); - } - - for (size_t i = 0; i < ints.size(); ++i) { - UNIT_ASSERT_EQUAL(ints[i], (int)i); - } - - for (int i = 14; i < 20; ++i) { - ints.push_back(i); - } - - for (size_t i = 0; i < ints.size(); ++i) { - UNIT_ASSERT_EQUAL(ints[i], (int)i); - } - - TSmallVec<int> ints2 = ints; - - for (size_t i = 0; i < ints2.size(); ++i) { - UNIT_ASSERT_EQUAL(ints2[i], (int)i); - } - - TSmallVec<int> ints3; - ints3 = ints2; - - for (size_t i = 0; i < ints3.size(); ++i) { - UNIT_ASSERT_EQUAL(ints3[i], (int)i); - } - } + TSmallVec<int> ints; + for (int i = 0; i < 14; ++i) { + ints.push_back(i); + } + + for (size_t i = 0; i < ints.size(); ++i) { + UNIT_ASSERT_EQUAL(ints[i], (int)i); + } + + for (int i = 14; i < 20; ++i) { + ints.push_back(i); + } + + for (size_t i = 0; i < ints.size(); ++i) { + UNIT_ASSERT_EQUAL(ints[i], (int)i); + } + + TSmallVec<int> ints2 = ints; + + for (size_t i = 0; i < ints2.size(); ++i) { + UNIT_ASSERT_EQUAL(ints2[i], (int)i); + } + + TSmallVec<int> ints3; + ints3 = ints2; + + for (size_t i = 0; i < ints3.size(); ++i) { + UNIT_ASSERT_EQUAL(ints3[i], (int)i); + } + } Y_UNIT_TEST(TestCappedSize) { TStackVec<int, 8, false> ints; @@ -141,4 +141,4 @@ Y_UNIT_TEST_SUITE(TStackBasedVectorTest) { } UNIT_ASSERT_VALUES_EQUAL(count, 3); } -} +} diff --git a/library/cpp/containers/stack_vector/ut/ya.make b/library/cpp/containers/stack_vector/ut/ya.make index 1d70496954..da5a9d0b11 100644 --- a/library/cpp/containers/stack_vector/ut/ya.make +++ b/library/cpp/containers/stack_vector/ut/ya.make @@ -1,11 +1,11 @@ -UNITTEST() - +UNITTEST() + OWNER(ilnurkh) - + SRCDIR(library/cpp/containers/stack_vector) - -SRCS( - stack_vec_ut.cpp -) - -END() + +SRCS( + stack_vec_ut.cpp +) + +END() diff --git a/library/cpp/containers/stack_vector/ya.make b/library/cpp/containers/stack_vector/ya.make index cfb63295ec..3c31a00b70 100644 --- a/library/cpp/containers/stack_vector/ya.make +++ b/library/cpp/containers/stack_vector/ya.make @@ -1,11 +1,11 @@ -LIBRARY() - +LIBRARY() + OWNER(ilnurkh) - -SRCS( - stack_vec.cpp -) - -END() + +SRCS( + stack_vec.cpp +) + +END() RECURSE_FOR_TESTS(ut) diff --git a/library/cpp/coroutine/engine/iostatus.h b/library/cpp/coroutine/engine/iostatus.h index bf6036805d..99c2fb8e90 100644 --- a/library/cpp/coroutine/engine/iostatus.h +++ b/library/cpp/coroutine/engine/iostatus.h @@ -1,7 +1,7 @@ #pragma once -#include <util/generic/yexception.h> - +#include <util/generic/yexception.h> + class TIOStatus { public: TIOStatus(int status) noexcept diff --git a/library/cpp/dbg_output/DONT_COMMIT.h b/library/cpp/dbg_output/DONT_COMMIT.h index e7b3182c20..0493d7e094 100644 --- a/library/cpp/dbg_output/DONT_COMMIT.h +++ b/library/cpp/dbg_output/DONT_COMMIT.h @@ -1,9 +1,9 @@ -#pragma once - -// Including this file is possible without modifying PEERDIR (for debug purposes). -// The latter is allowed only locally, so this file is named -// in such a way that including it prevents from committing the #include via ARC-1205. - +#pragma once + +// Including this file is possible without modifying PEERDIR (for debug purposes). +// The latter is allowed only locally, so this file is named +// in such a way that including it prevents from committing the #include via ARC-1205. + #define DBGDUMP_INLINE_IF_INCLUDED inline #include "dump.cpp" @@ -12,5 +12,5 @@ #include <library/cpp/colorizer/colors.cpp> #include <library/cpp/colorizer/output.cpp> - + #undef DBGDUMP_INLINE_IF_INCLUDED diff --git a/library/cpp/dbg_output/auto.h b/library/cpp/dbg_output/auto.h index 8d96167f6a..bfac869ae6 100644 --- a/library/cpp/dbg_output/auto.h +++ b/library/cpp/dbg_output/auto.h @@ -1,15 +1,15 @@ -#pragma once - -#include <util/generic/va_args.h> - -// int a = 1, b = 2; Cout << LabeledDump(a, b, 1 + 2); yields {"a": 1, "b": 2, "1 + 2": 3} -#define LabeledDump(...) \ +#pragma once + +#include <util/generic/va_args.h> + +// int a = 1, b = 2; Cout << LabeledDump(a, b, 1 + 2); yields {"a": 1, "b": 2, "1 + 2": 3} +#define LabeledDump(...) \ '{' Y_PASS_VA_ARGS(Y_MAP_ARGS_WITH_LAST(__LABELED_DUMP_NONLAST__, __LABELED_DUMP_IMPL__, __VA_ARGS__)) << '}' -#define __LABELED_DUMP_IMPL__(x) << "\"" #x "\": " << DbgDump(x) -#define __LABELED_DUMP_NONLAST__(x) __LABELED_DUMP_IMPL__(x) << ", " - -// Usage: struct TMyStruct { int A, B; }; DEFINE_DUMPER(TMyStruct, A, B); Cout << TMyStruct{3, 4}; -// yields {"A": 3, "B": 4} +#define __LABELED_DUMP_IMPL__(x) << "\"" #x "\": " << DbgDump(x) +#define __LABELED_DUMP_NONLAST__(x) __LABELED_DUMP_IMPL__(x) << ", " + +// Usage: struct TMyStruct { int A, B; }; DEFINE_DUMPER(TMyStruct, A, B); Cout << TMyStruct{3, 4}; +// yields {"A": 3, "B": 4} #define DEFINE_DUMPER(C, ...) \ template <> \ struct TDumper<C> { \ @@ -17,6 +17,6 @@ static inline void Dump(S& s, const C& v) { \ s << DumpRaw("{") Y_PASS_VA_ARGS(Y_MAP_ARGS_WITH_LAST(__DEFINE_DUMPER_NONLAST__, __DEFINE_DUMPER_IMPL__, __VA_ARGS__)) << DumpRaw("}"); \ } \ - }; -#define __DEFINE_DUMPER_IMPL__(x) << DumpRaw("\"" #x "\": ") << v.x -#define __DEFINE_DUMPER_NONLAST__(x) __DEFINE_DUMPER_IMPL__(x) << DumpRaw(", ") + }; +#define __DEFINE_DUMPER_IMPL__(x) << DumpRaw("\"" #x "\": ") << v.x +#define __DEFINE_DUMPER_NONLAST__(x) __DEFINE_DUMPER_IMPL__(x) << DumpRaw(", ") diff --git a/library/cpp/dbg_output/colorscheme.h b/library/cpp/dbg_output/colorscheme.h index a5b9cf749a..1c2b12f00b 100644 --- a/library/cpp/dbg_output/colorscheme.h +++ b/library/cpp/dbg_output/colorscheme.h @@ -1,17 +1,17 @@ -#pragma once - -#include "engine.h" +#pragma once + +#include "engine.h" #include <library/cpp/colorizer/output.h> - -#ifndef DBG_OUTPUT_DEFAULT_COLOR_SCHEME + +#ifndef DBG_OUTPUT_DEFAULT_COLOR_SCHEME #define DBG_OUTPUT_DEFAULT_COLOR_SCHEME NDbgDump::NColorScheme::TPlain -#endif - -#define DBG_OUTPUT_COLOR_HANDLER(NAME) \ +#endif + +#define DBG_OUTPUT_COLOR_HANDLER(NAME) \ template <class S> \ - inline void NAME(S& stream) - -namespace NDbgDump { + inline void NAME(S& stream) + +namespace NDbgDump { namespace NColorScheme { /// Start by copying this one if you want to define a custom color scheme. struct TPlain { @@ -28,7 +28,7 @@ namespace NDbgDump { DBG_OUTPUT_COLOR_HANDLER(ResetType) { Y_UNUSED(stream); } - + // Background color modifiers DBG_OUTPUT_COLOR_HANDLER(Key) { Y_UNUSED(stream); @@ -40,7 +40,7 @@ namespace NDbgDump { Y_UNUSED(stream); } }; - + /// Use this one if you want colors but are lazy enough to define a custom color scheme. /// Be careful enough to use DumpRaw for avoiding an endless recursion. /// Enforce controls whether colors should be applied even if stdout is not a TTY. @@ -51,8 +51,8 @@ namespace NDbgDump { if (Enforce) { Colors.Enable(); } - } - + } + // Foreground color modifiers DBG_OUTPUT_COLOR_HANDLER(Markup) { stream << DumpRaw(Colors.LightGreenColor()); @@ -66,35 +66,35 @@ namespace NDbgDump { DBG_OUTPUT_COLOR_HANDLER(ResetType) { stream << DumpRaw(Colors.OldColor()); } - + // Background color modifiers // TODO: support backgrounds in library/cpp/colorizer DBG_OUTPUT_COLOR_HANDLER(Key) { if (Depth++ == 0 && Colors.IsTTY()) { stream << DumpRaw(TStringBuf("\033[42m")); } - } + } DBG_OUTPUT_COLOR_HANDLER(Value) { if (Depth++ == 0 && Colors.IsTTY()) { stream << DumpRaw(TStringBuf("\033[44m")); } - } + } DBG_OUTPUT_COLOR_HANDLER(ResetRole) { if (--Depth == 0 && Colors.IsTTY()) { stream << DumpRaw(TStringBuf("\033[49m")); } - } - + } + private: NColorizer::TColors Colors; size_t Depth = 0; }; } } - -namespace NPrivate { - template <typename CS> - struct TColorSchemeContainer { - CS ColorScheme; - }; -} + +namespace NPrivate { + template <typename CS> + struct TColorSchemeContainer { + CS ColorScheme; + }; +} diff --git a/library/cpp/dbg_output/dump.h b/library/cpp/dbg_output/dump.h index c7efa105ee..bb64ca36d5 100644 --- a/library/cpp/dbg_output/dump.h +++ b/library/cpp/dbg_output/dump.h @@ -2,8 +2,8 @@ #include "engine.h" #include "dumpers.h" -#include "auto.h" -#include "colorscheme.h" +#include "auto.h" +#include "colorscheme.h" #include <util/stream/format.h> #include <util/system/type_name.h> @@ -21,7 +21,7 @@ namespace NPrivate { template <class TColorScheme> struct TTraitsShallow { - struct TDump: public TDumpBase, public TColorSchemeContainer<TColorScheme> { + struct TDump: public TDumpBase, public TColorSchemeContainer<TColorScheme> { template <typename... Args> inline TDump(Args&&... args) : TDumpBase(std::forward<Args>(args)...) @@ -41,7 +41,7 @@ namespace NPrivate { template <class TColorScheme> struct TTraitsDeep { - struct TDump: public TDumpBase, public TColorSchemeContainer<TColorScheme> { + struct TDump: public TDumpBase, public TColorSchemeContainer<TColorScheme> { template <typename... Args> inline TDump(Args&&... args) : TDumpBase(std::forward<Args>(args)...) @@ -95,12 +95,12 @@ namespace NPrivate { } } -template <class T, class TColorScheme = DBG_OUTPUT_DEFAULT_COLOR_SCHEME> -static inline ::NPrivate::TDbgDump<T, ::NPrivate::TTraitsShallow<TColorScheme>> DbgDump(const T& t) { +template <class T, class TColorScheme = DBG_OUTPUT_DEFAULT_COLOR_SCHEME> +static inline ::NPrivate::TDbgDump<T, ::NPrivate::TTraitsShallow<TColorScheme>> DbgDump(const T& t) { return {std::addressof(t)}; } -template <class T, class TColorScheme = DBG_OUTPUT_DEFAULT_COLOR_SCHEME> -static inline ::NPrivate::TDbgDump<T, ::NPrivate::TTraitsDeep<TColorScheme>> DbgDumpDeep(const T& t) { +template <class T, class TColorScheme = DBG_OUTPUT_DEFAULT_COLOR_SCHEME> +static inline ::NPrivate::TDbgDump<T, ::NPrivate::TTraitsDeep<TColorScheme>> DbgDumpDeep(const T& t) { return {std::addressof(t)}; } diff --git a/library/cpp/dbg_output/dumpers.h b/library/cpp/dbg_output/dumpers.h index 4868e97da0..43a21c208e 100644 --- a/library/cpp/dbg_output/dumpers.h +++ b/library/cpp/dbg_output/dumpers.h @@ -74,18 +74,18 @@ template <class A, class B> struct TDumper<std::pair<A, B>> { template <class S> static inline void Dump(S& s, const std::pair<A, B>& v) { - s.ColorScheme.Key(s); - s.ColorScheme.Literal(s); - s << v.first; - s.ColorScheme.ResetType(s); - s.ColorScheme.ResetRole(s); - s.ColorScheme.Markup(s); - s << DumpRaw(" -> "); - s.ColorScheme.Value(s); - s.ColorScheme.Literal(s); - s << v.second; - s.ColorScheme.ResetType(s); - s.ColorScheme.ResetRole(s); + s.ColorScheme.Key(s); + s.ColorScheme.Literal(s); + s << v.first; + s.ColorScheme.ResetType(s); + s.ColorScheme.ResetRole(s); + s.ColorScheme.Markup(s); + s << DumpRaw(" -> "); + s.ColorScheme.Value(s); + s.ColorScheme.Literal(s); + s << v.second; + s.ColorScheme.ResetType(s); + s.ColorScheme.ResetRole(s); } }; diff --git a/library/cpp/dbg_output/engine.h b/library/cpp/dbg_output/engine.h index f13c728c39..140a766952 100644 --- a/library/cpp/dbg_output/engine.h +++ b/library/cpp/dbg_output/engine.h @@ -76,10 +76,10 @@ struct TRawLiteral { template <class TChar> static inline TRawLiteral<TChar> DumpRaw(const TBasicStringBuf<TChar>& s) noexcept { - return {s}; -} - -template <class TChar> + return {s}; +} + +template <class TChar> static inline TRawLiteral<TChar> DumpRaw(const TChar* s) noexcept { return {s}; } @@ -130,7 +130,7 @@ struct TCharDumper { template <class S, class V> static inline void OutSequence(S& s, const V& v, const char* openTag, const char* closeTag) { - s.ColorScheme.Markup(s); + s.ColorScheme.Markup(s); s << DumpRaw(openTag); { @@ -139,21 +139,21 @@ static inline void OutSequence(S& s, const V& v, const char* openTag, const char for (const auto& x : v) { if (cnt) { - s.ColorScheme.Markup(s); + s.ColorScheme.Markup(s); s << DumpRaw(", "); } - s << IndentNewLine(); - s.ColorScheme.Literal(s); - s << x; + s << IndentNewLine(); + s.ColorScheme.Literal(s); + s << x; ++cnt; } } - s << IndentNewLine(); - s.ColorScheme.Markup(s); - s << DumpRaw(closeTag); - s.ColorScheme.ResetType(s); + s << IndentNewLine(); + s.ColorScheme.Markup(s); + s << DumpRaw(closeTag); + s.ColorScheme.ResetType(s); } struct TAssocDumper { @@ -173,8 +173,8 @@ struct TSeqDumper { struct TStrDumper { template <class S, class V> static inline void Dump(S& s, const V& v) { - s.ColorScheme.String(s); + s.ColorScheme.String(s); s.String(v); - s.ColorScheme.ResetType(s); + s.ColorScheme.ResetType(s); } }; diff --git a/library/cpp/dbg_output/ut/dbg_output_ut.cpp b/library/cpp/dbg_output/ut/dbg_output_ut.cpp index 7b285c84cb..7839504bce 100644 --- a/library/cpp/dbg_output/ut/dbg_output_ut.cpp +++ b/library/cpp/dbg_output/ut/dbg_output_ut.cpp @@ -1,17 +1,17 @@ #include <library/cpp/dbg_output/dump.h> #include <library/cpp/testing/unittest/registar.h> - -#include <util/stream/str.h> + +#include <util/stream/str.h> #include <util/string/builder.h> -#include <util/string/escape.h> +#include <util/string/escape.h> #include <util/generic/map.h> - + namespace { struct TX { inline TX() { N = this; } - + TX* N; }; } @@ -24,22 +24,22 @@ struct TDumper<TX> { } }; -namespace TMyNS { - struct TMyStruct { - int A, B; - }; -} -DEFINE_DUMPER(TMyNS::TMyStruct, A, B) - +namespace TMyNS { + struct TMyStruct { + int A, B; + }; +} +DEFINE_DUMPER(TMyNS::TMyStruct, A, B) + Y_UNIT_TEST_SUITE(TContainerPrintersTest) { Y_UNIT_TEST(TestVectorInt) { - TStringStream out; + TStringStream out; out << DbgDump(TVector<int>({1, 2, 3, 4, 5})); UNIT_ASSERT_STRINGS_EQUAL(out.Str(), "[1, 2, 3, 4, 5]"); - } - + } + Y_UNIT_TEST(TestMapCharToCharArray) { - TStringStream out; + TStringStream out; TMap<char, const char*> m; @@ -49,51 +49,51 @@ Y_UNIT_TEST_SUITE(TContainerPrintersTest) { out << DbgDump(m); UNIT_ASSERT_STRINGS_EQUAL(out.Str(), "{'a' -> \"SMALL LETTER A\", 'b' -> (empty)}"); - } - + } + Y_UNIT_TEST(TestVectorOfVectors) { - TStringStream out; + TStringStream out; TVector<TVector<wchar16>> vec(2); - vec[0].push_back(0); + vec[0].push_back(0); vec[1] = {wchar16('a')}; out << DbgDump(vec); UNIT_ASSERT_STRINGS_EQUAL(out.Str(), "[[w'\\0'], [w'a']]"); - } + } Y_UNIT_TEST(TestInfinite) { UNIT_ASSERT(!!(TStringBuilder() << DbgDumpDeep(TX()))); } - + Y_UNIT_TEST(TestLabeledDump) { - TStringStream out; - int a = 1, b = 2; - out << LabeledDump(a, b, 1 + 2); + TStringStream out; + int a = 1, b = 2; + out << LabeledDump(a, b, 1 + 2); UNIT_ASSERT_STRINGS_EQUAL(out.Str(), "{\"a\": 1, \"b\": 2, \"1 + 2\": 3}"); - } - + } + Y_UNIT_TEST(TestStructDumper) { - TStringStream out; - out << DbgDump(TMyNS::TMyStruct{3, 4}); + TStringStream out; + out << DbgDump(TMyNS::TMyStruct{3, 4}); UNIT_ASSERT_STRINGS_EQUAL(out.Str(), "{\"A\": 3, \"B\": 4}"); - } - + } + Y_UNIT_TEST(TestColors) { using TComplex = TMap<TString, TMap<int, char>>; - TComplex test; - test["a"][1] = '7'; - test["b"][2] = '6'; - TStringStream out; - out << DbgDump<TComplex, NDbgDump::NColorScheme::TEyebleed</* Enforce = */ true>>(test); - UNIT_ASSERT_STRINGS_EQUAL( - EscapeC(out.Str()), - "\\x1B[1;32m{\\x1B[1;31m\\x1B[42m\\x1B[1;31m\\x1B[1;33m\\\"a\\\"\\x1B[22;39m\\x1B[22;39m" - "\\x1B[49m\\x1B[1;32m -> \\x1B[44m\\x1B[1;31m\\x1B[1;32m{\\x1B[1;31m\\x1B[1;31m1" - "\\x1B[22;39m\\x1B[1;32m -> \\x1B[1;31m'7'\\x1B[22;39m\\x1B[1;32m}" - "\\x1B[22;39m\\x1B[22;39m\\x1B[49m\\x1B[1;32m, \\x1B[1;31m\\x1B[42m\\x1B[1;31m\\x1B[1;33m" - "\\\"b\\\"\\x1B[22;39m\\x1B[22;39m\\x1B[49m\\x1B[1;32m -> " - "\\x1B[44m\\x1B[1;31m\\x1B[1;32m{\\x1B[1;31m\\x1B[1;31m2\\x1B[22;39m\\x1B[1;32m -> " + TComplex test; + test["a"][1] = '7'; + test["b"][2] = '6'; + TStringStream out; + out << DbgDump<TComplex, NDbgDump::NColorScheme::TEyebleed</* Enforce = */ true>>(test); + UNIT_ASSERT_STRINGS_EQUAL( + EscapeC(out.Str()), + "\\x1B[1;32m{\\x1B[1;31m\\x1B[42m\\x1B[1;31m\\x1B[1;33m\\\"a\\\"\\x1B[22;39m\\x1B[22;39m" + "\\x1B[49m\\x1B[1;32m -> \\x1B[44m\\x1B[1;31m\\x1B[1;32m{\\x1B[1;31m\\x1B[1;31m1" + "\\x1B[22;39m\\x1B[1;32m -> \\x1B[1;31m'7'\\x1B[22;39m\\x1B[1;32m}" + "\\x1B[22;39m\\x1B[22;39m\\x1B[49m\\x1B[1;32m, \\x1B[1;31m\\x1B[42m\\x1B[1;31m\\x1B[1;33m" + "\\\"b\\\"\\x1B[22;39m\\x1B[22;39m\\x1B[49m\\x1B[1;32m -> " + "\\x1B[44m\\x1B[1;31m\\x1B[1;32m{\\x1B[1;31m\\x1B[1;31m2\\x1B[22;39m\\x1B[1;32m -> " "\\x1B[1;31m'6'\\x1B[22;39m\\x1B[1;32m}\\x1B[22;39m\\x1B[22;39m\\x1B[49m\\x1B[1;32m}\\x1B[22;39m"); - } + } Y_UNIT_TEST(SmallIntOrChar) { char c = 'e'; @@ -103,4 +103,4 @@ Y_UNIT_TEST_SUITE(TContainerPrintersTest) { UNIT_ASSERT_VALUES_EQUAL(TStringBuilder() << DbgDump(i), "-100"); UNIT_ASSERT_VALUES_EQUAL(TStringBuilder() << DbgDump(u), "10"); } -} +} diff --git a/library/cpp/dbg_output/ut/ya.make b/library/cpp/dbg_output/ut/ya.make index 201601295d..77a8f38976 100644 --- a/library/cpp/dbg_output/ut/ya.make +++ b/library/cpp/dbg_output/ut/ya.make @@ -1,9 +1,9 @@ UNITTEST_FOR(library/cpp/dbg_output) - + OWNER(pg) - -SRCS( - dbg_output_ut.cpp -) - -END() + +SRCS( + dbg_output_ut.cpp +) + +END() diff --git a/library/cpp/dbg_output/ya.make b/library/cpp/dbg_output/ya.make index 7d54108f93..f8f75fa330 100644 --- a/library/cpp/dbg_output/ya.make +++ b/library/cpp/dbg_output/ya.make @@ -2,10 +2,10 @@ LIBRARY() OWNER(pg) -PEERDIR( +PEERDIR( library/cpp/colorizer -) - +) + SRCS( dump.cpp dumpers.cpp diff --git a/library/cpp/protobuf/json/proto2json.h b/library/cpp/protobuf/json/proto2json.h index 89a1781a40..c7770a62b8 100644 --- a/library/cpp/protobuf/json/proto2json.h +++ b/library/cpp/protobuf/json/proto2json.h @@ -10,7 +10,7 @@ #include <util/generic/fwd.h> #include <util/generic/vector.h> #include <util/generic/yexception.h> -#include <util/stream/str.h> +#include <util/stream/str.h> #include <functional> @@ -51,7 +51,7 @@ namespace NProtobufJson { inline void Proto2Json(const T& proto, TStringStream& out) { out << proto.AsJSON(); } - + /// @throw yexception void Proto2Json(const NProtoBuf::Message& proto, TString& str, const TProto2JsonConfig& config); @@ -75,4 +75,4 @@ namespace NProtobufJson { return result; } -} +} diff --git a/library/cpp/protobuf/json/ut/json.h b/library/cpp/protobuf/json/ut/json.h index c1f108e6e4..2ee855cf61 100644 --- a/library/cpp/protobuf/json/ut/json.h +++ b/library/cpp/protobuf/json/ut/json.h @@ -55,9 +55,9 @@ namespace NProtobufJsonTest { #define UNIT_ASSERT_JSONS_EQUAL(lhs, rhs) \ if (lhs != rhs) { \ - UNIT_ASSERT_STRINGS_EQUAL(lhs.GetStringRobust(), rhs.GetStringRobust()); \ - } - + UNIT_ASSERT_STRINGS_EQUAL(lhs.GetStringRobust(), rhs.GetStringRobust()); \ + } + #define UNIT_ASSERT_JSON_STRINGS_EQUAL(lhs, rhs) \ if (lhs != rhs) { \ NJson::TJsonValue _lhs_json, _rhs_json; \ diff --git a/library/cpp/protobuf/json/ut/proto2json_ut.cpp b/library/cpp/protobuf/json/ut/proto2json_ut.cpp index 07e52d7f2f..f447f5bb5f 100644 --- a/library/cpp/protobuf/json/ut/proto2json_ut.cpp +++ b/library/cpp/protobuf/json/ut/proto2json_ut.cpp @@ -201,7 +201,7 @@ Y_UNIT_TEST(TestFlatRepeated) { UNIT_ASSERT_JSONS_EQUAL(json, modelJson); } // streamed } - + TProto2JsonConfig config; config.SetMissingRepeatedKeyMode(TProto2JsonConfig::MissingKeySkip); @@ -358,7 +358,7 @@ Y_UNIT_TEST(TestCompositeRepeated) { { NJson::TJsonValue json; UNIT_ASSERT_NO_EXCEPTION(Proto2Json(proto, json)); - UNIT_ASSERT_JSONS_EQUAL(json, modelJson); + UNIT_ASSERT_JSONS_EQUAL(json, modelJson); } { @@ -366,7 +366,7 @@ Y_UNIT_TEST(TestCompositeRepeated) { NJson::TJsonValue json; UNIT_ASSERT_NO_EXCEPTION(Proto2Json(proto, jsonStream)); UNIT_ASSERT(ReadJsonTree(&jsonStream, &json)); - UNIT_ASSERT_JSONS_EQUAL(json, modelJson); + UNIT_ASSERT_JSONS_EQUAL(json, modelJson); } // streamed } } // TestCompositeRepeated @@ -518,12 +518,12 @@ Y_UNIT_TEST(TestMissingRepeatedKeyNoConfig) { TFlatRepeated proto; NJson::TJsonValue modelJson(NJson::JSON_MAP); NJson::TJsonValue json; - + UNIT_ASSERT_NO_EXCEPTION(Proto2Json(proto, json)); UNIT_ASSERT_JSONS_EQUAL(json, modelJson); } } // TestMissingRepeatedKeyNoConfig - + Y_UNIT_TEST(TestMissingRepeatedKeyConfig) { { TFlatRepeated proto; diff --git a/library/cpp/string_utils/url/url.cpp b/library/cpp/string_utils/url/url.cpp index 85f4ac5d69..2e7c68a7ae 100644 --- a/library/cpp/string_utils/url/url.cpp +++ b/library/cpp/string_utils/url/url.cpp @@ -125,10 +125,10 @@ TStringBuf CutSchemePrefix(const TStringBuf url) noexcept { template <bool KeepPort> static inline TStringBuf GetHostAndPortImpl(const TStringBuf url) { - TStringBuf urlNoScheme = url; - - urlNoScheme.Skip(GetHttpPrefixSize(url)); + TStringBuf urlNoScheme = url; + urlNoScheme.Skip(GetHttpPrefixSize(url)); + struct TDelim: public str_spn { inline TDelim() : str_spn(KeepPort ? "/;?#" : "/:;?#") @@ -137,7 +137,7 @@ static inline TStringBuf GetHostAndPortImpl(const TStringBuf url) { }; const auto& nonHostCharacters = *Singleton<TDelim>(); - const char* firstNonHostCharacter = nonHostCharacters.brk(urlNoScheme.begin(), urlNoScheme.end()); + const char* firstNonHostCharacter = nonHostCharacters.brk(urlNoScheme.begin(), urlNoScheme.end()); if (firstNonHostCharacter != urlNoScheme.end()) { return urlNoScheme.substr(0, firstNonHostCharacter - urlNoScheme.data()); diff --git a/library/cpp/string_utils/url/url_ut.cpp b/library/cpp/string_utils/url/url_ut.cpp index 1588013893..63b579db7d 100644 --- a/library/cpp/string_utils/url/url_ut.cpp +++ b/library/cpp/string_utils/url/url_ut.cpp @@ -15,7 +15,7 @@ Y_UNIT_TEST_SUITE(TUtilUrlTest) { UNIT_ASSERT_VALUES_EQUAL("ya.ru", GetHost("ya.ru/bebe:8080")); UNIT_ASSERT_VALUES_EQUAL("ya.ru", GetHostAndPort("ya.ru/bebe:8080")); UNIT_ASSERT_VALUES_EQUAL("ya.ru", GetHost("ya.ru:8080/bebe")); - UNIT_ASSERT_VALUES_EQUAL("ya.ru", GetHost("https://ya.ru:8080/bebe")); + UNIT_ASSERT_VALUES_EQUAL("ya.ru", GetHost("https://ya.ru:8080/bebe")); UNIT_ASSERT_VALUES_EQUAL("www.ya.ru", GetHost("www.ya.ru:8080/bebe")); UNIT_ASSERT_VALUES_EQUAL("www.ya.ru", GetHost("https://www.ya.ru:8080/bebe")); UNIT_ASSERT_VALUES_EQUAL("ya.ru:8080", GetHostAndPort("ya.ru:8080/bebe")); diff --git a/library/cpp/uri/uri.cpp b/library/cpp/uri/uri.cpp index 56a9a4e5ef..a44a05acbe 100644 --- a/library/cpp/uri/uri.cpp +++ b/library/cpp/uri/uri.cpp @@ -41,7 +41,7 @@ namespace NUri { continue; if (ch == '_') { // non-standard case we allow for certain hosts - domainLevelOfUnderscore = domainLevel; + domainLevelOfUnderscore = domainLevel; continue; } |