aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/protobuf/util/walk.cpp
diff options
context:
space:
mode:
authorsvkrasnov <svkrasnov@yandex-team.ru>2022-02-10 16:50:36 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:50:36 +0300
commit16dee8c560e5d85ff488841421cc9e2bff3da817 (patch)
tree5d5cb817648f650d76cf1076100726fd9b8448e8 /library/cpp/protobuf/util/walk.cpp
parentf844999843f80df761f7bbd58b0d2ca479f2dd32 (diff)
downloadydb-16dee8c560e5d85ff488841421cc9e2bff3da817.tar.gz
Restoring authorship annotation for <svkrasnov@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/protobuf/util/walk.cpp')
-rw-r--r--library/cpp/protobuf/util/walk.cpp144
1 files changed, 72 insertions, 72 deletions
diff --git a/library/cpp/protobuf/util/walk.cpp b/library/cpp/protobuf/util/walk.cpp
index e1c2aef73d..b65ec03e04 100644
--- a/library/cpp/protobuf/util/walk.cpp
+++ b/library/cpp/protobuf/util/walk.cpp
@@ -1,72 +1,72 @@
-#include "walk.h"
-
-#include <util/generic/hash_set.h>
-
-namespace {
- using namespace NProtoBuf;
-
- template <typename TMessage, typename TOnField>
- void DoWalkReflection(TMessage& msg, TOnField& onField) {
- const Descriptor* descr = msg.GetDescriptor();
- for (int i1 = 0; i1 < descr->field_count(); ++i1) {
- const FieldDescriptor* fd = descr->field(i1);
- if (!onField(msg, fd)) {
- continue;
- }
-
- std::conditional_t<std::is_const_v<TMessage>, TConstField, TMutableField> ff(msg, fd);
- if (ff.IsMessage()) {
- for (size_t i2 = 0; i2 < ff.Size(); ++i2) {
- if constexpr (std::is_const_v<TMessage>) {
- WalkReflection(*ff.template Get<Message>(i2), onField);
- } else {
- WalkReflection(*ff.MutableMessage(i2), onField);
- }
- }
- }
- }
- }
-
- void DoWalkSchema(const Descriptor* descriptor,
- std::function<bool(const FieldDescriptor*)>& onField,
- THashSet<const Descriptor*>& visited)
- {
- if (!visited.emplace(descriptor).second) {
- return;
- }
- for (int i1 = 0; i1 < descriptor->field_count(); ++i1) {
- const FieldDescriptor* fd = descriptor->field(i1);
- if (!onField(fd)) {
- continue;
- }
-
- if (fd->type() == FieldDescriptor::Type::TYPE_MESSAGE) {
- DoWalkSchema(fd->message_type(), onField, visited);
- }
- }
- visited.erase(descriptor);
- }
-
-}
-
-namespace NProtoBuf {
- void WalkReflection(Message& msg,
- std::function<bool(Message&, const FieldDescriptor*)> onField)
- {
- DoWalkReflection(msg, onField);
- }
-
- void WalkReflection(const Message& msg,
- std::function<bool(const Message&, const FieldDescriptor*)> onField)
- {
- DoWalkReflection(msg, onField);
- }
-
- void WalkSchema(const Descriptor* descriptor,
- std::function<bool(const FieldDescriptor*)> onField)
- {
- THashSet<const Descriptor*> visited;
- DoWalkSchema(descriptor, onField, visited);
- }
-
-} // namespace NProtoBuf
+#include "walk.h"
+
+#include <util/generic/hash_set.h>
+
+namespace {
+ using namespace NProtoBuf;
+
+ template <typename TMessage, typename TOnField>
+ void DoWalkReflection(TMessage& msg, TOnField& onField) {
+ const Descriptor* descr = msg.GetDescriptor();
+ for (int i1 = 0; i1 < descr->field_count(); ++i1) {
+ const FieldDescriptor* fd = descr->field(i1);
+ if (!onField(msg, fd)) {
+ continue;
+ }
+
+ std::conditional_t<std::is_const_v<TMessage>, TConstField, TMutableField> ff(msg, fd);
+ if (ff.IsMessage()) {
+ for (size_t i2 = 0; i2 < ff.Size(); ++i2) {
+ if constexpr (std::is_const_v<TMessage>) {
+ WalkReflection(*ff.template Get<Message>(i2), onField);
+ } else {
+ WalkReflection(*ff.MutableMessage(i2), onField);
+ }
+ }
+ }
+ }
+ }
+
+ void DoWalkSchema(const Descriptor* descriptor,
+ std::function<bool(const FieldDescriptor*)>& onField,
+ THashSet<const Descriptor*>& visited)
+ {
+ if (!visited.emplace(descriptor).second) {
+ return;
+ }
+ for (int i1 = 0; i1 < descriptor->field_count(); ++i1) {
+ const FieldDescriptor* fd = descriptor->field(i1);
+ if (!onField(fd)) {
+ continue;
+ }
+
+ if (fd->type() == FieldDescriptor::Type::TYPE_MESSAGE) {
+ DoWalkSchema(fd->message_type(), onField, visited);
+ }
+ }
+ visited.erase(descriptor);
+ }
+
+}
+
+namespace NProtoBuf {
+ void WalkReflection(Message& msg,
+ std::function<bool(Message&, const FieldDescriptor*)> onField)
+ {
+ DoWalkReflection(msg, onField);
+ }
+
+ void WalkReflection(const Message& msg,
+ std::function<bool(const Message&, const FieldDescriptor*)> onField)
+ {
+ DoWalkReflection(msg, onField);
+ }
+
+ void WalkSchema(const Descriptor* descriptor,
+ std::function<bool(const FieldDescriptor*)> onField)
+ {
+ THashSet<const Descriptor*> visited;
+ DoWalkSchema(descriptor, onField, visited);
+ }
+
+} // namespace NProtoBuf