aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEgor Kochetov <gluk47@gmail.com>2022-02-10 16:50:36 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:50:36 +0300
commit40896b241c91572ea1369526ee1e6ae0ba340f34 (patch)
treecb6d8f482e66c136ec128a42417cd5f858520d12
parent3889d4c01a589a555fbc33d66279be23e267ab3b (diff)
downloadydb-40896b241c91572ea1369526ee1e6ae0ba340f34.tar.gz
Restoring authorship annotation for Egor Kochetov <gluk47@gmail.com>. Commit 1 of 2.
-rw-r--r--library/cpp/protobuf/json/json2proto.cpp14
-rw-r--r--library/cpp/protobuf/json/json2proto.h16
-rw-r--r--library/cpp/protobuf/json/ut/json2proto_ut.cpp32
-rw-r--r--library/cpp/protobuf/util/iterators.h104
-rw-r--r--library/cpp/protobuf/util/iterators_ut.cpp94
-rw-r--r--library/cpp/protobuf/util/ut/ya.make2
-rw-r--r--library/cpp/protobuf/util/ya.make2
-rw-r--r--tools/ya.make6
-rw-r--r--util/stream/str.h14
-rw-r--r--util/stream/str_ut.cpp16
-rw-r--r--util/string/hex.h40
-rw-r--r--util/string/hex_ut.cpp2
-rw-r--r--util/string/subst_ut.cpp6
-rw-r--r--util/system/file.cpp10
14 files changed, 179 insertions, 179 deletions
diff --git a/library/cpp/protobuf/json/json2proto.cpp b/library/cpp/protobuf/json/json2proto.cpp
index 640c10f5a5..94cab335c9 100644
--- a/library/cpp/protobuf/json/json2proto.cpp
+++ b/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);
}
}
}
diff --git a/library/cpp/protobuf/json/json2proto.h b/library/cpp/protobuf/json/json2proto.h
index 4c33498dfa..9667bb5c83 100644
--- a/library/cpp/protobuf/json/json2proto.h
+++ b/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;
diff --git a/library/cpp/protobuf/json/ut/json2proto_ut.cpp b/library/cpp/protobuf/json/ut/json2proto_ut.cpp
index 0dfe57bc7a..f313968d31 100644
--- a/library/cpp/protobuf/json/ut/json2proto_ut.cpp
+++ b/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
diff --git a/library/cpp/protobuf/util/iterators.h b/library/cpp/protobuf/util/iterators.h
index 6d53ac71b1..7830127d3f 100644
--- a/library/cpp/protobuf/util/iterators.h
+++ b/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());
+ }
+ }
+}
diff --git a/library/cpp/protobuf/util/iterators_ut.cpp b/library/cpp/protobuf/util/iterators_ut.cpp
index 9ebcff2963..0350fa425c 100644
--- a/library/cpp/protobuf/util/iterators_ut.cpp
+++ b/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();
+ }));
+ }
+}
diff --git a/library/cpp/protobuf/util/ut/ya.make b/library/cpp/protobuf/util/ut/ya.make
index 701ba9a8c8..bc1bacc52f 100644
--- a/library/cpp/protobuf/util/ut/ya.make
+++ b/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
diff --git a/library/cpp/protobuf/util/ya.make b/library/cpp/protobuf/util/ya.make
index b62028af58..a5bf4383a7 100644
--- a/library/cpp/protobuf/util/ya.make
+++ b/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
diff --git a/tools/ya.make b/tools/ya.make
index 51a6b8b426..fb6dca955a 100644
--- a/tools/ya.make
+++ b/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
diff --git a/util/stream/str.h b/util/stream/str.h
index 028bd572c0..6c43fe9607 100644
--- a/util/stream/str.h
+++ b/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 {
diff --git a/util/stream/str_ut.cpp b/util/stream/str_ut.cpp
index fc6b46c31a..a7d075d5fa 100644
--- a/util/stream/str_ut.cpp
+++ b/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");
diff --git a/util/string/hex.h b/util/string/hex.h
index af3d2d528f..0cef23cfff 100644
--- a/util/string/hex.h
+++ b/util/string/hex.h
@@ -2,7 +2,7 @@
#include <util/generic/string.h>
#include <util/generic/yexception.h>
-#include <util/system/yassert.h>
+#include <util/system/yassert.h>
inline static char DigitToChar(unsigned char digit) {
if (digit < 10) {
@@ -20,7 +20,7 @@ inline static int Char2Digit(char ch) {
return result;
}
-//! Convert a hex string of exactly 2 chars to int
+//! Convert a hex string of exactly 2 chars to int
/*! @example String2Byte("10") => 16 */
inline static int String2Byte(const char* s) {
return Char2Digit(*s) * 16 + Char2Digit(*(s + 1));
@@ -34,26 +34,26 @@ inline TString HexEncode(const TStringBuf h) {
return HexEncode(h.data(), h.size());
}
-//! Convert a hex string @c in of @c len chars (case-insensitive) to array of ints stored at @c ptr and return this array.
-/*! @note len must be even (len % 2 == 0), otherwise an exception will be thrown.
- * @return @c ptr, which is an array of chars, where each char holds the numeric value
- * equal to the corresponding 2 digits of the input stream.
- * @warning You must ensure that @c ptr has (len/2) allocated bytes, otherwise SIGSEGV will happen.
- *
- * @example HexDecode("beef", 4, ptr) => {190, 239}
- */
-void* HexDecode(const void* in, size_t len, void* ptr);
-
-//! Convert a hex string @c in of @c len chars (case-insensitive) to array of ints and return this array.
-/*! @note len must be even (len % 2 == 0), otherwise an exception will be thrown.
- * @return an array of chars, where each char holds the numeric value equal to the corresponding 2 digits
- * of the input stream.
- *
- * @example HexDecode("beef", 4) => {190, 239}
- */
+//! Convert a hex string @c in of @c len chars (case-insensitive) to array of ints stored at @c ptr and return this array.
+/*! @note len must be even (len % 2 == 0), otherwise an exception will be thrown.
+ * @return @c ptr, which is an array of chars, where each char holds the numeric value
+ * equal to the corresponding 2 digits of the input stream.
+ * @warning You must ensure that @c ptr has (len/2) allocated bytes, otherwise SIGSEGV will happen.
+ *
+ * @example HexDecode("beef", 4, ptr) => {190, 239}
+ */
+void* HexDecode(const void* in, size_t len, void* ptr);
+
+//! Convert a hex string @c in of @c len chars (case-insensitive) to array of ints and return this array.
+/*! @note len must be even (len % 2 == 0), otherwise an exception will be thrown.
+ * @return an array of chars, where each char holds the numeric value equal to the corresponding 2 digits
+ * of the input stream.
+ *
+ * @example HexDecode("beef", 4) => {190, 239}
+ */
TString HexDecode(const void* in, size_t len);
-//! Convert an ASCII hex-string (case-insensitive) to the binary form. Note that h.Size() must be even (+h % 2 == 0).
+//! Convert an ASCII hex-string (case-insensitive) to the binary form. Note that h.Size() must be even (+h % 2 == 0).
inline TString HexDecode(const TStringBuf h) {
return HexDecode(h.data(), h.size());
}
diff --git a/util/string/hex_ut.cpp b/util/string/hex_ut.cpp
index 39a83d5e62..33c9d9091b 100644
--- a/util/string/hex_ut.cpp
+++ b/util/string/hex_ut.cpp
@@ -13,7 +13,7 @@ Y_UNIT_TEST_SUITE(THexCodingTest) {
Y_UNIT_TEST(TestDecodeCase) {
UNIT_ASSERT_EQUAL(HexDecode("12ABCDEF"), HexDecode("12abcdef"));
- UNIT_ASSERT_EXCEPTION(HexDecode("Hello"), yexception); //< incorrect chars
+ UNIT_ASSERT_EXCEPTION(HexDecode("Hello"), yexception); //< incorrect chars
UNIT_ASSERT_EXCEPTION(HexDecode("123"), yexception); //< odd length
}
}
diff --git a/util/string/subst_ut.cpp b/util/string/subst_ut.cpp
index 21eccef779..5fcf91d423 100644
--- a/util/string/subst_ut.cpp
+++ b/util/string/subst_ut.cpp
@@ -133,9 +133,9 @@ Y_UNIT_TEST_SUITE(TStringSubst) {
s = "abcdefbcbcdfb";
SubstGlobal(s, "bc", "bbc", 2);
UNIT_ASSERT_EQUAL(s, TString("abcdefbbcbbcdfb"));
- s = "Москва ~ Париж";
- SubstGlobal(s, " ~ ", " ");
- UNIT_ASSERT_EQUAL(s, TString("Москва Париж"));
+ s = "Москва ~ Париж";
+ SubstGlobal(s, " ~ ", " ");
+ UNIT_ASSERT_EQUAL(s, TString("Москва Париж"));
}
Y_UNIT_TEST(TestSubstGlobalOldRet) {
diff --git a/util/system/file.cpp b/util/system/file.cpp
index 4a261d020c..7092c6c32f 100644
--- a/util/system/file.cpp
+++ b/util/system/file.cpp
@@ -58,15 +58,15 @@
#define HAVE_SYNC_FILE_RANGE 0
#endif
-static bool IsStupidFlagCombination(EOpenMode oMode) {
- // ForAppend will actually not be applied in the following combinations:
+static bool IsStupidFlagCombination(EOpenMode oMode) {
+ // ForAppend will actually not be applied in the following combinations:
return (oMode & (CreateAlways | ForAppend)) == (CreateAlways | ForAppend) || (oMode & (TruncExisting | ForAppend)) == (TruncExisting | ForAppend) || (oMode & (CreateNew | ForAppend)) == (CreateNew | ForAppend);
-}
-
+}
+
TFileHandle::TFileHandle(const TString& fName, EOpenMode oMode) noexcept {
ui32 fcMode = 0;
EOpenMode createMode = oMode & MaskCreation;
- Y_VERIFY(!IsStupidFlagCombination(oMode), "oMode %d makes no sense", static_cast<int>(oMode));
+ Y_VERIFY(!IsStupidFlagCombination(oMode), "oMode %d makes no sense", static_cast<int>(oMode));
if (!(oMode & MaskRW)) {
oMode |= RdWr;
}