Browse Source

Restoring authorship annotation for Egor Kochetov <gluk47@gmail.com>. Commit 2 of 2.

Egor Kochetov 3 years ago
parent
commit
a1fb24cd14

+ 7 - 7
library/cpp/protobuf/json/json2proto.cpp

@@ -356,17 +356,17 @@ Json2RepeatedField(const NJson::TJsonValue& json,
         if (config.ReplaceRepeatedFields) {
             reflection->ClearField(&proto, &field);
         }
-        if (fieldJson.GetType() == NJson::JSON_ARRAY) { 
-            const NJson::TJsonValue::TArray& jsonArray = fieldJson.GetArray(); 
-            for (const NJson::TJsonValue& jsonValue : jsonArray) { 
-                Json2RepeatedFieldValue(jsonValue, proto, field, config, reflection); 
-            } 
+        if (fieldJson.GetType() == NJson::JSON_ARRAY) {
+            const NJson::TJsonValue::TArray& jsonArray = fieldJson.GetArray();
+            for (const NJson::TJsonValue& jsonValue : jsonArray) {
+                Json2RepeatedFieldValue(jsonValue, proto, field, config, reflection);
+            }
         } else if (config.ValueVectorizer) {
             for (const NJson::TJsonValue& jsonValue : config.ValueVectorizer(fieldJson)) {
                 Json2RepeatedFieldValue(jsonValue, proto, field, config, reflection);
             }
-        } else if (config.VectorizeScalars) { 
-            Json2RepeatedFieldValue(fieldJson, proto, field, config, reflection); 
+        } else if (config.VectorizeScalars) {
+            Json2RepeatedFieldValue(fieldJson, proto, field, config, reflection);
         }
     }
 }

+ 8 - 8
library/cpp/protobuf/json/json2proto.h

@@ -88,11 +88,11 @@ namespace NProtobufJson {
             return *this;
         }
 
