diff options
author | Arslan Urtashev <urtashev@gmail.com> | 2022-02-10 16:48:55 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:48:55 +0300 |
commit | b97740540e7302cec9efa181e106ae1990a0cc1c (patch) | |
tree | 1a2a0bfe523c3272d207e2d75254a41d3945a3bb | |
parent | 31789673dc3562bc7540e00fe031ba84ae282c24 (diff) | |
download | ydb-b97740540e7302cec9efa181e106ae1990a0cc1c.tar.gz |
Restoring authorship annotation for Arslan Urtashev <urtashev@gmail.com>. Commit 1 of 2.
49 files changed, 387 insertions, 387 deletions
diff --git a/build/ya.conf.json b/build/ya.conf.json index 5f7cc875d6..a1ad7a2369 100644 --- a/build/ya.conf.json +++ b/build/ya.conf.json @@ -3562,14 +3562,14 @@ } ] }, - "yp-util": { - "tools": { + "yp-util": { + "tools": { "yp-util": { "bottle": "yp-util", "executable": "yp-util" } - }, - "platforms": [ + }, + "platforms": [ { "host": { "os": "LINUX" @@ -3582,16 +3582,16 @@ }, "default": true } - ] - }, - "yp": { - "tools": { + ] + }, + "yp": { + "tools": { "yp": { "bottle": "yp", "executable": "yp" } - }, - "platforms": [ + }, + "platforms": [ { "host": { "os": "LINUX" @@ -3604,8 +3604,8 @@ }, "default": true } - ] - }, + ] + }, "yd-migrate": { "tools": { "yd-migrate": { @@ -6824,32 +6824,32 @@ }, "executable": "rtmr-deploy" }, - "yp-util": { - "formula": { + "yp-util": { + "formula": { "sandbox_id": [ 1204918529 ], "match": "yp_util" - }, - "executable": { + }, + "executable": { "yp-util": [ "yp_util" ] - } - }, - "yp": { - "formula": { + } + }, + "yp": { + "formula": { "sandbox_id": [ 1204919943 ], "match": "YP" - }, - "executable": { + }, + "executable": { "yp": [ "yp" ] - } - }, + } + }, "yd-migrate": { "formula": { "sandbox_id": [ diff --git a/contrib/python/ya.make b/contrib/python/ya.make index d01ced9f3a..066395c585 100644 --- a/contrib/python/ya.make +++ b/contrib/python/ya.make @@ -980,7 +980,7 @@ RECURSE( scour scp Scrapy - seaborn + seaborn selectors2 selenium semantic-version diff --git a/library/cpp/getopt/ut/last_getopt_ut.cpp b/library/cpp/getopt/ut/last_getopt_ut.cpp index c99a1d053d..429bb53990 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 77cfd96902..13237d9ab6 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 f6951f68cd..035eccf7b9 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 16e59c4d78..6bc816fcf5 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 e7f16ef27c..554a4c9645 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 02370c2d79..1a8e44e757 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 0aae2531b9..80a09de607 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 9980555683..c278b6f73c 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 f72cb7a9ef..53f4c9bf18 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 758eb6d0cf..b0d127a1a2 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 b083163a7b..18e2884b41 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 670cf8651e..6cda12596e 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 86d9a52ec0..10002a3897 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 dc84fb4d5d..0ea37f1898 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 640c10f5a5..5efa6d4b6c 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 4c33498dfa..5d35991cf3 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 378e4ea65a..a0515b9ce7 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 d845cc1c74..88f52f8490 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 3fc6ff2ab0..d1127d0673 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 3d8a2daa56..fbd3f10c6f 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 c1fb421175..c692cb3120 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 2b5361bee2..e9ce067800 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 6123eab0f2..31e7fe66d3 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 0dfe57bc7a..42a8ddf2c3 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 8183bfc8e1..db1e58557d 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 07e52d7f2f..3e21b23371 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 0fa996fd41..c8352b8c52 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 b60a6d3c17..4b8ed9c804 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 2f2c75cfdb..a9049e5655 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 e955448c66..856b6ad796 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 74e7545de3..f84e601b98 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 bb07da0cfb..b81fb8c88d 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 9be16baf3d..99a5d877a8 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 b946f1fbf2..0dbfe761fa 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 ab4c329d26..c62b958f78 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 86bbd639cf..d5ba699713 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( diff --git a/tools/enum_parser/enum_parser/main.cpp b/tools/enum_parser/enum_parser/main.cpp index 0943c69c1d..cc7fafc0c4 100644 --- a/tools/enum_parser/enum_parser/main.cpp +++ b/tools/enum_parser/enum_parser/main.cpp @@ -34,7 +34,7 @@ void WriteHeader(const TString& headerName, IOutputStream& out, IOutputStream* h out << "#include <util/generic/string.h>\n"; out << "#include <util/generic/vector.h>\n"; out << "#include <util/generic/map.h>\n"; - out << "#include <util/generic/serialized_enum.h>\n"; + out << "#include <util/generic/serialized_enum.h>\n"; out << "#include <util/string/cast.h>\n"; out << "#include <util/stream/output.h>\n\n"; @@ -339,13 +339,13 @@ void GenerateEnum( out << " return names.AllEnumNames();\n"; out << " }\n\n"; - // template<> GetEnumNames<EnumType> + // template<> GetEnumNames<EnumType> out << " template<>\n"; out << " TMappedDictView<" << name << ", TString> GetEnumNamesImpl<" << name << ">() {\n"; out << " const " << nsName << "::TNameBufs& names = " << nsName << "::TNameBufs::Instance();\n"; out << " return names.EnumNames();\n"; out << " }\n\n"; - + // template<> GetEnumAllCppNames, see IGNIETFERRO-534 out << " template<>\n"; out << " const TVector<TString>& GetEnumAllCppNamesImpl<" << name << ">() {\n"; diff --git a/tools/ya.make b/tools/ya.make index 51a6b8b426..577b135971 100644 --- a/tools/ya.make +++ b/tools/ya.make @@ -179,7 +179,7 @@ RECURSE( ylzocat yson_pp zk_client - idx_print + idx_print ) IF (NOT OS_WINDOWS) diff --git a/util/generic/serialized_enum.h b/util/generic/serialized_enum.h index 79df2bac22..d67ec655b8 100644 --- a/util/generic/serialized_enum.h +++ b/util/generic/serialized_enum.h @@ -1,9 +1,9 @@ #pragma once -#include <util/generic/fwd.h> +#include <util/generic/fwd.h> #include <util/generic/vector.h> #include <util/generic/map.h> - + #include <cstddef> #include <type_traits> @@ -30,7 +30,7 @@ in your ya.make */ template <typename EnumT> Y_CONST_FUNCTION constexpr size_t GetEnumItemsCount(); - + namespace NEnumSerializationRuntime { namespace NDetail { template <typename EEnum> @@ -83,12 +83,12 @@ namespace NEnumSerializationRuntime { const TVector<TString>& GetEnumAllCppNamesImpl(); } -/** - * Returns names for items in enum or enum class - * - * @tparam EnumT enum type - */ -template <typename EnumT> +/** + * Returns names for items in enum or enum class + * + * @tparam EnumT enum type + */ +template <typename EnumT> Y_CONST_FUNCTION ::NEnumSerializationRuntime::TMappedDictView<EnumT, TString> GetEnumNames() { return ::NEnumSerializationRuntime::GetEnumNamesImpl<EnumT>(); } diff --git a/util/generic/string.h b/util/generic/string.h index 8cd8aa6917..e3e2a4912a 100644 --- a/util/generic/string.h +++ b/util/generic/string.h @@ -104,20 +104,20 @@ private: }; template <class TStringType> -class TBasicCharRef { -public: +class TBasicCharRef { +public: using TChar = typename TStringType::TChar; - + TBasicCharRef(TStringType& s, size_t pos) : S_(s) , Pos_(pos) { } - - operator TChar() const { - return S_.at(Pos_); - } - + + operator TChar() const { + return S_.at(Pos_); + } + TChar* operator&() { return S_.begin() + Pos_; } @@ -126,14 +126,14 @@ public: return S_.cbegin() + Pos_; } - TBasicCharRef& operator=(TChar c) { + TBasicCharRef& operator=(TChar c) { Y_ASSERT(Pos_ < S_.size() || (Pos_ == S_.size() && !c)); - + S_.Detach()[Pos_] = c; - - return *this; - } - + + return *this; + } + TBasicCharRef& operator=(const TBasicCharRef& other) { return this->operator=(static_cast<TChar>(other)); } @@ -149,12 +149,12 @@ public: */ TBasicCharRef(const TBasicCharRef&) = default; -private: +private: TStringType& S_; - size_t Pos_; -}; + size_t Pos_; +}; #endif - + template <typename TCharType, typename TTraits> class TBasicString: public TStringBase<TBasicString<TCharType, TTraits>, TCharType, TTraits> { public: @@ -252,7 +252,7 @@ public: inline const_reference operator[](size_t pos) const noexcept { Y_ASSERT(pos <= length()); - + return this->data()[pos]; } @@ -264,8 +264,8 @@ public: #else return reference(*this, pos); #endif - } - + } + using TBase::back; inline reference back() noexcept { @@ -468,9 +468,9 @@ public: explicit TBasicString(const reference& c) : TBasicString(&c, 1) { - } + } #endif - + TBasicString(size_t n, TCharType c) #ifdef TSTRING_IS_STD_STRING : Storage_(n, c) diff --git a/util/generic/string_ut.cpp b/util/generic/string_ut.cpp index ac82e9091d..c2623acc17 100644 --- a/util/generic/string_ut.cpp +++ b/util/generic/string_ut.cpp @@ -742,7 +742,7 @@ public: UNIT_TEST(TestStrCpy); UNIT_TEST(TestPrefixSuffix); #ifndef TSTRING_IS_STD_STRING - UNIT_TEST(TestCharRef); + UNIT_TEST(TestCharRef); #endif UNIT_TEST(TestBack) UNIT_TEST(TestFront) @@ -804,7 +804,7 @@ public: UNIT_TEST(TestStrCpy); UNIT_TEST(TestPrefixSuffix); #ifndef TSTRING_IS_STD_STRING - UNIT_TEST(TestCharRef); + UNIT_TEST(TestCharRef); #endif UNIT_TEST(TestBack); UNIT_TEST(TestFront) diff --git a/util/generic/string_ut.h b/util/generic/string_ut.h index 44bb10bdeb..99ce4999db 100644 --- a/util/generic/string_ut.h +++ b/util/generic/string_ut.h @@ -997,37 +997,37 @@ public: UNIT_ASSERT_EQUAL(str.StartsWith(emptyStr), true); UNIT_ASSERT_EQUAL(str.EndsWith(emptyStr), true); } - + #ifndef TSTRING_IS_STD_STRING - void TestCharRef() { + void TestCharRef() { const char_type abc[] = {'a', 'b', 'c', 0}; const char_type bbc[] = {'b', 'b', 'c', 0}; const char_type cbc[] = {'c', 'b', 'c', 0}; - + TStringType s0 = abc; TStringType s1 = s0; - - UNIT_ASSERT(!s0.IsDetached()); - UNIT_ASSERT(!s1.IsDetached()); - - /* Read access shouldn't detach. */ + + UNIT_ASSERT(!s0.IsDetached()); + UNIT_ASSERT(!s1.IsDetached()); + + /* Read access shouldn't detach. */ UNIT_ASSERT_VALUES_EQUAL(s0[0], (ui8)'a'); - UNIT_ASSERT(!s0.IsDetached()); - UNIT_ASSERT(!s1.IsDetached()); - - /* Writing should detach. */ + UNIT_ASSERT(!s0.IsDetached()); + UNIT_ASSERT(!s1.IsDetached()); + + /* Writing should detach. */ s1[0] = (ui8)'b'; TStringType s2 = s0; s0[0] = (ui8)'c'; - - UNIT_ASSERT_VALUES_EQUAL(s0, cbc); - UNIT_ASSERT_VALUES_EQUAL(s1, bbc); - UNIT_ASSERT_VALUES_EQUAL(s2, abc); - UNIT_ASSERT(s0.IsDetached()); - UNIT_ASSERT(s1.IsDetached()); - UNIT_ASSERT(s2.IsDetached()); - - /* Accessing null terminator is OK. Note that writing into it is UB. */ + + UNIT_ASSERT_VALUES_EQUAL(s0, cbc); + UNIT_ASSERT_VALUES_EQUAL(s1, bbc); + UNIT_ASSERT_VALUES_EQUAL(s2, abc); + UNIT_ASSERT(s0.IsDetached()); + UNIT_ASSERT(s1.IsDetached()); + UNIT_ASSERT(s2.IsDetached()); + + /* Accessing null terminator is OK. Note that writing into it is UB. */ UNIT_ASSERT_VALUES_EQUAL(s0[3], (ui8)'\0'); UNIT_ASSERT_VALUES_EQUAL(s1[3], (ui8)'\0'); UNIT_ASSERT_VALUES_EQUAL(s2[3], (ui8)'\0'); @@ -1044,7 +1044,7 @@ public: } UNIT_ASSERT_VALUES_EQUAL(s1, red_eared); } - } + } #endif void TestBack() { diff --git a/util/stream/output.cpp b/util/stream/output.cpp index db81b81b70..983ae1cdec 100644 --- a/util/stream/output.cpp +++ b/util/stream/output.cpp @@ -212,15 +212,15 @@ void Out<typename std::vector<bool>::reference>(IOutputStream& o, const std::vec #ifndef TSTRING_IS_STD_STRING template <> void Out<TBasicCharRef<TString>>(IOutputStream& o, const TBasicCharRef<TString>& c) { - o << static_cast<char>(c); -} - -template <> + o << static_cast<char>(c); +} + +template <> void Out<TBasicCharRef<TUtf16String>>(IOutputStream& o, const TBasicCharRef<TUtf16String>& c) { o << static_cast<wchar16>(c); -} - -template <> +} + +template <> void Out<TBasicCharRef<TUtf32String>>(IOutputStream& o, const TBasicCharRef<TUtf32String>& c) { o << static_cast<wchar32>(c); } diff --git a/util/string/ascii.h b/util/string/ascii.h index 10344384d3..5ad6db1eff 100644 --- a/util/string/ascii.h +++ b/util/string/ascii.h @@ -27,36 +27,36 @@ namespace NPrivate { extern const unsigned char ASCII_LOWER[256]; template <class T> - struct TDereference { - using type = T; + struct TDereference { + using type = T; }; #ifndef TSTRING_IS_STD_STRING template <class String> - struct TDereference<TBasicCharRef<String>> { - using type = typename String::value_type; + struct TDereference<TBasicCharRef<String>> { + using type = typename String::value_type; }; #endif template <class T> - using TDereferenced = typename TDereference<T>::type; - + using TDereferenced = typename TDereference<T>::type; + template <class T> - bool RangeOk(T c) noexcept { - static_assert(std::is_integral<T>::value, "Integral type character expected"); - + bool RangeOk(T c) noexcept { + static_assert(std::is_integral<T>::value, "Integral type character expected"); + if (sizeof(T) == 1) { - return true; + return true; } - - return c >= static_cast<T>(0) && c <= static_cast<T>(127); + + return c >= static_cast<T>(0) && c <= static_cast<T>(127); } - + #ifndef TSTRING_IS_STD_STRING template <class String> - bool RangeOk(const TBasicCharRef<String>& c) { - return RangeOk(static_cast<typename String::value_type>(c)); - } + bool RangeOk(const TBasicCharRef<String>& c) { + return RangeOk(static_cast<typename String::value_type>(c)); + } #endif } diff --git a/util/system/env.cpp b/util/system/env.cpp index ead9b566a5..19d570532a 100644 --- a/util/system/env.cpp +++ b/util/system/env.cpp @@ -26,9 +26,9 @@ TString GetEnv(const TString& key, const TString& def) { size_t len = GetEnvironmentVariableA(key.data(), nullptr, 0); if (len == 0) { - if (GetLastError() == ERROR_ENVVAR_NOT_FOUND) { - return def; - } + if (GetLastError() == ERROR_ENVVAR_NOT_FOUND) { + return def; + } return TString{}; } diff --git a/util/system/env.h b/util/system/env.h index e2ccdd1e95..b8a3154710 100644 --- a/util/system/env.h +++ b/util/system/env.h @@ -5,8 +5,8 @@ /** * Search the environment list provided by the host environment for associated variable. * - * @param key String identifying the name of the environmental variable to look for - * @param def String that returns if environmental variable not found by key + * @param key String identifying the name of the environmental variable to look for + * @param def String that returns if environmental variable not found by key * * @return String that is associated with the matched environment variable or empty string if * such variable is missing. diff --git a/util/system/env_ut.cpp b/util/system/env_ut.cpp index e03cc01658..5b34b3ea64 100644 --- a/util/system/env_ut.cpp +++ b/util/system/env_ut.cpp @@ -10,11 +10,11 @@ Y_UNIT_TEST_SUITE(EnvTest) { TString def = "Some default value for env var"; // first of all, it should be clear UNIT_ASSERT_VALUES_EQUAL(GetEnv(key), TString()); - UNIT_ASSERT_VALUES_EQUAL(GetEnv(key, def), def); + UNIT_ASSERT_VALUES_EQUAL(GetEnv(key, def), def); SetEnv(key, value); // set and see what value we get here UNIT_ASSERT_VALUES_EQUAL(GetEnv(key), value); - UNIT_ASSERT_VALUES_EQUAL(GetEnv(key, def), value); + UNIT_ASSERT_VALUES_EQUAL(GetEnv(key, def), value); // set empty value SetEnv(key, TString()); UNIT_ASSERT_VALUES_EQUAL(GetEnv(key), TString()); |