diff options
author | Vasily Gerasimov <UgnineSirdis@gmail.com> | 2022-02-10 16:49:09 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:49:09 +0300 |
commit | 6cdc8f140213c595e4ad38bc3d97fcef1146b8c3 (patch) | |
tree | f69637041e6fed76ebae0c74ae1fa0c4be6ab5b4 /library/cpp/protobuf/util/simple_reflection.cpp | |
parent | e5d4696304c6689379ac7ce334512404d4b7836c (diff) | |
download | ydb-6cdc8f140213c595e4ad38bc3d97fcef1146b8c3.tar.gz |
Restoring authorship annotation for Vasily Gerasimov <UgnineSirdis@gmail.com>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/protobuf/util/simple_reflection.cpp')
-rw-r--r-- | library/cpp/protobuf/util/simple_reflection.cpp | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/library/cpp/protobuf/util/simple_reflection.cpp b/library/cpp/protobuf/util/simple_reflection.cpp index d842e9ee44..83afa0ce0c 100644 --- a/library/cpp/protobuf/util/simple_reflection.cpp +++ b/library/cpp/protobuf/util/simple_reflection.cpp @@ -1,10 +1,10 @@ -#include "simple_reflection.h" - -namespace NProtoBuf { +#include "simple_reflection.h" + +namespace NProtoBuf { const Message* GetMessageHelper(const TConstField& curField, bool) { return curField.HasValue() && curField.IsMessage() ? curField.Get<Message>() : nullptr; } - + Message* GetMessageHelper(TMutableField& curField, bool createPath) { if (curField.IsMessage()) { if (!curField.HasValue()) { @@ -13,14 +13,14 @@ namespace NProtoBuf { } else { return curField.MutableMessage(); } - } + } return nullptr; - } - + } + template <class TField, class TMsg> TMaybe<TField> ByPathImpl(TMsg& msg, const TVector<const FieldDescriptor*>& fieldsPath, bool createPath) { if (fieldsPath.empty()) - return TMaybe<TField>(); + return TMaybe<TField>(); TMsg* curParent = &msg; for (size_t i = 0, size = fieldsPath.size(); i < size; ++i) { const FieldDescriptor* field = fieldsPath[i]; @@ -35,36 +35,36 @@ namespace NProtoBuf { return TField(*curParent, fieldsPath.back()); else return TMaybe<TField>(); - } - + } + TMaybe<TConstField> TConstField::ByPath(const Message& msg, const TVector<const FieldDescriptor*>& fieldsPath) { return ByPathImpl<TConstField, const Message>(msg, fieldsPath, false); } - + TMaybe<TConstField> TConstField::ByPath(const Message& msg, const TStringBuf& path) { TFieldPath fieldPath; if (!fieldPath.InitUnsafe(msg.GetDescriptor(), path)) return TMaybe<TConstField>(); return ByPathImpl<TConstField, const Message>(msg, fieldPath.Fields(), false); } - + TMaybe<TConstField> TConstField::ByPath(const Message& msg, const TFieldPath& path) { return ByPathImpl<TConstField, const Message>(msg, path.Fields(), false); } - + TMaybe<TMutableField> TMutableField::ByPath(Message& msg, const TVector<const FieldDescriptor*>& fieldsPath, bool createPath) { return ByPathImpl<TMutableField, Message>(msg, fieldsPath, createPath); } - + TMaybe<TMutableField> TMutableField::ByPath(Message& msg, const TStringBuf& path, bool createPath) { TFieldPath fieldPath; if (!fieldPath.InitUnsafe(msg.GetDescriptor(), path)) return TMaybe<TMutableField>(); return ByPathImpl<TMutableField, Message>(msg, fieldPath.Fields(), createPath); } - + TMaybe<TMutableField> TMutableField::ByPath(Message& msg, const TFieldPath& path, bool createPath) { return ByPathImpl<TMutableField, Message>(msg, path.Fields(), createPath); } -} +} |