diff options
author | Egor Kochetov <gluk47@gmail.com> | 2022-02-10 16:50:36 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:50:36 +0300 |
commit | 40896b241c91572ea1369526ee1e6ae0ba340f34 (patch) | |
tree | cb6d8f482e66c136ec128a42417cd5f858520d12 /library/cpp/protobuf/util/iterators.h | |
parent | 3889d4c01a589a555fbc33d66279be23e267ab3b (diff) | |
download | ydb-40896b241c91572ea1369526ee1e6ae0ba340f34.tar.gz |
Restoring authorship annotation for Egor Kochetov <gluk47@gmail.com>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/protobuf/util/iterators.h')
-rw-r--r-- | library/cpp/protobuf/util/iterators.h | 104 |
1 files changed, 52 insertions, 52 deletions
diff --git a/library/cpp/protobuf/util/iterators.h b/library/cpp/protobuf/util/iterators.h index 6d53ac71b1..7830127d3f 100644 --- a/library/cpp/protobuf/util/iterators.h +++ b/library/cpp/protobuf/util/iterators.h @@ -1,53 +1,53 @@ -#pragma once - +#pragma once + #include <google/protobuf/descriptor.h> - -namespace NProtoBuf { - class TFieldsIterator { - public: - explicit TFieldsIterator(const NProtoBuf::Descriptor* descriptor, int position = 0) - : Descriptor(descriptor) - , Position(position) - { } - - TFieldsIterator& operator++() { - ++Position; - return *this; - } - - TFieldsIterator& operator++(int) { - auto& ret = *this; - ++*this; - return ret; - } - - const NProtoBuf::FieldDescriptor* operator*() const { - return Descriptor->field(Position); - } - - bool operator== (const TFieldsIterator& other) const { - return Position == other.Position && Descriptor == other.Descriptor; - } - - bool operator!= (const TFieldsIterator& other) const { - return !(*this == other); - } - - private: - const NProtoBuf::Descriptor* Descriptor = nullptr; - int Position = 0; - }; -} - -// Namespaces required by `range-based for` ADL: -namespace google { - namespace protobuf { - NProtoBuf::TFieldsIterator begin(const NProtoBuf::Descriptor& descriptor) { - return NProtoBuf::TFieldsIterator(&descriptor); - } - - NProtoBuf::TFieldsIterator end(const NProtoBuf::Descriptor& descriptor) { - return NProtoBuf::TFieldsIterator(&descriptor, descriptor.field_count()); - } - } -} + +namespace NProtoBuf { + class TFieldsIterator { + public: + explicit TFieldsIterator(const NProtoBuf::Descriptor* descriptor, int position = 0) + : Descriptor(descriptor) + , Position(position) + { } + + TFieldsIterator& operator++() { + ++Position; + return *this; + } + + TFieldsIterator& operator++(int) { + auto& ret = *this; + ++*this; + return ret; + } + + const NProtoBuf::FieldDescriptor* operator*() const { + return Descriptor->field(Position); + } + + bool operator== (const TFieldsIterator& other) const { + return Position == other.Position && Descriptor == other.Descriptor; + } + + bool operator!= (const TFieldsIterator& other) const { + return !(*this == other); + } + + private: + const NProtoBuf::Descriptor* Descriptor = nullptr; + int Position = 0; + }; +} + +// Namespaces required by `range-based for` ADL: +namespace google { + namespace protobuf { + NProtoBuf::TFieldsIterator begin(const NProtoBuf::Descriptor& descriptor) { + return NProtoBuf::TFieldsIterator(&descriptor); + } + + NProtoBuf::TFieldsIterator end(const NProtoBuf::Descriptor& descriptor) { + return NProtoBuf::TFieldsIterator(&descriptor, descriptor.field_count()); + } + } +} |