diff options
author | Anton Samokhvalov <pg83@yandex.ru> | 2022-02-10 16:45:15 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:45:15 +0300 |
commit | 72cb13b4aff9bc9cf22e49251bc8fd143f82538f (patch) | |
tree | da2c34829458c7d4e74bdfbdf85dff449e9e7fb8 /library/cpp/deprecated/accessors | |
parent | 778e51ba091dc39e7b7fcab2b9cf4dbedfb6f2b5 (diff) | |
download | ydb-72cb13b4aff9bc9cf22e49251bc8fd143f82538f.tar.gz |
Restoring authorship annotation for Anton Samokhvalov <pg83@yandex.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/deprecated/accessors')
-rw-r--r-- | library/cpp/deprecated/accessors/accessors.cpp | 2 | ||||
-rw-r--r-- | library/cpp/deprecated/accessors/accessors.h | 38 | ||||
-rw-r--r-- | library/cpp/deprecated/accessors/accessors_impl.cpp | 2 | ||||
-rw-r--r-- | library/cpp/deprecated/accessors/accessors_impl.h | 254 | ||||
-rw-r--r-- | library/cpp/deprecated/accessors/accessors_ut.cpp | 12 | ||||
-rw-r--r-- | library/cpp/deprecated/accessors/memory_traits.cpp | 2 | ||||
-rw-r--r-- | library/cpp/deprecated/accessors/memory_traits.h | 22 |
7 files changed, 166 insertions, 166 deletions
diff --git a/library/cpp/deprecated/accessors/accessors.cpp b/library/cpp/deprecated/accessors/accessors.cpp index 7d37e586fa..92f8817c3e 100644 --- a/library/cpp/deprecated/accessors/accessors.cpp +++ b/library/cpp/deprecated/accessors/accessors.cpp @@ -1 +1 @@ -#include "accessors.h" +#include "accessors.h" diff --git a/library/cpp/deprecated/accessors/accessors.h b/library/cpp/deprecated/accessors/accessors.h index 6d4b1da3ad..8ad5f56a34 100644 --- a/library/cpp/deprecated/accessors/accessors.h +++ b/library/cpp/deprecated/accessors/accessors.h @@ -3,7 +3,7 @@ #include "accessors_impl.h" namespace NAccessors { - /* + /* * Adds API compatibility between different types representing memory regions. * * i.e. this will work: @@ -23,26 +23,26 @@ namespace NAccessors { * Both will give you begin, end and size of the underlying memory region. */ - template <typename T> - inline const typename TMemoryTraits<T>::TElementType* Begin(const T& t) { - return NPrivate::TBegin<T>::Get(t); - } + template <typename T> + inline const typename TMemoryTraits<T>::TElementType* Begin(const T& t) { + return NPrivate::TBegin<T>::Get(t); + } - template <typename T> - inline const typename TMemoryTraits<T>::TElementType* End(const T& t) { - return NPrivate::TEnd<T>::Get(t); - } + template <typename T> + inline const typename TMemoryTraits<T>::TElementType* End(const T& t) { + return NPrivate::TEnd<T>::Get(t); + } - template <typename T> - inline size_t Size(const T& t) { - return End(t) - Begin(t); - } + template <typename T> + inline size_t Size(const T& t) { + return End(t) - Begin(t); + } /** * This gives some unification in terms of memory manipulation. */ - template <typename T> + template <typename T> inline void Reserve(T& t, size_t sz) { NPrivate::TReserve<T>::Do(t, sz); } @@ -75,9 +75,9 @@ namespace NAccessors { } template <typename T> - inline void Assign(T& t, - const typename TMemoryTraits<T>::TElementType* beg, - const typename TMemoryTraits<T>::TElementType* end) { - NPrivate::TAssign<T>::Do(t, beg, end); - } + inline void Assign(T& t, + const typename TMemoryTraits<T>::TElementType* beg, + const typename TMemoryTraits<T>::TElementType* end) { + NPrivate::TAssign<T>::Do(t, beg, end); + } } diff --git a/library/cpp/deprecated/accessors/accessors_impl.cpp b/library/cpp/deprecated/accessors/accessors_impl.cpp index 0bf74cab7b..f5191d647e 100644 --- a/library/cpp/deprecated/accessors/accessors_impl.cpp +++ b/library/cpp/deprecated/accessors/accessors_impl.cpp @@ -1 +1 @@ -#include "accessors_impl.h" +#include "accessors_impl.h" diff --git a/library/cpp/deprecated/accessors/accessors_impl.h b/library/cpp/deprecated/accessors/accessors_impl.h index 6b2b987351..e04cc0679f 100644 --- a/library/cpp/deprecated/accessors/accessors_impl.h +++ b/library/cpp/deprecated/accessors/accessors_impl.h @@ -3,114 +3,114 @@ #include "memory_traits.h" namespace NAccessors { - namespace NPrivate { - template <typename Ta> - struct TMemoryAccessorBase { - enum { - SimpleMemory = TMemoryTraits<Ta>::SimpleMemory, - ContinuousMemory = TMemoryTraits<Ta>::ContinuousMemory, - }; - - struct TBadAccessor; - }; - - template <typename Ta> - struct TBegin: public TMemoryAccessorBase<Ta> { + namespace NPrivate { + template <typename Ta> + struct TMemoryAccessorBase { + enum { + SimpleMemory = TMemoryTraits<Ta>::SimpleMemory, + ContinuousMemory = TMemoryTraits<Ta>::ContinuousMemory, + }; + + struct TBadAccessor; + }; + + template <typename Ta> + struct TBegin: public TMemoryAccessorBase<Ta> { using TElementType = typename TMemoryTraits<Ta>::TElementType; - template <typename Tb> - struct TNoMemoryIndirectionBegin { - static const TElementType* Get(const Tb& b) { - return (const TElementType*)&b; - } - }; + template <typename Tb> + struct TNoMemoryIndirectionBegin { + static const TElementType* Get(const Tb& b) { + return (const TElementType*)&b; + } + }; - template <typename Tb> - struct TIndirectMemoryRegionBegin { + template <typename Tb> + struct TIndirectMemoryRegionBegin { Y_HAS_MEMBER(Begin); Y_HAS_MEMBER(begin); - template <typename Tc> - struct TByBegin { - static const TElementType* Get(const Tc& b) { - return (const TElementType*)b.Begin(); - } - }; - - template <typename Tc> - struct TBybegin { - static const TElementType* Get(const Tc& b) { - return (const TElementType*)b.begin(); - } - }; - + template <typename Tc> + struct TByBegin { + static const TElementType* Get(const Tc& b) { + return (const TElementType*)b.Begin(); + } + }; + + template <typename Tc> + struct TBybegin { + static const TElementType* Get(const Tc& b) { + return (const TElementType*)b.begin(); + } + }; + using TGet = std::conditional_t<THasBegin<Tb>::value, TByBegin<Tb>, TBybegin<Tb>>; - - static const TElementType* Get(const Tb& b) { - return TGet::Get(b); - } - }; - + + static const TElementType* Get(const Tb& b) { + return TGet::Get(b); + } + }; + using TGet = std::conditional_t< - TMemoryAccessorBase<Ta>::SimpleMemory, - TNoMemoryIndirectionBegin<Ta>, + TMemoryAccessorBase<Ta>::SimpleMemory, + TNoMemoryIndirectionBegin<Ta>, std::conditional_t< - TMemoryAccessorBase<Ta>::ContinuousMemory, - TIndirectMemoryRegionBegin<Ta>, + TMemoryAccessorBase<Ta>::ContinuousMemory, + TIndirectMemoryRegionBegin<Ta>, typename TMemoryAccessorBase<Ta>::TBadAccessor>>; - - static const TElementType* Get(const Ta& b) { - return TGet::Get(b); + + static const TElementType* Get(const Ta& b) { + return TGet::Get(b); } }; - template <typename Ta> - struct TEnd: public TMemoryAccessorBase<Ta> { + template <typename Ta> + struct TEnd: public TMemoryAccessorBase<Ta> { using TElementType = typename TMemoryTraits<Ta>::TElementType; - template <typename Tb> - struct TNoMemoryIndirectionEnd { - static const TElementType* Get(const Tb& b) { - return (const TElementType*)(&b + 1); - } - }; + template <typename Tb> + struct TNoMemoryIndirectionEnd { + static const TElementType* Get(const Tb& b) { + return (const TElementType*)(&b + 1); + } + }; - template <typename Tb> - struct TIndirectMemoryRegionEnd { + template <typename Tb> + struct TIndirectMemoryRegionEnd { Y_HAS_MEMBER(End); Y_HAS_MEMBER(end); - template <typename Tc> - struct TByEnd { - static const TElementType* Get(const Tc& b) { - return (const TElementType*)b.End(); - } - }; + template <typename Tc> + struct TByEnd { + static const TElementType* Get(const Tc& b) { + return (const TElementType*)b.End(); + } + }; - template <typename Tc> - struct TByend { - static const TElementType* Get(const Tc& b) { - return (const TElementType*)b.end(); - } - }; + template <typename Tc> + struct TByend { + static const TElementType* Get(const Tc& b) { + return (const TElementType*)b.end(); + } + }; using TGet = std::conditional_t<THasEnd<Tb>::value, TByEnd<Tb>, TByend<Tb>>; - static const TElementType* Get(const Tb& b) { - return TGet::Get(b); - } - }; + static const TElementType* Get(const Tb& b) { + return TGet::Get(b); + } + }; using TGet = std::conditional_t< - TMemoryAccessorBase<Ta>::SimpleMemory, - TNoMemoryIndirectionEnd<Ta>, + TMemoryAccessorBase<Ta>::SimpleMemory, + TNoMemoryIndirectionEnd<Ta>, std::conditional_t< - TMemoryAccessorBase<Ta>::ContinuousMemory, - TIndirectMemoryRegionEnd<Ta>, + TMemoryAccessorBase<Ta>::ContinuousMemory, + TIndirectMemoryRegionEnd<Ta>, typename TMemoryAccessorBase<Ta>::TBadAccessor>>; - static const TElementType* Get(const Ta& b) { - return TGet::Get(b); + static const TElementType* Get(const Ta& b) { + return TGet::Get(b); } }; @@ -343,13 +343,13 @@ namespace NAccessors { } }; - template <typename Ta> - struct TAssign: public TMemoryAccessorBase<Ta> { + template <typename Ta> + struct TAssign: public TMemoryAccessorBase<Ta> { using TElementType = typename TMemoryTraits<Ta>::TElementType; - template <typename Tb> - struct TNoMemoryIndirectionAssign { - static void Do(Tb& b, const TElementType* beg, const TElementType* end) { + template <typename Tb> + struct TNoMemoryIndirectionAssign { + static void Do(Tb& b, const TElementType* beg, const TElementType* end) { if (sizeof(Tb) == sizeof(TElementType) && end - beg > 0) { memcpy(&b, beg, sizeof(Tb)); } else if (end - beg > 0) { @@ -357,63 +357,63 @@ namespace NAccessors { } else { Zero(b); } - } - }; + } + }; - template <typename Tb> - struct TIndirectMemoryRegionAssign { + template <typename Tb> + struct TIndirectMemoryRegionAssign { Y_HAS_MEMBER(Assign); Y_HAS_MEMBER(assign); - template <typename Tc> - struct TByAssign { - static void Do(Tc& b, const TElementType* beg, const TElementType* end) { - b.Assign(beg, end); - } - }; - - template <typename Tc> - struct TByassign { - static void Do(Tc& b, const TElementType* beg, const TElementType* end) { - b.assign(beg, end); - } - }; - - template <typename Tc> - struct TByClearAppend { - static void Do(Tc& b, const TElementType* beg, const TElementType* end) { - TClear<Tc, false>::Do(b); - TAppendRegion<Tc>::Do(b, beg, end); - } - }; - - template <typename Tc> - struct TByConstruction { - static void Do(Tc& b, const TElementType* beg, const TElementType* end) { - b = Tc(beg, end); - } - }; + template <typename Tc> + struct TByAssign { + static void Do(Tc& b, const TElementType* beg, const TElementType* end) { + b.Assign(beg, end); + } + }; + + template <typename Tc> + struct TByassign { + static void Do(Tc& b, const TElementType* beg, const TElementType* end) { + b.assign(beg, end); + } + }; + + template <typename Tc> + struct TByClearAppend { + static void Do(Tc& b, const TElementType* beg, const TElementType* end) { + TClear<Tc, false>::Do(b); + TAppendRegion<Tc>::Do(b, beg, end); + } + }; + + template <typename Tc> + struct TByConstruction { + static void Do(Tc& b, const TElementType* beg, const TElementType* end) { + b = Tc(beg, end); + } + }; using TDo = std::conditional_t< THasAssign<Tb>::value, - TByAssign<Tb>, + TByAssign<Tb>, std::conditional_t< THasassign<Tb>::value, - TByassign<Tb>, + TByassign<Tb>, std::conditional_t< - TMemoryTraits<Tb>::OwnsMemory, - TByClearAppend<Tb>, + TMemoryTraits<Tb>::OwnsMemory, + TByClearAppend<Tb>, TByConstruction<Tb>>>>; - static void Do(Tb& b, const TElementType* beg, const TElementType* end) { - TDo::Do(b, beg, end); - } - }; + static void Do(Tb& b, const TElementType* beg, const TElementType* end) { + TDo::Do(b, beg, end); + } + }; using TDo = std::conditional_t<TMemoryAccessorBase<Ta>::SimpleMemory, TNoMemoryIndirectionAssign<Ta>, TIndirectMemoryRegionAssign<Ta>>; - static void Do(Ta& b, const TElementType* beg, const TElementType* end) { - TDo::Do(b, beg, end); + static void Do(Ta& b, const TElementType* beg, const TElementType* end) { + TDo::Do(b, beg, end); } }; } diff --git a/library/cpp/deprecated/accessors/accessors_ut.cpp b/library/cpp/deprecated/accessors/accessors_ut.cpp index a9bdc9fcc4..9d993b10bf 100644 --- a/library/cpp/deprecated/accessors/accessors_ut.cpp +++ b/library/cpp/deprecated/accessors/accessors_ut.cpp @@ -1,17 +1,17 @@ #include "accessors.h" #include <library/cpp/testing/unittest/registar.h> - + #include <util/generic/buffer.h> #include <util/generic/vector.h> #include <array> class TAccessorsTest: public TTestBase { - UNIT_TEST_SUITE(TAccessorsTest); - UNIT_TEST(TestAccessors); - UNIT_TEST_SUITE_END(); - + UNIT_TEST_SUITE(TAccessorsTest); + UNIT_TEST(TestAccessors); + UNIT_TEST_SUITE_END(); + private: template <typename T> void TestRead(const T& t, const char* comm) { @@ -50,7 +50,7 @@ private: TestRead('a', "char"); TestRead(1, "int"); - int t[4] = {0, 1, 2, 3}; + int t[4] = {0, 1, 2, 3}; TestRead(t, "int[4]"); diff --git a/library/cpp/deprecated/accessors/memory_traits.cpp b/library/cpp/deprecated/accessors/memory_traits.cpp index df53026cf4..76d0d3bad4 100644 --- a/library/cpp/deprecated/accessors/memory_traits.cpp +++ b/library/cpp/deprecated/accessors/memory_traits.cpp @@ -1 +1 @@ -#include "memory_traits.h" +#include "memory_traits.h" diff --git a/library/cpp/deprecated/accessors/memory_traits.h b/library/cpp/deprecated/accessors/memory_traits.h index aa837705d3..1ebf53f108 100644 --- a/library/cpp/deprecated/accessors/memory_traits.h +++ b/library/cpp/deprecated/accessors/memory_traits.h @@ -1,13 +1,13 @@ #pragma once #include <util/generic/array_ref.h> -#include <util/memory/blob.h> -#include <util/memory/tempbuf.h> +#include <util/memory/blob.h> +#include <util/memory/tempbuf.h> #include <util/generic/buffer.h> #include <util/generic/strbuf.h> #include <util/generic/string.h> -#include <util/generic/vector.h> -#include <util/generic/typetraits.h> +#include <util/generic/vector.h> +#include <util/generic/typetraits.h> #include <array> #include <string> @@ -47,14 +47,14 @@ struct TMemoryTraits<std::array<T, n>> { }; template <typename A, typename B> -struct TMemoryTraits<std::pair<A, B>> { +struct TMemoryTraits<std::pair<A, B>> { enum { SimpleMemory = TMemoryTraits<A>::SimpleMemory && TMemoryTraits<B>::SimpleMemory, ContinuousMemory = SimpleMemory, OwnsMemory = SimpleMemory, }; - using TElementType = std::pair<A, B>; + using TElementType = std::pair<A, B>; }; template <> @@ -80,7 +80,7 @@ struct TMemoryTraits<TTempBuf> { }; template <> -struct TMemoryTraits< ::TBlob> { +struct TMemoryTraits< ::TBlob> { enum { SimpleMemory = false, ContinuousMemory = true, @@ -101,7 +101,7 @@ struct TElementDependentMemoryTraits { }; template <typename T, typename TAlloc> -struct TMemoryTraits<std::vector<T, TAlloc>>: public TElementDependentMemoryTraits<T> { +struct TMemoryTraits<std::vector<T, TAlloc>>: public TElementDependentMemoryTraits<T> { enum { OwnsMemory = TMemoryTraits<T>::OwnsMemory }; @@ -112,14 +112,14 @@ struct TMemoryTraits<TVector<T, TAlloc>>: public TMemoryTraits<std::vector<T, TA }; template <typename T> -struct TMemoryTraits<TTempArray<T>>: public TElementDependentMemoryTraits<T> { +struct TMemoryTraits<TTempArray<T>>: public TElementDependentMemoryTraits<T> { enum { OwnsMemory = TMemoryTraits<T>::OwnsMemory }; }; template <typename T, typename TCharTraits, typename TAlloc> -struct TMemoryTraits<std::basic_string<T, TCharTraits, TAlloc>>: public TElementDependentMemoryTraits<T> { +struct TMemoryTraits<std::basic_string<T, TCharTraits, TAlloc>>: public TElementDependentMemoryTraits<T> { enum { OwnsMemory = TMemoryTraits<T>::OwnsMemory }; @@ -154,7 +154,7 @@ struct TMemoryTraits<TBasicStringBuf<TCharType, TCharTraits>>: public TElementDe }; template <> -struct TMemoryTraits<TStringBuf>: public TElementDependentMemoryTraits<char> { +struct TMemoryTraits<TStringBuf>: public TElementDependentMemoryTraits<char> { enum { OwnsMemory = false }; |