Browse Source

Restoring authorship annotation for <finder@yandex-team.ru>. Commit 1 of 2.

finder 3 years ago
parent
commit
abbbaf4075

+ 32 - 32
library/cpp/binsaver/bin_saver.h

@@ -13,7 +13,7 @@
 #include <util/generic/variant.h>
 #include <util/generic/ylimits.h>
 #include <util/memory/blob.h>
-#include <util/digest/murmur.h>
+#include <util/digest/murmur.h> 
 
 #include <array>
 #include <bitset>
@@ -186,25 +186,25 @@ private:
 
     template <class T>
     void DoAnySet(T& data) {
-        if (IsReading()) {
-            data.clear();
+        if (IsReading()) { 
+            data.clear(); 
             TStoredSize nSize;
             Add(2, &nSize);
             for (TStoredSize i = 0; i < nSize; ++i) {
                 typename T::value_type member;
-                Add(1, &member);
-                data.insert(member);
-            }
-        } else {
+                Add(1, &member); 
+                data.insert(member); 
+            } 
+        } else { 
             TStoredSize nSize = data.size();
             CheckOverflow(nSize, data.size());
             Add(2, &nSize);
             for (const auto& elem : data) {
                 auto member = elem;
-                Add(1, &member);
-            }
-        }
-    }
+                Add(1, &member); 
+            } 
+        } 
+    } 
 
     // 2D array
     template <class T>
@@ -240,19 +240,19 @@ private:
             TStoredSize nCount = data.size();
             CheckOverflow(nCount, data.size());
             File.Write(&nCount, sizeof(TStoredSize));
