diff options
| author | Arslan Urtashev <[email protected]> | 2022-02-10 16:48:55 +0300 | 
|---|---|---|
| committer | Daniil Cherednik <[email protected]> | 2022-02-10 16:48:55 +0300 | 
| commit | 1136f2ce7cce7bcc84e695272c0d92d4eb900c2b (patch) | |
| tree | 5d5cb817648f650d76cf1076100726fd9b8448e8 /library/cpp | |
| parent | b97740540e7302cec9efa181e106ae1990a0cc1c (diff) | |
Restoring authorship annotation for Arslan Urtashev <[email protected]>. Commit 2 of 2.
Diffstat (limited to 'library/cpp')
36 files changed, 272 insertions, 272 deletions
diff --git a/library/cpp/getopt/ut/last_getopt_ut.cpp b/library/cpp/getopt/ut/last_getopt_ut.cpp index 429bb539905..c99a1d053d1 100644 --- a/library/cpp/getopt/ut/last_getopt_ut.cpp +++ b/library/cpp/getopt/ut/last_getopt_ut.cpp @@ -474,11 +474,11 @@ Y_UNIT_TEST_SUITE(TLastGetoptTests) {      Y_UNIT_TEST(TestDefaultValue) {          TOptsNoDefault opts;          opts.AddLongOption("path").DefaultValue("/etc"); -        int value = 42;  -        opts.AddLongOption("value").StoreResult(&value).DefaultValue(32);  +        int value = 42; +        opts.AddLongOption("value").StoreResult(&value).DefaultValue(32);          TOptsParseResultTestWrapper r(&opts, V({"cmd", "dfdf"}));          UNIT_ASSERT_VALUES_EQUAL("/etc", r.Get("path")); -        UNIT_ASSERT_VALUES_EQUAL(32, value);  +        UNIT_ASSERT_VALUES_EQUAL(32, value);      }      Y_UNIT_TEST(TestSplitValue) { diff --git a/library/cpp/histogram/ya.make b/library/cpp/histogram/ya.make index 13237d9ab63..77cfd96902f 100644 --- a/library/cpp/histogram/ya.make +++ b/library/cpp/histogram/ya.make @@ -2,8 +2,8 @@ RECURSE(      adaptive      hdr      hdr/ut -    simple  -    simple/ut  +    simple +    simple/ut      rt      rt/ut  ) diff --git a/library/cpp/http/misc/httpreqdata.cpp b/library/cpp/http/misc/httpreqdata.cpp index 035eccf7b98..f6951f68cd9 100644 --- a/library/cpp/http/misc/httpreqdata.cpp +++ b/library/cpp/http/misc/httpreqdata.cpp @@ -1,7 +1,7 @@  #include "httpreqdata.h" -#include <util/stream/mem.h>  -  +#include <util/stream/mem.h> +  TBaseServerRequestData::TBaseServerRequestData(SOCKET s)      : Addr(nullptr)      , Host() @@ -46,14 +46,14 @@ void TBaseServerRequestData::AppendQueryString(const char* str, size_t length) {      SearchLength = ModifiedQueryString.size() - 1; // ignore terminator  } -void TBaseServerRequestData::SetRemoteAddr(TStringBuf addr) {  -    TMemoryOutput out(AddrData, Y_ARRAY_SIZE(AddrData) - 1);  -    out.Write(addr.substr(0, Y_ARRAY_SIZE(AddrData) - 1));  -    *out.Buf() = '\0';  -  -    Addr = AddrData;  -}  -  +void TBaseServerRequestData::SetRemoteAddr(TStringBuf addr) { +    TMemoryOutput out(AddrData, Y_ARRAY_SIZE(AddrData) - 1); +    out.Write(addr.substr(0, Y_ARRAY_SIZE(AddrData) - 1)); +    *out.Buf() = '\0'; + +    Addr = AddrData; +} +  const char* TBaseServerRequestData::RemoteAddr() const {      if (!Addr) {          *AddrData = 0; diff --git a/library/cpp/http/misc/httpreqdata.h b/library/cpp/http/misc/httpreqdata.h index 6bc816fcf53..16e59c4d78c 100644 --- a/library/cpp/http/misc/httpreqdata.h +++ b/library/cpp/http/misc/httpreqdata.h @@ -57,7 +57,7 @@ public:      void AppendQueryString(const char* str, size_t length);      const char* RemoteAddr() const; -    void SetRemoteAddr(TStringBuf addr);  +    void SetRemoteAddr(TStringBuf addr);      const char* HeaderIn(TStringBuf key) const;      const THttpHeadersContainer& HeadersIn() const { diff --git a/library/cpp/http/misc/httpreqdata_ut.cpp b/library/cpp/http/misc/httpreqdata_ut.cpp index 554a4c9645b..e7f16ef27c8 100644 --- a/library/cpp/http/misc/httpreqdata_ut.cpp +++ b/library/cpp/http/misc/httpreqdata_ut.cpp @@ -135,20 +135,20 @@ Y_UNIT_TEST_SUITE(TRequestServerDataTest) {      }      Y_UNIT_TEST(SetRemoteAddrSimple) { -        static const TString TEST = "abacaba.search.yandex.net";  -  -        TServerRequestData rd;  -        rd.SetRemoteAddr(TEST);  -        UNIT_ASSERT_STRINGS_EQUAL(TEST, rd.RemoteAddr());  -    }  -  +        static const TString TEST = "abacaba.search.yandex.net"; + +        TServerRequestData rd; +        rd.SetRemoteAddr(TEST); +        UNIT_ASSERT_STRINGS_EQUAL(TEST, rd.RemoteAddr()); +    } +      Y_UNIT_TEST(SetRemoteAddrRandom) { -        for (size_t size = 0; size < 2 * INET6_ADDRSTRLEN; ++size) {  -            const TString test = NUnitTest::RandomString(size, size);  -            TServerRequestData rd;  -            rd.SetRemoteAddr(test);  -            UNIT_ASSERT_STRINGS_EQUAL(test.substr(0, INET6_ADDRSTRLEN - 1), rd.RemoteAddr());  -        }  -    }  -  +        for (size_t size = 0; size < 2 * INET6_ADDRSTRLEN; ++size) { +            const TString test = NUnitTest::RandomString(size, size); +            TServerRequestData rd; +            rd.SetRemoteAddr(test); +            UNIT_ASSERT_STRINGS_EQUAL(test.substr(0, INET6_ADDRSTRLEN - 1), rd.RemoteAddr()); +        } +    } +  } // TRequestServerDataTest diff --git a/library/cpp/json/writer/json.cpp b/library/cpp/json/writer/json.cpp index 1a8e44e7574..02370c2d79e 100644 --- a/library/cpp/json/writer/json.cpp +++ b/library/cpp/json/writer/json.cpp @@ -188,7 +188,7 @@ namespace NJsonWriter {          RawWriteChar(':');          return TAfterColonContext(*this);      } -  +      TBuf& TBuf::EndList() {          CheckAndPop(JE_LIST);          EndValue(); diff --git a/library/cpp/json/writer/json.h b/library/cpp/json/writer/json.h index 80a09de607b..0aae2531b94 100644 --- a/library/cpp/json/writer/json.h +++ b/library/cpp/json/writer/json.h @@ -60,7 +60,7 @@ namespace NJsonWriter {          TPairContext BeginObject();          TAfterColonContext WriteKey(const TStringBuf& key, EHtmlEscapeMode hem);          TAfterColonContext WriteKey(const TStringBuf& key); -        TAfterColonContext UnsafeWriteKey(const TStringBuf& key);  +        TAfterColonContext UnsafeWriteKey(const TStringBuf& key);          bool KeyExpected() const {              return Stack.back() == JE_OBJECT;          } @@ -227,9 +227,9 @@ namespace NJsonWriter {          TAfterColonContext WriteKey(const TStringBuf& s) {              return Buf.WriteKey(s);          } -        TAfterColonContext UnsafeWriteKey(const TStringBuf& s) {  -            return Buf.UnsafeWriteKey(s);  -        }  +        TAfterColonContext UnsafeWriteKey(const TStringBuf& s) { +            return Buf.UnsafeWriteKey(s); +        }          TAfterColonContext CompatWriteKeyWithoutQuotes(const TStringBuf& s) {              return Buf.CompatWriteKeyWithoutQuotes(s);          } diff --git a/library/cpp/json/writer/json_ut.cpp b/library/cpp/json/writer/json_ut.cpp index c278b6f73c5..9980555683f 100644 --- a/library/cpp/json/writer/json_ut.cpp +++ b/library/cpp/json/writer/json_ut.cpp @@ -252,18 +252,18 @@ Y_UNIT_TEST_SUITE(JsonWriter) {              UNIT_ASSERT_STRINGS_EQUAL(buf.Str(), R"raw_json({"nanvalue":"nan","infvalue":"inf","minus_infvalue":"-inf","l":["nan"]})raw_json");          } -  -        {  -            NJsonWriter::TBuf buf;  -            buf.BeginObject()  + +        { +            NJsonWriter::TBuf buf; +            buf.BeginObject()                  .WriteKey("<>&")                  .WriteString("Ololo")                  .UnsafeWriteKey("<>&")                  .WriteString("Ololo2")                  .EndObject(); -  -            UNIT_ASSERT_STRINGS_EQUAL(buf.Str(), R"({"\u003C\u003E&":"Ololo","<>&":"Ololo2"})");  -        }  + +            UNIT_ASSERT_STRINGS_EQUAL(buf.Str(), R"({"\u003C\u003E&":"Ololo","<>&":"Ololo2"})"); +        }      }      Y_UNIT_TEST(WriteUninitializedBoolDoesntCrashProgram) { diff --git a/library/cpp/json/yson/json2yson.cpp b/library/cpp/json/yson/json2yson.cpp index 53f4c9bf186..f72cb7a9ef9 100644 --- a/library/cpp/json/yson/json2yson.cpp +++ b/library/cpp/json/yson/json2yson.cpp @@ -93,11 +93,11 @@ namespace NJson2Yson {          NYson::TYsonParser ysonParser(&writer, inputStream, ::NYson::EYsonType::Node);          ysonParser.Parse();      } -  +      void ConvertYson2Json(TStringBuf yson, IOutputStream* outputStream) {          TMemoryInput inputStream(yson);          ConvertYson2Json(&inputStream, outputStream); -    }  +    }      TString ConvertYson2Json(TStringBuf yson) {          TString json; diff --git a/library/cpp/json/yson/json2yson.h b/library/cpp/json/yson/json2yson.h index b0d127a1a20..758eb6d0cfd 100644 --- a/library/cpp/json/yson/json2yson.h +++ b/library/cpp/json/yson/json2yson.h @@ -7,7 +7,7 @@  namespace NJson2Yson {      class TJsonBuilderImpl: public NYson::TYsonConsumerBase {      public: -        TJsonBuilderImpl(NJson::TJsonCallbacks* parserCallbacks)  +        TJsonBuilderImpl(NJson::TJsonCallbacks* parserCallbacks)              : ParserCallbacks_(parserCallbacks)          {          } @@ -66,15 +66,15 @@ namespace NJson2Yson {          }      private: -        NJson::TJsonCallbacks* ParserCallbacks_;  +        NJson::TJsonCallbacks* ParserCallbacks_;      };      template <typename TBase>      class TSkipAttributesProxy: public TBase {      public: -        template <typename... TArgs>  -        TSkipAttributesProxy<TBase>(TArgs&&... args)  -            : TBase(std::forward<TArgs>(args)...)  +        template <typename... TArgs> +        TSkipAttributesProxy<TBase>(TArgs&&... args) +            : TBase(std::forward<TArgs>(args)...)          {          } @@ -156,7 +156,7 @@ namespace NJson2Yson {          void OnEndAttributes() override {              --AttributesDepth; -            Y_ASSERT(AttributesDepth >= 0);  +            Y_ASSERT(AttributesDepth >= 0);          }      private: @@ -168,7 +168,7 @@ namespace NJson2Yson {      void ConvertYson2Json(IInputStream* inputStream, IOutputStream* outputStream);      void ConvertYson2Json(TStringBuf yson, IOutputStream* outputStream);      TString ConvertYson2Json(TStringBuf yson); -  +      bool DeserializeYsonAsJsonValue(IInputStream* inputStream, NJson::TJsonValue* outputValue, bool throwOnError = false);      bool DeserializeYsonAsJsonValue(TStringBuf str, NJson::TJsonValue* outputValue, bool throwOnError = false); diff --git a/library/cpp/monlib/metrics/metric_registry.cpp b/library/cpp/monlib/metrics/metric_registry.cpp index 18e2884b418..b083163a7b2 100644 --- a/library/cpp/monlib/metrics/metric_registry.cpp +++ b/library/cpp/monlib/metrics/metric_registry.cpp @@ -161,7 +161,7 @@ namespace NMonitoring {      TMetric* TMetricRegistry::Metric(TLabelsType&& labels, Args&&... args) {          {              TReadGuard g{Lock_}; -  +              auto it = Metrics_.find(labels);              if (it != Metrics_.end()) {                  Y_ENSURE(it->second->Type() == type, "cannot create metric " << labels @@ -170,7 +170,7 @@ namespace NMonitoring {                  return static_cast<TMetric*>(it->second.Get());              }          } -  +          {              IMetricPtr metric = MakeHolder<TMetric>(std::forward<Args>(args)...); @@ -186,7 +186,7 @@ namespace NMonitoring {              return static_cast<TMetric*>(it->second.Get());          }      } -  +      void TMetricRegistry::RemoveMetric(const ILabels& labels) noexcept {          TWriteGuard g{Lock_};          Metrics_.erase(labels); @@ -214,7 +214,7 @@ namespace NMonitoring {          consumer->OnStreamEnd();      } -  +      void TMetricRegistry::Append(TInstant time, IMetricConsumer* consumer) const {          TReadGuard g{Lock_}; diff --git a/library/cpp/monlib/metrics/metric_registry.h b/library/cpp/monlib/metrics/metric_registry.h index 6cda12596e5..670cf8651e1 100644 --- a/library/cpp/monlib/metrics/metric_registry.h +++ b/library/cpp/monlib/metrics/metric_registry.h @@ -124,6 +124,6 @@ namespace NMonitoring {          TLabels CommonLabels_;      }; -  +      void WriteLabels(IMetricConsumer* consumer, const ILabels& labels);  } diff --git a/library/cpp/monlib/metrics/metric_registry_ut.cpp b/library/cpp/monlib/metrics/metric_registry_ut.cpp index 10002a38972..86d9a52ec0c 100644 --- a/library/cpp/monlib/metrics/metric_registry_ut.cpp +++ b/library/cpp/monlib/metrics/metric_registry_ut.cpp @@ -157,15 +157,15 @@ Y_UNIT_TEST_SUITE(TMetricRegistryTest) {      Y_UNIT_TEST(DoubleCounter) {          TMetricRegistry registry(TLabels{{"common", "label"}}); -  +          TCounter* c = registry.Counter({{"my", "counter"}});          UNIT_ASSERT_VALUES_EQUAL(c->Get(), 0); -        c->Add(10);  -  -        c = registry.Counter({{"my", "counter"}});  +        c->Add(10); + +        c = registry.Counter({{"my", "counter"}});          UNIT_ASSERT_VALUES_EQUAL(c->Get(), 10); -    }  -  +    } +      Y_UNIT_TEST(Sample) {          TMetricRegistry registry(TLabels{{"common", "label"}}); diff --git a/library/cpp/protobuf/json/config.h b/library/cpp/protobuf/json/config.h index 0ea37f1898e..dc84fb4d5db 100644 --- a/library/cpp/protobuf/json/config.h +++ b/library/cpp/protobuf/json/config.h @@ -1,13 +1,13 @@  #pragma once  #include "string_transform.h" -#include "name_generator.h"  +#include "name_generator.h"  #include <util/generic/vector.h>  #include <util/generic/yexception.h> -#include <functional>  -  +#include <functional> +  namespace NProtobufJson {      struct TProto2JsonConfig {          using TSelf = TProto2JsonConfig; @@ -85,14 +85,14 @@ namespace NProtobufJson {          /// Custom enum values generator.          TEnumValueGenerator EnumValueGenerator = {}; -  +          bool WriteNanAsString = false;          TSelf& SetFormatOutput(bool format) {              FormatOutput = format;              return *this;          } -  +          TSelf& SetMissingSingleKeyMode(MissingKeyMode mode) {              MissingSingleKeyMode = mode;              return *this; @@ -149,7 +149,7 @@ namespace NProtobufJson {              NameGenerator = callback;              return *this;          } -  +          TSelf& SetEnumValueGenerator(TEnumValueGenerator callback) {              EnumValueGenerator = callback;              return *this; @@ -160,5 +160,5 @@ namespace NProtobufJson {              return *this;          }      }; -  +  } diff --git a/library/cpp/protobuf/json/json2proto.cpp b/library/cpp/protobuf/json/json2proto.cpp index 5efa6d4b6c2..640c10f5a51 100644 --- a/library/cpp/protobuf/json/json2proto.cpp +++ b/library/cpp/protobuf/json/json2proto.cpp @@ -36,10 +36,10 @@  static TString GetFieldName(const google::protobuf::FieldDescriptor& field,                              const NProtobufJson::TJson2ProtoConfig& config) { -    if (config.NameGenerator) {  -        return config.NameGenerator(field);  -    }  -  +    if (config.NameGenerator) { +        return config.NameGenerator(field); +    } +      if (config.UseJsonName) {          Y_ASSERT(!field.json_name().empty());          TString name = field.json_name(); @@ -409,10 +409,10 @@ namespace NProtobufJson {          NJson::TJsonReaderConfig jsonCfg;          jsonCfg.DontValidateUtf8 = true;          jsonCfg.AllowComments = config.AllowComments; -  +          NJson::TJsonValue jsonValue;          ReadJsonTree(json, &jsonCfg, &jsonValue, /* throwOnError = */ true); -  +          MergeJson2Proto(jsonValue, proto, config);      } @@ -425,4 +425,4 @@ namespace NProtobufJson {          proto.Clear();          MergeJson2Proto(json, proto, config);      } -}  +} diff --git a/library/cpp/protobuf/json/json2proto.h b/library/cpp/protobuf/json/json2proto.h index 5d35991cf3d..4c33498dfa3 100644 --- a/library/cpp/protobuf/json/json2proto.h +++ b/library/cpp/protobuf/json/json2proto.h @@ -1,7 +1,7 @@  #pragma once  #include "string_transform.h" -#include "name_generator.h"  +#include "name_generator.h"  #include <library/cpp/json/json_reader.h>  #include <library/cpp/json/json_value.h> @@ -105,7 +105,7 @@ namespace NProtobufJson {          FldNameMode FieldNameMode = FieldNameOriginalCase;          bool AllowUnknownFields = true; -  +          /// Use 'json_name' protobuf option for field name, mutually exclusive          /// with FieldNameMode.          bool UseJsonName = false; @@ -126,7 +126,7 @@ namespace NProtobufJson {          /// Throw exception if there is no required fields in json object.          bool CheckRequiredFields = true; -  +          /// Replace repeated fields content during merging          bool ReplaceRepeatedFields = false; @@ -145,7 +145,7 @@ namespace NProtobufJson {          /// Allow js-style comments (both // and /**/)          bool AllowComments = false;      }; -  +      /// @throw yexception      void MergeJson2Proto(const NJson::TJsonValue& json, google::protobuf::Message& proto,                      const TJson2ProtoConfig& config = TJson2ProtoConfig()); @@ -173,7 +173,7 @@ namespace NProtobufJson {                             const TJson2ProtoConfig& config = TJson2ProtoConfig()) {          Json2Proto(TStringBuf(json), proto, config);      } -  +      /// @throw yexception      inline void Json2Proto(IInputStream& in, google::protobuf::Message& proto,                             const TJson2ProtoConfig& config = TJson2ProtoConfig()) { @@ -190,7 +190,7 @@ namespace NProtobufJson {          Json2Proto(jsonValue, protoValue, config);          return protoValue;      } -  +      /// @throw yexception      template <typename T>      T Json2Proto(IInputStream& in, const TJson2ProtoConfig& config = TJson2ProtoConfig()) { @@ -219,4 +219,4 @@ namespace NProtobufJson {          return Json2Proto<T>(TStringBuf(ptr), config);      } -}  +} diff --git a/library/cpp/protobuf/json/json_output_create.cpp b/library/cpp/protobuf/json/json_output_create.cpp index a0515b9ce73..378e4ea65a0 100644 --- a/library/cpp/protobuf/json/json_output_create.cpp +++ b/library/cpp/protobuf/json/json_output_create.cpp @@ -16,7 +16,7 @@ namespace NProtobufJson {      TJsonMapOutputPtr CreateJsonMapOutput(TString& str, const TProto2JsonConfig& config) {          return MakeHolder<TJsonStringWriterOutput>(&str, config);      } -  +      TJsonMapOutputPtr CreateJsonMapOutput(TStringStream& out, const TProto2JsonConfig& config) {          return MakeHolder<TJsonWriterOutput>(&out, config);      } diff --git a/library/cpp/protobuf/json/json_value_output.cpp b/library/cpp/protobuf/json/json_value_output.cpp index 88f52f84900..d845cc1c74a 100644 --- a/library/cpp/protobuf/json/json_value_output.cpp +++ b/library/cpp/protobuf/json/json_value_output.cpp @@ -1,5 +1,5 @@ -#include "json_value_output.h"  -  +#include "json_value_output.h" +  #include <library/cpp/json/json_reader.h>  namespace NProtobufJson { @@ -17,7 +17,7 @@ namespace NProtobufJson {      void TJsonValueOutput::DoWrite(const TStringBuf& s) {          WriteImpl(s); -    }  +    }      void TJsonValueOutput::DoWrite(const TString& s) {          WriteImpl(s); @@ -34,7 +34,7 @@ namespace NProtobufJson {      void TJsonValueOutput::DoWrite(long long i) {          WriteImpl(i);      } -  +      void TJsonValueOutput::DoWrite(unsigned long long i) {          WriteImpl(i);      } @@ -69,7 +69,7 @@ namespace NProtobufJson {      void TJsonValueOutput::DoEndList() {          Y_ASSERT(Context.top().Type == TContext::JSON_ARRAY);          Context.pop(); -    }  +    }      void TJsonValueOutput::DoBeginObject() {          Y_ASSERT(Context.top().Type == TContext::JSON_ARRAY || Context.top().Type == TContext::JSON_AFTER_KEY); @@ -85,7 +85,7 @@ namespace NProtobufJson {      void TJsonValueOutput::DoWriteKey(const TStringBuf& key) {          Y_ASSERT(Context.top().Type == TContext::JSON_MAP);          Context.emplace(TContext::JSON_AFTER_KEY, Context.top().Value[key]); -    }  +    }      void TJsonValueOutput::DoEndObject() {          Y_ASSERT(Context.top().Type == TContext::JSON_MAP); diff --git a/library/cpp/protobuf/json/json_value_output.h b/library/cpp/protobuf/json/json_value_output.h index d1127d06732..3fc6ff2ab0f 100644 --- a/library/cpp/protobuf/json/json_value_output.h +++ b/library/cpp/protobuf/json/json_value_output.h @@ -1,11 +1,11 @@  #pragma once -#include "json_output.h"  -  +#include "json_output.h" +  #include <library/cpp/json/writer/json_value.h> -#include <util/generic/stack.h>  -  +#include <util/generic/stack.h> +  namespace NProtobufJson {      class TJsonValueOutput: public IJsonOutput {      public: @@ -54,10 +54,10 @@ namespace NProtobufJson {              EType Type;              NJson::TJsonValue& Value; -        };  +        };          NJson::TJsonValue& Root;          TStack<TContext, TVector<TContext>> Context; -    };  +    };  } diff --git a/library/cpp/protobuf/json/json_writer_output.h b/library/cpp/protobuf/json/json_writer_output.h index fbd3f10c6f9..3d8a2daa56c 100644 --- a/library/cpp/protobuf/json/json_writer_output.h +++ b/library/cpp/protobuf/json/json_writer_output.h @@ -5,7 +5,7 @@  #include <library/cpp/json/json_writer.h> -#include <util/string/builder.h>  +#include <util/string/builder.h>  #include <util/generic/store_policy.h>  namespace NProtobufJson { diff --git a/library/cpp/protobuf/json/name_generator.cpp b/library/cpp/protobuf/json/name_generator.cpp index c692cb31209..c1fb421175d 100644 --- a/library/cpp/protobuf/json/name_generator.cpp +++ b/library/cpp/protobuf/json/name_generator.cpp @@ -1 +1 @@ -#include "name_generator.h"  +#include "name_generator.h" diff --git a/library/cpp/protobuf/json/name_generator.h b/library/cpp/protobuf/json/name_generator.h index e9ce067800f..2b5361bee2e 100644 --- a/library/cpp/protobuf/json/name_generator.h +++ b/library/cpp/protobuf/json/name_generator.h @@ -1,18 +1,18 @@ -#pragma once  -  -#include <util/generic/string.h>  -  -#include <functional>  -  -namespace google {  +#pragma once + +#include <util/generic/string.h> + +#include <functional> + +namespace google {      namespace protobuf {          class FieldDescriptor;          class EnumValueDescriptor;      }  } -  -namespace NProtobufJson {  + +namespace NProtobufJson {      using TNameGenerator = std::function<TString(const google::protobuf::FieldDescriptor&)>;      using TEnumValueGenerator = std::function<TString(const google::protobuf::EnumValueDescriptor&)>; -  +  } diff --git a/library/cpp/protobuf/json/proto2json_printer.cpp b/library/cpp/protobuf/json/proto2json_printer.cpp index 31e7fe66d3d..6123eab0f25 100644 --- a/library/cpp/protobuf/json/proto2json_printer.cpp +++ b/library/cpp/protobuf/json/proto2json_printer.cpp @@ -14,12 +14,12 @@ namespace NProtobufJson {          TJsonKeyBuilder(const FieldDescriptor& field, const TProto2JsonConfig& config, TString& tmpBuf)              : NewKeyStr(tmpBuf)          { -            if (config.NameGenerator) {  -                NewKeyStr = config.NameGenerator(field);  -                NewKeyBuf = NewKeyStr;  -                return;  -            }  -  +            if (config.NameGenerator) { +                NewKeyStr = config.NameGenerator(field); +                NewKeyBuf = NewKeyStr; +                return; +            } +              if (config.UseJsonName) {                  Y_ASSERT(!field.json_name().empty());                  NewKeyStr = field.json_name(); @@ -136,11 +136,11 @@ namespace NProtobufJson {      void TProto2JsonPrinter::PrintEnumValue(const TStringBuf& key,                                              const EnumValueDescriptor* value,                                              IJsonOutput& json) { -        if (Config.EnumValueGenerator) {  -            WriteWithMaybeEmptyKey<InMapContext>(json, key, Config.EnumValueGenerator(*value));  -            return;  -        }  -  +        if (Config.EnumValueGenerator) { +            WriteWithMaybeEmptyKey<InMapContext>(json, key, Config.EnumValueGenerator(*value)); +            return; +        } +          switch (GetConfig().EnumMode) {              case TProto2JsonConfig::EnumNumber: {                  WriteWithMaybeEmptyKey<InMapContext>(json, key, value->number()); @@ -333,7 +333,7 @@ namespace NProtobufJson {                  default:                      ythrow yexception() << "Unknown protobuf field type: "                                          << static_cast<int>(field.cpp_type()) << "."; -            }  +            }              if (isMap) {                  json.EndObject(); @@ -462,7 +462,7 @@ namespace NProtobufJson {              Y_ASSERT(field);              PrintField(proto, *field, json);          } -  +          // Check extensions via ListFields          std::vector<const FieldDescriptor*> fields;          auto* ref = proto.GetReflection(); diff --git a/library/cpp/protobuf/json/ut/json2proto_ut.cpp b/library/cpp/protobuf/json/ut/json2proto_ut.cpp index 42a8ddf2c32..0dfe57bc7a2 100644 --- a/library/cpp/protobuf/json/ut/json2proto_ut.cpp +++ b/library/cpp/protobuf/json/ut/json2proto_ut.cpp @@ -1,6 +1,6 @@  #include "json.h"  #include "proto.h" -#include "proto2json.h"  +#include "proto2json.h"  #include <library/cpp/protobuf/json/ut/test.pb.h> @@ -50,11 +50,11 @@ namespace {      TString ConvertToString(double value) {          return FloatToString(value);      } -  -    TString JsonValueToString(const NJson::TJsonValue& json) {  -        NJsonWriter::TBuf buf(NJsonWriter::HEM_UNSAFE);  -        return buf.WriteJsonValue(&json).Str();  -    }  + +    TString JsonValueToString(const NJson::TJsonValue& json) { +        NJsonWriter::TBuf buf(NJsonWriter::HEM_UNSAFE); +        return buf.WriteJsonValue(&json).Str(); +    }      void TestComplexMapAsObject(std::function<void(TComplexMapType&)>&& init, const TString& json, const TJson2ProtoConfig& config = TJson2ProtoConfig().SetMapAsObject(true)) {          TComplexMapType modelProto; @@ -121,13 +121,13 @@ UNIT_ASSERT_PROTOS_EQUAL(proto, modelProto);  Y_UNIT_TEST(TestNameGenerator) {      TJson2ProtoConfig cfg;      cfg.SetNameGenerator([](const NProtoBuf::FieldDescriptor&) { return "42"; }); -  +      TNameGeneratorType proto;      Json2Proto(TStringBuf(R"({"42":42})"), proto, cfg); -  +      TNameGeneratorType expected;      expected.SetField(42); -  +      UNIT_ASSERT_PROTOS_EQUAL(expected, proto);  } @@ -139,11 +139,11 @@ Y_UNIT_TEST(TestFlatNoCheckRequired) {          TFlatRequired modelProto;          FillFlatProto(&modelProto);          UNIT_ASSERT_PROTOS_EQUAL(proto, modelProto); -    }  -  +    } +      TJson2ProtoConfig cfg;      cfg.CheckRequiredFields = false; -  +      // Try to skip each field  #define DEFINE_FIELD(name, value)                                     \      {                                                                 \ @@ -154,9 +154,9 @@ Y_UNIT_TEST(TestFlatNoCheckRequired) {          UNIT_ASSERT_NO_EXCEPTION(Json2Proto(json, proto, cfg));       \      }  #include <library/cpp/protobuf/json/ut/fields.incl> -#undef DEFINE_FIELD  +#undef DEFINE_FIELD  } // TestFlatNoCheckRequired -  +  Y_UNIT_TEST(TestFlatRepeated){      {const NJson::TJsonValue& json = CreateRepeatedFlatJson();  TFlatRepeated proto; @@ -217,7 +217,7 @@ FillCompositeProto(&modelProto);  modelProto.MutablePart()->SetDouble(42.5);  UNIT_ASSERT_PROTOS_EQUAL(proto, modelProto);  } -  +  // Try to skip each field  #define DEFINE_FIELD(name, value)                                   \      {                                                               \ @@ -237,9 +237,9 @@ UNIT_ASSERT_PROTOS_EQUAL(proto, modelProto);          UNIT_ASSERT_PROTOS_EQUAL(proto, modelProto);                \      }  #include <library/cpp/protobuf/json/ut/fields.incl> -#undef DEFINE_FIELD  +#undef DEFINE_FIELD  } // TestCompositeOptionalStringBuf -  +  Y_UNIT_TEST(TestCompositeRequired) {      {          const NJson::TJsonValue& json = CreateCompositeJson(); diff --git a/library/cpp/protobuf/json/ut/proto.h b/library/cpp/protobuf/json/ut/proto.h index db1e58557d1..8183bfc8e18 100644 --- a/library/cpp/protobuf/json/ut/proto.h +++ b/library/cpp/protobuf/json/ut/proto.h @@ -55,8 +55,8 @@ namespace NProtobufJsonTest {              Cerr << lhs.DebugString() << Endl;                                           \              Cerr << rhs.DebugString() << Endl;                                           \              UNIT_ASSERT_STRINGS_EQUAL(lhs.DebugString(), rhs.DebugString());             \ -            UNIT_ASSERT_STRINGS_EQUAL(lhs.SerializeAsString(), rhs.SerializeAsString()); \  +            UNIT_ASSERT_STRINGS_EQUAL(lhs.SerializeAsString(), rhs.SerializeAsString()); \          }                                                                                \ -    } while (false);  +    } while (false);  } diff --git a/library/cpp/protobuf/json/ut/proto2json_ut.cpp b/library/cpp/protobuf/json/ut/proto2json_ut.cpp index 3e21b233712..07e52d7f2f5 100644 --- a/library/cpp/protobuf/json/ut/proto2json_ut.cpp +++ b/library/cpp/protobuf/json/ut/proto2json_ut.cpp @@ -75,31 +75,31 @@ Y_UNIT_TEST_SUITE(TProto2JsonFlatTest) {      }      Y_UNIT_TEST(TestNameGenerator) { -        TNameGeneratorType proto;  -        proto.SetField(42);  -  -        TProto2JsonConfig cfg;  +        TNameGeneratorType proto; +        proto.SetField(42); + +        TProto2JsonConfig cfg;          cfg.SetNameGenerator([](const NProtoBuf::FieldDescriptor&) { return "42"; }); -  -        TStringStream str;  -        Proto2Json(proto, str, cfg);  -  -        UNIT_ASSERT_STRINGS_EQUAL(R"({"42":42})", str.Str());  -    }  -  + +        TStringStream str; +        Proto2Json(proto, str, cfg); + +        UNIT_ASSERT_STRINGS_EQUAL(R"({"42":42})", str.Str()); +    } +      Y_UNIT_TEST(TestEnumValueGenerator) { -        TEnumValueGeneratorType proto;  -        proto.SetEnum(TEnumValueGeneratorType::ENUM_42);  -  -        TProto2JsonConfig cfg;  +        TEnumValueGeneratorType proto; +        proto.SetEnum(TEnumValueGeneratorType::ENUM_42); + +        TProto2JsonConfig cfg;          cfg.SetEnumValueGenerator([](const NProtoBuf::EnumValueDescriptor&) { return "42"; }); -  -        TStringStream str;  -        Proto2Json(proto, str, cfg);  -  -        UNIT_ASSERT_STRINGS_EQUAL(R"({"Enum":"42"})", str.Str());  -    }  -  + +        TStringStream str; +        Proto2Json(proto, str, cfg); + +        UNIT_ASSERT_STRINGS_EQUAL(R"({"Enum":"42"})", str.Str()); +    } +      Y_UNIT_TEST(TestFlatOptional){          {TFlatOptional proto;      FillFlatProto(&proto); diff --git a/library/cpp/protobuf/json/ut/test.proto b/library/cpp/protobuf/json/ut/test.proto index c8352b8c520..0fa996fd413 100644 --- a/library/cpp/protobuf/json/ut/test.proto +++ b/library/cpp/protobuf/json/ut/test.proto @@ -135,18 +135,18 @@ message TMapType {      map<string, string> Items = 1;  }; -message TNameGeneratorType {  -    optional int32 Field = 1;  -};  -  -message TEnumValueGeneratorType {  -    enum EEnum {  -        ENUM_42 = 1;  -    };  -  -    optional EEnum Enum = 1;  -};  -  +message TNameGeneratorType { +    optional int32 Field = 1; +}; + +message TEnumValueGeneratorType { +    enum EEnum { +        ENUM_42 = 1; +    }; + +    optional EEnum Enum = 1; +}; +  message TComplexMapType {      map<int32, int32> I32 = 1;      map<int64, int64> I64 = 2; diff --git a/library/cpp/protobuf/json/ut/ya.make b/library/cpp/protobuf/json/ut/ya.make index 4b8ed9c8044..b60a6d3c17f 100644 --- a/library/cpp/protobuf/json/ut/ya.make +++ b/library/cpp/protobuf/json/ut/ya.make @@ -1,6 +1,6 @@  UNITTEST_FOR(library/cpp/protobuf/json) -OWNER(avitella)  +OWNER(avitella)  SRCS(      filter_ut.cpp diff --git a/library/cpp/protobuf/json/ya.make b/library/cpp/protobuf/json/ya.make index a9049e5655a..2f2c75cfdb2 100644 --- a/library/cpp/protobuf/json/ya.make +++ b/library/cpp/protobuf/json/ya.make @@ -1,15 +1,15 @@  LIBRARY() -OWNER(avitella)  +OWNER(avitella)  SRCS(      json2proto.cpp      json_output_create.cpp      json_value_output.cpp      json_writer_output.cpp -    name_generator.cpp  -    proto2json.cpp  -    proto2json_printer.cpp  +    name_generator.cpp +    proto2json.cpp +    proto2json_printer.cpp      string_transform.cpp      util.h      util.cpp diff --git a/library/cpp/xml/document/ut/ya.make b/library/cpp/xml/document/ut/ya.make index 856b6ad796a..e955448c66a 100644 --- a/library/cpp/xml/document/ut/ya.make +++ b/library/cpp/xml/document/ut/ya.make @@ -5,7 +5,7 @@ OWNER(finder)  SRCS(      xml-document_ut.cpp      xml-textreader_ut.cpp -    xml-options_ut.cpp  +    xml-options_ut.cpp  )  END() diff --git a/library/cpp/xml/document/xml-options.cpp b/library/cpp/xml/document/xml-options.cpp index f84e601b98f..74e7545de3b 100644 --- a/library/cpp/xml/document/xml-options.cpp +++ b/library/cpp/xml/document/xml-options.cpp @@ -1 +1 @@ -#include "xml-options.h"  +#include "xml-options.h" diff --git a/library/cpp/xml/document/xml-options.h b/library/cpp/xml/document/xml-options.h index b81fb8c88d0..bb07da0cfbb 100644 --- a/library/cpp/xml/document/xml-options.h +++ b/library/cpp/xml/document/xml-options.h @@ -1,67 +1,67 @@ -#pragma once  -  -#include <contrib/libs/libxml/include/libxml/parser.h>  -  -namespace NXml {  -    enum class EOption : int {  -        // clang-format off  -        Recover    = XML_PARSE_RECOVER,  -        NoEnt      = XML_PARSE_NOENT,  -        DTDLoad    = XML_PARSE_DTDLOAD,  -        DTDAttr    = XML_PARSE_DTDATTR,  -        DTDValid   = XML_PARSE_DTDVALID,  -        NoError    = XML_PARSE_NOERROR,  -        NoWarning  = XML_PARSE_NOWARNING,  -        Pedantic   = XML_PARSE_PEDANTIC,  -        NoBlanks   = XML_PARSE_NOBLANKS,  -        SAX1       = XML_PARSE_SAX1,  -        XInclude   = XML_PARSE_XINCLUDE,  -        NoNet      = XML_PARSE_NONET,  -        NoDict     = XML_PARSE_NODICT,  -        NSClean    = XML_PARSE_NSCLEAN,  -        NoCData    = XML_PARSE_NOCDATA,  -        NoXInclude = XML_PARSE_NOXINCNODE,  -        Compact    = XML_PARSE_COMPACT,  -        Old10      = XML_PARSE_OLD10,  -        NoBaseFix  = XML_PARSE_NOBASEFIX,  -        Huge       = XML_PARSE_HUGE,  -        OldSAX     = XML_PARSE_OLDSAX,  -        IgnoreEnc  = XML_PARSE_IGNORE_ENC,  -        BigLines   = XML_PARSE_BIG_LINES,  -        // clang-format on  -    };  -  -    class TOptions {  -    public:  -        TOptions()  -            : Mask(0)  -        {  -        }  -  -        template <typename... TArgs>  -        TOptions(TArgs... args)  -            : Mask(0)  -        {  -            Set(args...);  -        }  -  -        TOptions& Set(EOption option) {  -            Mask |= static_cast<int>(option);  -            return *this;  -        }  -  -        template <typename... TArgs>  -        TOptions& Set(EOption arg, TArgs... args) {  -            Set(arg);  -            return Set(args...);  -        }  -  -        int GetMask() const {  -            return Mask;  -        }  -  -    private:  -        int Mask;  -    };  -  +#pragma once + +#include <contrib/libs/libxml/include/libxml/parser.h> + +namespace NXml { +    enum class EOption : int { +        // clang-format off +        Recover    = XML_PARSE_RECOVER, +        NoEnt      = XML_PARSE_NOENT, +        DTDLoad    = XML_PARSE_DTDLOAD, +        DTDAttr    = XML_PARSE_DTDATTR, +        DTDValid   = XML_PARSE_DTDVALID, +        NoError    = XML_PARSE_NOERROR, +        NoWarning  = XML_PARSE_NOWARNING, +        Pedantic   = XML_PARSE_PEDANTIC, +        NoBlanks   = XML_PARSE_NOBLANKS, +        SAX1       = XML_PARSE_SAX1, +        XInclude   = XML_PARSE_XINCLUDE, +        NoNet      = XML_PARSE_NONET, +        NoDict     = XML_PARSE_NODICT, +        NSClean    = XML_PARSE_NSCLEAN, +        NoCData    = XML_PARSE_NOCDATA, +        NoXInclude = XML_PARSE_NOXINCNODE, +        Compact    = XML_PARSE_COMPACT, +        Old10      = XML_PARSE_OLD10, +        NoBaseFix  = XML_PARSE_NOBASEFIX, +        Huge       = XML_PARSE_HUGE, +        OldSAX     = XML_PARSE_OLDSAX, +        IgnoreEnc  = XML_PARSE_IGNORE_ENC, +        BigLines   = XML_PARSE_BIG_LINES, +        // clang-format on +    }; + +    class TOptions { +    public: +        TOptions() +            : Mask(0) +        { +        } + +        template <typename... TArgs> +        TOptions(TArgs... args) +            : Mask(0) +        { +            Set(args...); +        } + +        TOptions& Set(EOption option) { +            Mask |= static_cast<int>(option); +            return *this; +        } + +        template <typename... TArgs> +        TOptions& Set(EOption arg, TArgs... args) { +            Set(arg); +            return Set(args...); +        } + +        int GetMask() const { +            return Mask; +        } + +    private: +        int Mask; +    }; +  } diff --git a/library/cpp/xml/document/xml-options_ut.cpp b/library/cpp/xml/document/xml-options_ut.cpp index 99a5d877a8c..9be16baf3d3 100644 --- a/library/cpp/xml/document/xml-options_ut.cpp +++ b/library/cpp/xml/document/xml-options_ut.cpp @@ -1,26 +1,26 @@ -#include "xml-options.h"  -  +#include "xml-options.h" +  #include <library/cpp/testing/unittest/registar.h> -  +  Y_UNIT_TEST_SUITE(TestXmlOptions) {      Y_UNIT_TEST(SetHuge) { -        NXml::TOptions opts;  -        opts.Set(NXml::EOption::Huge);  -        UNIT_ASSERT_EQUAL(XML_PARSE_HUGE, opts.GetMask());  -    }  -  +        NXml::TOptions opts; +        opts.Set(NXml::EOption::Huge); +        UNIT_ASSERT_EQUAL(XML_PARSE_HUGE, opts.GetMask()); +    } +      Y_UNIT_TEST(VariadicContructor) { -        NXml::TOptions opts(NXml::EOption::Huge, NXml::EOption::Compact, NXml::EOption::SAX1);  -        UNIT_ASSERT_EQUAL(XML_PARSE_HUGE | XML_PARSE_COMPACT | XML_PARSE_SAX1, opts.GetMask());  -    }  -  +        NXml::TOptions opts(NXml::EOption::Huge, NXml::EOption::Compact, NXml::EOption::SAX1); +        UNIT_ASSERT_EQUAL(XML_PARSE_HUGE | XML_PARSE_COMPACT | XML_PARSE_SAX1, opts.GetMask()); +    } +      Y_UNIT_TEST(Chaining) { -        NXml::TOptions opts;  -  -        opts  -            .Set(NXml::EOption::Huge)  -            .Set(NXml::EOption::Compact);  -  -        UNIT_ASSERT_EQUAL(XML_PARSE_HUGE | XML_PARSE_COMPACT, opts.GetMask());  -    }  -}  +        NXml::TOptions opts; + +        opts +            .Set(NXml::EOption::Huge) +            .Set(NXml::EOption::Compact); + +        UNIT_ASSERT_EQUAL(XML_PARSE_HUGE | XML_PARSE_COMPACT, opts.GetMask()); +    } +} diff --git a/library/cpp/xml/document/xml-textreader.cpp b/library/cpp/xml/document/xml-textreader.cpp index 0dbfe761fad..b946f1fbf2f 100644 --- a/library/cpp/xml/document/xml-textreader.cpp +++ b/library/cpp/xml/document/xml-textreader.cpp @@ -11,7 +11,7 @@ namespace NXml {          : Stream(stream)          , IsError(false)      { -        Impl.Reset(xmlReaderForIO(ReadFromInputStreamCallback, nullptr, this, nullptr, nullptr, options.GetMask()));  +        Impl.Reset(xmlReaderForIO(ReadFromInputStreamCallback, nullptr, this, nullptr, nullptr, options.GetMask()));          if (!Impl) {              ythrow yexception() << "cannot instantiate underlying xmlTextReader structure"; diff --git a/library/cpp/xml/document/xml-textreader.h b/library/cpp/xml/document/xml-textreader.h index c62b958f78d..ab4c329d26d 100644 --- a/library/cpp/xml/document/xml-textreader.h +++ b/library/cpp/xml/document/xml-textreader.h @@ -1,7 +1,7 @@  #pragma once  #include "xml-document.h" -#include "xml-options.h"  +#include "xml-options.h"  #include <contrib/libs/libxml/include/libxml/xmlreader.h> diff --git a/library/cpp/xml/document/ya.make b/library/cpp/xml/document/ya.make index d5ba6997139..86bbd639cf8 100644 --- a/library/cpp/xml/document/ya.make +++ b/library/cpp/xml/document/ya.make @@ -5,7 +5,7 @@ OWNER(finder)  SRCS(      xml-document.cpp      xml-textreader.cpp -    xml-options.cpp  +    xml-options.cpp  )  PEERDIR(  | 
