14#ifndef OR_TOOLS_BASE_PROTO_ENUM_UTILS_H_
15#define OR_TOOLS_BASE_PROTO_ENUM_UTILS_H_
32#include "google/protobuf/descriptor.pb.h"
33#include "google/protobuf/repeated_field.h"
36using google::protobuf::GetEnumDescriptor;
37using google::protobuf::RepeatedField;
64 : current_(other.current_) {}
67 current_ = other.current_;
83 return static_cast<E
>(GetEnumDescriptor<E>()->value(current_)->number());
93 friend bool operator==
95 friend bool operator!=
101 return a.current_ == b.current_;
106 return a.current_ != b.current_;
116 return iterator(GetEnumDescriptor<E>()->value_count());
163#define REPEATED_ENUM_ADAPTER(var, field) \
164 google::protobuf::contrib::utils::internal::RepeatedEnumView< \
165 decltype(var.field(0))>(var.field())
180#
if __cplusplus < 201703L
181 :
public std::iterator<std::input_iterator_tag, E>
187#if __cplusplus >= 201703L
188 using iterator_category = std::input_iterator_tag;
190 using reference = E&;
192 explicit Iterator(RepeatedField<int>::const_iterator ptr) : ptr_(ptr) {}
202 RepeatedField<int>::const_iterator ptr_;
206 : repeated_field_(repeated_field) {}
212 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)
ptrdiff_t difference_type
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)