diff options
author | levysotsky <levysotsky@yandex-team.ru> | 2022-02-10 16:47:29 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:47:29 +0300 |
commit | 57f874ffc2a75047c1c4fea7a9fc86cb0f56ed50 (patch) | |
tree | ba6454f353979bb4bafaf230cafdf3e02ea120b2 /library/cpp/yt | |
parent | 23d4769f0fea97cfb1028710e50f2b5ecd0ac2c0 (diff) | |
download | ydb-57f874ffc2a75047c1c4fea7a9fc86cb0f56ed50.tar.gz |
Restoring authorship annotation for <levysotsky@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/yt')
-rw-r--r-- | library/cpp/yt/memory/new-inl.h | 12 | ||||
-rw-r--r-- | library/cpp/yt/misc/enum-inl.h | 114 | ||||
-rw-r--r-- | library/cpp/yt/misc/enum.h | 20 | ||||
-rw-r--r-- | library/cpp/yt/string/enum.cpp | 14 | ||||
-rw-r--r-- | library/cpp/yt/string/enum.h | 10 | ||||
-rw-r--r-- | library/cpp/yt/string/format-inl.h | 8 | ||||
-rw-r--r-- | library/cpp/yt/string/string.cpp | 2 | ||||
-rw-r--r-- | library/cpp/yt/string/string.h | 4 | ||||
-rw-r--r-- | library/cpp/yt/yson_string/string.cpp | 38 | ||||
-rw-r--r-- | library/cpp/yt/yson_string/string.h | 38 |
10 files changed, 130 insertions, 130 deletions
diff --git a/library/cpp/yt/memory/new-inl.h b/library/cpp/yt/memory/new-inl.h index 0a84818516..ce00d338f5 100644 --- a/library/cpp/yt/memory/new-inl.h +++ b/library/cpp/yt/memory/new-inl.h @@ -227,16 +227,16 @@ Y_FORCE_INLINE TIntrusivePtr<T> NewWithExtraSpace( size_t extraSpaceSize, As&&... args) { - auto totalSize = NYT::NDetail::TConstructHelper<T>::Size + extraSpaceSize; + auto totalSize = NYT::NDetail::TConstructHelper<T>::Size + extraSpaceSize; void* ptr = nullptr; - if (NYT::NDetail::TConstructHelper<T>::Alignment <= 16) { + if (NYT::NDetail::TConstructHelper<T>::Alignment <= 16) { ptr = NYTAlloc::Allocate(totalSize); } else { - ptr = NYT::NDetail::AllignedMalloc(totalSize, NYT::NDetail::TConstructHelper<T>::Alignment); + ptr = NYT::NDetail::AllignedMalloc(totalSize, NYT::NDetail::TConstructHelper<T>::Alignment); } - return NYT::NDetail::SafeConstruct<T>(ptr, std::forward<As>(args)...); + return NYT::NDetail::SafeConstruct<T>(ptr, std::forward<As>(args)...); } template <class T, class... As, class> @@ -245,12 +245,12 @@ Y_FORCE_INLINE TIntrusivePtr<T> NewWithExtraSpace( size_t extraSpaceSize, As&&... args) { - auto totalSize = NYT::NDetail::TConstructHelper<T>::Size + extraSpaceSize; + auto totalSize = NYT::NDetail::TConstructHelper<T>::Size + extraSpaceSize; auto* ptr = allocator->Allocate(totalSize); if (!ptr) { return nullptr; } - return NYT::NDetail::SafeConstruct<T>(ptr, std::forward<As>(args)...); + return NYT::NDetail::SafeConstruct<T>(ptr, std::forward<As>(args)...); } //////////////////////////////////////////////////////////////////////////////// diff --git a/library/cpp/yt/misc/enum-inl.h b/library/cpp/yt/misc/enum-inl.h index 59ef704775..0941e1fb63 100644 --- a/library/cpp/yt/misc/enum-inl.h +++ b/library/cpp/yt/misc/enum-inl.h @@ -8,7 +8,7 @@ #include <util/string/printf.h> #include <util/string/cast.h> -#include <algorithm> +#include <algorithm> #include <stdexcept> namespace NYT { @@ -36,25 +36,25 @@ namespace NYT { //////////////////////////////////////////////////////////////////////////////// -namespace NDetail { - -template <typename TValues> -static constexpr bool AreValuesDistinct(const TValues& values) -{ - for (int i = 0; i < static_cast<int>(values.size()); ++i) { - for (int j = i + 1; j < static_cast<int>(values.size()); ++j) { - if (values[i] == values[j]) { - return false; - } - } - } - return true; -} - -} // namespace NDetail - -//////////////////////////////////////////////////////////////////////////////// - +namespace NDetail { + +template <typename TValues> +static constexpr bool AreValuesDistinct(const TValues& values) +{ + for (int i = 0; i < static_cast<int>(values.size()); ++i) { + for (int j = i + 1; j < static_cast<int>(values.size()); ++j) { + if (values[i] == values[j]) { + return false; + } + } + } + return true; +} + +} // namespace NDetail + +//////////////////////////////////////////////////////////////////////////////// + #define ENUM__BEGIN_TRAITS(name, underlyingType, isBit, isStringSerializable, seq) \ struct TEnumTraitsImpl_##name \ { \ @@ -64,13 +64,13 @@ static constexpr bool AreValuesDistinct(const TValues& values) [[maybe_unused]] static constexpr bool IsStringSerializableEnum = isStringSerializable; \ [[maybe_unused]] static constexpr int DomainSize = PP_COUNT(seq); \ \ - static constexpr std::array<TStringBuf, DomainSize> Names{{ \ - PP_FOR_EACH(ENUM__GET_DOMAIN_NAMES_ITEM, seq) \ - }}; \ - static constexpr std::array<TType, DomainSize> Values{{ \ - PP_FOR_EACH(ENUM__GET_DOMAIN_VALUES_ITEM, seq) \ - }}; \ - \ + static constexpr std::array<TStringBuf, DomainSize> Names{{ \ + PP_FOR_EACH(ENUM__GET_DOMAIN_NAMES_ITEM, seq) \ + }}; \ + static constexpr std::array<TType, DomainSize> Values{{ \ + PP_FOR_EACH(ENUM__GET_DOMAIN_VALUES_ITEM, seq) \ + }}; \ + \ static TStringBuf GetTypeName() \ { \ static constexpr TStringBuf typeName = PP_STRINGIZE(name); \ @@ -79,33 +79,33 @@ static constexpr bool AreValuesDistinct(const TValues& values) \ static const TStringBuf* FindLiteralByValue(TType value) \ { \ - for (int i = 0; i < DomainSize; ++i) { \ - if (Values[i] == value) { \ - return &Names[i]; \ - } \ - } \ + for (int i = 0; i < DomainSize; ++i) { \ + if (Values[i] == value) { \ + return &Names[i]; \ + } \ + } \ return nullptr; \ } \ \ static bool FindValueByLiteral(TStringBuf literal, TType* result) \ { \ - for (int i = 0; i < DomainSize; ++i) { \ - if (Names[i] == literal) { \ - *result = Values[i]; \ - return true; \ - } \ - } \ + for (int i = 0; i < DomainSize; ++i) { \ + if (Names[i] == literal) { \ + *result = Values[i]; \ + return true; \ + } \ + } \ return false; \ } \ \ static const std::array<TStringBuf, DomainSize>& GetDomainNames() \ { \ - return Names; \ + return Names; \ } \ \ static const std::array<TType, DomainSize>& GetDomainValues() \ { \ - return Values; \ + return Values; \ } \ \ static TType FromString(TStringBuf str) \ @@ -145,34 +145,34 @@ static constexpr bool AreValuesDistinct(const TValues& values) #define ENUM__GET_DOMAIN_NAMES_ITEM_ATOMIC(item) \ TStringBuf(PP_STRINGIZE(item)), -#define ENUM__DECOMPOSE \ +#define ENUM__DECOMPOSE \ static std::vector<TType> Decompose(TType value) \ { \ std::vector<TType> result; \ - for (int i = 0; i < DomainSize; ++i) { \ - if (static_cast<TUnderlying>(value) & static_cast<TUnderlying>(Values[i])) { \ - result.push_back(Values[i]); \ - } \ - } \ + for (int i = 0; i < DomainSize; ++i) { \ + if (static_cast<TUnderlying>(value) & static_cast<TUnderlying>(Values[i])) { \ + result.push_back(Values[i]); \ + } \ + } \ return result; \ } -#define ENUM__MINMAX \ - static constexpr TType GetMinValue() \ +#define ENUM__MINMAX \ + static constexpr TType GetMinValue() \ { \ - static_assert(!Values.empty()); \ - return *std::min_element(std::begin(Values), std::end(Values)); \ + static_assert(!Values.empty()); \ + return *std::min_element(std::begin(Values), std::end(Values)); \ } \ \ - static constexpr TType GetMaxValue() \ + static constexpr TType GetMaxValue() \ { \ - static_assert(!Values.empty()); \ - return *std::max_element(std::begin(Values), std::end(Values)); \ + static_assert(!Values.empty()); \ + return *std::max_element(std::begin(Values), std::end(Values)); \ } -#define ENUM__VALIDATE_UNIQUE(name) \ - static_assert(::NYT::NDetail::AreValuesDistinct(Values), \ - "Enumeration " #name " contains duplicate values"); +#define ENUM__VALIDATE_UNIQUE(name) \ + static_assert(::NYT::NDetail::AreValuesDistinct(Values), \ + "Enumeration " #name " contains duplicate values"); #define ENUM__END_TRAITS(name) \ }; \ @@ -181,7 +181,7 @@ static constexpr bool AreValuesDistinct(const TValues& values) { \ return TEnumTraitsImpl_##name(); \ } \ - \ + \ using ::ToString; \ [[maybe_unused]] inline TString ToString(name value) \ { \ diff --git a/library/cpp/yt/misc/enum.h b/library/cpp/yt/misc/enum.h index 894364aa43..97c62cac93 100644 --- a/library/cpp/yt/misc/enum.h +++ b/library/cpp/yt/misc/enum.h @@ -108,16 +108,16 @@ struct TEnumTraits<T, true> #define DEFINE_ENUM_WITH_UNDERLYING_TYPE(name, underlyingType, seq) \ ENUM__CLASS(name, underlyingType, seq) \ ENUM__BEGIN_TRAITS(name, underlyingType, false, false, seq) \ - ENUM__MINMAX \ - ENUM__VALIDATE_UNIQUE(name) \ - ENUM__END_TRAITS(name) + ENUM__MINMAX \ + ENUM__VALIDATE_UNIQUE(name) \ + ENUM__END_TRAITS(name) //! Defines a smart enumeration with a specific underlying type. //! Duplicate enumeration values are allowed. #define DEFINE_AMBIGUOUS_ENUM_WITH_UNDERLYING_TYPE(name, underlyingType, seq) \ ENUM__CLASS(name, underlyingType, seq) \ ENUM__BEGIN_TRAITS(name, underlyingType, false, false, seq) \ - ENUM__MINMAX \ + ENUM__MINMAX \ ENUM__END_TRAITS(name) //! Defines a smart enumeration with the default |int| underlying type. @@ -133,8 +133,8 @@ struct TEnumTraits<T, true> #define DEFINE_BIT_ENUM_WITH_UNDERLYING_TYPE(name, underlyingType, seq) \ ENUM__CLASS(name, underlyingType, seq) \ ENUM__BEGIN_TRAITS(name, underlyingType, true, false, seq) \ - ENUM__DECOMPOSE \ - ENUM__VALIDATE_UNIQUE(name) \ + ENUM__DECOMPOSE \ + ENUM__VALIDATE_UNIQUE(name) \ ENUM__END_TRAITS(name) \ ENUM__BITWISE_OPS(name) @@ -148,7 +148,7 @@ struct TEnumTraits<T, true> #define DEFINE_AMBIGUOUS_BIT_ENUM_WITH_UNDERLYING_TYPE(name, underlyingType, seq) \ ENUM__CLASS(name, underlyingType, seq) \ ENUM__BEGIN_TRAITS(name, underlyingType, true, false, seq) \ - ENUM__DECOMPOSE \ + ENUM__DECOMPOSE \ ENUM__END_TRAITS(name) \ ENUM__BITWISE_OPS(name) @@ -169,8 +169,8 @@ struct TEnumTraits<T, true> #define DEFINE_STRING_SERIALIZABLE_ENUM_WITH_UNDERLYING_TYPE(name, underlyingType, seq) \ ENUM__CLASS(name, underlyingType, seq) \ ENUM__BEGIN_TRAITS(name, underlyingType, false, true, seq) \ - ENUM__MINMAX \ - ENUM__VALIDATE_UNIQUE(name) \ + ENUM__MINMAX \ + ENUM__VALIDATE_UNIQUE(name) \ ENUM__END_TRAITS(name) \ //! Defines a smart enumeration with a specific underlying type and IsStringSerializable attribute. @@ -178,7 +178,7 @@ struct TEnumTraits<T, true> #define DEFINE_AMBIGUOUS_STRING_SERIALIZABLE_ENUM_WITH_UNDERLYING_TYPE(name, underlyingType, seq) \ ENUM__CLASS(name, underlyingType, seq) \ ENUM__BEGIN_TRAITS(name, underlyingType, false, true, seq) \ - ENUM__MINMAX \ + ENUM__MINMAX \ ENUM__END_TRAITS(name) //! Defines a smart enumeration with the default |int| underlying type and IsStringSerializable attribute. diff --git a/library/cpp/yt/string/enum.cpp b/library/cpp/yt/string/enum.cpp index 7cb8e5c6b6..aaff64f2df 100644 --- a/library/cpp/yt/string/enum.cpp +++ b/library/cpp/yt/string/enum.cpp @@ -26,17 +26,17 @@ TString EncodeEnumValue(TStringBuf value) namespace NDetail { void ThrowMalformedEnumValueException(TStringBuf typeName, TStringBuf value) -{ +{ throw TSimpleException(Format("Error parsing %v value %Qv", typeName, value)); -} - +} + void FormatUnknownEnumValue(TStringBuilderBase* builder, TStringBuf name, i64 value) -{ - builder->AppendFormat("%v(%v)", name, value); -} - +{ + builder->AppendFormat("%v(%v)", name, value); +} + } // namespace NDetail //////////////////////////////////////////////////////////////////////////////// diff --git a/library/cpp/yt/string/enum.h b/library/cpp/yt/string/enum.h index 10dc02610f..6490114bed 100644 --- a/library/cpp/yt/string/enum.h +++ b/library/cpp/yt/string/enum.h @@ -5,7 +5,7 @@ #include <library/cpp/yt/misc/enum.h> #include <optional> - + namespace NYT { //////////////////////////////////////////////////////////////////////////////// @@ -15,13 +15,13 @@ TString EncodeEnumValue(TStringBuf value); template <class T> T ParseEnum(TStringBuf value); - -template <class T> + +template <class T> void FormatEnum(TStringBuilderBase* builder, T value, bool lowerCase); - + template <class T> TString FormatEnum(T value, typename TEnumTraits<T>::TType* = nullptr); - + //////////////////////////////////////////////////////////////////////////////// } // namespace NYT diff --git a/library/cpp/yt/string/format-inl.h b/library/cpp/yt/string/format-inl.h index 5484d4a216..ab08c58f55 100644 --- a/library/cpp/yt/string/format-inl.h +++ b/library/cpp/yt/string/format-inl.h @@ -4,7 +4,7 @@ #include "format.h" #endif -#include "enum.h" +#include "enum.h" #include "string.h" #include <library/cpp/yt/assert/assert.h> @@ -180,12 +180,12 @@ struct TValueFormatter<TEnum, typename std::enable_if<TEnumTraits<TEnum>::IsEnum lowercase = true; } else if (IsQuotationSpecSymbol(*current)) { ++current; - } else { + } else { break; - } + } } - FormatEnum(builder, value, lowercase); + FormatEnum(builder, value, lowercase); } }; diff --git a/library/cpp/yt/string/string.cpp b/library/cpp/yt/string/string.cpp index 7440ac3fdd..1229359833 100644 --- a/library/cpp/yt/string/string.cpp +++ b/library/cpp/yt/string/string.cpp @@ -1,5 +1,5 @@ #include "string.h" -#include "format.h" +#include "format.h" #include <library/cpp/yt/assert/assert.h> diff --git a/library/cpp/yt/string/string.h b/library/cpp/yt/string/string.h index ae6c99caab..c51b9ae410 100644 --- a/library/cpp/yt/string/string.h +++ b/library/cpp/yt/string/string.h @@ -8,8 +8,8 @@ #include <util/generic/string.h> -#include <util/string/strip.h> - +#include <util/string/strip.h> + #include <vector> #include <set> #include <map> diff --git a/library/cpp/yt/yson_string/string.cpp b/library/cpp/yt/yson_string/string.cpp index 99d45e8616..c00aa98a50 100644 --- a/library/cpp/yt/yson_string/string.cpp +++ b/library/cpp/yt/yson_string/string.cpp @@ -99,8 +99,8 @@ TYsonString::TYsonString( TStringBuf data, EYsonType type) : TYsonString(TYsonStringBuf(data, type)) -{ } - +{ } + #ifdef TSTRING_IS_STD_STRING TYsonString::TYsonString( const TString& data, @@ -120,7 +120,7 @@ TYsonString::TYsonString( Type_ = type; } #endif - + TYsonString::TYsonString( const TSharedRef& data, EYsonType type) @@ -134,22 +134,22 @@ TYsonString::TYsonString( TYsonString::operator bool() const { return !std::holds_alternative<TNullPayload>(Payload_); -} - +} + EYsonType TYsonString::GetType() const -{ +{ YT_VERIFY(*this); return Type_; } TStringBuf TYsonString::AsStringBuf() const -{ +{ YT_VERIFY(*this); return TStringBuf(Begin_, Begin_ + Size_); -} - +} + TString TYsonString::ToString() const -{ +{ return Visit( Payload_, [] (const TNullPayload&) -> TString { @@ -161,13 +161,13 @@ TString TYsonString::ToString() const [] (const TString& payload) { return payload; }); -} - +} + size_t TYsonString::ComputeHash() const -{ +{ return THash<TStringBuf>()(TStringBuf(Begin_, Begin_ + Size_)); -} - +} + //////////////////////////////////////////////////////////////////////////////// TString ToString(const TYsonString& yson) @@ -175,11 +175,11 @@ TString ToString(const TYsonString& yson) return yson.ToString(); } -TString ToString(const TYsonStringBuf& yson) -{ +TString ToString(const TYsonStringBuf& yson) +{ return TString(yson.AsStringBuf()); -} - +} + //////////////////////////////////////////////////////////////////////////////// } // namespace NYT::NYson diff --git a/library/cpp/yt/yson_string/string.h b/library/cpp/yt/yson_string/string.h index e13af37a6d..b25223aa6c 100644 --- a/library/cpp/yt/yson_string/string.h +++ b/library/cpp/yt/yson_string/string.h @@ -47,28 +47,28 @@ public: //! Returns type of YSON contained here. The instance must be non-null. EYsonType GetType() const; -protected: +protected: TStringBuf Data_; EYsonType Type_; - bool Null_; -}; - + bool Null_; +}; + //////////////////////////////////////////////////////////////////////////////// //! An owning version of TYsonStringBuf. /*! * Internally captures the data either via TString or a polymorphic ref-counted holder. */ -class TYsonString -{ -public: +class TYsonString +{ +public: //! Constructs a null instance. TYsonString(); - + //! Constructs an instance from TYsonStringBuf. //! Copies the data into a ref-counted payload. - explicit TYsonString(const TYsonStringBuf& ysonStringBuf); - + explicit TYsonString(const TYsonStringBuf& ysonStringBuf); + //! Constructs an instance from TStringBuf. //! Copies the data into a ref-counted payload. explicit TYsonString( @@ -108,7 +108,7 @@ private: { }; using THolder = TRefCountedPtr; - + std::variant<TNullPayload, THolder, TString> Payload_; const char* Begin_; @@ -119,17 +119,17 @@ private: //////////////////////////////////////////////////////////////////////////////// bool operator == (const TYsonString& lhs, const TYsonString& rhs); -bool operator == (const TYsonString& lhs, const TYsonStringBuf& rhs); -bool operator == (const TYsonStringBuf& lhs, const TYsonString& rhs); -bool operator == (const TYsonStringBuf& lhs, const TYsonStringBuf& rhs); - +bool operator == (const TYsonString& lhs, const TYsonStringBuf& rhs); +bool operator == (const TYsonStringBuf& lhs, const TYsonString& rhs); +bool operator == (const TYsonStringBuf& lhs, const TYsonStringBuf& rhs); + bool operator != (const TYsonString& lhs, const TYsonString& rhs); -bool operator != (const TYsonString& lhs, const TYsonStringBuf& rhs); -bool operator != (const TYsonStringBuf& lhs, const TYsonString& rhs); -bool operator != (const TYsonStringBuf& lhs, const TYsonStringBuf& rhs); +bool operator != (const TYsonString& lhs, const TYsonStringBuf& rhs); +bool operator != (const TYsonStringBuf& lhs, const TYsonString& rhs); +bool operator != (const TYsonStringBuf& lhs, const TYsonStringBuf& rhs); TString ToString(const TYsonString& yson); -TString ToString(const TYsonStringBuf& yson); +TString ToString(const TYsonStringBuf& yson); //////////////////////////////////////////////////////////////////////////////// |