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/scimpl_protobuf.cpp | |
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/scimpl_protobuf.cpp')
-rw-r--r-- | library/cpp/scheme/scimpl_protobuf.cpp | 46 |
1 files changed, 23 insertions, 23 deletions
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); } } -} +} |