Go to the documentation of this file.
33 #ifndef GOOGLE_PROTOBUF_REFLECTION_H__
34 #define GOOGLE_PROTOBUF_REFLECTION_H__
38 #include <google/protobuf/message.h>
39 #include <google/protobuf/generated_enum_util.h>
42 #error "You cannot SWIG proto headers"
45 #include <google/protobuf/port_def.inc>
50 template <
typename T,
typename Enable =
void>
68 class RepeatedFieldRef<
69 T, typename
std::enable_if<!std::is_base_of<Message, T>::value>
::type> {
100 const AccessorType* accessor_;
104 template <
typename T>
105 class MutableRepeatedFieldRef<
106 T, typename
std::enable_if<!std::is_base_of<Message, T>::value>
::type> {
120 accessor_->SwapElements(
data_, index1, index2);
125 accessor_->Swap(
data_, other.accessor_, other.data_);
128 template <
typename Container>
130 typedef typename Container::const_iterator
Iterator;
135 template <
typename Container>
151 const AccessorType* accessor_;
155 template <
typename T>
156 class RepeatedFieldRef<
157 T, typename
std::enable_if<std::is_base_of<Message, T>::value>
::type> {
174 return *
static_cast<const T*
>(accessor_->Get(
data_,
index, scratch_space));
178 T*
NewMessage()
const {
return static_cast<T*
>(default_instance_->New()); }
210 const AccessorType* accessor_;
211 const Message* default_instance_;
215 template <
typename T>
216 class MutableRepeatedFieldRef<
217 T, typename
std::enable_if<std::is_base_of<Message, T>::value>
::type> {
225 return *
static_cast<const T*
>(accessor_->Get(
data_,
index, scratch_space));
229 T*
NewMessage()
const {
return static_cast<T*
>(default_instance_->New()); }
237 accessor_->SwapElements(
data_, index1, index2);
242 accessor_->Swap(
data_, other.accessor_, other.data_);
245 template <
typename Container>
247 typedef typename Container::const_iterator
Iterator;
252 template <
typename Container>
271 const AccessorType* accessor_;
272 const Message* default_instance_;
301 class PROTOBUF_EXPORT RepeatedFieldAccessor {
309 virtual int Size(
const Field*
data)
const = 0;
316 Value* scratch_space)
const = 0;
321 virtual void RemoveLast(
Field*
data)
const = 0;
322 virtual void SwapElements(
Field*
data,
int index1,
int index2)
const = 0;
324 Field* other_data)
const = 0;
345 Value* scratch_space)
const = 0;
349 template <
typename T>
352 ActualType scratch_space;
353 return static_cast<T>(*
reinterpret_cast<const ActualType*
>(
357 template <
typename T,
typename ValueType>
367 ActualType
tmp =
static_cast<ActualType
>(
value);
371 template <
typename T,
typename ValueType>
381 ActualType
tmp =
static_cast<ActualType
>(
value);
394 template <
typename T>
395 class RepeatedFieldRefIterator {
413 : accessor->EndIterator(
data)),
423 : accessor->EndIterator(
data)),
445 assert(
data_ == other.data_);
458 if (
this != &other) {
477 template <
typename T>
478 struct PrimitiveTraits {
481 #define DEFINE_PRIMITIVE(TYPE, type) \
483 struct PrimitiveTraits<type> { \
484 static const bool is_primitive = true; \
485 static const FieldDescriptor::CppType cpp_type = \
486 FieldDescriptor::CPPTYPE_##TYPE; \
495 #undef DEFINE_PRIMITIVE
497 template <
typename T>
498 struct RefTypeTraits<
499 T, typename
std::enable_if<PrimitiveTraits<T>::is_primitive>
::type> {
510 template <
typename T>
511 struct RefTypeTraits<
512 T, typename
std::enable_if<is_proto_enum<T>::value>
::type> {
524 template <
typename T>
525 struct RefTypeTraits<
526 T, typename
std::enable_if<std::is_same<std::string, T>::value>
::type> {
537 template <
typename T>
538 struct MessageDescriptorGetter {
540 return T::default_instance().GetDescriptor();
544 struct MessageDescriptorGetter<
Message> {
548 template <
typename T>
549 struct RefTypeTraits<
550 T, typename
std::enable_if<std::is_base_of<Message, T>::value>
::type> {
554 typedef const T& IteratorValueType;
555 typedef const T* IteratorPointerType;
566 #include <google/protobuf/port_undef.inc>
568 #endif // GOOGLE_PROTOBUF_REFLECTION_H__
int32_t AccessorValueType
void Swap(T &lhs, T &rhs) noexcept(IsNothrowSwappable< T >::value)
const Descriptor::ReservedRange value
MutableRepeatedFieldRef(Message *message, const FieldDescriptor *field)
static const bool is_primitive
const T & Get(const void *ptr)
void SwapElements(int index1, int index2) const
void CopyFrom(const Container &container) const
RepeatedFieldAccessor AccessorType
IteratorType const_iterator
bool operator==(const RepeatedFieldRefIterator &other) const
Message AccessorValueType
std::string AccessorValueType
internal::RefTypeTraits< T >::AccessorType AccessorType
std::unique_ptr< AccessorValueType > scratch_space_
RepeatedFieldRef< T > GetRepeatedFieldRef(const Message &message, const FieldDescriptor *field) const
RepeatedFieldRefIterator< T > iterator
void Set(int index, const T &value) const
MessageFactory * GetMessageFactory() const
virtual const Message * GetPrototype(const Descriptor *type)=0
int32_t * IteratorPointerType
void Add(const T &value) const
static PyObject * Add(PyObject *self, PyObject *file_descriptor_proto)
void Swap(const MutableRepeatedFieldRef &other) const
RepeatedFieldRefIterator(const void *data, const RepeatedFieldAccessor *accessor, bool begin, AccessorValueType *scratch_space)
internal::RefTypeTraits< T >::AccessorType AccessorType
const T & Get(int index, T *scratch_space) const
const typedef MCPhysReg * iterator
std::forward_iterator_tag iterator_category
#define T(upbtypeconst, upbtype, ctype, default_value)
virtual Iterator * AdvanceIterator(const Field *data, Iterator *iterator) const =0
RepeatedFieldRef(const Message &message, const FieldDescriptor *field)
static const Descriptor * GetMessageFieldDescriptor()
bool operator!=(const RepeatedFieldRefIterator &other) const
RepeatedFieldRefIterator operator++(int)
RepeatedFieldRefIterator< T > iterator
MutableRepeatedFieldRef(Message *message, const FieldDescriptor *field)
RepeatedFieldRefIterator & operator=(const RepeatedFieldRefIterator &other)
internal::RefTypeTraits< T >::iterator IteratorType
void MergeFrom(const Container &container) const
virtual const Value * GetIteratorValue(const Field *data, const Iterator *iterator, Value *scratch_space) const =0
const internal::RepeatedFieldAccessor * RepeatedFieldAccessor(const FieldDescriptor *field) const
void Add(const T &value) const
MutableRepeatedFieldRef< T > GetMutableRepeatedFieldRef(Message *message, const FieldDescriptor *field) const
RepeatedFieldRefIterator(const RepeatedFieldRefIterator &other)
unsigned __int64 uint64_t
void Set(Field *data, int index, const ValueType &value) const
RepeatedFieldRefIterator< T > iterator
void Set(int index, const T &value) const
void * RepeatedFieldData(Message *message, const FieldDescriptor *field, FieldDescriptor::CppType cpp_type, const Descriptor *message_type) const
static const Descriptor * GetMessageFieldDescriptor()
ptrdiff_t difference_type
static const Descriptor * get()
RepeatedFieldRefIterator< T > iterator
void CopyFrom(const Container &container) const
ValueType
Type of the value held by a Value object.
static const Descriptor * get()
std::ptrdiff_t difference_type
static const Descriptor * GetMessageFieldDescriptor()
void Swap(const MutableRepeatedFieldRef &other) const
void MergeFrom(const Container &container) const
virtual Iterator * CopyIterator(const Field *data, const Iterator *iterator) const =0
RepeatedFieldAccessor AccessorType
const FieldDescriptor * field
void SwapElements(int index1, int index2) const
IteratorPointerType operator->() const
IteratorType const_iterator
virtual bool EqualsIterator(const Field *data, const Iterator *a, const Iterator *b) const =0
IteratorValueType operator*() const
RepeatedFieldRefIterator & operator++()
const T & Get(int index, T *scratch_space) const
RefTypeTraits< T >::IteratorPointerType IteratorPointerType
RepeatedFieldRef(const Message &message, const FieldDescriptor *field)
static const Descriptor * GetMessageFieldDescriptor()
T Get(const Field *data, int index) const
RefTypeTraits< T >::IteratorValueType IteratorValueType
RepeatedFieldRefIterator(const void *data, const RepeatedFieldAccessor *accessor, bool begin)
RepeatedFieldAccessor AccessorType
~RepeatedFieldRefIterator()
const RepeatedFieldAccessor * accessor_
internal::RefTypeTraits< T >::AccessorType AccessorType
ptrdiff_t difference_type
const typedef T & const_reference
void Add(Field *data, const ValueType &value) const
internal::RefTypeTraits< T >::AccessorType AccessorType
RefTypeTraits< T >::AccessorValueType AccessorValueType
virtual void DeleteIterator(const Field *data, Iterator *iterator) const =0
RepeatedFieldAccessor AccessorType
static struct async_container * container
FieldDescriptor::CppType cpp_type(FieldType type)
#define DEFINE_PRIMITIVE(TYPE, type)
internal::RefTypeTraits< T >::iterator IteratorType
grpc
Author(s):
autogenerated on Fri May 16 2025 03:00:01