-            File.Write(data.c_str(), nCount * elemSize);
+            File.Write(data.c_str(), nCount * elemSize); 
         }
     }
     void DataChunkString(std::string& data) {
-        DataChunkStr(data, sizeof(char));
-    }
+        DataChunkStr(data, sizeof(char)); 
+    } 
     void DataChunkStroka(TString& data) {
         DataChunkStr(data, sizeof(TString::char_type));
-    }
+    } 
     void DataChunkWtroka(TUtf16String& data) {
         DataChunkStr(data, sizeof(wchar16));
-    }
-
+    } 
+ 
     void DataChunk(void* pData, i64 nSize) {
         i64 chunkSize = 1 << 30;
         for (i64 offset = 0; offset < nSize; offset += chunkSize) {
@@ -302,13 +302,13 @@ public:
         return 0;
     }
     int Add(const chunk_id, TString* pStr) {
-        DataChunkStroka(*pStr);
+        DataChunkStroka(*pStr); 
         return 0;
-    }
+    } 
     int Add(const chunk_id, TUtf16String* pStr) {
-        DataChunkWtroka(*pStr);
+        DataChunkWtroka(*pStr); 
         return 0;
-    }
+    } 
     int Add(const chunk_id, TBlob* blob) {
         if (bRead) {
             ui64 size = 0;
@@ -367,7 +367,7 @@ public:
     int Add(const chunk_id, THashSet<T1, T2, T3, T4>* pHash) {
         DoAnySet(*pHash);
         return 0;
-    }
+    } 
 
     template <class T1>
     int Add(const chunk_id, TArray2D<T1>* pArr) {
@@ -524,17 +524,17 @@ public:
         return 0;
     }
 
-    template <typename TOne>
+    template <typename TOne> 
     void AddMulti(TOne& one) {
-        Add(0, &one);
-    }
-
+        Add(0, &one); 
+    } 
+ 
     template <typename THead, typename... TTail>
     void AddMulti(THead& head, TTail&... tail) {
-        Add(0, &head);
+        Add(0, &head); 
         AddMulti(tail...);
-    }
-
+    } 
+ 
     template <class T, typename = decltype(std::declval<T&>() & std::declval<IBinSaver&>())>
     static bool HasNonTrivialSerializer(ui32) {
         return true;
@@ -580,8 +580,8 @@ struct TRegisterSaveLoadType {
 
 #define Y_BINSAVER_REGISTER(name) \
     BASIC_REGISTER_CLASS(name)    \
-    static TRegisterSaveLoadType<name> init##name(MurmurHash<int>(#name, sizeof(#name)));
-
+    static TRegisterSaveLoadType<name> init##name(MurmurHash<int>(#name, sizeof(#name))); 
+ 
 #define REGISTER_SAVELOAD_CLASS(N, name) \
     BASIC_REGISTER_CLASS(name)           \
     static TRegisterSaveLoadType<name> init##name##N(N);
@@ -618,7 +618,7 @@ struct TRegisterSaveLoadType {
 
 #define REGISTER_SAVELOAD_CLASS_NS_PREF(N, cls, ns, pref) \
     REGISTER_SAVELOAD_CLASS_NAME(N, ns ::cls, _##pref##_##cls)
-
+ 
 #define SAVELOAD(...)             \
     int operator&(IBinSaver& f) { \
         f.AddMulti(__VA_ARGS__);  \

+ 1 - 1
library/cpp/binsaver/class_factory.h

@@ -93,7 +93,7 @@ void TClassFactory<T>::RegisterTypeBase(int nTypeID, newFunc func, VFT vft) {
     CTypeIndexHash::iterator typeIndexIt = typeIndex.find(vft);
     if (typeIndexIt != typeIndex.end() && nTypeID != typeIndexIt->second) {
         fprintf(stderr, "IBinSaver: class (Type ID 0x%08X) has been already registered (Type ID 0x%08X)\n", nTypeID, typeIndexIt->second);
-        abort();
+        abort(); 
     }
     typeIndex[vft] = nTypeID;
     typeInfo[nTypeID] = func;

+ 33 - 33
library/cpp/binsaver/util_stream_io.h

@@ -1,21 +1,21 @@
-#pragma once
+#pragma once 
 
 #include "bin_saver.h"
-
-#include <util/stream/input.h>
-#include <util/stream/output.h>
+ 
+#include <util/stream/input.h> 
+#include <util/stream/output.h> 
 #include <util/stream/file.h>
-
+ 
 class TYaStreamInput: public IBinaryStream {
     IInputStream& Stream;
 
     int WriteImpl(const void*, int) override {
         Y_ASSERT(0);
-        return 0;
-    }
+        return 0; 
+    } 
     int ReadImpl(void* userBuffer, int size) override {
         return (int)Stream.Read(userBuffer, (size_t)size);
-    }
+    } 
     bool IsValid() const override {
         return true;
     }
@@ -23,22 +23,22 @@ class TYaStreamInput: public IBinaryStream {
         return false;
     }
 
-public:
+public: 
     TYaStreamInput(IInputStream& stream)
         : Stream(stream)
     {
-    }
-};
-
+    } 
+}; 
+ 
 template <class T>
 inline void SerializeFromStream(IInputStream& stream, T& c) {
-    TYaStreamInput f(stream);
-    {
-        IBinSaver bs(f, true);
-        bs.Add(1, &c);
-    }
-}
-
+    TYaStreamInput f(stream); 
+    { 
+        IBinSaver bs(f, true); 
+        bs.Add(1, &c); 
+    } 
+} 
+ 
 template <class T>
 inline void SerializeFromFile(const TString& fileName, T& c) {
     TIFStream in(fileName);
@@ -50,12 +50,12 @@ class TYaStreamOutput: public IBinaryStream {
 
     int WriteImpl(const void* what, int size) override {
         Stream.Write(what, (size_t)size);
-        return size;
-    }
+        return size; 
+    } 
     int ReadImpl(void*, int) override {
         Y_ASSERT(0);
-        return 0;
-    }
+        return 0; 
+    } 
     bool IsValid() const override {
         return true;
     }
@@ -63,21 +63,21 @@ class TYaStreamOutput: public IBinaryStream {
         return false;
     }
 
-public:
+public: 
     TYaStreamOutput(IOutputStream& stream)
         : Stream(stream)
     {
-    }
-};
-
+    } 
+}; 
+ 
 template <class T>
 inline void SerializeToArcadiaStream(IOutputStream& stream, T& c) {
-    TYaStreamOutput f(stream);
-    {
-        IBinSaver bs(f, false);
-        bs.Add(1, &c);
-    }
-}
+    TYaStreamOutput f(stream); 
+    { 
+        IBinSaver bs(f, false); 
+        bs.Add(1, &c); 
+    } 
+} 
 
 template <class T>
 inline void SerializeToFile(const TString& fileName, T& c) {

+ 19 - 19
library/cpp/containers/2d_array/2d_array.h

@@ -1,8 +1,8 @@
-#pragma once
+#pragma once 
 
 #include <util/system/yassert.h>
 #include <util/generic/algorithm.h>
-
+ 
 #ifdef _DEBUG
 template <class T>
 struct TBoundCheck {
@@ -16,10 +16,10 @@ struct TBoundCheck {
         Y_ASSERT(i >= 0 && i < Size);
         return Data[i];
     }
-};
+}; 
 #endif
