Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(213)

Side by Side Diff: third_party/protobuf/src/google/protobuf/reflection.h

Issue 2590803003: Revert "third_party/protobuf: Update to HEAD (83d681ee2c)" (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Protocol Buffers - Google's data interchange format 1 // Protocol Buffers - Google's data interchange format
2 // Copyright 2008 Google Inc. All rights reserved. 2 // Copyright 2008 Google Inc. All rights reserved.
3 // https://developers.google.com/protocol-buffers/ 3 // https://developers.google.com/protocol-buffers/
4 // 4 //
5 // Redistribution and use in source and binary forms, with or without 5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are 6 // modification, are permitted provided that the following conditions are
7 // met: 7 // met:
8 // 8 //
9 // * Redistributions of source code must retain the above copyright 9 // * Redistributions of source code must retain the above copyright
10 // notice, this list of conditions and the following disclaimer. 10 // notice, this list of conditions and the following disclaimer.
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 } 73 }
74 int size() const { 74 int size() const {
75 return accessor_->Size(data_); 75 return accessor_->Size(data_);
76 } 76 }
77 T Get(int index) const { 77 T Get(int index) const {
78 return accessor_->template Get<T>(data_, index); 78 return accessor_->template Get<T>(data_, index);
79 } 79 }
80 80
81 typedef IteratorType iterator; 81 typedef IteratorType iterator;
82 typedef IteratorType const_iterator; 82 typedef IteratorType const_iterator;
83 typedef T value_type;
84 typedef T& reference;
85 typedef const T& const_reference;
86 typedef int size_type;
87 typedef ptrdiff_t difference_type;
88
89 iterator begin() const { 83 iterator begin() const {
90 return iterator(data_, accessor_, true); 84 return iterator(data_, accessor_, true);
91 } 85 }
92 iterator end() const { 86 iterator end() const {
93 return iterator(data_, accessor_, false); 87 return iterator(data_, accessor_, false);
94 } 88 }
95 89
96 private: 90 private:
97 friend class Reflection; 91 friend class Reflection;
98 RepeatedFieldRef( 92 RepeatedFieldRef(
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 return *static_cast<const T*>(accessor_->Get(data_, index, scratch_space)); 195 return *static_cast<const T*>(accessor_->Get(data_, index, scratch_space));
202 } 196 }
203 // Create a new message of the same type as the messages stored in this 197 // Create a new message of the same type as the messages stored in this
204 // repeated field. Caller takes ownership of the returned object. 198 // repeated field. Caller takes ownership of the returned object.
205 T* NewMessage() const { 199 T* NewMessage() const {
206 return static_cast<T*>(default_instance_->New()); 200 return static_cast<T*>(default_instance_->New());
207 } 201 }
208 202
209 typedef IteratorType iterator; 203 typedef IteratorType iterator;
210 typedef IteratorType const_iterator; 204 typedef IteratorType const_iterator;
211 typedef T value_type;
212 typedef T& reference;
213 typedef const T& const_reference;
214 typedef int size_type;
215 typedef ptrdiff_t difference_type;
216
217 iterator begin() const { 205 iterator begin() const {
218 return iterator(data_, accessor_, true, NewMessage()); 206 return iterator(data_, accessor_, true, NewMessage());
219 } 207 }
220 iterator end() const { 208 iterator end() const {
221 // The end iterator must not be dereferenced, no need for scratch space. 209 return iterator(data_, accessor_, false, NewMessage());
222 return iterator(data_, accessor_, false, NULL);
223 } 210 }
224 211
225 private: 212 private:
226 friend class Reflection; 213 friend class Reflection;
227 RepeatedFieldRef( 214 RepeatedFieldRef(
228 const Message& message, 215 const Message& message,
229 const FieldDescriptor* field) { 216 const FieldDescriptor* field) {
230 const Reflection* reflection = message.GetReflection(); 217 const Reflection* reflection = message.GetReflection();
231 data_ = reflection->RepeatedFieldData( 218 data_ = reflection->RepeatedFieldData(
232 const_cast<Message*>(&message), field, 219 const_cast<Message*>(&message), field,
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 const Field* data, int index, Value* scratch_space) const = 0; 349 const Field* data, int index, Value* scratch_space) const = 0;
363 350
364 virtual void Clear(Field* data) const = 0; 351 virtual void Clear(Field* data) const = 0;
365 virtual void Set(Field* data, int index, const Value* value) const = 0; 352 virtual void Set(Field* data, int index, const Value* value) const = 0;
366 virtual void Add(Field* data, const Value* value) const = 0; 353 virtual void Add(Field* data, const Value* value) const = 0;
367 virtual void RemoveLast(Field* data) const = 0; 354 virtual void RemoveLast(Field* data) const = 0;
368 virtual void SwapElements(Field* data, int index1, int index2) const = 0; 355 virtual void SwapElements(Field* data, int index1, int index2) const = 0;
369 virtual void Swap(Field* data, const RepeatedFieldAccessor* other_mutator, 356 virtual void Swap(Field* data, const RepeatedFieldAccessor* other_mutator,
370 Field* other_data) const = 0; 357 Field* other_data) const = 0;
371 358
372 // Create an iterator that points at the beginning of the repeated field. 359 // Create an iterator that points at the begining of the repeated field.
373 virtual Iterator* BeginIterator(const Field* data) const = 0; 360 virtual Iterator* BeginIterator(const Field* data) const = 0;
374 // Create an iterator that points at the end of the repeated field. 361 // Create an iterator that points at the end of the repeated field.
375 virtual Iterator* EndIterator(const Field* data) const = 0; 362 virtual Iterator* EndIterator(const Field* data) const = 0;
376 // Make a copy of an iterator and return the new copy. 363 // Make a copy of an iterator and return the new copy.
377 virtual Iterator* CopyIterator(const Field* data, 364 virtual Iterator* CopyIterator(const Field* data,
378 const Iterator* iterator) const = 0; 365 const Iterator* iterator) const = 0;
379 // Move an iterator to point to the next element. 366 // Move an iterator to point to the next element.
380 virtual Iterator* AdvanceIterator(const Field* data, 367 virtual Iterator* AdvanceIterator(const Field* data,
381 Iterator* iterator) const = 0; 368 Iterator* iterator) const = 0;
382 // Compare whether two iterators point to the same element. 369 // Compare whether two iterators point to the same element.
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
434 template<typename T> 421 template<typename T>
435 class RepeatedFieldRefIterator 422 class RepeatedFieldRefIterator
436 : public std::iterator<std::forward_iterator_tag, T> { 423 : public std::iterator<std::forward_iterator_tag, T> {
437 typedef typename RefTypeTraits<T>::AccessorValueType AccessorValueType; 424 typedef typename RefTypeTraits<T>::AccessorValueType AccessorValueType;
438 typedef typename RefTypeTraits<T>::IteratorValueType IteratorValueType; 425 typedef typename RefTypeTraits<T>::IteratorValueType IteratorValueType;
439 typedef typename RefTypeTraits<T>::IteratorPointerType IteratorPointerType; 426 typedef typename RefTypeTraits<T>::IteratorPointerType IteratorPointerType;
440 427
441 public: 428 public:
442 // Constructor for non-message fields. 429 // Constructor for non-message fields.
443 RepeatedFieldRefIterator(const void* data, 430 RepeatedFieldRefIterator(const void* data,
444 const RepeatedFieldAccessor* accessor, bool begin) 431 const RepeatedFieldAccessor* accessor,
445 : data_(data), 432 bool begin)
446 accessor_(accessor), 433 : data_(data), accessor_(accessor),
447 iterator_(begin ? accessor->BeginIterator(data) 434 iterator_(begin ? accessor->BeginIterator(data) :
448 : accessor->EndIterator(data)), 435 accessor->EndIterator(data)),
449 // The end iterator must not be dereferenced, no need for scratch space. 436 scratch_space_(new AccessorValueType) {
450 scratch_space_(begin ? new AccessorValueType : NULL) {} 437 }
451 // Constructor for message fields. 438 // Constructor for message fields.
452 RepeatedFieldRefIterator(const void* data, 439 RepeatedFieldRefIterator(const void* data,
453 const RepeatedFieldAccessor* accessor, 440 const RepeatedFieldAccessor* accessor,
454 bool begin, 441 bool begin,
455 AccessorValueType* scratch_space) 442 AccessorValueType* scratch_space)
456 : data_(data), accessor_(accessor), 443 : data_(data), accessor_(accessor),
457 iterator_(begin ? accessor->BeginIterator(data) : 444 iterator_(begin ? accessor->BeginIterator(data) :
458 accessor->EndIterator(data)), 445 accessor->EndIterator(data)),
459 scratch_space_(scratch_space) { 446 scratch_space_(scratch_space) {
460 } 447 }
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
604 FieldDescriptor::CPPTYPE_MESSAGE; 591 FieldDescriptor::CPPTYPE_MESSAGE;
605 static const Descriptor* GetMessageFieldDescriptor() { 592 static const Descriptor* GetMessageFieldDescriptor() {
606 return MessageDescriptorGetter<T>::get(); 593 return MessageDescriptorGetter<T>::get();
607 } 594 }
608 }; 595 };
609 } // namespace internal 596 } // namespace internal
610 } // namespace protobuf 597 } // namespace protobuf
611 } // namespace google 598 } // namespace google
612 599
613 #endif // GOOGLE_PROTOBUF_REFLECTION_H__ 600 #endif // GOOGLE_PROTOBUF_REFLECTION_H__
OLDNEW
« no previous file with comments | « third_party/protobuf/src/google/protobuf/metadata.h ('k') | third_party/protobuf/src/google/protobuf/reflection_ops.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698