-        TSelf& SetVectorizeScalars(bool vectorizeScalars) { 
-            VectorizeScalars = vectorizeScalars; 
-            return *this; 
-        } 
- 
+        TSelf& SetVectorizeScalars(bool vectorizeScalars) {
+            VectorizeScalars = vectorizeScalars;
+            return *this;
+        }
+
         TSelf& SetAllowComments(bool value) {
             AllowComments = value;
             return *this;
@@ -135,9 +135,9 @@ namespace NProtobufJson {
 
         /// Enum value parsing mode.
         EnumValueMode EnumValueMode = EnumCaseSensetive;
- 
-        /// Append scalars to repeated fields 
-        bool VectorizeScalars = false; 
+
+        /// Append scalars to repeated fields
+        bool VectorizeScalars = false;
 
         /// Custom spliter non array value to repeated fields.
         TValueVectorizer ValueVectorizer;

+ 16 - 16
library/cpp/protobuf/json/ut/json2proto_ut.cpp

@@ -672,24 +672,24 @@ Y_UNIT_TEST(TestCastRobust) {
     UNIT_ASSERT_PROTOS_EQUAL(proto, expected);
 }
 
-Y_UNIT_TEST(TestVectorizeScalars) { 
-    NJson::TJsonValue json; 
-#define DEFINE_FIELD(name, value) \ 
-    json.InsertValue(#name, value); 
+Y_UNIT_TEST(TestVectorizeScalars) {
+    NJson::TJsonValue json;
+#define DEFINE_FIELD(name, value) \
+    json.InsertValue(#name, value);
 #include <library/cpp/protobuf/json/ut/fields.incl>
-#undef DEFINE_FIELD 
- 
-    TFlatRepeated proto; 
-    TJson2ProtoConfig config; 
-    config.SetVectorizeScalars(true); 
-    Json2Proto(json, proto, config); 
- 
-#define DEFINE_FIELD(name, value) \ 
-    UNIT_ASSERT_VALUES_EQUAL(proto.Get ## name(0), value); 
+#undef DEFINE_FIELD
+
+    TFlatRepeated proto;
+    TJson2ProtoConfig config;
+    config.SetVectorizeScalars(true);
+    Json2Proto(json, proto, config);
+
+#define DEFINE_FIELD(name, value) \
+    UNIT_ASSERT_VALUES_EQUAL(proto.Get ## name(0), value);
 #include <library/cpp/protobuf/json/ut/fields.incl>
-#undef DEFINE_FIELD 
-} 
- 
+#undef DEFINE_FIELD
+}
+
 Y_UNIT_TEST(TestValueVectorizer) {
     {
         // No ValueVectorizer

+ 52 - 52
library/cpp/protobuf/util/iterators.h

@@ -1,53 +1,53 @@
-#pragma once 
- 
+#pragma once
+
 #include <google/protobuf/descriptor.h>
- 
-namespace NProtoBuf { 
-    class TFieldsIterator { 
-    public: 
-        explicit TFieldsIterator(const NProtoBuf::Descriptor* descriptor, int position = 0) 
-        : Descriptor(descriptor) 
-        , Position(position) 
-        { } 
- 
-        TFieldsIterator& operator++() { 
-            ++Position; 
-            return *this; 
-        } 
- 
-        TFieldsIterator& operator++(int) { 
-            auto& ret = *this; 
-            ++*this; 
-            return ret; 
-        } 
- 
-        const NProtoBuf::FieldDescriptor* operator*() const { 
-            return Descriptor->field(Position); 
-        } 
- 
-        bool operator== (const TFieldsIterator& other) const { 
-            return Position == other.Position && Descriptor == other.Descriptor; 
-        } 
- 
-        bool operator!= (const TFieldsIterator& other) const { 
-            return !(*this == other); 
-        } 
- 
-    private: 
-        const NProtoBuf::Descriptor* Descriptor = nullptr; 
-        int Position = 0; 
-    }; 
-} 
- 
-// Namespaces required by `range-based for` ADL: 
-namespace google { 
-    namespace protobuf { 
-        NProtoBuf::TFieldsIterator begin(const NProtoBuf::Descriptor& descriptor) { 
-            return NProtoBuf::TFieldsIterator(&descriptor); 
-        } 
- 
-        NProtoBuf::TFieldsIterator end(const NProtoBuf::Descriptor& descriptor) { 
-            return NProtoBuf::TFieldsIterator(&descriptor, descriptor.field_count()); 
-        } 
-    } 
-} 
+
+namespace NProtoBuf {
+    class TFieldsIterator {
+    public:
+        explicit TFieldsIterator(const NProtoBuf::Descriptor* descriptor, int position = 0)
+        : Descriptor(descriptor)
+        , Position(position)
+        { }
+
+        TFieldsIterator& operator++() {
+            ++Position;
+            return *this;
+        }
+
+        TFieldsIterator& operator++(int) {
+            auto& ret = *this;
+            ++*this;
+            return ret;
+        }
+
+        const NProtoBuf::FieldDescriptor* operator*() const {
+            return Descriptor->field(Position);
+        }
+
+        bool operator== (const TFieldsIterator& other) const {
+            return Position == other.Position && Descriptor == other.Descriptor;
+        }
+
+        bool operator!= (const TFieldsIterator& other) const {
+            return !(*this == other);
+        }
+
+    private:
+        const NProtoBuf::Descriptor* Descriptor = nullptr;
+        int Position = 0;
+    };
+}
+
+// Namespaces required by `range-based for` ADL:
+namespace google {
+    namespace protobuf {
+        NProtoBuf::TFieldsIterator begin(const NProtoBuf::Descriptor& descriptor) {
+            return NProtoBuf::TFieldsIterator(&descriptor);
+        }
+
+        NProtoBuf::TFieldsIterator end(const NProtoBuf::Descriptor& descriptor) {
+            return NProtoBuf::TFieldsIterator(&descriptor, descriptor.field_count());
+        }
+    }
+}

+ 47 - 47
library/cpp/protobuf/util/iterators_ut.cpp

@@ -1,52 +1,52 @@
-#include "iterators.h" 
-#include "simple_reflection.h" 
+#include "iterators.h"
+#include "simple_reflection.h"
 #include <library/cpp/protobuf/util/ut/common_ut.pb.h>
- 
+
 #include <library/cpp/testing/unittest/registar.h>
- 
-#include <util/generic/algorithm.h> 
- 
-using NProtoBuf::TFieldsIterator; 
-using NProtoBuf::TConstField; 
- 
+
+#include <util/generic/algorithm.h>
+
+using NProtoBuf::TFieldsIterator;
+using NProtoBuf::TConstField;
+
 Y_UNIT_TEST_SUITE(Iterators) {
     Y_UNIT_TEST(Count) {
-        const NProtobufUtilUt::TWalkTest proto; 
-        const NProtoBuf::Descriptor* d = proto.GetDescriptor(); 
-        TFieldsIterator dbegin(d), dend(d, d->field_count()); 
-        size_t steps = 0; 
- 
-        UNIT_ASSERT_EQUAL(dbegin, begin(*d)); 
-        UNIT_ASSERT_EQUAL(dend, end(*d)); 
- 
-        for (; dbegin != dend; ++dbegin) 
-            ++steps; 
-        UNIT_ASSERT_VALUES_EQUAL(steps, d->field_count()); 
-    } 
- 
-    Y_UNIT_TEST(RangeFor) { 
-        size_t steps = 0, values = 0; 
-        NProtobufUtilUt::TWalkTest proto; 
-        proto.SetOptStr("yandex"); 
-        for (const auto& field : *proto.GetDescriptor()) { 
-            values += TConstField(proto, field).HasValue(); 
-            ++steps; 
-        } 
-        UNIT_ASSERT_VALUES_EQUAL(steps, proto.GetDescriptor()->field_count()); 
-        UNIT_ASSERT_VALUES_EQUAL(values, 1); 
-    } 
- 
+        const NProtobufUtilUt::TWalkTest proto;
+        const NProtoBuf::Descriptor* d = proto.GetDescriptor();
+        TFieldsIterator dbegin(d), dend(d, d->field_count());
+        size_t steps = 0;
+
+        UNIT_ASSERT_EQUAL(dbegin, begin(*d));
+        UNIT_ASSERT_EQUAL(dend, end(*d));
+
+        for (; dbegin != dend; ++dbegin)
+            ++steps;
+        UNIT_ASSERT_VALUES_EQUAL(steps, d->field_count());
+    }
+
+    Y_UNIT_TEST(RangeFor) {
+        size_t steps = 0, values = 0;
+        NProtobufUtilUt::TWalkTest proto;
+        proto.SetOptStr("yandex");
+        for (const auto& field : *proto.GetDescriptor()) {
+            values += TConstField(proto, field).HasValue();
+            ++steps;
+        }
+        UNIT_ASSERT_VALUES_EQUAL(steps, proto.GetDescriptor()->field_count());
+        UNIT_ASSERT_VALUES_EQUAL(values, 1);
+    }
+
     Y_UNIT_TEST(AnyOf) {
-        NProtobufUtilUt::TWalkTest proto; 
-        const NProtoBuf::Descriptor* d = proto.GetDescriptor(); 
-        TFieldsIterator begin(d), end(d, d->field_count()); 
-        UNIT_ASSERT(!AnyOf(begin, end, [&proto](const NProtoBuf::FieldDescriptor* f){ 
-            return TConstField(proto, f).HasValue(); 
-        })); 
- 
-        proto.SetOptStr("yandex"); 
-        UNIT_ASSERT(AnyOf(begin, end, [&proto](const NProtoBuf::FieldDescriptor* f){ 
-            return TConstField(proto, f).HasValue(); 
-        })); 
-    } 
-} 
+        NProtobufUtilUt::TWalkTest proto;
+        const NProtoBuf::Descriptor* d = proto.GetDescriptor();
+        TFieldsIterator begin(d), end(d, d->field_count());
+        UNIT_ASSERT(!AnyOf(begin, end, [&proto](const NProtoBuf::FieldDescriptor* f){
+            return TConstField(proto, f).HasValue();
+        }));
+
+        proto.SetOptStr("yandex");
+        UNIT_ASSERT(AnyOf(begin, end, [&proto](const NProtoBuf::FieldDescriptor* f){
+            return TConstField(proto, f).HasValue();
+        }));
+    }
+}

+ 1 - 1
library/cpp/protobuf/util/ut/ya.make

@@ -9,7 +9,7 @@ SRCS(
     common_ut.proto
     pb_io_ut.cpp
     is_equal_ut.cpp
-    iterators_ut.cpp 
+    iterators_ut.cpp
     simple_reflection_ut.cpp
     repeated_field_utils_ut.cpp
     walk_ut.cpp

+ 1 - 1
library/cpp/protobuf/util/ya.make

@@ -11,7 +11,7 @@ PEERDIR(
 
 SRCS(
     is_equal.cpp
-    iterators.h 
+    iterators.h
     merge.cpp
     path.cpp
     pb_io.cpp

+ 3 - 3
tools/ya.make

@@ -25,8 +25,8 @@ RECURSE(
     curl_to_ab
     diaprintkeys
     directindexer
-    doc_handle_decode 
-    doc_handle_decode/ut 
+    doc_handle_decode
+    doc_handle_decode/ut
     doc_url_index_print
     dolbilo
     domschemec
@@ -102,7 +102,7 @@ RECURSE(
     printurls
     printwzrd
     printwzrd/scripts
-    printwzrd/tests 
+    printwzrd/tests
     printxmap
     printxref
     prngrp_index_print

+ 7 - 7
util/stream/str.h

@@ -143,13 +143,13 @@ public:
     ~TStringStream() override;
 
     /**
-     * @returns                         Whether @c this contains any data 
-     */ 
-    explicit operator bool() const noexcept { 
-        return !Empty(); 
-    } 
- 
-    /** 
+     * @returns                         Whether @c this contains any data
+     */
+    explicit operator bool() const noexcept {
+        return !Empty();
+    }
+
+    /**
      * @returns                         String that this stream is writing into.
      */
     inline TString& Str() noexcept {

+ 8 - 8
util/stream/str_ut.cpp

@@ -67,15 +67,15 @@ Y_UNIT_TEST_SUITE(TStringInputOutputTest) {
 
         UNIT_ASSERT_VALUES_EQUAL(string2, string1.substr(5));
     }
- 
+
     Y_UNIT_TEST(OperatorBool) {
-        TStringStream str; 
-        UNIT_ASSERT(!str); 
-        str << "data"; 
-        UNIT_ASSERT(str); 
-        str.Clear(); 
-        UNIT_ASSERT(!str); 
-    } 
+        TStringStream str;
+        UNIT_ASSERT(!str);
+        str << "data";
+        UNIT_ASSERT(str);
+        str.Clear();
+        UNIT_ASSERT(!str);
+    }
 
     Y_UNIT_TEST(TestReadTo) {
         TString s("0123456789abc");

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