-
-template <class T>
+ 
+template <class T> 
 class TArray2D {
 private:
     typedef T* PT;
@@ -47,7 +47,7 @@ private:
             PData[i] = Data + i * XSize;
     }
 
-public:
+public: 
     TArray2D(size_t xsize = 1, size_t ysize = 1) {
         XSize = xsize;
         YSize = ysize;
@@ -75,17 +75,17 @@ public:
     void Clear() {
         SetSizes(1, 1);
     }
-#ifdef _DEBUG
+#ifdef _DEBUG 
     TBoundCheck<T> operator[](size_t i) const {
         Y_ASSERT(i < YSize);
         return TBoundCheck<T>(PData[i], XSize);
     }
-#else
+#else 
     T* operator[](size_t i) const {
         Y_ASSERT(i < YSize);
         return PData[i];
     }
-#endif
+#endif 
     size_t GetXSize() const {
         return XSize;
     }
@@ -105,20 +105,20 @@ public:
         std::swap(XSize, a.XSize);
         std::swap(YSize, a.YSize);
     }
-};
-
+}; 
+ 
 template <class T>
 inline bool operator==(const TArray2D<T>& a, const TArray2D<T>& b) {
-    if (a.GetXSize() != b.GetXSize() || a.GetYSize() != b.GetYSize())
-        return false;
+    if (a.GetXSize() != b.GetXSize() || a.GetYSize() != b.GetYSize()) 
+        return false; 
     for (size_t y = 0; y < a.GetYSize(); ++y) {
         for (size_t x = 0; x < a.GetXSize(); ++x)
-            if (a[y][x] != b[y][x])
-                return false;
-    }
-    return true;
-}
-
+            if (a[y][x] != b[y][x]) 
+                return false; 
+    } 
+    return true; 
+} 
+ 
 template <class T>
 inline bool operator!=(const TArray2D<T>& a, const TArray2D<T>& b) {
     return !(a == b);

+ 22 - 22
library/cpp/containers/comptrie/comptrie_ut.cpp

@@ -70,9 +70,9 @@ private:
     UNIT_TEST(TestUnique);
     UNIT_TEST(TestAddRetValue);
     UNIT_TEST(TestClear);
-
+ 
     UNIT_TEST(TestIterateEmptyKey);
-
+ 
     UNIT_TEST(TestTrieSet);
 
     UNIT_TEST(TestTrieForVectorInt64);
@@ -207,8 +207,8 @@ public:
     void TestUnique();
     void TestAddRetValue();
     void TestClear();
-
-    void TestIterateEmptyKey();
+ 
+    void TestIterateEmptyKey(); 
 
     void TestTrieSet();
 
@@ -1042,24 +1042,24 @@ public:
         return RandomNumber<std::make_unsigned_t<T>>();
     }
 };
