diff options
author | akhropov <akhropov@yandex-team.ru> | 2022-02-10 16:46:32 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:46:32 +0300 |
commit | 00afc96e9c0298054b7386fa7fb9e3cc3d67b974 (patch) | |
tree | cb7a9f4a92c0d4cc5a86eeed49ad71e810953c1f /library | |
parent | 83a8efcf3af051e3dd59c00d1d5dafc96412ec1e (diff) | |
download | ydb-00afc96e9c0298054b7386fa7fb9e3cc3d67b974.tar.gz |
Restoring authorship annotation for <akhropov@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'library')
31 files changed, 517 insertions, 517 deletions
diff --git a/library/README.md b/library/README.md index fc418bef7b..00201a3f0f 100644 --- a/library/README.md +++ b/library/README.md @@ -23,7 +23,7 @@ library 7. The library **MUST** be accompanied by `README.md` file and a brief description of the project. 8. The library **MUST** be accompanied by unit-tests. - + 9. CPU- or/and RAM-bound algorithms **SHOULD** provide benchmarks. 10. There **MUST** be no trade secrets of Yandex in `library/`: anything that can cause harm on publishing as OpenSource. For example: diff --git a/library/cpp/binsaver/bin_saver.h b/library/cpp/binsaver/bin_saver.h index 412424889f..88de676e8f 100644 --- a/library/cpp/binsaver/bin_saver.h +++ b/library/cpp/binsaver/bin_saver.h @@ -10,8 +10,8 @@ #include <util/generic/list.h> #include <util/generic/maybe.h> #include <util/generic/bitmap.h> -#include <util/generic/variant.h> -#include <util/generic/ylimits.h> +#include <util/generic/variant.h> +#include <util/generic/ylimits.h> #include <util/memory/blob.h> #include <util/digest/murmur.h> @@ -404,13 +404,13 @@ public: template <class T1, size_t N> int Add(const chunk_id, std::array<T1, N>* pData) { if (HasNonTrivialSerializer<T1>(0u)) { - for (size_t i = 0; i < N; ++i) - Add(1, &(*pData)[i]); - } else { + for (size_t i = 0; i < N; ++i) + Add(1, &(*pData)[i]); + } else { DataChunk((void*)pData->data(), pData->size() * sizeof(T1)); - } - return 0; - } + } + return 0; + } template <size_t N> int Add(const chunk_id, std::bitset<N>* pData) { @@ -451,46 +451,46 @@ public: return 0; } - template <class TVariantClass> - struct TLoadFromTypeFromListHelper { - template <class T0, class... TTail> - static void Do(IBinSaver& binSaver, ui32 typeIndex, TVariantClass* pData) { - if constexpr (sizeof...(TTail) == 0) { - Y_ASSERT(typeIndex == 0); - T0 chunk; - binSaver.Add(2, &chunk); - *pData = std::move(chunk); - } else { - if (typeIndex == 0) { - Do<T0>(binSaver, 0, pData); - } else { - Do<TTail...>(binSaver, typeIndex - 1, pData); - } - } - } - }; - - template <class... TVariantTypes> + template <class TVariantClass> + struct TLoadFromTypeFromListHelper { + template <class T0, class... TTail> + static void Do(IBinSaver& binSaver, ui32 typeIndex, TVariantClass* pData) { + if constexpr (sizeof...(TTail) == 0) { + Y_ASSERT(typeIndex == 0); + T0 chunk; + binSaver.Add(2, &chunk); + *pData = std::move(chunk); + } else { + if (typeIndex == 0) { + Do<T0>(binSaver, 0, pData); + } else { + Do<TTail...>(binSaver, typeIndex - 1, pData); + } + } + } + }; + + template <class... TVariantTypes> int Add(const chunk_id, std::variant<TVariantTypes...>* pData) { static_assert(std::variant_size_v<std::variant<TVariantTypes...>> < Max<ui32>()); - - ui32 index; - if (IsReading()) { - Add(1, &index); + + ui32 index; + if (IsReading()) { + Add(1, &index); TLoadFromTypeFromListHelper<std::variant<TVariantTypes...>>::template Do<TVariantTypes...>( - *this, - index, - pData - ); - } else { - index = pData->index(); // type cast is safe because of static_assert check above - Add(1, &index); + *this, + index, + pData + ); + } else { + index = pData->index(); // type cast is safe because of static_assert check above + Add(1, &index); std::visit([&](auto& dst) -> void { Add(2, &dst); }, *pData); - } - return 0; - } - - + } + return 0; + } + + void AddPolymorphicBase(chunk_id, IObjectBase* pObject) { (*pObject) & (*this); } @@ -504,9 +504,9 @@ public: else StoreObject(pData->GetBarePtr()); } - template <class T, class TPolicy> - int Add(const chunk_id, TMaybe<T, TPolicy>* pData) { - TMaybe<T, TPolicy>& data = *pData; + template <class T, class TPolicy> + int Add(const chunk_id, TMaybe<T, TPolicy>* pData) { + TMaybe<T, TPolicy>& data = *pData; if (IsReading()) { bool defined = false; Add(1, &defined); @@ -585,23 +585,23 @@ struct TRegisterSaveLoadType { #define REGISTER_SAVELOAD_CLASS(N, name) \ BASIC_REGISTER_CLASS(name) \ static TRegisterSaveLoadType<name> init##name##N(N); - + // using TObj/TRef on forward declared templ class will not work // but multiple registration with same id is allowed #define REGISTER_SAVELOAD_TEMPL1_CLASS(N, className, T) \ static TRegisterSaveLoadType<className<T>> init##className##T##N(N); - + #define REGISTER_SAVELOAD_TEMPL2_CLASS(N, className, T1, T2) \ typedef className<T1, T2> temp##className##T1##_##T2##temp; \ static TRegisterSaveLoadType<className<T1, T2>> init##className##T1##_##T2##N(N); - + #define REGISTER_SAVELOAD_TEMPL3_CLASS(N, className, T1, T2, T3) \ typedef className<T1, T2, T3> temp##className##T1##_##T2##_##T3##temp; \ static TRegisterSaveLoadType<className<T1, T2, T3>> init##className##T1##_##T2##_##T3##N(N); - + #define REGISTER_SAVELOAD_NM_CLASS(N, nmspace, className) \ BASIC_REGISTER_CLASS(nmspace::className) \ - static TRegisterSaveLoadType<nmspace::className> init_##nmspace##_##name##N(N); + static TRegisterSaveLoadType<nmspace::className> init_##nmspace##_##name##N(N); #define REGISTER_SAVELOAD_NM2_CLASS(N, nmspace1, nmspace2, className) \ BASIC_REGISTER_CLASS(nmspace1::nmspace2::className) \ diff --git a/library/cpp/binsaver/ut/binsaver_ut.cpp b/library/cpp/binsaver/ut/binsaver_ut.cpp index 37eba5406f..a42d161947 100644 --- a/library/cpp/binsaver/ut/binsaver_ut.cpp +++ b/library/cpp/binsaver/ut/binsaver_ut.cpp @@ -80,51 +80,51 @@ UNIT_ASSERT(IBinSaver::HasNonTrivialSerializer<TVector<TCustomSerializer>>(0u)); Y_UNIT_TEST(TestStroka) { - TestBinSaverSerialization(TString("QWERTY")); + TestBinSaverSerialization(TString("QWERTY")); } Y_UNIT_TEST(TestMoveOnlyType) { - TestBinSaverSerializationToBuffer(TMoveOnlyType()); + TestBinSaverSerializationToBuffer(TMoveOnlyType()); } Y_UNIT_TEST(TestVectorStrok) { - TestBinSaverSerialization(TVector<TString>{"A", "B", "C"}); + TestBinSaverSerialization(TVector<TString>{"A", "B", "C"}); } Y_UNIT_TEST(TestCArray) { - TestBinSaverSerialization(TTypeWithArray()); + TestBinSaverSerialization(TTypeWithArray()); } Y_UNIT_TEST(TestSets) { - TestBinSaverSerialization(THashSet<TString>{"A", "B", "C"}); - TestBinSaverSerialization(TSet<TString>{"A", "B", "C"}); + TestBinSaverSerialization(THashSet<TString>{"A", "B", "C"}); + TestBinSaverSerialization(TSet<TString>{"A", "B", "C"}); } Y_UNIT_TEST(TestMaps) { - TestBinSaverSerialization(THashMap<TString, ui32>{{"A", 1}, {"B", 2}, {"C", 3}}); - TestBinSaverSerialization(TMap<TString, ui32>{{"A", 1}, {"B", 2}, {"C", 3}}); + TestBinSaverSerialization(THashMap<TString, ui32>{{"A", 1}, {"B", 2}, {"C", 3}}); + TestBinSaverSerialization(TMap<TString, ui32>{{"A", 1}, {"B", 2}, {"C", 3}}); } Y_UNIT_TEST(TestBlob) { - TestBinSaverSerialization(TBlob::FromStringSingleThreaded("qwerty")); + TestBinSaverSerialization(TBlob::FromStringSingleThreaded("qwerty")); } -Y_UNIT_TEST(TestVariant) { - { +Y_UNIT_TEST(TestVariant) { + { using T = std::variant<TString, int>; - - TestBinSaverSerialization(T(TString(""))); - TestBinSaverSerialization(T(0)); - } - { + + TestBinSaverSerialization(T(TString(""))); + TestBinSaverSerialization(T(0)); + } + { using T = std::variant<TString, int, float>; - - TestBinSaverSerialization(T(TString("ask"))); - TestBinSaverSerialization(T(12)); - TestBinSaverSerialization(T(0.64f)); - } -} - + + TestBinSaverSerialization(T(TString("ask"))); + TestBinSaverSerialization(T(12)); + TestBinSaverSerialization(T(0.64f)); + } +} + Y_UNIT_TEST(TestPod) { struct TPod { ui32 A = 5; @@ -133,12 +133,12 @@ Y_UNIT_TEST(TestPod) { return A == other.A && B == other.B; } }; - TestBinSaverSerialization(TPod()); + TestBinSaverSerialization(TPod()); TPod custom; custom.A = 25; custom.B = 37; - TestBinSaverSerialization(custom); - TestBinSaverSerialization(TVector<TPod>{custom}); + TestBinSaverSerialization(custom); + TestBinSaverSerialization(TVector<TPod>{custom}); } Y_UNIT_TEST(TestSubPod) { @@ -158,12 +158,12 @@ Y_UNIT_TEST(TestSubPod) { return B == other.B; } }; - TestBinSaverSerialization(TPod()); + TestBinSaverSerialization(TPod()); TPod::TSub sub; sub.X = 1; TPod custom; custom.B = {sub}; - TestBinSaverSerialization(TVector<TPod>{custom}); + TestBinSaverSerialization(TVector<TPod>{custom}); } Y_UNIT_TEST(TestMemberAndOpIsMain) { @@ -192,7 +192,7 @@ Y_UNIT_TEST(TestMemberAndOpIsMain) { obj.S = "TString"; obj.A = 42; - TestBinSaverSerialization(obj); + TestBinSaverSerialization(obj); } } ; diff --git a/library/cpp/binsaver/ut/ya.make b/library/cpp/binsaver/ut/ya.make index 43dc20bff7..a60a2684f9 100644 --- a/library/cpp/binsaver/ut/ya.make +++ b/library/cpp/binsaver/ut/ya.make @@ -7,5 +7,5 @@ SRCS( ) PEERDIR(library/cpp/binsaver/ut_util) - + END() diff --git a/library/cpp/binsaver/ut_util/README.md b/library/cpp/binsaver/ut_util/README.md index 41641cd1e1..9f7e1b0b94 100644 --- a/library/cpp/binsaver/ut_util/README.md +++ b/library/cpp/binsaver/ut_util/README.md @@ -1 +1 @@ -Library for testing BinSaver serialization.
\ No newline at end of file +Library for testing BinSaver serialization.
\ No newline at end of file diff --git a/library/cpp/binsaver/ut_util/ut_util.cpp b/library/cpp/binsaver/ut_util/ut_util.cpp index 4cd8daa931..8e466a5acd 100644 --- a/library/cpp/binsaver/ut_util/ut_util.cpp +++ b/library/cpp/binsaver/ut_util/ut_util.cpp @@ -1 +1 @@ -#include "ut_util.h" +#include "ut_util.h" diff --git a/library/cpp/binsaver/ut_util/ut_util.h b/library/cpp/binsaver/ut_util/ut_util.h index 52e7bcf8e1..be8f89cc7c 100644 --- a/library/cpp/binsaver/ut_util/ut_util.h +++ b/library/cpp/binsaver/ut_util/ut_util.h @@ -1,71 +1,71 @@ -#pragma once - +#pragma once + #include <library/cpp/binsaver/bin_saver.h> #include <library/cpp/binsaver/mem_io.h> #include <library/cpp/binsaver/util_stream_io.h> - + #include <library/cpp/testing/unittest/registar.h> - -#include <util/generic/vector.h> -#include <util/stream/buffer.h> - -#include <functional> - - -/* comparerChecksInside == true means comparer uses UNIT_ASSERT... inside itself - * comparerChecksInside == false means comparer returns if its arguments are equal - */ - -template <class T, class TComparer = std::equal_to<T>, bool comparerChecksInside = false> -void UnitTestCheckWithComparer(const T& lhs, const T& rhs, const TComparer& comparer) { - if constexpr (comparerChecksInside) { - comparer(lhs, rhs); - } else { - UNIT_ASSERT(comparer(lhs, rhs)); - } -} - - -/* comparerChecksInside == true means comparer uses UNIT_ASSERT... inside itself - * comparerChecksInside == false means comparer returns true if its arguments are equal - */ - -template <typename T, typename TComparer = std::equal_to<T>, bool comparerChecksInside = false> -void TestBinSaverSerializationToBuffer(const T& original, const TComparer& comparer = TComparer()) { - TBufferOutput out; - { - TYaStreamOutput yaOut(out); - - IBinSaver f(yaOut, false, false); - f.Add(0, const_cast<T*>(&original)); - } - TBufferInput in(out.Buffer()); - T restored; - { - TYaStreamInput yaIn(in); - IBinSaver f(yaIn, true, false); - f.Add(0, &restored); - } - UnitTestCheckWithComparer<T, TComparer, comparerChecksInside>(original, restored, comparer); -} - -template <typename T, typename TComparer = std::equal_to<T>, bool comparerChecksInside = false> -void TestBinSaverSerializationToVector(const T& original, const TComparer& comparer = TComparer()) { - TVector<char> out; - SerializeToMem(&out, *const_cast<T*>(&original)); - T restored; - SerializeFromMem(&out, restored); - UnitTestCheckWithComparer<T, TComparer, comparerChecksInside>(original, restored, comparer); - - TVector<TVector<char>> out2D; - SerializeToMem(&out2D, *const_cast<T*>(&original)); - T restored2D; - SerializeFromMem(&out2D, restored2D); - UnitTestCheckWithComparer<T, TComparer, comparerChecksInside>(original, restored2D, comparer); -} - -template <typename T, typename TComparer = std::equal_to<T>, bool comparerChecksInside = false> -void TestBinSaverSerialization(const T& original, const TComparer& comparer = TComparer()) { - TestBinSaverSerializationToBuffer<T, TComparer, comparerChecksInside>(original, comparer); - TestBinSaverSerializationToVector<T, TComparer, comparerChecksInside>(original, comparer); -} + +#include <util/generic/vector.h> +#include <util/stream/buffer.h> + +#include <functional> + + +/* comparerChecksInside == true means comparer uses UNIT_ASSERT... inside itself + * comparerChecksInside == false means comparer returns if its arguments are equal + */ + +template <class T, class TComparer = std::equal_to<T>, bool comparerChecksInside = false> +void UnitTestCheckWithComparer(const T& lhs, const T& rhs, const TComparer& comparer) { + if constexpr (comparerChecksInside) { + comparer(lhs, rhs); + } else { + UNIT_ASSERT(comparer(lhs, rhs)); + } +} + + +/* comparerChecksInside == true means comparer uses UNIT_ASSERT... inside itself + * comparerChecksInside == false means comparer returns true if its arguments are equal + */ + +template <typename T, typename TComparer = std::equal_to<T>, bool comparerChecksInside = false> +void TestBinSaverSerializationToBuffer(const T& original, const TComparer& comparer = TComparer()) { + TBufferOutput out; + { + TYaStreamOutput yaOut(out); + + IBinSaver f(yaOut, false, false); + f.Add(0, const_cast<T*>(&original)); + } + TBufferInput in(out.Buffer()); + T restored; + { + TYaStreamInput yaIn(in); + IBinSaver f(yaIn, true, false); + f.Add(0, &restored); + } + UnitTestCheckWithComparer<T, TComparer, comparerChecksInside>(original, restored, comparer); +} + +template <typename T, typename TComparer = std::equal_to<T>, bool comparerChecksInside = false> +void TestBinSaverSerializationToVector(const T& original, const TComparer& comparer = TComparer()) { + TVector<char> out; + SerializeToMem(&out, *const_cast<T*>(&original)); + T restored; + SerializeFromMem(&out, restored); + UnitTestCheckWithComparer<T, TComparer, comparerChecksInside>(original, restored, comparer); + + TVector<TVector<char>> out2D; + SerializeToMem(&out2D, *const_cast<T*>(&original)); + T restored2D; + SerializeFromMem(&out2D, restored2D); + UnitTestCheckWithComparer<T, TComparer, comparerChecksInside>(original, restored2D, comparer); +} + +template <typename T, typename TComparer = std::equal_to<T>, bool comparerChecksInside = false> +void TestBinSaverSerialization(const T& original, const TComparer& comparer = TComparer()) { + TestBinSaverSerializationToBuffer<T, TComparer, comparerChecksInside>(original, comparer); + TestBinSaverSerializationToVector<T, TComparer, comparerChecksInside>(original, comparer); +} diff --git a/library/cpp/binsaver/ut_util/ya.make b/library/cpp/binsaver/ut_util/ya.make index 7e60f13ef3..25c867f631 100644 --- a/library/cpp/binsaver/ut_util/ya.make +++ b/library/cpp/binsaver/ut_util/ya.make @@ -1,14 +1,14 @@ -LIBRARY() - -OWNER(gulin) - -SRCS( - ut_util.cpp -) - -PEERDIR( +LIBRARY() + +OWNER(gulin) + +SRCS( + ut_util.cpp +) + +PEERDIR( library/cpp/binsaver library/cpp/testing/unittest -) - -END() +) + +END() diff --git a/library/cpp/binsaver/util_stream_io.h b/library/cpp/binsaver/util_stream_io.h index d65d630b93..31d8df5351 100644 --- a/library/cpp/binsaver/util_stream_io.h +++ b/library/cpp/binsaver/util_stream_io.h @@ -4,11 +4,11 @@ #include <util/stream/input.h> #include <util/stream/output.h> -#include <util/stream/file.h> +#include <util/stream/file.h> class TYaStreamInput: public IBinaryStream { IInputStream& Stream; - + int WriteImpl(const void*, int) override { Y_ASSERT(0); return 0; @@ -41,13 +41,13 @@ inline void SerializeFromStream(IInputStream& stream, T& c) { template <class T> inline void SerializeFromFile(const TString& fileName, T& c) { - TIFStream in(fileName); - SerializeFromStream(in, c); -} - + TIFStream in(fileName); + SerializeFromStream(in, c); +} + class TYaStreamOutput: public IBinaryStream { IOutputStream& Stream; - + int WriteImpl(const void* what, int size) override { Stream.Write(what, (size_t)size); return size; @@ -78,9 +78,9 @@ inline void SerializeToArcadiaStream(IOutputStream& stream, T& c) { bs.Add(1, &c); } } - + template <class T> inline void SerializeToFile(const TString& fileName, T& c) { - TOFStream out(fileName); + TOFStream out(fileName); SerializeToArcadiaStream(out, c); -} +} diff --git a/library/cpp/charset/wide_ut.cpp b/library/cpp/charset/wide_ut.cpp index 78947d51ba..aa2902b99b 100644 --- a/library/cpp/charset/wide_ut.cpp +++ b/library/cpp/charset/wide_ut.cpp @@ -208,8 +208,8 @@ void TConversionTest::TestYandexEncoding() { UNIT_ASSERT(w == wideCyrillicAlphabet); w = UTF8ToWide(yandexCyrillicAlphabet, strlen(yandexCyrillicAlphabet), csYandex); UNIT_ASSERT(w == wideCyrillicAlphabet); - - const char* utf8NonBMP2 = "ab\xf4\x80\x89\x87n"; + + const char* utf8NonBMP2 = "ab\xf4\x80\x89\x87n"; wchar16 wNonBMPDummy2[] = {'a', 'b', 0xDBC0, 0xDE47, 'n'}; TestSurrogates(utf8NonBMP2, wNonBMPDummy2, Y_ARRAY_SIZE(wNonBMPDummy2), CODES_UTF8); diff --git a/library/cpp/containers/comptrie/ya.make b/library/cpp/containers/comptrie/ya.make index 81352da4b2..970a3bbf57 100644 --- a/library/cpp/containers/comptrie/ya.make +++ b/library/cpp/containers/comptrie/ya.make @@ -3,11 +3,11 @@ LIBRARY() OWNER(velavokr) SRCS( - array_with_size.h - chunked_helpers_trie.h - comptrie.h + array_with_size.h + chunked_helpers_trie.h + comptrie.h comptrie_packer.h - comptrie_trie.h + comptrie_trie.h first_symbol_iterator.h key_selector.h leaf_skipper.h diff --git a/library/cpp/deprecated/mapped_file/mapped_file.h b/library/cpp/deprecated/mapped_file/mapped_file.h index 45859ed65a..445d070c69 100644 --- a/library/cpp/deprecated/mapped_file/mapped_file.h +++ b/library/cpp/deprecated/mapped_file/mapped_file.h @@ -59,7 +59,7 @@ public: return (Map_ ? Map_->MappedSize() : 0); } - void* getData(size_t pos = 0) const { + void* getData(size_t pos = 0) const { Y_ASSERT(!Map_ || (pos <= getSize())); return (Map_ ? (void*)((unsigned char*)Map_->Ptr() + pos) : nullptr); } diff --git a/library/cpp/deprecated/mapped_file/ut/mapped_file_ut.cpp b/library/cpp/deprecated/mapped_file/ut/mapped_file_ut.cpp index afbd5b3358..d62d0bb18c 100644 --- a/library/cpp/deprecated/mapped_file/ut/mapped_file_ut.cpp +++ b/library/cpp/deprecated/mapped_file/ut/mapped_file_ut.cpp @@ -6,13 +6,13 @@ Y_UNIT_TEST_SUITE(TMappedFileTest) { static const char* FileName_("./mappped_file"); Y_UNIT_TEST(TestFileMapEmpty) { - TFile file(FileName_, CreateAlways | WrOnly); - file.Close(); + TFile file(FileName_, CreateAlways | WrOnly); + file.Close(); - TMappedFile map; - map.init(FileName_); + TMappedFile map; + map.init(FileName_); map.getData(0); - + NFs::Remove(FileName_); - } + } }; diff --git a/library/cpp/deprecated/split/delim_string_iter.h b/library/cpp/deprecated/split/delim_string_iter.h index 8e4ca171a0..3d47d23ad9 100644 --- a/library/cpp/deprecated/split/delim_string_iter.h +++ b/library/cpp/deprecated/split/delim_string_iter.h @@ -1,13 +1,13 @@ #pragma once - + #include <util/generic/algorithm.h> #include <util/generic/strbuf.h> #include <util/generic/yexception.h> #include <util/string/cast.h> #include <util/system/yassert.h> - + #include <iterator> - + class TDelimStringIter { public: using value_type = TStringBuf; @@ -20,7 +20,7 @@ public: : TDelimStringIter(TStringBuf(begin, strEnd), delim) { } - + inline TDelimStringIter(TStringBuf str, TStringBuf delim) : IsValid(true) , Str(str) @@ -33,7 +33,7 @@ public: : IsValid(false) { } - + inline explicit operator bool() const { return IsValid; } @@ -43,32 +43,32 @@ public: if (Current.end() != Str.end()) { Str.Skip(Current.length() + Delim.length()); UpdateCurrent(); - } else { + } else { Str.Clear(); Current.Clear(); - IsValid = false; - } - return *this; - } - + IsValid = false; + } + return *this; + } + inline void operator+=(size_t n) { for (; n > 0; --n) { - ++(*this); - } - } - + ++(*this); + } + } + inline bool operator==(const TDelimStringIter& rhs) const { return (IsValid == rhs.IsValid) && (!IsValid || (Current.begin() == rhs.Current.begin())); - } - + } + inline bool operator!=(const TDelimStringIter& rhs) const { return !(*this == rhs); - } - + } + inline TStringBuf operator*() const { return Current; - } - + } + inline const TStringBuf* operator->() const { return &Current; } @@ -76,23 +76,23 @@ public: // Get & advance template <class T> inline bool TryNext(T& t) { - if (IsValid) { + if (IsValid) { t = FromString<T>(Current); - operator++(); - return true; - } else { - return false; - } - } - + operator++(); + return true; + } else { + return false; + } + } + template <class T> inline TDelimStringIter& Next(T& t) // Get & advance - { - if (!TryNext(t)) - ythrow yexception() << "No valid field"; - return *this; - } - + { + if (!TryNext(t)) + ythrow yexception() << "No valid field"; + return *this; + } + template <class T> inline T GetNext() { T res; @@ -102,24 +102,24 @@ public: inline const char* GetBegin() const { return Current.begin(); - } - + } + inline const char* GetEnd() const { return Current.end(); - } - + } + inline bool Valid() const { - return IsValid; - } - + return IsValid; + } + // contents from next token to the end of string inline TStringBuf Cdr() const { return Str.SubStr(Current.length() + Delim.length()); - } - + } + inline TDelimStringIter IterEnd() const { return TDelimStringIter(); - } + } private: inline void UpdateCurrent() { @@ -134,8 +134,8 @@ private: TStringBuf Str; TStringBuf Current; TStringBuf Delim; -}; - +}; + //example: for (TStringBuf field: TDelimStroka(line, "@@")) { ... } struct TDelimStroka { TStringBuf S; @@ -158,15 +158,15 @@ struct TDelimStroka { inline TDelimStringIter begin_delim(const TString& str, TStringBuf delim) { return TDelimStringIter(str, delim); -} - +} + inline TDelimStringIter begin_delim(TStringBuf str, TStringBuf delim) { return TDelimStringIter(str.begin(), str.end(), delim); -} - +} + inline TDelimStringIter end_delim(const TString& /*str*/, TStringBuf /*delim*/) { return TDelimStringIter(); -} +} class TKeyValueDelimStringIter { public: diff --git a/library/cpp/lcs/ya.make b/library/cpp/lcs/ya.make index 3a7caafc88..1ddb171ece 100644 --- a/library/cpp/lcs/ya.make +++ b/library/cpp/lcs/ya.make @@ -10,4 +10,4 @@ SRCS( lcs_via_lis.cpp ) -END() +END() diff --git a/library/cpp/lfalloc/lf_allocX64.h b/library/cpp/lfalloc/lf_allocX64.h index fd2a906d6f..c005e8852f 100644 --- a/library/cpp/lfalloc/lf_allocX64.h +++ b/library/cpp/lfalloc/lf_allocX64.h @@ -262,7 +262,7 @@ static volatile int freeChunkCount; static void AddFreeChunk(uintptr_t chunkId) { chunkSizeIdx[chunkId] = -1; if (Y_UNLIKELY(freeChunkCount == FREE_CHUNK_ARR_BUF)) - NMalloc::AbortFromCorruptedAllocator("free chunks array overflowed"); + NMalloc::AbortFromCorruptedAllocator("free chunks array overflowed"); freeChunkArr[freeChunkCount++] = chunkId; } diff --git a/library/cpp/object_factory/object_factory.h b/library/cpp/object_factory/object_factory.h index 96cc11bcfd..57a9ee8f4e 100644 --- a/library/cpp/object_factory/object_factory.h +++ b/library/cpp/object_factory/object_factory.h @@ -11,7 +11,7 @@ namespace NObjectFactory { template <class TProduct, class... TArgs> class IFactoryObjectCreator { public: - virtual TProduct* Create(TArgs... args) const = 0; + virtual TProduct* Create(TArgs... args) const = 0; virtual ~IFactoryObjectCreator() { } }; @@ -34,8 +34,8 @@ namespace NObjectFactory { template <class TBaseProduct, class TDerivedProduct, class... TArgs> class TFactoryObjectCreator: public IFactoryObjectCreator<TBaseProduct, TArgs...> { - TDerivedProduct* Create(TArgs... args) const override { - return new TDerivedProduct(std::forward<TArgs>(args)...); + TDerivedProduct* Create(TArgs... args) const override { + return new TDerivedProduct(std::forward<TArgs>(args)...); } }; @@ -185,7 +185,7 @@ namespace NObjectFactory { public: TProduct* Create(const TKey& key, TArgs... args) const { IFactoryObjectCreator<TProduct, TArgs...>* creator = IObjectFactory<TProduct, TKey, TArgs...>::GetCreator(key); - return creator == nullptr ? nullptr : creator->Create(std::forward<TArgs>(args)...); + return creator == nullptr ? nullptr : creator->Create(std::forward<TArgs>(args)...); } static bool Has(const TKey& key) { @@ -193,7 +193,7 @@ namespace NObjectFactory { } static TProduct* Construct(const TKey& key, TArgs... args) { - return Singleton<TParametrizedObjectFactory<TProduct, TKey, TArgs...>>()->Create(key, std::forward<TArgs>(args)...); + return Singleton<TParametrizedObjectFactory<TProduct, TKey, TArgs...>>()->Create(key, std::forward<TArgs>(args)...); } template <class... Args> diff --git a/library/cpp/object_factory/object_factory_ut.cpp b/library/cpp/object_factory/object_factory_ut.cpp index 06fb0739ff..49e2ca2cec 100644 --- a/library/cpp/object_factory/object_factory_ut.cpp +++ b/library/cpp/object_factory/object_factory_ut.cpp @@ -1,7 +1,7 @@ #include <library/cpp/object_factory/object_factory.h> #include <library/cpp/testing/unittest/registar.h> -#include <util/generic/noncopyable.h> +#include <util/generic/noncopyable.h> #include <util/generic/string.h> #include <util/generic/ptr.h> @@ -59,7 +59,7 @@ private: }; struct TDirectOrderCreator: public IFactoryObjectCreator<ICommonInterface, const TString&, float, TArgument&> { - ICommonInterface* Create(const TString& provider, float factor, TArgument& argument) const override { + ICommonInterface* Create(const TString& provider, float factor, TArgument& argument) const override { ++CallsCounter; return new TDirectOrder(provider, factor, argument); } @@ -73,65 +73,65 @@ using TTestFactory = TParametrizedObjectFactory<ICommonInterface, TString, const static TTestFactory::TRegistrator<TDirectOrder> Direct("direct", new TDirectOrderCreator); static TTestFactory::TRegistrator<TInverseOrder> Inverse("inverse"); - - -class IMoveableOnlyInterface { -public: - virtual ~IMoveableOnlyInterface() { - } - - virtual TString GetValue() const = 0; -}; - -class TMoveableOnly: public IMoveableOnlyInterface, public TMoveOnly { -public: - TMoveableOnly(TString&& value) - : Value(value) - {} - - TString GetValue() const override { - return Value; - } - -private: - const TString Value; -}; - - -using TMoveableOnlyFactory = TParametrizedObjectFactory<IMoveableOnlyInterface, TString, TString&&>; - -static TMoveableOnlyFactory::TRegistrator<TMoveableOnly> MoveableOnlyReg("move"); - - - -class TMoveableOnly2: public IMoveableOnlyInterface, public TMoveOnly { -public: - TMoveableOnly2(THolder<TString>&& value) - : Value(std::move(value)) - {} - - TString GetValue() const override { - return *Value; - } - -private: - const THolder<TString> Value; -}; - - -using TMoveableOnly2Factory = TParametrizedObjectFactory<IMoveableOnlyInterface, TString, THolder<TString>&&>; - -static TMoveableOnly2Factory::TRegistrator<TMoveableOnly2> MoveableOnly2Reg("move2"); - + + +class IMoveableOnlyInterface { +public: + virtual ~IMoveableOnlyInterface() { + } + + virtual TString GetValue() const = 0; +}; + +class TMoveableOnly: public IMoveableOnlyInterface, public TMoveOnly { +public: + TMoveableOnly(TString&& value) + : Value(value) + {} + + TString GetValue() const override { + return Value; + } + +private: + const TString Value; +}; + + +using TMoveableOnlyFactory = TParametrizedObjectFactory<IMoveableOnlyInterface, TString, TString&&>; + +static TMoveableOnlyFactory::TRegistrator<TMoveableOnly> MoveableOnlyReg("move"); + + + +class TMoveableOnly2: public IMoveableOnlyInterface, public TMoveOnly { +public: + TMoveableOnly2(THolder<TString>&& value) + : Value(std::move(value)) + {} + + TString GetValue() const override { + return *Value; + } + +private: + const THolder<TString> Value; +}; + + +using TMoveableOnly2Factory = TParametrizedObjectFactory<IMoveableOnlyInterface, TString, THolder<TString>&&>; + +static TMoveableOnly2Factory::TRegistrator<TMoveableOnly2> MoveableOnly2Reg("move2"); + class TDirectOrderDifferentSignature : public TDirectOrder { public: TDirectOrderDifferentSignature(const TString& provider, TArgument& argument) : TDirectOrder(provider, 0.01f, argument) { } - + }; - + struct TDirectOrderDSCreator: public IFactoryObjectCreator<ICommonInterface, const TString&, float, TArgument&> { ICommonInterface* Create(const TString& provider, float factor, TArgument& argument) const override { Y_UNUSED(factor); @@ -157,26 +157,26 @@ Y_UNIT_TEST_SUITE(TestObjectFactory) { UNIT_ASSERT_EQUAL(TDirectOrderCreator::CallsCounter, 1); } - - Y_UNIT_TEST(TestMoveableOnly) { - TString v = "value1"; - - THolder<IMoveableOnlyInterface> moveableOnly(TMoveableOnlyFactory::Construct("move", std::move(v))); - - UNIT_ASSERT(!!moveableOnly); - - UNIT_ASSERT(moveableOnly->GetValue() == "value1"); - } - - Y_UNIT_TEST(TestMoveableOnly2) { - THolder<TString> v = MakeHolder<TString>("value2"); - - THolder<IMoveableOnlyInterface> moveableOnly2(TMoveableOnly2Factory::Construct("move2", std::move(v))); - - UNIT_ASSERT(!!moveableOnly2); - - UNIT_ASSERT(moveableOnly2->GetValue() == "value2"); - } + + Y_UNIT_TEST(TestMoveableOnly) { + TString v = "value1"; + + THolder<IMoveableOnlyInterface> moveableOnly(TMoveableOnlyFactory::Construct("move", std::move(v))); + + UNIT_ASSERT(!!moveableOnly); + + UNIT_ASSERT(moveableOnly->GetValue() == "value1"); + } + + Y_UNIT_TEST(TestMoveableOnly2) { + THolder<TString> v = MakeHolder<TString>("value2"); + + THolder<IMoveableOnlyInterface> moveableOnly2(TMoveableOnly2Factory::Construct("move2", std::move(v))); + + UNIT_ASSERT(!!moveableOnly2); + + UNIT_ASSERT(moveableOnly2->GetValue() == "value2"); + } Y_UNIT_TEST(TestDifferentSignature) { TArgument directArg{"Name", nullptr}; diff --git a/library/cpp/packedtypes/packed.h b/library/cpp/packedtypes/packed.h index 88cff26ae2..044e53be34 100644 --- a/library/cpp/packedtypes/packed.h +++ b/library/cpp/packedtypes/packed.h @@ -1,10 +1,10 @@ #pragma once - + #include <library/cpp/streams/zc_memory_input/zc_memory_input.h> - + #include <util/stream/output.h> -#include <util/ysaveload.h> - +#include <util/ysaveload.h> + #include "longs.h" struct Stream_traits { @@ -38,57 +38,57 @@ struct Stream_traits { static int is_good(IOutputStream& /*out*/) { return 1; } -}; - +}; + struct TZCMemoryInput_traits { template <typename T> static T get(TZCMemoryInput& in) { T x; - in.ReadPOD(x); + in.ReadPOD(x); return x; - } - + } + static ui8 Y_FORCE_INLINE get_8(TZCMemoryInput& in) { return get<ui8>(in); - } - + } + static ui16 Y_FORCE_INLINE get_16(TZCMemoryInput& in) { return get<ui16>(in); - } - + } + static ui32 Y_FORCE_INLINE get_32(TZCMemoryInput& in) { return get<ui32>(in); } static int Y_FORCE_INLINE is_good(TZCMemoryInput&) { - return 1; - } -}; - + return 1; + } +}; + void Y_FORCE_INLINE PackUI32(IOutputStream& out, ui32 v) { - char buf[sizeof(ui32)]; - char* bufPtr = buf; - size_t size; + char buf[sizeof(ui32)]; + char* bufPtr = buf; + size_t size; PACK_28(v, bufPtr, mem_traits, size); - out.Write(buf, size); -} - + out.Write(buf, size); +} + template <class TStream> struct TInputStream2Traits { - typedef Stream_traits TTraits; -}; - + typedef Stream_traits TTraits; +}; + template <> struct TInputStream2Traits<TZCMemoryInput> { - typedef TZCMemoryInput_traits TTraits; -}; - + typedef TZCMemoryInput_traits TTraits; +}; + template <class TStream> void Y_FORCE_INLINE UnPackUI32(TStream& in, ui32& v) { - size_t size; + size_t size; UNPACK_28(v, in, TInputStream2Traits<TStream>::TTraits, size); (void)size; -} +} template <class TStream> ui32 Y_FORCE_INLINE UnPackUI32(TStream& in) { diff --git a/library/cpp/packedtypes/packed_ut.cpp b/library/cpp/packedtypes/packed_ut.cpp index 70a22cf9c3..2be6f6f77f 100644 --- a/library/cpp/packedtypes/packed_ut.cpp +++ b/library/cpp/packedtypes/packed_ut.cpp @@ -1,13 +1,13 @@ #include "packed.h" #include <library/cpp/testing/unittest/registar.h> - + #include <util/system/defaults.h> #include <util/generic/ylimits.h> #include <util/generic/buffer.h> -#include <util/stream/mem.h> +#include <util/stream/mem.h> #include <util/stream/buffer.h> - + namespace NPrivate { #if 0 static ui64 gSeed = 42; @@ -26,67 +26,67 @@ static T PseudoRandom(T max = Max<T>()) { Y_UNIT_TEST_SUITE(TPackedTest) { void TestPackUi32Sub(ui32 v, const TVector<char>& p) { - TBufferOutput out; - PackUI32(out, v); - const TBuffer& buf = out.Buffer(); + TBufferOutput out; + PackUI32(out, v); + const TBuffer& buf = out.Buffer(); UNIT_ASSERT_VALUES_EQUAL(buf.Size(), p.size()); - UNIT_ASSERT(!memcmp(buf.Data(), &p[0], buf.Size())); + UNIT_ASSERT(!memcmp(buf.Data(), &p[0], buf.Size())); - { - TBufferInput in(buf); - ui32 v2; - UnPackUI32(in, v2); + { + TBufferInput in(buf); + ui32 v2; + UnPackUI32(in, v2); UNIT_ASSERT_VALUES_EQUAL(v, v2); - } - + } + { - TZCMemoryInput in(buf.Data(), buf.Size()); - ui32 v2; - UnPackUI32(in, v2); + TZCMemoryInput in(buf.Data(), buf.Size()); + ui32 v2; + UnPackUI32(in, v2); UNIT_ASSERT_VALUES_EQUAL(v, v2); - } - } + } + } Y_UNIT_TEST(TestPackUi32) { - ui32 v; + ui32 v; TVector<char> pv; - - v = 0; - pv.resize(1); - pv[0] = 0x0; + + v = 0; + pv.resize(1); + pv[0] = 0x0; TestPackUi32Sub(v, pv); - - v = 0x1600; - pv.resize(2); - pv[0] = 0x96; - pv[1] = 0x00; + + v = 0x1600; + pv.resize(2); + pv[0] = 0x96; + pv[1] = 0x00; TestPackUi32Sub(v, pv); - - v = 0xEF98; - pv.resize(3); - pv[0] = 0xC0; + + v = 0xEF98; + pv.resize(3); + pv[0] = 0xC0; #if defined(_big_endian_) - pv[1] = 0xEF; - pv[2] = 0x98; -#elif defined(_little_endian_) - pv[1] = 0x98; - pv[2] = 0xEF; -#endif + pv[1] = 0xEF; + pv[2] = 0x98; +#elif defined(_little_endian_) + pv[1] = 0x98; + pv[2] = 0xEF; +#endif TestPackUi32Sub(v, pv); - - v = 0xF567FE4; - pv.resize(4); - pv[0] = 0xEF; - pv[1] = 0x56; + + v = 0xF567FE4; + pv.resize(4); + pv[0] = 0xEF; + pv[1] = 0x56; #if defined(_big_endian_) - pv[2] = 0x7F; - pv[3] = 0xE4; -#elif defined(_little_endian_) - pv[2] = 0xE4; - pv[3] = 0x7F; -#endif + pv[2] = 0x7F; + pv[3] = 0xE4; +#elif defined(_little_endian_) + pv[2] = 0xE4; + pv[3] = 0x7F; +#endif TestPackUi32Sub(v, pv); - } + } #if 0 Y_UNIT_TEST(ReadWrite32) { @@ -127,4 +127,4 @@ Y_UNIT_TEST_SUITE(TPackedTest) { } } #endif -}; +}; diff --git a/library/cpp/packedtypes/packedfloat.h b/library/cpp/packedtypes/packedfloat.h index f178912ed3..334072f211 100644 --- a/library/cpp/packedtypes/packedfloat.h +++ b/library/cpp/packedtypes/packedfloat.h @@ -157,27 +157,27 @@ using uf8 = NPackedFloat::float8<0>; using f8d = NPackedFloat::float8<1, 1>; using uf8d = NPackedFloat::float8<0, 1>; -// [0,1) value in 1/255s. +// [0,1) value in 1/255s. using frac8 = ui8; - + using frac16 = ui16; template <class T> inline constexpr T Float2Frac(float fac) { return T(fac * float(Max<T>())); -} - +} + template <class T> inline constexpr T Float2FracR(float fac) { float v = fac * float(Max<T>()); - return T(v + 0.5f); -} - + return T(v + 0.5f); +} + template <class T> inline constexpr float Frac2Float(T pf) { constexpr float multiplier = float(1.0 / Max<T>()); return pf * multiplier; -} +} class TUi82FloatMapping { private: diff --git a/library/cpp/protobuf/util/pb_io.cpp b/library/cpp/protobuf/util/pb_io.cpp index 6270ee0624..d57effb114 100644 --- a/library/cpp/protobuf/util/pb_io.cpp +++ b/library/cpp/protobuf/util/pb_io.cpp @@ -2,16 +2,16 @@ #include <library/cpp/binsaver/bin_saver.h> #include <library/cpp/string_utils/base64/base64.h> - + #include <google/protobuf/message.h> #include <google/protobuf/messagext.h> #include <google/protobuf/text_format.h> - + #include <util/generic/string.h> #include <util/stream/file.h> #include <util/stream/str.h> #include <util/string/cast.h> - + namespace NProtoBuf { class TEnumIdValuePrinter : public google::protobuf::TextFormat::FastFieldValuePrinter { @@ -97,10 +97,10 @@ void SerializeToTextFormat(const NProtoBuf::Message& m, IOutputStream& out) { NProtoBuf::io::TCopyingOutputStreamAdaptor adaptor(&out); if (!NProtoBuf::TextFormat::Print(m, &adaptor)) { - ythrow yexception() << "SerializeToTextFormat failed on Print"; + ythrow yexception() << "SerializeToTextFormat failed on Print"; } -} - +} + void SerializeToTextFormat(const NProtoBuf::Message& m, const TString& fileName) { /* TUnbufferedFileOutput is unbuffered, but TCopyingOutputStreamAdaptor adds * a buffer on top of it. */ @@ -167,8 +167,8 @@ bool TryParseFromTextFormat(const TString& fileName, NProtoBuf::Message& m, } return true; -} - +} + bool TryParseFromTextFormat(IInputStream& in, NProtoBuf::Message& m, const EParseFromTextFormatOptions options) { try { diff --git a/library/cpp/protobuf/util/pb_io.h b/library/cpp/protobuf/util/pb_io.h index 493c84cb5f..b265a13cf3 100644 --- a/library/cpp/protobuf/util/pb_io.h +++ b/library/cpp/protobuf/util/pb_io.h @@ -1,8 +1,8 @@ -#pragma once - +#pragma once + #include <util/generic/fwd.h> #include <util/generic/flags.h> - + struct IBinSaver; namespace google { @@ -10,11 +10,11 @@ namespace google { class Message; } } - + namespace NProtoBuf { using Message = ::google::protobuf::Message; } - + class IInputStream; class IOutputStream; @@ -69,7 +69,7 @@ void ParseFromTextFormat(const TString& fileName, NProtoBuf::Message& m, // NOTE: will read `in` till the end. void ParseFromTextFormat(IInputStream& in, NProtoBuf::Message& m, const EParseFromTextFormatOptions options = {}); - + /* @return `true` if parsing was successfull and `false` otherwise. * * @see `ParseFromTextFormat` diff --git a/library/cpp/protobuf/util/pb_utils.h b/library/cpp/protobuf/util/pb_utils.h index 9e9a110b48..83fe0af167 100644 --- a/library/cpp/protobuf/util/pb_utils.h +++ b/library/cpp/protobuf/util/pb_utils.h @@ -1,10 +1,10 @@ -#pragma once - -#define UPDATE_PB_FIELD_MAX(PBMESS, FIELD, VAL) \ +#pragma once + +#define UPDATE_PB_FIELD_MAX(PBMESS, FIELD, VAL) \ if ((VAL) > (PBMESS).Get##FIELD()) { \ (PBMESS).Set##FIELD(VAL); \ } - + #define UPDATE_OPT_PB_FIELD_MAX(PBMESS, FIELD, VAL) \ if (!(PBMESS).Has##FIELD() || ((VAL) > (PBMESS).Get##FIELD())) { \ (PBMESS).Set##FIELD(VAL); \ diff --git a/library/cpp/protobuf/util/ya.make b/library/cpp/protobuf/util/ya.make index b62028af58..9d267d435f 100644 --- a/library/cpp/protobuf/util/ya.make +++ b/library/cpp/protobuf/util/ya.make @@ -1,26 +1,26 @@ LIBRARY() - + OWNER(mowgli) -PEERDIR( - contrib/libs/protobuf +PEERDIR( + contrib/libs/protobuf library/cpp/binsaver library/cpp/protobuf/util/proto library/cpp/string_utils/base64 -) - -SRCS( +) + +SRCS( is_equal.cpp iterators.h merge.cpp path.cpp pb_io.cpp - pb_utils.h + pb_utils.h repeated_field_utils.h simple_reflection.cpp walk.cpp -) - -END() +) + +END() RECURSE_FOR_TESTS(ut) diff --git a/library/cpp/regex/pcre/regexp.cpp b/library/cpp/regex/pcre/regexp.cpp index 575c09cee4..dc288c2c61 100644 --- a/library/cpp/regex/pcre/regexp.cpp +++ b/library/cpp/regex/pcre/regexp.cpp @@ -137,7 +137,7 @@ protected: int CompileOptions; TString RegExpr; regex_t Preg; - + public: TRegExBaseImpl() : CompileOptions(0) @@ -156,8 +156,8 @@ public: regerror(rc, &Preg, errbuf, ERRBUF_SIZE); Error = "Error: regular expression " + re + " is wrong: " + errbuf; ythrow yexception() << "RegExp " << re << ": " << Error.data(); - } - } + } + } int Exec(const char* str, regmatch_t pmatch[], int eflags, int nmatches) const { if (!RegExpr) { @@ -205,7 +205,7 @@ TRegExBase::TRegExBase(const TString& re, int cflags) { Compile(re, cflags); } -TRegExBase::~TRegExBase() { +TRegExBase::~TRegExBase() { } void TRegExBase::Compile(const TString& re, int cflags) { @@ -234,7 +234,7 @@ TRegExMatch::TRegExMatch(const char* re, int cflags) : TRegExBase(re, cflags) { } - + TRegExMatch::TRegExMatch(const TString& re, int cflags) : TRegExBase(re, cflags) { @@ -242,47 +242,47 @@ TRegExMatch::TRegExMatch(const TString& re, int cflags) bool TRegExMatch::Match(const char* str) const { return Exec(str, nullptr, 0, 0) == 0; -} - +} + TRegExSubst::TRegExSubst(const char* re, int cflags) : TRegExBase(re, cflags) , Replacement(nullptr) -{ - memset(Brfs, 0, sizeof(TBackReferences) * NMATCHES); -} - +{ + memset(Brfs, 0, sizeof(TBackReferences) * NMATCHES); +} + TString TRegExSubst::Replace(const char* str, int eflags) { TString s; - if (BrfsCount) { - if (Exec(str, PMatch, eflags) == 0) { + if (BrfsCount) { + if (Exec(str, PMatch, eflags) == 0) { int i; for (i = 0; i < BrfsCount; i++) { s += TString(Replacement, Brfs[i].Beg, Brfs[i].End - Brfs[i].Beg); - if (Brfs[i].Refer >= 0 && Brfs[i].Refer < NMATCHES) + if (Brfs[i].Refer >= 0 && Brfs[i].Refer < NMATCHES) s += TString(str, PMatch[Brfs[i].Refer].rm_so, int(PMatch[Brfs[i].Refer].rm_eo - PMatch[Brfs[i].Refer].rm_so)); } s += TString(Replacement, Brfs[i].Beg, Brfs[i].End - Brfs[i].Beg); } } else { - s = Replacement; + s = Replacement; } return s; } //*** // ��� ������������ ������ aaa.$1.$$$$.$2.bbb.$$$ccc Brfs ����� �����: -// {beg = 0, end = 4, Refer = 1} => "aaa." + $1_match -// {beg = 6, end = 8, Refer = -1} => ".$" -// {beg = 9, end = 10, Refer = -1} => "$" -// {beg = 11, end = 12, Refer = 2} => "." + $2_match -// {beg = 14, end = 20, Refer = -1} => ".bbb.$" -// {beg = 21, end = 22, Refer = -1} => "$" -// {beg = 22, end = 25, Refer = -1} => "ccc" -// {beg = 0, end = 0, Refer = 0} +// {beg = 0, end = 4, Refer = 1} => "aaa." + $1_match +// {beg = 6, end = 8, Refer = -1} => ".$" +// {beg = 9, end = 10, Refer = -1} => "$" +// {beg = 11, end = 12, Refer = 2} => "." + $2_match +// {beg = 14, end = 20, Refer = -1} => ".bbb.$" +// {beg = 21, end = 22, Refer = -1} => "$" +// {beg = 22, end = 25, Refer = -1} => "ccc" +// {beg = 0, end = 0, Refer = 0} //*** int TRegExSubst::ParseReplacement(const char* repl) { - Replacement = repl; - if (!Replacement || *Replacement == 0) + Replacement = repl; + if (!Replacement || *Replacement == 0) return 0; char* pos = (char*)Replacement; char* pos1 = nullptr; @@ -290,7 +290,7 @@ int TRegExSubst::ParseReplacement(const char* repl) { int i = 0; while (pos && *pos && i < NMATCHES) { pos1 = strchr(pos, '$'); - Brfs[i].Refer = -1; + Brfs[i].Refer = -1; pos2 = pos1; if (pos1) { pos2 = pos1 + 1; @@ -302,16 +302,16 @@ int TRegExSubst::ParseReplacement(const char* repl) { pos1++; if (*pos2 == '$') pos2++; - Brfs[i].Refer = -1; + Brfs[i].Refer = -1; } } - Brfs[i].Beg = int(pos - (char*)Replacement); + Brfs[i].Beg = int(pos - (char*)Replacement); Brfs[i].End = (pos1 == nullptr ? (int)strlen(Replacement) : int(pos1 - Replacement)); pos = pos2; i++; } - Brfs[i].Beg = Brfs[i].End = 0; - Brfs[i].Refer = -1; - BrfsCount = i; - return BrfsCount; + Brfs[i].Beg = Brfs[i].End = 0; + Brfs[i].Refer = -1; + BrfsCount = i; + return BrfsCount; } diff --git a/library/cpp/regex/pcre/regexp.h b/library/cpp/regex/pcre/regexp.h index bc610bd2f3..9862a9b85b 100644 --- a/library/cpp/regex/pcre/regexp.h +++ b/library/cpp/regex/pcre/regexp.h @@ -17,15 +17,15 @@ class TRegExBaseImpl; class TRegExBase { -protected: +protected: TSimpleIntrusivePtr<TRegExBaseImpl> Impl; -public: +public: TRegExBase(const char* regExpr = nullptr, int cflags = REG_EXTENDED); TRegExBase(const TString& regExpr, int cflags = REG_EXTENDED); virtual ~TRegExBase(); - + int Exec(const char* str, regmatch_t pmatch[], int eflags, int nmatches = NMATCHES) const; void Compile(const TString& regExpr, int cflags = REG_EXTENDED); bool IsCompiled() const; @@ -34,30 +34,30 @@ public: }; class TRegExMatch: public TRegExBase { -public: +public: TRegExMatch(const char* regExpr = nullptr, int cflags = REG_NOSUB | REG_EXTENDED); TRegExMatch(const TString& regExpr, int cflags = REG_NOSUB | REG_EXTENDED); bool Match(const char* str) const; -}; +}; struct TBackReferences { - int Beg; - int End; - int Refer; -}; + int Beg; + int End; + int Refer; +}; class TRegExSubst: public TRegExBase { -private: - const char* Replacement; +private: + const char* Replacement; regmatch_t PMatch[NMATCHES]; - - TBackReferences Brfs[NMATCHES]; - int BrfsCount; - -public: + + TBackReferences Brfs[NMATCHES]; + int BrfsCount; + +public: TRegExSubst(const char* regExpr = nullptr, int cflags = REG_EXTENDED); - + TString Replace(const char* str, int eflags = 0); int ParseReplacement(const char* replacement); }; diff --git a/library/cpp/streams/zc_memory_input/zc_memory_input.h b/library/cpp/streams/zc_memory_input/zc_memory_input.h index c939d8e426..3880959afd 100644 --- a/library/cpp/streams/zc_memory_input/zc_memory_input.h +++ b/library/cpp/streams/zc_memory_input/zc_memory_input.h @@ -1,48 +1,48 @@ -#pragma once - -#include <util/stream/mem.h> -#include <util/system/defaults.h> +#pragma once + +#include <util/stream/mem.h> +#include <util/system/defaults.h> #include <util/generic/yexception.h> - -/// Zero-copy memory input with fixed read + +/// Zero-copy memory input with fixed read class TZCMemoryInput: public TMemoryInput { -public: +public: TZCMemoryInput() { } - TZCMemoryInput(const char* dataPtr, size_t size) - : TMemoryInput(dataPtr, size) + TZCMemoryInput(const char* dataPtr, size_t size) + : TMemoryInput(dataPtr, size) { } - TZCMemoryInput(TMemoryInput& rhs) - : TMemoryInput(rhs.Buf(), rhs.Avail()) + TZCMemoryInput(TMemoryInput& rhs) + : TMemoryInput(rhs.Buf(), rhs.Avail()) { } - /// if there's 'size' data read it, otherwise just return false + /// if there's 'size' data read it, otherwise just return false Y_FORCE_INLINE bool ReadFixed(const char*& buf, size_t size) { - if (Avail() >= size) { - buf = Buf(); - Reset(Buf() + size, Avail() - size); - return true; - } - return false; - } - + if (Avail() >= size) { + buf = Buf(); + Reset(Buf() + size, Avail() - size); + return true; + } + return false; + } + template <class T> Y_FORCE_INLINE T LoadPOD() { const char* buf = nullptr; - if (!ReadFixed(buf, sizeof(T))) + if (!ReadFixed(buf, sizeof(T))) ythrow yexception() << "TZCMemoryInput::LoadPOD failed: not enough data (" - << Avail() << " of " << sizeof(T) << " bytes)"; + << Avail() << " of " << sizeof(T) << " bytes)"; T res; memcpy(&res, buf, sizeof(T)); return res; } - + template <class T> Y_FORCE_INLINE void ReadPOD(T& x) { - x = LoadPOD<T>(); - } -}; + x = LoadPOD<T>(); + } +}; diff --git a/library/cpp/testing/unittest/utmain.cpp b/library/cpp/testing/unittest/utmain.cpp index 305bc6b40f..1610d5d39b 100644 --- a/library/cpp/testing/unittest/utmain.cpp +++ b/library/cpp/testing/unittest/utmain.cpp @@ -651,7 +651,7 @@ int NUnitTest::RunMain(int argc, char** argv) { InitNetworkSubSystem(); try { - GetExecPath(); + GetExecPath(); } catch (...) { } diff --git a/library/cpp/threading/local_executor/local_executor.h b/library/cpp/threading/local_executor/local_executor.h index c1c824f67c..0bf5db9304 100644 --- a/library/cpp/threading/local_executor/local_executor.h +++ b/library/cpp/threading/local_executor/local_executor.h @@ -7,7 +7,7 @@ #include <util/generic/noncopyable.h> #include <util/generic/ptr.h> #include <util/generic/singleton.h> -#include <util/generic/ymath.h> +#include <util/generic/ymath.h> #include <functional> diff --git a/library/cpp/xml/ya.make b/library/cpp/xml/ya.make index 5a685b70e6..a83e9eb31d 100644 --- a/library/cpp/xml/ya.make +++ b/library/cpp/xml/ya.make @@ -4,9 +4,9 @@ RECURSE( encode encode/ut init - parslib + parslib parslib/ut - sax + sax sax/ut validator validator/ut |