diff options
author | stakanviski <stakanviski@yandex-team.ru> | 2022-02-10 16:50:01 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:50:01 +0300 |
commit | da8356a5535e6177965cba3bbae73c5fb28f6ccc (patch) | |
tree | 61a6bb4fa5e2c51ac92f621f5a9eba5658d8aba0 /library/cpp/scheme | |
parent | c345445ed6cb1fc34136ef6f02ce07f5aff9e504 (diff) | |
download | ydb-da8356a5535e6177965cba3bbae73c5fb28f6ccc.tar.gz |
Restoring authorship annotation for <stakanviski@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/scheme')
-rw-r--r-- | library/cpp/scheme/scheme.h | 2 | ||||
-rw-r--r-- | library/cpp/scheme/scimpl_defs.h | 6 | ||||
-rw-r--r-- | library/cpp/scheme/scimpl_protobuf.cpp | 46 | ||||
-rw-r--r-- | library/cpp/scheme/tests/ut/scheme_ut.proto | 160 | ||||
-rw-r--r-- | library/cpp/scheme/ya.make | 4 |
5 files changed, 109 insertions, 109 deletions
diff --git a/library/cpp/scheme/scheme.h b/library/cpp/scheme/scheme.h index 3d7c59f3c9..f8399292cd 100644 --- a/library/cpp/scheme/scheme.h +++ b/library/cpp/scheme/scheme.h @@ -384,7 +384,7 @@ namespace NSc { public: // very specific methods useful in very specific corner cases - + static TValue From(const ::google::protobuf::Message&, bool mapAsDict = false); void To(::google::protobuf::Message&, const TProtoOpts& opts = {}) const; diff --git a/library/cpp/scheme/scimpl_defs.h b/library/cpp/scheme/scimpl_defs.h index f3dd66b437..40962a30a2 100644 --- a/library/cpp/scheme/scimpl_defs.h +++ b/library/cpp/scheme/scimpl_defs.h @@ -131,10 +131,10 @@ namespace NSc { class TSelfOverrideContext; } } - -namespace google { + +namespace google { namespace protobuf { class Message; class FieldDescriptor; } -} +} diff --git a/library/cpp/scheme/scimpl_protobuf.cpp b/library/cpp/scheme/scimpl_protobuf.cpp index 0c99122c69..af6cca56bf 100644 --- a/library/cpp/scheme/scimpl_protobuf.cpp +++ b/library/cpp/scheme/scimpl_protobuf.cpp @@ -1,22 +1,22 @@ -#include "scheme.h" - -#include <util/generic/vector.h> -#include <util/generic/yexception.h> - +#include "scheme.h" + +#include <util/generic/vector.h> +#include <util/generic/yexception.h> + #include <google/protobuf/descriptor.h> #include <google/protobuf/message.h> #include <google/protobuf/reflection.h> - -using namespace google::protobuf; - -namespace NSc { + +using namespace google::protobuf; + +namespace NSc { TValue TValue::From(const Message& msg, bool mapAsDict) { TValue v; const Reflection* r = msg.GetReflection(); TVector<const FieldDescriptor*> fields; TVector<const FieldDescriptor*>::iterator it; int i1; - + r->ListFields(msg, &fields); for (it = fields.begin(), i1 = 0; it != fields.end(); ++it, ++i1) { const FieldDescriptor* field = *it; @@ -39,16 +39,16 @@ namespace NSc { } } catch (...) { /* conversion failed, skip this field */ - } - } + } + } return v; - } - + } + TValue TValue::FromField(const Message& msg, const FieldDescriptor* field) { TValue v; const Reflection* r = msg.GetReflection(); - + switch (field->cpp_type()) { case FieldDescriptor::CPPTYPE_INT32: v = r->GetInt32(msg, field); @@ -83,14 +83,14 @@ namespace NSc { default: ythrow TSchemeException() << "field " << field->full_name() << " unexpected type " << (int)field->cpp_type(); } - + return v; - } - + } + TValue TValue::FromRepeatedField(const Message& msg, const FieldDescriptor* field, int index) { TValue v; const Reflection* r = msg.GetReflection(); - + switch (field->cpp_type()) { case FieldDescriptor::CPPTYPE_INT32: v = r->GetRepeatedInt32(msg, field, index); @@ -125,10 +125,10 @@ namespace NSc { default: ythrow TSchemeException() << "field " << field->full_name() << " unexpected type " << (int)field->cpp_type(); } - + return v; - } - + } + void TValue::To(Message& msg, const TProtoOpts& opts) const { msg.Clear(); @@ -326,4 +326,4 @@ namespace NSc { mutableField.Add(*entry); } } -} +} diff --git a/library/cpp/scheme/tests/ut/scheme_ut.proto b/library/cpp/scheme/tests/ut/scheme_ut.proto index 7981af7eae..139c293b3c 100644 --- a/library/cpp/scheme/tests/ut/scheme_ut.proto +++ b/library/cpp/scheme/tests/ut/scheme_ut.proto @@ -1,84 +1,84 @@ -package NSc; - -message TMessage { - optional double Double = 1; - optional float Float = 2; - optional int32 Int32 = 3; - optional int64 Int64 = 4; - optional uint32 UInt32 = 5; - optional uint64 UInt64 = 6; - optional sint32 SInt32 = 7; - optional sint64 SInt64 = 8; - optional fixed32 Fixed32 = 9; - optional fixed64 Fixed64 = 10; - optional sfixed32 SFixed32 = 11; - optional sfixed64 SFixed64 = 12; - optional bool Bool = 13; - optional string String = 14; - optional bytes Bytes = 15; - optional EEnum Enum = 16; - optional TMessage2 Message = 17; - - repeated double Doubles = 18; - repeated float Floats = 19; - repeated int32 Int32s = 20; - repeated int64 Int64s = 21; - repeated uint32 UInt32s = 22; - repeated uint64 UInt64s = 23; - repeated sint32 SInt32s = 24; - repeated sint64 SInt64s = 25; - repeated fixed32 Fixed32s = 26; - repeated fixed64 Fixed64s = 27; - repeated sfixed32 SFixed32s = 28; - repeated sfixed64 SFixed64s = 29; - repeated bool Bools = 30; - repeated string Strings = 31; - repeated bytes Bytess = 32; - repeated EEnum Enums = 33; - repeated TMessage2 Messages = 34; +package NSc; + +message TMessage { + optional double Double = 1; + optional float Float = 2; + optional int32 Int32 = 3; + optional int64 Int64 = 4; + optional uint32 UInt32 = 5; + optional uint64 UInt64 = 6; + optional sint32 SInt32 = 7; + optional sint64 SInt64 = 8; + optional fixed32 Fixed32 = 9; + optional fixed64 Fixed64 = 10; + optional sfixed32 SFixed32 = 11; + optional sfixed64 SFixed64 = 12; + optional bool Bool = 13; + optional string String = 14; + optional bytes Bytes = 15; + optional EEnum Enum = 16; + optional TMessage2 Message = 17; + + repeated double Doubles = 18; + repeated float Floats = 19; + repeated int32 Int32s = 20; + repeated int64 Int64s = 21; + repeated uint32 UInt32s = 22; + repeated uint64 UInt64s = 23; + repeated sint32 SInt32s = 24; + repeated sint64 SInt64s = 25; + repeated fixed32 Fixed32s = 26; + repeated fixed64 Fixed64s = 27; + repeated sfixed32 SFixed32s = 28; + repeated sfixed64 SFixed64s = 29; + repeated bool Bools = 30; + repeated string Strings = 31; + repeated bytes Bytess = 32; + repeated EEnum Enums = 33; + repeated TMessage2 Messages = 34; map<string, double> MapDoubles = 35; map<string, int32> MapInt32s = 36; map<string, string> MapString = 37; -} - -enum EEnum { - VALUE1 = 0; - VALUE2 = 1; -} - -message TMessage2 { - optional double Double = 1; - optional float Float = 2; - optional int32 Int32 = 3; - optional int64 Int64 = 4; - optional uint32 UInt32 = 5; - optional uint64 UInt64 = 6; - optional sint32 SInt32 = 7; - optional sint64 SInt64 = 8; - optional fixed32 Fixed32 = 9; - optional fixed64 Fixed64 = 10; - optional sfixed32 SFixed32 = 11; - optional sfixed64 SFixed64 = 12; - optional bool Bool = 13; - optional string String = 14; - optional bytes Bytes = 15; - optional EEnum Enum = 16; - - repeated double Doubles = 18; - repeated float Floats = 19; - repeated int32 Int32s = 20; - repeated int64 Int64s = 21; - repeated uint32 UInt32s = 22; - repeated uint64 UInt64s = 23; - repeated sint32 SInt32s = 24; - repeated sint64 SInt64s = 25; - repeated fixed32 Fixed32s = 26; - repeated fixed64 Fixed64s = 27; - repeated sfixed32 SFixed32s = 28; - repeated sfixed64 SFixed64s = 29; - repeated bool Bools = 30; - repeated string Strings = 31; - repeated bytes Bytess = 32; - repeated EEnum Enums = 33; -} +} + +enum EEnum { + VALUE1 = 0; + VALUE2 = 1; +} + +message TMessage2 { + optional double Double = 1; + optional float Float = 2; + optional int32 Int32 = 3; + optional int64 Int64 = 4; + optional uint32 UInt32 = 5; + optional uint64 UInt64 = 6; + optional sint32 SInt32 = 7; + optional sint64 SInt64 = 8; + optional fixed32 Fixed32 = 9; + optional fixed64 Fixed64 = 10; + optional sfixed32 SFixed32 = 11; + optional sfixed64 SFixed64 = 12; + optional bool Bool = 13; + optional string String = 14; + optional bytes Bytes = 15; + optional EEnum Enum = 16; + + repeated double Doubles = 18; + repeated float Floats = 19; + repeated int32 Int32s = 20; + repeated int64 Int64s = 21; + repeated uint32 UInt32s = 22; + repeated uint64 UInt64s = 23; + repeated sint32 SInt32s = 24; + repeated sint64 SInt64s = 25; + repeated fixed32 Fixed32s = 26; + repeated fixed64 Fixed64s = 27; + repeated sfixed32 SFixed32s = 28; + repeated sfixed64 SFixed64s = 29; + repeated bool Bools = 30; + repeated string Strings = 31; + repeated bytes Bytess = 32; + repeated EEnum Enums = 33; +} diff --git a/library/cpp/scheme/ya.make b/library/cpp/scheme/ya.make index bac08ba5a4..9f1d307a71 100644 --- a/library/cpp/scheme/ya.make +++ b/library/cpp/scheme/ya.make @@ -8,7 +8,7 @@ SRCS( scimpl.h scimpl_defs.h scimpl_private.cpp - scimpl_protobuf.cpp + scimpl_protobuf.cpp scimpl_select.rl6 scimpl_json_read.cpp scimpl_json_write.cpp @@ -22,4 +22,4 @@ PEERDIR( GENERATE_ENUM_SERIALIZATION(scheme.h) -END() +END() |