-
-void TCompactTrieTest::TestIterateEmptyKey() {
-    TBuffer trieBuffer;
-    {
-        TCompactTrieBuilder<char, ui32> builder;
-        UNIT_ASSERT(builder.Add("", 1));
-        TBufferStream trieBufferO(trieBuffer);
-        builder.Save(trieBufferO);
-    }
-    TCompactTrie<char, ui32> trie(TBlob::FromBuffer(trieBuffer));
-    ui32 val;
-    UNIT_ASSERT(trie.Find("", &val));
-    UNIT_ASSERT(val == 1);
-    TCompactTrie<char, ui32>::TConstIterator it = trie.Begin();
-    UNIT_ASSERT(it.GetKey().empty());
-    UNIT_ASSERT(it.GetValue() == 1);
-}
-
+ 
+void TCompactTrieTest::TestIterateEmptyKey() { 
+    TBuffer trieBuffer; 
+    { 
+        TCompactTrieBuilder<char, ui32> builder; 
+        UNIT_ASSERT(builder.Add("", 1)); 
+        TBufferStream trieBufferO(trieBuffer); 
+        builder.Save(trieBufferO); 
+    } 
+    TCompactTrie<char, ui32> trie(TBlob::FromBuffer(trieBuffer)); 
+    ui32 val; 
+    UNIT_ASSERT(trie.Find("", &val)); 
+    UNIT_ASSERT(val == 1); 
+    TCompactTrie<char, ui32>::TConstIterator it = trie.Begin(); 
+    UNIT_ASSERT(it.GetKey().empty()); 
+    UNIT_ASSERT(it.GetValue() == 1); 
+} 
+ 
 void TCompactTrieTest::TestTrieSet() {
     TBuffer buffer;
     {

+ 48 - 48
library/cpp/json/easy_parse/json_easy_parser.cpp

@@ -1,14 +1,14 @@
-#include "json_easy_parser.h"
+#include "json_easy_parser.h" 
 #include <library/cpp/json/json_reader.h>
 #include <util/string/cast.h>
-#include <util/string/split.h>
-#include <util/string/strip.h>
-
-namespace NJson {
+#include <util/string/split.h> 
+#include <util/string/strip.h> 
+ 
+namespace NJson { 
     static TString MAP_IDENTIFIER = "{}";
     static TString ARRAY_IDENTIFIER = "[]";
     static TString ANY_IDENTIFIER = "*";
-
+ 
     static void ParsePath(TString path, TVector<TPathElem>* res) {
         TVector<const char*> parts;
         Split(path.begin(), '/', &parts);
@@ -26,24 +26,24 @@ namespace NJson {
                         arrayCounter = -1;
                     }
                     res->push_back(TPathElem(arrayCounter));
-                }
-            }
-        }
-    }
-
+                } 
+            } 
+        } 
+    } 
+ 
     void TJsonParser::AddField(const TString& path, bool nonEmpty) {
         Fields.emplace_back();
         Fields.back().NonEmpty = nonEmpty;
         ParsePath(path, &Fields.back().Path);
     }
-
+ 
     TString TJsonParser::ConvertToTabDelimited(const TString& json) const {
         TStringInput in(json);
         TStringStream out;
         ConvertToTabDelimited(in, out);
         return out.Str();
     }
-
+ 
     class TRewriteJsonImpl: public NJson::TJsonCallbacks {
         const TJsonParser& Parent;
         TVector<TString> FieldValues;
@@ -51,7 +51,7 @@ namespace NJson {
         bool ShouldUpdateOnArrayChange;
         int CurrentFieldIdx;
         bool HasFormatError;
-
+ 
     private:
         static bool PathElementMatch(const TPathElem& templ, const TPathElem& real) {
             if (templ.Type != real.Type)
@@ -62,31 +62,31 @@ namespace NJson {
                 return templ.Key == ANY_IDENTIFIER || templ.Key == real.Key;
             return true;
         }
-
+ 
         bool CheckFilter(const TVector<TPathElem>& path) const {
             if (Stack.size() < path.size())
-                return false;
+                return false; 
             for (size_t n = 0; n < path.size(); ++n) {
                 if (!PathElementMatch(path[n], Stack[n]))
                     return false;
             }
             return true;
-        }
-
+        } 
+ 
         void UpdateRule() {
             for (size_t n = 0; n < Parent.Fields.size(); ++n) {
                 if (FieldValues[n].empty() && CheckFilter(Parent.Fields[n].Path)) {
                     CurrentFieldIdx = n;
                     return;
                 }
-            }
+            } 
             CurrentFieldIdx = -1;
-        }
-
+        } 
+ 
         void Pop() {
             Stack.pop_back();
         }
