14#ifndef OR_TOOLS_BASE_PROTO_ENUM_UTILS_H_
15#define OR_TOOLS_BASE_PROTO_ENUM_UTILS_H_
32#include "absl/types/span.h"
33#include "google/protobuf/descriptor.pb.h"
37using google::protobuf::GetEnumDescriptor;
38using google::protobuf::RepeatedField;
65 : current_(other.current_) {}
68 current_ = other.current_;
84 return static_cast<E
>(GetEnumDescriptor<E>()->value(current_)->number());
94 friend bool operator==
96 friend bool operator!=
102 return a.current_ == b.current_;
107 return a.current_ != b.current_;
117 return iterator(GetEnumDescriptor<E>()->value_count());
164#define REPEATED_ENUM_ADAPTER(var, field) \
165 google::protobuf::contrib::utils::internal::RepeatedEnumView< \
166 decltype(var.field(0))>(var.field())
180 class Iterator :
public std::iterator<std::input_iterator_tag, E> {
182 explicit Iterator(RepeatedField<int>::const_iterator ptr) : ptr_(ptr) {}
192 RepeatedField<int>::const_iterator ptr_;
196 : repeated_field_(repeated_field) {}
202 const RepeatedField<int>& repeated_field_;
ProtoEnumIterator< E > iterator
Generic Proto enum iterator.
ProtoEnumIterator operator++(int)
ProtoEnumIterator & operator=(const ProtoEnumIterator &other)
ProtoEnumIterator(const ProtoEnumIterator &other)
std::forward_iterator_tag iterator_category
ProtoEnumIterator & operator++()
bool operator==(const Iterator &it) const
Iterator(RepeatedField< int >::const_iterator ptr)
bool operator!=(const Iterator &it) const
RepeatedEnumView(const RepeatedField< int > &repeated_field)
EnumeratedProtoEnumView< E > EnumerateEnumValues()
bool operator!=(const ProtoEnumIterator< E > &a, const ProtoEnumIterator< E > &b)
bool operator==(const ProtoEnumIterator< E > &a, const ProtoEnumIterator< E > &b)