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/path.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/path.cpp')
-rw-r--r-- | library/cpp/protobuf/util/path.cpp | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/library/cpp/protobuf/util/path.cpp b/library/cpp/protobuf/util/path.cpp index efa2a42c8a..8a9c2ba7d7 100644 --- a/library/cpp/protobuf/util/path.cpp +++ b/library/cpp/protobuf/util/path.cpp @@ -1,20 +1,20 @@ -#include "path.h" - -#include <util/generic/yexception.h> - -namespace NProtoBuf { +#include "path.h" + +#include <util/generic/yexception.h> + +namespace NProtoBuf { TFieldPath::TFieldPath() { } - + TFieldPath::TFieldPath(const Descriptor* msgType, const TStringBuf& path) { Init(msgType, path); } - + TFieldPath::TFieldPath(const TVector<const FieldDescriptor*>& path) : Path(path) { } - + bool TFieldPath::InitUnsafe(const Descriptor* msgType, TStringBuf path) { Path.clear(); while (path) { @@ -23,10 +23,10 @@ namespace NProtoBuf { next = path.NextTok('/'); if (!next) return true; - + if (!msgType) // need field but no message type return false; - + TString nextStr(next); const FieldDescriptor* field = msgType->FindFieldByName(nextStr); if (!field) { @@ -41,21 +41,21 @@ namespace NProtoBuf { return false; // ambiguity field = ext; } - } - } - + } + } + if (!field) return false; - + Path.push_back(field); msgType = field->type() == FieldDescriptor::TYPE_MESSAGE ? field->message_type() : nullptr; } return true; - } - + } + void TFieldPath::Init(const Descriptor* msgType, const TStringBuf& path) { if (!InitUnsafe(msgType, path)) ythrow yexception() << "Failed to resolve path \"" << path << "\" relative to " << msgType->full_name(); } -} +} |