-
+ 
         void IncreaseArrayCounter() {
             if (!Stack.empty() && Stack.back().Type == NImpl::ARRAY) {
                 ++Stack.back().ArrayCounter;
@@ -100,11 +100,11 @@ namespace NJson {
             IncreaseArrayCounter();
             if (CurrentFieldIdx >= 0) {
                 FieldValues[CurrentFieldIdx] = ToString(val);
-                UpdateRule();
+                UpdateRule(); 
             }
             return true;
-        }
-
+        } 
+ 
     public:
         TRewriteJsonImpl(const TJsonParser& parent)
             : Parent(parent)
@@ -117,8 +117,8 @@ namespace NJson {
                 if (!Parent.Fields[n].Path.empty() && Parent.Fields[n].Path.back().Type == NImpl::ARRAY)
                     ShouldUpdateOnArrayChange = true;
             }
-        }
-
+        } 
+ 
         bool OnOpenMap() override {
             IncreaseArrayCounter();
             Stack.push_back(TPathElem(NImpl::MAP));
@@ -127,8 +127,8 @@ namespace NJson {
             else
                 UpdateRule();
             return true;
-        }
-
+        } 
+ 
         bool OnOpenArray() override {
             IncreaseArrayCounter();
             Stack.push_back(TPathElem(-1));
@@ -144,17 +144,17 @@ namespace NJson {
                 Pop();
             if (!Stack.empty())
                 Pop();
-            UpdateRule();
+            UpdateRule(); 
             return true;
         }
-
+ 
         bool OnCloseArray() override {
             if (!Stack.empty())
                 Pop();
-            UpdateRule();
+            UpdateRule(); 
             return true;
         }
-
+ 
         bool OnMapKey(const TStringBuf& key) override {
             if (!Stack.empty() && Stack.back().Type == NImpl::MAP_KEY) {
                 Pop();
@@ -167,23 +167,23 @@ namespace NJson {
                 UpdateRule();
             return true;
         }
-
+ 
         bool OnBoolean(bool b) override {
             return OnValue(b);
         }
-
+ 
         bool OnInteger(long long i) override {
             return OnValue(i);
-        }
-
+        } 
+ 
         bool OnDouble(double f) override {
             return OnValue(f);
         }
-
+ 
         bool OnString(const TStringBuf& str) override {
             return OnValue(str);
         }
-
+ 
         bool IsOK() const {
             if (HasFormatError)
                 return false;
@@ -192,17 +192,17 @@ namespace NJson {
                     return false;
             return true;
         }
-
+ 
         void WriteTo(IOutputStream& out) const {
             for (size_t n = 0; n < FieldValues.size(); ++n)
                 out << "\t" << FieldValues[n];
         }
-
+ 
         void WriteTo(TVector<TString>* res) const {
             *res = FieldValues;
         }
     };
-
+ 
     void TJsonParser::ConvertToTabDelimited(IInputStream& in, IOutputStream& out) const {
         TRewriteJsonImpl impl(*this);
         ReadJson(&in, &impl);
@@ -211,8 +211,8 @@ namespace NJson {
             impl.WriteTo(out);
             out.Flush();
         }
-    }
-
+    } 
+ 
     bool TJsonParser::Parse(const TString& json, TVector<TString>* res) const {
         TRewriteJsonImpl impl(*this);
         TStringInput in(json);
@@ -222,8 +222,8 @@ namespace NJson {
             return true;
         } else
             return false;
-    }
-
+    } 
+ 
     //struct TTestMe {
     //    TTestMe() {
     //        TJsonParser worker;
@@ -232,5 +232,5 @@ namespace NJson {
     //        TString ret2 = worker.ConvertToTabDelimited(" [1, 2, 3, 4, 5] ");
     //    }
     //} testMe;
-
-}
+ 
+} 

+ 21 - 21
library/cpp/json/easy_parse/json_easy_parser.h

@@ -1,12 +1,12 @@
-#pragma once
+#pragma once 
 
 #include <util/generic/string.h>
-#include <util/generic/vector.h>
-#include <util/stream/input.h>
-#include <util/stream/output.h>
-#include "json_easy_parser_impl.h"
-
-namespace NJson {
+#include <util/generic/vector.h> 
+#include <util/stream/input.h> 
+#include <util/stream/output.h> 
+#include "json_easy_parser_impl.h" 
+ 
+namespace NJson { 
     /* This class filters out nodes from a source JSON by a xpath-style description. It represent these nodes as a tab-delimited string (or a vector).
      * It is useful if you need to parse a data which comes into JSON in a known and fixed format.
      * Fields are set as a list of keys separated by slash, for example:
@@ -21,26 +21,26 @@ namespace NJson {
      * NB! Library can not extract values of not a simple type (namely it doesn't support the case when a result is a vocabulary or an array) from JSON.
      * If you expect such a case, please check json_value.h.
      */
-
-    class TJsonParser {
+ 
+    class TJsonParser { 
         TString Prefix;
-
-        struct TField {
+ 
+        struct TField { 
             TVector<TPathElem> Path;
-            bool NonEmpty;
-        };
+            bool NonEmpty; 
+        }; 
         TVector<TField> Fields;
-
-        friend class TRewriteJsonImpl;
-
+ 
+        friend class TRewriteJsonImpl; 
+ 
         void ConvertToTabDelimited(IInputStream& in, IOutputStream& out) const;
 
-    public:
+    public: 
         void SetPrefix(const TString& prefix) {
-            Prefix = prefix;
-        }
+            Prefix = prefix; 
+        } 
         void AddField(const TString& path, bool mustExist);
         TString ConvertToTabDelimited(const TString& json) const;
         bool Parse(const TString& json, TVector<TString>* res) const;
-    };
-}
+    }; 
+} 

+ 19 - 19
library/cpp/json/easy_parse/json_easy_parser_impl.h

@@ -1,40 +1,40 @@
-#pragma once
-
+#pragma once 
+ 
 #include <util/generic/string.h>
 
-namespace NJson {
+namespace NJson { 
     namespace NImpl {
-        enum EType {
-            ARRAY,
-            MAP,
-            MAP_KEY
-        };
+        enum EType { 
+            ARRAY, 
+            MAP, 
+            MAP_KEY 
+        }; 
     }
     template <class TStringType>
     struct TPathElemImpl {
         NImpl::EType Type;
         TStringType Key;
-        int ArrayCounter;
-
+        int ArrayCounter; 
+ 
         TPathElemImpl(NImpl::EType type)
             : Type(type)
             , ArrayCounter()
         {
-        }
-
+        } 
+ 
         TPathElemImpl(const TStringType& key)
             : Type(NImpl::MAP_KEY)
             , Key(key)
             , ArrayCounter()
         {
-        }
-
-        TPathElemImpl(int arrayCounter)
+        } 
+ 
+        TPathElemImpl(int arrayCounter) 
             : Type(NImpl::ARRAY)
             , ArrayCounter(arrayCounter)
         {
-        }
-    };
-
+        } 
+    }; 
+ 
     typedef TPathElemImpl<TString> TPathElem;
-}
+} 

+ 11 - 11
library/cpp/json/easy_parse/ya.make

@@ -1,13 +1,13 @@
-OWNER(finder)
-
-LIBRARY()
-
+OWNER(finder) 
+ 
+LIBRARY() 
+ 
 SRCS(
-    json_easy_parser.cpp
-)
-
-PEERDIR(
+    json_easy_parser.cpp 
+) 
+ 
+PEERDIR( 
     library/cpp/json
-)
-
-END()
+) 
+ 
+END() 

+ 2 - 2
library/cpp/json/writer/json.cpp

@@ -2,7 +2,7 @@
 
 #include <library/cpp/json/json_value.h>
 
-#include <util/string/cast.h>
+#include <util/string/cast.h> 
 #include <util/string/strspn.h>
 #include <util/generic/algorithm.h>
 #include <util/generic/ymath.h>
@@ -263,7 +263,7 @@ namespace NJsonWriter {
         UnsafeWriteValue(buf, len);
         return TValueContext(*this);
     }
-
+ 
     TValueContext TBuf::WriteFloat(float f, EFloatToStringMode mode, int ndigits) {
         return WriteFloatImpl(f, mode, ndigits);
     }

Some files were not shown because too many files changed in this diff