map_field.h
Go to the documentation of this file.
1 // Protocol Buffers - Google's data interchange format
2 // Copyright 2008 Google Inc. All rights reserved.
3 // https://developers.google.com/protocol-buffers/
4 //
5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are
7 // met:
8 //
9 // * Redistributions of source code must retain the above copyright
10 // notice, this list of conditions and the following disclaimer.
11 // * Redistributions in binary form must reproduce the above
12 // copyright notice, this list of conditions and the following disclaimer
13 // in the documentation and/or other materials provided with the
14 // distribution.
15 // * Neither the name of Google Inc. nor the names of its
16 // contributors may be used to endorse or promote products derived from
17 // this software without specific prior written permission.
18 //
19 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 
31 #ifndef GOOGLE_PROTOBUF_MAP_FIELD_H__
32 #define GOOGLE_PROTOBUF_MAP_FIELD_H__
33 
34 #include <atomic>
35 
36 #include <google/protobuf/arena.h>
44 #include <google/protobuf/port.h>
47 
48 
49 #include <google/protobuf/port_def.inc>
50 
51 #ifdef SWIG
52 #error "You cannot SWIG proto headers"
53 #endif
54 
55 namespace google {
56 namespace protobuf {
57 class DynamicMessage;
58 class MapKey;
59 class MapIterator;
60 namespace internal {
61 
62 class ContendedMapCleanTest;
63 class GeneratedMessageReflection;
64 class MapFieldAccessor;
65 
66 // This class provides access to map field using reflection, which is the same
67 // as those provided for RepeatedPtrField<Message>. It is used for internal
68 // reflection implentation only. Users should never use this directly.
69 class PROTOBUF_EXPORT MapFieldBase {
70  public:
72  : arena_(NULL), repeated_field_(NULL), state_(STATE_MODIFIED_MAP) {}
73  explicit MapFieldBase(Arena* arena)
74  : arena_(arena), repeated_field_(NULL), state_(STATE_MODIFIED_MAP) {
75  // Mutex's destructor needs to be called explicitly to release resources
76  // acquired in its constructor.
77  arena->OwnDestructor(&mutex_);
78  }
79  virtual ~MapFieldBase();
80 
81  // Returns reference to internal repeated field. Data written using
82  // Map's api prior to calling this function is guarantted to be
83  // included in repeated field.
84  const RepeatedPtrFieldBase& GetRepeatedField() const;
85 
86  // Like above. Returns mutable pointer to the internal repeated field.
87  RepeatedPtrFieldBase* MutableRepeatedField();
88 
89  // Pure virtual map APIs for Map Reflection.
90  virtual bool ContainsMapKey(const MapKey& map_key) const = 0;
91  virtual bool InsertOrLookupMapValue(const MapKey& map_key,
92  MapValueRef* val) = 0;
93  // Returns whether changes to the map are reflected in the repeated field.
94  bool IsRepeatedFieldValid() const;
95  // Insures operations after won't get executed before calling this.
96  bool IsMapValid() const;
97  virtual bool DeleteMapValue(const MapKey& map_key) = 0;
98  virtual bool EqualIterator(const MapIterator& a,
99  const MapIterator& b) const = 0;
100  virtual void MapBegin(MapIterator* map_iter) const = 0;
101  virtual void MapEnd(MapIterator* map_iter) const = 0;
102  virtual void MergeFrom(const MapFieldBase& other) = 0;
103  virtual void Swap(MapFieldBase* other) = 0;
104  // Sync Map with repeated field and returns the size of map.
105  virtual int size() const = 0;
106  virtual void Clear() = 0;
107 
108  // Returns the number of bytes used by the repeated field, excluding
109  // sizeof(*this)
110  size_t SpaceUsedExcludingSelfLong() const;
111 
113  return internal::ToIntSize(SpaceUsedExcludingSelfLong());
114  }
115 
116  protected:
117  // Gets the size of space used by map field.
118  virtual size_t SpaceUsedExcludingSelfNoLock() const;
119 
120  // Synchronizes the content in Map to RepeatedPtrField if there is any change
121  // to Map after last synchronization.
122  void SyncRepeatedFieldWithMap() const;
123  virtual void SyncRepeatedFieldWithMapNoLock() const;
124 
125  // Synchronizes the content in RepeatedPtrField to Map if there is any change
126  // to RepeatedPtrField after last synchronization.
127  void SyncMapWithRepeatedField() const;
128  virtual void SyncMapWithRepeatedFieldNoLock() const {}
129 
130  // Tells MapFieldBase that there is new change to Map.
131  void SetMapDirty();
132 
133  // Tells MapFieldBase that there is new change to RepeatedPTrField.
134  void SetRepeatedDirty();
135 
136  // Provides derived class the access to repeated field.
137  void* MutableRepeatedPtrField() const;
138 
139  enum State {
140  STATE_MODIFIED_MAP = 0, // map has newly added data that has not been
141  // synchronized to repeated field
142  STATE_MODIFIED_REPEATED = 1, // repeated field has newly added data that
143  // has not been synchronized to map
144  CLEAN = 2, // data in map and repeated field are same
145  };
146 
147  Arena* arena_;
149 
150  mutable internal::WrappedMutex
151  mutex_; // The thread to synchronize map and repeated field
152  // needs to get lock first;
153  mutable std::atomic<State> state_;
154 
155  private:
156  friend class ContendedMapCleanTest;
157  friend class GeneratedMessageReflection;
158  friend class MapFieldAccessor;
159  friend class DynamicMessage;
160 
161  // Virtual helper methods for MapIterator. MapIterator doesn't have the
162  // type helper for key and value. Call these help methods to deal with
163  // different types. Real helper methods are implemented in
164  // TypeDefinedMapFieldBase.
165  friend class ::PROTOBUF_NAMESPACE_ID::MapIterator;
166  // Allocate map<...>::iterator for MapIterator.
167  virtual void InitializeIterator(MapIterator* map_iter) const = 0;
168 
169  // DeleteIterator() is called by the destructor of MapIterator only.
170  // It deletes map<...>::iterator for MapIterator.
171  virtual void DeleteIterator(MapIterator* map_iter) const = 0;
172 
173  // Copy the map<...>::iterator from other_iterator to
174  // this_iterator.
175  virtual void CopyIterator(MapIterator* this_iterator,
176  const MapIterator& other_iterator) const = 0;
177 
178  // IncreaseIterator() is called by operator++() of MapIterator only.
179  // It implements the ++ operator of MapIterator.
180  virtual void IncreaseIterator(MapIterator* map_iter) const = 0;
182 };
183 
184 // This class provides common Map Reflection implementations for generated
185 // message and dynamic message.
186 template <typename Key, typename T>
187 class TypeDefinedMapFieldBase : public MapFieldBase {
188  public:
190  explicit TypeDefinedMapFieldBase(Arena* arena) : MapFieldBase(arena) {}
192  void MapBegin(MapIterator* map_iter) const override;
193  void MapEnd(MapIterator* map_iter) const override;
194  bool EqualIterator(const MapIterator& a, const MapIterator& b) const override;
195 
196  virtual const Map<Key, T>& GetMap() const = 0;
197  virtual Map<Key, T>* MutableMap() = 0;
198 
199  protected:
201  const MapIterator* map_iter) const;
202 
203  private:
204  void InitializeIterator(MapIterator* map_iter) const override;
205  void DeleteIterator(MapIterator* map_iter) const override;
206  void CopyIterator(MapIterator* this_iteratorm,
207  const MapIterator& that_iterator) const override;
208  void IncreaseIterator(MapIterator* map_iter) const override;
209 
210  virtual void SetMapIteratorValue(MapIterator* map_iter) const = 0;
212 };
213 
214 // This class provides access to map field using generated api. It is used for
215 // internal generated message implentation only. Users should never use this
216 // directly.
217 template <typename Derived, typename Key, typename T,
218  WireFormatLite::FieldType kKeyFieldType,
219  WireFormatLite::FieldType kValueFieldType, int default_enum_value = 0>
220 class MapField : public TypeDefinedMapFieldBase<Key, T> {
221  // Provide utilities to parse/serialize key/value. Provide utilities to
222  // manipulate internal stored type.
225 
226  // Define message type for internal repeated field.
227  typedef Derived EntryType;
228 
229  // Define abbreviation for parent MapFieldLite
230  typedef MapFieldLite<Derived, Key, T, kKeyFieldType, kValueFieldType,
231  default_enum_value>
233 
234  // Enum needs to be handled differently from other types because it has
235  // different exposed type in Map's api and repeated field's api. For
236  // details see the comment in the implementation of
237  // SyncMapWithRepeatedFieldNoLock.
238  static const bool kIsValueEnum = ValueTypeHandler::kIsEnum;
240 
241  public:
242  typedef typename Derived::SuperType EntryTypeTrait;
244 
245  MapField() {}
246  explicit MapField(Arena* arena)
247  : TypeDefinedMapFieldBase<Key, T>(arena), impl_(arena) {}
248 
249  // Implement MapFieldBase
250  bool ContainsMapKey(const MapKey& map_key) const override;
251  bool InsertOrLookupMapValue(const MapKey& map_key, MapValueRef* val) override;
252  bool DeleteMapValue(const MapKey& map_key) override;
253 
254  const Map<Key, T>& GetMap() const override {
256  return impl_.GetMap();
257  }
258 
259  Map<Key, T>* MutableMap() override {
261  Map<Key, T>* result = impl_.MutableMap();
263  return result;
264  }
265 
266  int size() const override;
267  void Clear() override;
268  void MergeFrom(const MapFieldBase& other) override;
269  void Swap(MapFieldBase* other) override;
270 
271  // Used in the implementation of parsing. Caller should take the ownership iff
272  // arena_ is NULL.
273  EntryType* NewEntry() const { return impl_.NewEntry(); }
274  // Used in the implementation of serializing enum value type. Caller should
275  // take the ownership iff arena_ is NULL.
276  EntryType* NewEnumEntryWrapper(const Key& key, const T t) const {
277  return impl_.NewEnumEntryWrapper(key, t);
278  }
279  // Used in the implementation of serializing other value types. Caller should
280  // take the ownership iff arena_ is NULL.
281  EntryType* NewEntryWrapper(const Key& key, const T& t) const {
282  return impl_.NewEntryWrapper(key, t);
283  }
284 
285  const char* _InternalParse(const char* ptr, ParseContext* ctx) {
286  return impl_._InternalParse(ptr, ctx);
287  }
288  template <typename Metadata>
289  const char* ParseWithEnumValidation(const char* ptr, ParseContext* ctx,
290  bool (*is_valid)(int), uint32 field_num,
291  Metadata* metadata) {
292  return impl_.ParseWithEnumValidation(ptr, ctx, is_valid, field_num,
293  metadata);
294  }
295 
296  private:
298 
300  typedef void DestructorSkippable_;
301 
302  // Implements MapFieldBase
303  void SyncRepeatedFieldWithMapNoLock() const override;
304  void SyncMapWithRepeatedFieldNoLock() const override;
305  size_t SpaceUsedExcludingSelfNoLock() const override;
306 
307  void SetMapIteratorValue(MapIterator* map_iter) const override;
308 
309  friend class ::PROTOBUF_NAMESPACE_ID::Arena;
310  friend class MapFieldStateTest; // For testing, it needs raw access to impl_
312 };
313 
314 template <typename T, typename Key, typename Value,
315  WireFormatLite::FieldType kKeyFieldType,
316  WireFormatLite::FieldType kValueFieldType, int default_enum_value>
317 struct MapEntryToMapField<MapEntry<T, Key, Value, kKeyFieldType,
318  kValueFieldType, default_enum_value>> {
319  typedef MapField<T, Key, Value, kKeyFieldType, kValueFieldType,
320  default_enum_value>
322 };
323 
324 class PROTOBUF_EXPORT DynamicMapField
325  : public TypeDefinedMapFieldBase<MapKey, MapValueRef> {
326  public:
327  explicit DynamicMapField(const Message* default_entry);
328  DynamicMapField(const Message* default_entry, Arena* arena);
329  ~DynamicMapField() override;
330 
331  // Implement MapFieldBase
332  bool ContainsMapKey(const MapKey& map_key) const override;
333  bool InsertOrLookupMapValue(const MapKey& map_key, MapValueRef* val) override;
334  bool DeleteMapValue(const MapKey& map_key) override;
335  void MergeFrom(const MapFieldBase& other) override;
336  void Swap(MapFieldBase* other) override;
337 
338  const Map<MapKey, MapValueRef>& GetMap() const override;
339  Map<MapKey, MapValueRef>* MutableMap() override;
340 
341  int size() const override;
342  void Clear() override;
343 
344  private:
347 
348  void AllocateMapValue(MapValueRef* map_val);
349 
350  // Implements MapFieldBase
351  void SyncRepeatedFieldWithMapNoLock() const override;
352  void SyncMapWithRepeatedFieldNoLock() const override;
353  size_t SpaceUsedExcludingSelfNoLock() const override;
354  void SetMapIteratorValue(MapIterator* map_iter) const override;
356 };
357 
358 } // namespace internal
359 
360 #define TYPE_CHECK(EXPECTEDTYPE, METHOD) \
361  if (type() != EXPECTEDTYPE) { \
362  GOOGLE_LOG(FATAL) << "Protocol Buffer map usage error:\n" \
363  << METHOD << " type does not match\n" \
364  << " Expected : " \
365  << FieldDescriptor::CppTypeName(EXPECTEDTYPE) << "\n" \
366  << " Actual : " << FieldDescriptor::CppTypeName(type()); \
367  }
368 
369 // MapKey is an union type for representing any possible
370 // map key.
371 class PROTOBUF_EXPORT MapKey {
372  public:
373  MapKey() : type_(0) {}
374  MapKey(const MapKey& other) : type_(0) { CopyFrom(other); }
375  MapKey& operator=(const MapKey& other) {
376  CopyFrom(other);
377  return *this;
378  }
379 
381  if (type_ == FieldDescriptor::CPPTYPE_STRING) {
382  delete val_.string_value_;
383  }
384  }
385 
387  if (type_ == 0) {
388  GOOGLE_LOG(FATAL) << "Protocol Buffer map usage error:\n"
389  << "MapKey::type MapKey is not initialized. "
390  << "Call set methods to initialize MapKey.";
391  }
392  return (FieldDescriptor::CppType)type_;
393  }
394 
397  val_.int64_value_ = value;
398  }
401  val_.uint64_value_ = value;
402  }
405  val_.int32_value_ = value;
406  }
409  val_.uint32_value_ = value;
410  }
411  void SetBoolValue(bool value) {
413  val_.bool_value_ = value;
414  }
417  *val_.string_value_ = val;
418  }
419 
421  TYPE_CHECK(FieldDescriptor::CPPTYPE_INT64, "MapKey::GetInt64Value");
422  return val_.int64_value_;
423  }
425  TYPE_CHECK(FieldDescriptor::CPPTYPE_UINT64, "MapKey::GetUInt64Value");
426  return val_.uint64_value_;
427  }
429  TYPE_CHECK(FieldDescriptor::CPPTYPE_INT32, "MapKey::GetInt32Value");
430  return val_.int32_value_;
431  }
433  TYPE_CHECK(FieldDescriptor::CPPTYPE_UINT32, "MapKey::GetUInt32Value");
434  return val_.uint32_value_;
435  }
436  bool GetBoolValue() const {
437  TYPE_CHECK(FieldDescriptor::CPPTYPE_BOOL, "MapKey::GetBoolValue");
438  return val_.bool_value_;
439  }
440  const std::string& GetStringValue() const {
441  TYPE_CHECK(FieldDescriptor::CPPTYPE_STRING, "MapKey::GetStringValue");
442  return *val_.string_value_;
443  }
444 
445  bool operator<(const MapKey& other) const {
446  if (type_ != other.type_) {
447  // We could define a total order that handles this case, but
448  // there currently no need. So, for now, fail.
449  GOOGLE_LOG(FATAL) << "Unsupported: type mismatch";
450  }
451  switch (type()) {
456  GOOGLE_LOG(FATAL) << "Unsupported";
457  return false;
459  return *val_.string_value_ < *other.val_.string_value_;
461  return val_.int64_value_ < other.val_.int64_value_;
463  return val_.int32_value_ < other.val_.int32_value_;
465  return val_.uint64_value_ < other.val_.uint64_value_;
467  return val_.uint32_value_ < other.val_.uint32_value_;
469  return val_.bool_value_ < other.val_.bool_value_;
470  }
471  return false;
472  }
473 
474  bool operator==(const MapKey& other) const {
475  if (type_ != other.type_) {
476  // To be consistent with operator<, we don't allow this either.
477  GOOGLE_LOG(FATAL) << "Unsupported: type mismatch";
478  }
479  switch (type()) {
484  GOOGLE_LOG(FATAL) << "Unsupported";
485  break;
487  return *val_.string_value_ == *other.val_.string_value_;
489  return val_.int64_value_ == other.val_.int64_value_;
491  return val_.int32_value_ == other.val_.int32_value_;
493  return val_.uint64_value_ == other.val_.uint64_value_;
495  return val_.uint32_value_ == other.val_.uint32_value_;
497  return val_.bool_value_ == other.val_.bool_value_;
498  }
499  GOOGLE_LOG(FATAL) << "Can't get here.";
500  return false;
501  }
502 
503  void CopyFrom(const MapKey& other) {
504  SetType(other.type());
505  switch (type_) {
510  GOOGLE_LOG(FATAL) << "Unsupported";
511  break;
513  *val_.string_value_ = *other.val_.string_value_;
514  break;
516  val_.int64_value_ = other.val_.int64_value_;
517  break;
519  val_.int32_value_ = other.val_.int32_value_;
520  break;
522  val_.uint64_value_ = other.val_.uint64_value_;
523  break;
525  val_.uint32_value_ = other.val_.uint32_value_;
526  break;
528  val_.bool_value_ = other.val_.bool_value_;
529  break;
530  }
531  }
532 
533  private:
534  template <typename K, typename V>
536  friend class ::PROTOBUF_NAMESPACE_ID::MapIterator;
538 
539  union KeyValue {
540  KeyValue() {}
547  } val_;
548 
550  if (type_ == type) return;
551  if (type_ == FieldDescriptor::CPPTYPE_STRING) {
552  delete val_.string_value_;
553  }
554  type_ = type;
555  if (type_ == FieldDescriptor::CPPTYPE_STRING) {
556  val_.string_value_ = new std::string;
557  }
558  }
559 
560  // type_ is 0 or a valid FieldDescriptor::CppType.
561  int type_;
562 };
563 
564 // MapValueRef points to a map value.
565 class PROTOBUF_EXPORT MapValueRef {
566  public:
567  MapValueRef() : data_(NULL), type_(0) {}
568 
570  TYPE_CHECK(FieldDescriptor::CPPTYPE_INT64, "MapValueRef::SetInt64Value");
571  *reinterpret_cast<int64*>(data_) = value;
572  }
574  TYPE_CHECK(FieldDescriptor::CPPTYPE_UINT64, "MapValueRef::SetUInt64Value");
575  *reinterpret_cast<uint64*>(data_) = value;
576  }
578  TYPE_CHECK(FieldDescriptor::CPPTYPE_INT32, "MapValueRef::SetInt32Value");
579  *reinterpret_cast<int32*>(data_) = value;
580  }
582  TYPE_CHECK(FieldDescriptor::CPPTYPE_UINT32, "MapValueRef::SetUInt32Value");
583  *reinterpret_cast<uint32*>(data_) = value;
584  }
585  void SetBoolValue(bool value) {
586  TYPE_CHECK(FieldDescriptor::CPPTYPE_BOOL, "MapValueRef::SetBoolValue");
587  *reinterpret_cast<bool*>(data_) = value;
588  }
589  // TODO(jieluo) - Checks that enum is member.
590  void SetEnumValue(int value) {
591  TYPE_CHECK(FieldDescriptor::CPPTYPE_ENUM, "MapValueRef::SetEnumValue");
592  *reinterpret_cast<int*>(data_) = value;
593  }
595  TYPE_CHECK(FieldDescriptor::CPPTYPE_STRING, "MapValueRef::SetStringValue");
596  *reinterpret_cast<std::string*>(data_) = value;
597  }
598  void SetFloatValue(float value) {
599  TYPE_CHECK(FieldDescriptor::CPPTYPE_FLOAT, "MapValueRef::SetFloatValue");
600  *reinterpret_cast<float*>(data_) = value;
601  }
602  void SetDoubleValue(double value) {
603  TYPE_CHECK(FieldDescriptor::CPPTYPE_DOUBLE, "MapValueRef::SetDoubleValue");
604  *reinterpret_cast<double*>(data_) = value;
605  }
606 
608  TYPE_CHECK(FieldDescriptor::CPPTYPE_INT64, "MapValueRef::GetInt64Value");
609  return *reinterpret_cast<int64*>(data_);
610  }
612  TYPE_CHECK(FieldDescriptor::CPPTYPE_UINT64, "MapValueRef::GetUInt64Value");
613  return *reinterpret_cast<uint64*>(data_);
614  }
616  TYPE_CHECK(FieldDescriptor::CPPTYPE_INT32, "MapValueRef::GetInt32Value");
617  return *reinterpret_cast<int32*>(data_);
618  }
620  TYPE_CHECK(FieldDescriptor::CPPTYPE_UINT32, "MapValueRef::GetUInt32Value");
621  return *reinterpret_cast<uint32*>(data_);
622  }
623  bool GetBoolValue() const {
624  TYPE_CHECK(FieldDescriptor::CPPTYPE_BOOL, "MapValueRef::GetBoolValue");
625  return *reinterpret_cast<bool*>(data_);
626  }
627  int GetEnumValue() const {
628  TYPE_CHECK(FieldDescriptor::CPPTYPE_ENUM, "MapValueRef::GetEnumValue");
629  return *reinterpret_cast<int*>(data_);
630  }
631  const std::string& GetStringValue() const {
632  TYPE_CHECK(FieldDescriptor::CPPTYPE_STRING, "MapValueRef::GetStringValue");
633  return *reinterpret_cast<std::string*>(data_);
634  }
635  float GetFloatValue() const {
636  TYPE_CHECK(FieldDescriptor::CPPTYPE_FLOAT, "MapValueRef::GetFloatValue");
637  return *reinterpret_cast<float*>(data_);
638  }
639  double GetDoubleValue() const {
640  TYPE_CHECK(FieldDescriptor::CPPTYPE_DOUBLE, "MapValueRef::GetDoubleValue");
641  return *reinterpret_cast<double*>(data_);
642  }
643 
644  const Message& GetMessageValue() const {
646  "MapValueRef::GetMessageValue");
647  return *reinterpret_cast<Message*>(data_);
648  }
649 
652  "MapValueRef::MutableMessageValue");
653  return reinterpret_cast<Message*>(data_);
654  }
655 
656  private:
657  template <typename Derived, typename K, typename V,
659  internal::WireFormatLite::FieldType value_wire_type,
660  int default_enum_value>
661  friend class internal::MapField;
662  template <typename K, typename V>
664  friend class ::PROTOBUF_NAMESPACE_ID::MapIterator;
665  friend class Reflection;
667 
669 
671  if (type_ == 0 || data_ == NULL) {
672  GOOGLE_LOG(FATAL) << "Protocol Buffer map usage error:\n"
673  << "MapValueRef::type MapValueRef is not initialized.";
674  }
675  return (FieldDescriptor::CppType)type_;
676  }
677  void SetValue(const void* val) { data_ = const_cast<void*>(val); }
678  void CopyFrom(const MapValueRef& other) {
679  type_ = other.type_;
680  data_ = other.data_;
681  }
682  // Only used in DynamicMapField
683  void DeleteData() {
684  switch (type_) {
685 #define HANDLE_TYPE(CPPTYPE, TYPE) \
686  case FieldDescriptor::CPPTYPE_##CPPTYPE: { \
687  delete reinterpret_cast<TYPE*>(data_); \
688  break; \
689  }
690  HANDLE_TYPE(INT32, int32);
691  HANDLE_TYPE(INT64, int64);
692  HANDLE_TYPE(UINT32, uint32);
693  HANDLE_TYPE(UINT64, uint64);
694  HANDLE_TYPE(DOUBLE, double);
695  HANDLE_TYPE(FLOAT, float);
696  HANDLE_TYPE(BOOL, bool);
697  HANDLE_TYPE(STRING, std::string);
698  HANDLE_TYPE(ENUM, int32);
699  HANDLE_TYPE(MESSAGE, Message);
700 #undef HANDLE_TYPE
701  }
702  }
703  // data_ point to a map value. MapValueRef does not
704  // own this value.
705  void* data_;
706  // type_ is 0 or a valid FieldDescriptor::CppType.
707  int type_;
708 };
709 
710 #undef TYPE_CHECK
711 
712 class PROTOBUF_EXPORT MapIterator {
713  public:
715  const Reflection* reflection = message->GetReflection();
716  map_ = reflection->MutableMapData(message, field);
717  key_.SetType(field->message_type()->FindFieldByName("key")->cpp_type());
718  value_.SetType(field->message_type()->FindFieldByName("value")->cpp_type());
719  map_->InitializeIterator(this);
720  }
721  MapIterator(const MapIterator& other) {
722  map_ = other.map_;
723  map_->InitializeIterator(this);
724  map_->CopyIterator(this, other);
725  }
726  ~MapIterator() { map_->DeleteIterator(this); }
728  map_ = other.map_;
729  map_->CopyIterator(this, other);
730  return *this;
731  }
732  friend bool operator==(const MapIterator& a, const MapIterator& b) {
733  return a.map_->EqualIterator(a, b);
734  }
735  friend bool operator!=(const MapIterator& a, const MapIterator& b) {
736  return !a.map_->EqualIterator(a, b);
737  }
739  map_->IncreaseIterator(this);
740  return *this;
741  }
743  // iter_ is copied from Map<...>::iterator, no need to
744  // copy from its self again. Use the same implementation
745  // with operator++()
746  map_->IncreaseIterator(this);
747  return *this;
748  }
749  const MapKey& GetKey() { return key_; }
750  const MapValueRef& GetValueRef() { return value_; }
752  map_->SetMapDirty();
753  return &value_;
754  }
755 
756  private:
757  template <typename Key, typename T>
760  template <typename Derived, typename Key, typename T,
762  internal::WireFormatLite::FieldType kValueFieldType,
763  int default_enum_value>
764  friend class internal::MapField;
765 
766  // reinterpret_cast from heap-allocated Map<...>::iterator*. MapIterator owns
767  // the iterator. It is allocated by MapField<...>::InitializeIterator() called
768  // in constructor and deleted by MapField<...>::DeleteIterator() called in
769  // destructor.
770  void* iter_;
771  // Point to a MapField to call helper methods implemented in MapField.
772  // MapIterator does not own this object.
776 };
777 
778 } // namespace protobuf
779 } // namespace google
780 
782 template <>
783 struct hash<::PROTOBUF_NAMESPACE_ID::MapKey> {
784  size_t operator()(const ::PROTOBUF_NAMESPACE_ID::MapKey& map_key) const {
785  switch (map_key.type()) {
786  case ::PROTOBUF_NAMESPACE_ID::FieldDescriptor::CPPTYPE_DOUBLE:
787  case ::PROTOBUF_NAMESPACE_ID::FieldDescriptor::CPPTYPE_FLOAT:
788  case ::PROTOBUF_NAMESPACE_ID::FieldDescriptor::CPPTYPE_ENUM:
789  case ::PROTOBUF_NAMESPACE_ID::FieldDescriptor::CPPTYPE_MESSAGE:
790  GOOGLE_LOG(FATAL) << "Unsupported";
791  break;
792  case ::PROTOBUF_NAMESPACE_ID::FieldDescriptor::CPPTYPE_STRING:
793  return hash<std::string>()(map_key.GetStringValue());
794  case ::PROTOBUF_NAMESPACE_ID::FieldDescriptor::CPPTYPE_INT64:
795  return hash<int64>()(map_key.GetInt64Value());
796  case ::PROTOBUF_NAMESPACE_ID::FieldDescriptor::CPPTYPE_INT32:
797  return hash<int32>()(map_key.GetInt32Value());
798  case ::PROTOBUF_NAMESPACE_ID::FieldDescriptor::CPPTYPE_UINT64:
799  return hash<uint64>()(map_key.GetUInt64Value());
800  case ::PROTOBUF_NAMESPACE_ID::FieldDescriptor::CPPTYPE_UINT32:
801  return hash<uint32>()(map_key.GetUInt32Value());
802  case ::PROTOBUF_NAMESPACE_ID::FieldDescriptor::CPPTYPE_BOOL:
803  return hash<bool>()(map_key.GetBoolValue());
804  }
805  GOOGLE_LOG(FATAL) << "Can't get here.";
806  return 0;
807  }
808  bool operator()(const ::PROTOBUF_NAMESPACE_ID::MapKey& map_key1,
809  const ::PROTOBUF_NAMESPACE_ID::MapKey& map_key2) const {
810  return map_key1 < map_key2;
811  }
812 };
814 
815 #include <google/protobuf/port_undef.inc>
816 
817 #endif // GOOGLE_PROTOBUF_MAP_FIELD_H__
google::protobuf.internal::MapFieldLite::MutableMap
Map< Key, T > * MutableMap()
Definition: map_field_lite.h:74
google::protobuf.internal::MapIf
Definition: map_type_handler.h:50
google::protobuf.internal::MapField::MapType
Map< Key, T > MapType
Definition: map_field.h:243
google::protobuf::MapKey::operator<
bool operator<(const MapKey &other) const
Definition: map_field.h:445
google::protobuf.internal::MapField::MapField
MapField(Arena *arena)
Definition: map_field.h:246
google::protobuf::FieldDescriptor::CPPTYPE_ENUM
@ CPPTYPE_ENUM
Definition: src/google/protobuf/descriptor.h:561
google::protobuf::RepeatedPtrField
Definition: command_line_interface.h:62
TYPE_CHECK
#define TYPE_CHECK(EXPECTEDTYPE, METHOD)
Definition: map_field.h:360
google::protobuf::MapValueRef::SetBoolValue
void SetBoolValue(bool value)
Definition: map_field.h:585
google::protobuf.internal::MapField::MapField
MapField()
Definition: map_field.h:245
data_
StringPiece data_
Definition: bytestream_unittest.cc:60
google::protobuf::MapIterator::GetValueRef
const MapValueRef & GetValueRef()
Definition: map_field.h:750
google::protobuf::value
const Descriptor::ReservedRange value
Definition: src/google/protobuf/descriptor.h:1954
google::protobuf::Reflection::MutableMapData
internal::MapFieldBase * MutableMapData(Message *message, const FieldDescriptor *field) const
Definition: generated_message_reflection.cc:2211
google::protobuf::FieldDescriptor::CPPTYPE_STRING
@ CPPTYPE_STRING
Definition: src/google/protobuf/descriptor.h:562
google::protobuf::FieldDescriptor
Definition: src/google/protobuf/descriptor.h:515
K
#define K(t)
Definition: sha1.c:43
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS
#define GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(TypeName)
Definition: macros.h:40
hash<::PROTOBUF_NAMESPACE_ID::MapKey >::operator()
bool operator()(const ::PROTOBUF_NAMESPACE_ID::MapKey &map_key1, const ::PROTOBUF_NAMESPACE_ID::MapKey &map_key2) const
Definition: map_field.h:808
google::protobuf.internal::TypeDefinedMapFieldBase::EqualIterator
bool EqualIterator(const MapIterator &a, const MapIterator &b) const override
Definition: map_field_inl.h:125
google::protobuf.internal::MapFieldLite
Definition: map.h:73
google::protobuf.internal::TypeDefinedMapFieldBase::MapBegin
void MapBegin(MapIterator *map_iter) const override
Definition: map_field_inl.h:114
NULL
NULL
Definition: test_security_zap.cpp:405
google::protobuf::int64
int64_t int64
Definition: protobuf/src/google/protobuf/stubs/port.h:151
google::protobuf.internal::MapFieldBase::mutex_
internal::WrappedMutex mutex_
Definition: map_field.h:151
google::protobuf.internal::MapField::NewEntry
EntryType * NewEntry() const
Definition: map_field.h:273
google::protobuf.internal::MapField::SyncRepeatedFieldWithMapNoLock
void SyncRepeatedFieldWithMapNoLock() const override
Definition: map_field_inl.h:279
GOOGLE_PROTOBUF_HASH_NAMESPACE_DECLARATION_END
#define GOOGLE_PROTOBUF_HASH_NAMESPACE_DECLARATION_END
Definition: hash.h:45
google::protobuf.internal.python_message.MergeFrom
MergeFrom
Definition: python_message.py:1340
google::protobuf.internal::MapField
Definition: map.h:78
google::protobuf::FieldDescriptor::CPPTYPE_UINT64
@ CPPTYPE_UINT64
Definition: src/google/protobuf/descriptor.h:557
google::protobuf::MapKey::GetUInt64Value
uint64 GetUInt64Value() const
Definition: map_field.h:424
google::protobuf::MapValueRef::GetUInt32Value
uint32 GetUInt32Value() const
Definition: map_field.h:619
FATAL
const int FATAL
Definition: log_severity.h:60
google::protobuf::MapKey::SetUInt64Value
void SetUInt64Value(uint64 value)
Definition: map_field.h:399
google::protobuf::MapKey::SetStringValue
void SetStringValue(const std::string &val)
Definition: map_field.h:415
arena_
std::unique_ptr< Arena > arena_
Definition: lite_arena_unittest.cc:51
google::protobuf::MapIterator::MapIterator
MapIterator(const MapIterator &other)
Definition: map_field.h:721
benchmarks.util.result_uploader.metadata
def metadata
Definition: result_uploader.py:97
google::protobuf::python::cmessage::CopyFrom
static PyObject * CopyFrom(CMessage *self, PyObject *arg)
Definition: python/google/protobuf/pyext/message.cc:1861
google::protobuf::MapIterator::operator++
MapIterator operator++(int)
Definition: map_field.h:742
google::protobuf::FieldDescriptor::CPPTYPE_INT64
@ CPPTYPE_INT64
Definition: src/google/protobuf/descriptor.h:555
google::protobuf::MapKey::GetInt32Value
int32 GetInt32Value() const
Definition: map_field.h:428
google::protobuf::FieldDescriptor::CPPTYPE_UINT32
@ CPPTYPE_UINT32
Definition: src/google/protobuf/descriptor.h:556
google::protobuf::MapValueRef::GetBoolValue
bool GetBoolValue() const
Definition: map_field.h:623
google::protobuf::MapValueRef::type_
int type_
Definition: map_field.h:707
google::protobuf::MapIterator::~MapIterator
~MapIterator()
Definition: map_field.h:726
google::protobuf::uint32
uint32_t uint32
Definition: protobuf/src/google/protobuf/stubs/port.h:155
google::protobuf::MapKey::~MapKey
~MapKey()
Definition: map_field.h:380
google::protobuf.internal::ParseContext
Definition: parse_context.h:322
google::protobuf.internal::MapField::DeleteMapValue
bool DeleteMapValue(const MapKey &map_key) override
Definition: map_field_inl.h:243
google::protobuf.internal::MapField::InternalArenaConstructable_
void InternalArenaConstructable_
Definition: map_field.h:299
google::protobuf::MapKey::GetUInt32Value
uint32 GetUInt32Value() const
Definition: map_field.h:432
google::protobuf.internal::MapField::GOOGLE_DISALLOW_EVIL_CONSTRUCTORS
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MapField)
google::protobuf.internal::MapField::GetMap
const Map< Key, T > & GetMap() const override
Definition: map_field.h:254
map_type_handler.h
google::protobuf::MapIterator::iter_
void * iter_
Definition: map_field.h:770
google::protobuf.internal::TypeDefinedMapFieldBase
Definition: map.h:81
generated_message_reflection.h
string
GLsizei const GLchar *const * string
Definition: glcorearb.h:3083
Value
Definition: struct.pb.h:304
google::protobuf.internal::DynamicMapField
Definition: map_field.h:324
google::protobuf.internal::MapField::kIsValueEnum
static const bool kIsValueEnum
Definition: map_field.h:238
google::protobuf::MapValueRef::GetDoubleValue
double GetDoubleValue() const
Definition: map_field.h:639
google::protobuf::Reflection
Definition: src/google/protobuf/message.h:400
google::protobuf::MapValueRef::GetMessageValue
const Message & GetMessageValue() const
Definition: map_field.h:644
google::protobuf::HANDLE_TYPE
HANDLE_TYPE(int32, FieldDescriptor::CPPTYPE_INT32, -1)
google::protobuf::MapKey::SetType
void SetType(FieldDescriptor::CppType type)
Definition: map_field.h:549
port.h
google::protobuf.internal::MapField::_InternalParse
const char * _InternalParse(const char *ptr, ParseContext *ctx)
Definition: map_field.h:285
google::protobuf::MapKey::MapKey
MapKey()
Definition: map_field.h:373
T
#define T(upbtypeconst, upbtype, ctype, default_value)
google::protobuf.internal::MapFieldLite::GetMap
const Map< Key, T > & GetMap() const
Definition: map_field_lite.h:73
google::protobuf::MapIterator::MutableValueRef
MapValueRef * MutableValueRef()
Definition: map_field.h:751
google::protobuf.internal::TypeDefinedMapFieldBase::DeleteIterator
void DeleteIterator(MapIterator *map_iter) const override
Definition: map_field_inl.h:145
google::protobuf::MapValueRef::SetUInt32Value
void SetUInt32Value(uint32 value)
Definition: map_field.h:581
google::protobuf.internal::TypeDefinedMapFieldBase::IncreaseIterator
void IncreaseIterator(MapIterator *map_iter) const override
Definition: map_field_inl.h:131
google::protobuf::MapValueRef::GetInt32Value
int32 GetInt32Value() const
Definition: map_field.h:615
google::protobuf::MapKey::KeyValue
Definition: map_field.h:539
google::protobuf.internal::MapFieldLite::_InternalParse
const char * _InternalParse(const char *ptr, ParseContext *ctx)
Definition: map_field_lite.h:112
google::protobuf::MapIterator::key_
MapKey key_
Definition: map_field.h:774
google::protobuf.internal::MapFieldBase::InitializeIterator
virtual void InitializeIterator(MapIterator *map_iter) const =0
google::protobuf::MapValueRef::CopyFrom
void CopyFrom(const MapValueRef &other)
Definition: map_field.h:678
google::protobuf::MapKey::type
FieldDescriptor::CppType type() const
Definition: map_field.h:386
b
GLboolean GLboolean GLboolean b
Definition: glcorearb.h:3228
google::protobuf.internal::MapField::InsertOrLookupMapValue
bool InsertOrLookupMapValue(const MapKey &map_key, MapValueRef *val) override
Definition: map_field_inl.h:222
google::protobuf::MapKey::KeyValue::int64_value_
int64 int64_value_
Definition: map_field.h:542
google::protobuf::MapValueRef::GetUInt64Value
uint64 GetUInt64Value() const
Definition: map_field.h:611
google::protobuf::int32
int32_t int32
Definition: protobuf/src/google/protobuf/stubs/port.h:150
map_entry.h
google::protobuf::MapKey::CopyFrom
void CopyFrom(const MapKey &other)
Definition: map_field.h:503
google::protobuf.internal::MapField::EntryType
Derived EntryType
Definition: map_field.h:227
google::protobuf::MapKey::KeyValue::bool_value_
bool bool_value_
Definition: map_field.h:546
unknown_field_set.h
google::protobuf::MapValueRef::GetStringValue
const std::string & GetStringValue() const
Definition: map_field.h:631
val_
T * val_
Definition: gmock-matchers_test.cc:3778
google::protobuf::python::GetMap
static MapContainer * GetMap(PyObject *obj)
Definition: map_container.cc:307
google::protobuf.internal::MapField::SyncMapWithRepeatedFieldNoLock
void SyncMapWithRepeatedFieldNoLock() const override
Definition: map_field_inl.h:316
google::protobuf.internal::ToIntSize
int ToIntSize(size_t size)
Definition: message_lite.h:104
google::protobuf.internal::MapField::EntryTypeTrait
Derived::SuperType EntryTypeTrait
Definition: map_field.h:242
google::protobuf.internal::MapField::SetMapIteratorValue
void SetMapIteratorValue(MapIterator *map_iter) const override
Definition: map_field_inl.h:197
google::protobuf.internal::MapField::MergeFrom
void MergeFrom(const MapFieldBase &other) override
Definition: map_field_inl.h:252
GOOGLE_PROTOBUF_HASH_NAMESPACE_DECLARATION_START
#define GOOGLE_PROTOBUF_HASH_NAMESPACE_DECLARATION_START
Definition: hash.h:42
google::protobuf::MapValueRef::SetFloatValue
void SetFloatValue(float value)
Definition: map_field.h:598
google::protobuf::MapKey::type_
int type_
Definition: map_field.h:561
google::protobuf::MapValueRef::SetType
void SetType(FieldDescriptor::CppType type)
Definition: map_field.h:668
google::protobuf.internal::MapFieldBase::repeated_field_
RepeatedPtrField< Message > * repeated_field_
Definition: map_field.h:148
google::protobuf::MapKey::GetInt64Value
int64 GetInt64Value() const
Definition: map_field.h:420
google::protobuf::MapIterator::operator=
MapIterator & operator=(const MapIterator &other)
Definition: map_field.h:727
google::protobuf::MapIterator::operator!=
friend bool operator!=(const MapIterator &a, const MapIterator &b)
Definition: map_field.h:735
google::protobuf.internal::MapField::Swap
void Swap(MapFieldBase *other) override
Definition: map_field_inl.h:264
google::protobuf::MapKey::KeyValue::uint64_value_
uint64 uint64_value_
Definition: map_field.h:544
google::protobuf.internal::MapFieldBase::SetMapDirty
void SetMapDirty()
Definition: map_field.cc:84
google::protobuf::MapValueRef::type
FieldDescriptor::CppType type() const
Definition: map_field.h:670
google::protobuf::MapValueRef::SetEnumValue
void SetEnumValue(int value)
Definition: map_field.h:590
google::protobuf.internal::MapTypeHandler
Definition: map_type_handler.h:144
google::protobuf.internal::TypeDefinedMapFieldBase::SetMapIteratorValue
virtual void SetMapIteratorValue(MapIterator *map_iter) const =0
google::protobuf.internal::TypeDefinedMapFieldBase::InitializeIterator
void InitializeIterator(MapIterator *map_iter) const override
Definition: map_field_inl.h:138
google::protobuf::MapKey::operator=
MapKey & operator=(const MapKey &other)
Definition: map_field.h:375
google::protobuf.internal::TypeDefinedMapFieldBase::TypeDefinedMapFieldBase
TypeDefinedMapFieldBase(Arena *arena)
Definition: map_field.h:190
message.h
google::protobuf.internal::TypeDefinedMapFieldBase::~TypeDefinedMapFieldBase
~TypeDefinedMapFieldBase() override
Definition: map_field.h:191
GOOGLE_LOG
#define GOOGLE_LOG(LEVEL)
Definition: logging.h:146
mutex_
internal::WrappedMutex mutex_
Definition: src/google/protobuf/message.cc:579
google::protobuf::MapValueRef::SetUInt64Value
void SetUInt64Value(uint64 value)
Definition: map_field.h:573
google::protobuf.internal::MapFieldBase::arena_
Arena * arena_
Definition: map_field.h:147
google::protobuf.internal::MapField::KeyTypeHandler
MapTypeHandler< kKeyFieldType, Key > KeyTypeHandler
Definition: map_field.h:223
google::protobuf::MapIterator::MapIterator
MapIterator(Message *message, const FieldDescriptor *field)
Definition: map_field.h:714
google::protobuf::MapValueRef::SetInt32Value
void SetInt32Value(int32 value)
Definition: map_field.h:577
google::protobuf::uint64
uint64_t uint64
Definition: protobuf/src/google/protobuf/stubs/port.h:156
size
#define size
Definition: glcorearb.h:2944
repeated_field.h
hash<::PROTOBUF_NAMESPACE_ID::MapKey >::operator()
size_t operator()(const ::PROTOBUF_NAMESPACE_ID::MapKey &map_key) const
Definition: map_field.h:784
google::protobuf.internal::TypeDefinedMapFieldBase::MutableMap
virtual Map< Key, T > * MutableMap()=0
google::protobuf.internal::WireFormatLite::FieldType
FieldType
Definition: wire_format_lite.h:111
google::protobuf::MapKey::KeyValue::int32_value_
int32 int32_value_
Definition: map_field.h:543
google::protobuf::MapKey::MapKey
MapKey(const MapKey &other)
Definition: map_field.h:374
google::protobuf::MapValueRef::GetInt64Value
int64 GetInt64Value() const
Definition: map_field.h:607
google::protobuf::MapKey::KeyValue::uint32_value_
uint32 uint32_value_
Definition: map_field.h:545
google::protobuf::MapKey::operator==
bool operator==(const MapKey &other) const
Definition: map_field.h:474
google::protobuf::DynamicMessage
Definition: dynamic_message.cc:232
google::protobuf::MapKey::SetInt64Value
void SetInt64Value(int64 value)
Definition: map_field.h:395
field
const FieldDescriptor * field
Definition: parser_unittest.cc:2694
google::protobuf.internal::MapEntryToMapField
Definition: map_field_lite.h:173
key
const SETUP_TEARDOWN_TESTCONTEXT char * key
Definition: test_wss_transport.cpp:10
google::protobuf::FieldDescriptor::CPPTYPE_DOUBLE
@ CPPTYPE_DOUBLE
Definition: src/google/protobuf/descriptor.h:558
google::protobuf::MapKey::KeyValue::KeyValue
KeyValue()
Definition: map_field.h:540
google::protobuf.internal::MapFieldLite::ParseWithEnumValidation
const char * ParseWithEnumValidation(const char *ptr, ParseContext *ctx, bool(*is_valid)(int), uint32 field_num, Metadata *metadata)
Definition: map_field_lite.h:118
google::protobuf.internal::TypeDefinedMapFieldBase::GetMap
virtual const Map< Key, T > & GetMap() const =0
google::protobuf.internal::MapFieldBase::MapFieldBase
MapFieldBase()
Definition: map_field.h:71
google::protobuf::MapIterator::value_
MapValueRef value_
Definition: map_field.h:775
google::protobuf::MapValueRef::SetInt64Value
void SetInt64Value(int64 value)
Definition: map_field.h:569
google::protobuf.internal::MapFieldBase::MapFieldBase
MapFieldBase(Arena *arena)
Definition: map_field.h:73
google::protobuf::Metadata
Definition: src/google/protobuf/message.h:190
google::protobuf.internal::MapEntry
Definition: map_entry.h:95
google::protobuf::MapKey::SetInt32Value
void SetInt32Value(int32 value)
Definition: map_field.h:403
value_
int value_
Definition: gmock-matchers_test.cc:571
google::protobuf::FieldDescriptor::CPPTYPE_FLOAT
@ CPPTYPE_FLOAT
Definition: src/google/protobuf/descriptor.h:559
type
GLenum type
Definition: glcorearb.h:2695
google::protobuf::FieldDescriptor::CPPTYPE_BOOL
@ CPPTYPE_BOOL
Definition: src/google/protobuf/descriptor.h:560
google::protobuf::MapValueRef::DeleteData
void DeleteData()
Definition: map_field.h:683
google::protobuf::Message
Definition: src/google/protobuf/message.h:205
google::protobuf.internal::MapField::NewEnumEntryWrapper
EntryType * NewEnumEntryWrapper(const Key &key, const T t) const
Definition: map_field.h:276
google::protobuf::MapKey::KeyValue::string_value_
std::string * string_value_
Definition: map_field.h:541
google::protobuf.internal::TypeDefinedMapFieldBase::CopyIterator
void CopyIterator(MapIterator *this_iteratorm, const MapIterator &that_iterator) const override
Definition: map_field_inl.h:152
State
Definition: demangle.cc:151
google::protobuf::MapKey::val_
union google::protobuf::MapKey::KeyValue val_
google::protobuf.internal::MapField::ValueTypeHandler
MapTypeHandler< kValueFieldType, T > ValueTypeHandler
Definition: map_field.h:224
google::protobuf::MapValueRef::GetFloatValue
float GetFloatValue() const
Definition: map_field.h:635
google::protobuf.internal.python_message.Clear
Clear
Definition: python_message.py:1431
google::protobuf.internal::DynamicMapField::default_entry_
const Message * default_entry_
Definition: map_field.h:346
google::protobuf.internal::MapField::impl_
MapFieldLiteType impl_
Definition: map_field.h:297
google::protobuf::MapIterator::GetKey
const MapKey & GetKey()
Definition: map_field.h:749
google::protobuf.internal::TypeDefinedMapFieldBase::TypeDefinedMapFieldBase
TypeDefinedMapFieldBase()
Definition: map_field.h:189
google::protobuf::MapValueRef::MapValueRef
MapValueRef()
Definition: map_field.h:567
google::protobuf.internal::MapField::CastValueType
MapIf< kIsValueEnum, T, const T & >::type CastValueType
Definition: map_field.h:239
google::protobuf.internal::MapFieldLite::NewEnumEntryWrapper
EntryType * NewEnumEntryWrapper(const Key &key, const T t) const
Definition: map_field_lite.h:103
google::protobuf::MapKey
Definition: map_field.h:371
arena.h
google::protobuf::MapKey::GetStringValue
const std::string & GetStringValue() const
Definition: map_field.h:440
google::protobuf::MapValueRef::SetValue
void SetValue(const void *val)
Definition: map_field.h:677
google::protobuf.internal::MapField::DestructorSkippable_
void DestructorSkippable_
Definition: map_field.h:300
google::protobuf.internal::MapFieldBase::SyncMapWithRepeatedFieldNoLock
virtual void SyncMapWithRepeatedFieldNoLock() const
Definition: map_field.h:128
google::protobuf::MapValueRef::SetDoubleValue
void SetDoubleValue(double value)
Definition: map_field.h:602
google::protobuf.internal::MapFieldBase::SyncMapWithRepeatedField
void SyncMapWithRepeatedField() const
Definition: map_field.cc:137
descriptor.h
google::protobuf.internal::MapFieldStateTest
Definition: map_field_test.cc:201
google::protobuf.internal::MapField::Clear
void Clear() override
Definition: map_field_inl.h:178
google::protobuf::MapValueRef::SetStringValue
void SetStringValue(const std::string &value)
Definition: map_field.h:594
google::protobuf.internal::MapField::size
int size() const override
Definition: map_field_inl.h:169
google::protobuf.internal::MapField::MutableMap
Map< Key, T > * MutableMap() override
Definition: map_field.h:259
google::protobuf.internal::RepeatedPtrFieldBase
Definition: repeated_field.h:459
google::protobuf.internal::MapFieldBase::SpaceUsedExcludingSelf
int SpaceUsedExcludingSelf() const
Definition: map_field.h:112
google::protobuf.internal::MapField::ContainsMapKey
bool ContainsMapKey(const MapKey &map_key) const override
Definition: map_field_inl.h:211
mutex.h
google::protobuf.internal::TypeDefinedMapFieldBase::InternalGetIterator
Map< Key, T >::const_iterator & InternalGetIterator(const MapIterator *map_iter) const
Definition: map_field_inl.h:107
google::protobuf.internal::MapEntryToMapField< MapEntry< T, Key, Value, kKeyFieldType, kValueFieldType, default_enum_value > >::MapFieldType
MapField< T, Key, Value, kKeyFieldType, kValueFieldType, default_enum_value > MapFieldType
Definition: map_field.h:321
google::protobuf::Map
Definition: map.h:62
internal
Definition: any.pb.h:40
google::protobuf.internal::MapFieldBase
Definition: map_field.h:69
google::protobuf.internal::DynamicMapField::map_
Map< MapKey, MapValueRef > map_
Definition: map_field.h:345
google::protobuf::MapIterator::operator++
MapIterator & operator++()
Definition: map_field.h:738
google::protobuf.internal::TypeDefinedMapFieldBase::MapEnd
void MapEnd(MapIterator *map_iter) const override
Definition: map_field_inl.h:120
val
GLuint GLfloat * val
Definition: glcorearb.h:3604
google::protobuf::MapIterator::operator==
friend bool operator==(const MapIterator &a, const MapIterator &b)
Definition: map_field.h:732
google::protobuf.internal::TypeDefinedMapFieldBase::GOOGLE_DISALLOW_EVIL_CONSTRUCTORS
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(TypeDefinedMapFieldBase)
value
GLsizei const GLfloat * value
Definition: glcorearb.h:3093
google::protobuf.internal::MapFieldAccessor
Definition: reflection_internal.h:202
google::protobuf::MapKey::SetBoolValue
void SetBoolValue(bool value)
Definition: map_field.h:411
google::protobuf::FieldDescriptor::CPPTYPE_MESSAGE
@ CPPTYPE_MESSAGE
Definition: src/google/protobuf/descriptor.h:563
google::protobuf::MapKey::GetBoolValue
bool GetBoolValue() const
Definition: map_field.h:436
google::protobuf::MapIterator
Definition: map_field.h:712
google::protobuf::FieldDescriptor::CPPTYPE_INT32
@ CPPTYPE_INT32
Definition: src/google/protobuf/descriptor.h:554
google::protobuf.internal::MapField::SpaceUsedExcludingSelfNoLock
size_t SpaceUsedExcludingSelfNoLock() const override
Definition: map_field_inl.h:339
google::protobuf.internal::MapFieldLite::NewEntryWrapper
EntryType * NewEntryWrapper(const Key &key, const T &t) const
Definition: map_field_lite.h:108
google::protobuf.internal::MapField::NewEntryWrapper
EntryType * NewEntryWrapper(const Key &key, const T &t) const
Definition: map_field.h:281
google::protobuf.internal::MapFieldBase::state_
std::atomic< State > state_
Definition: map_field.h:153
google::protobuf::MapValueRef::GetEnumValue
int GetEnumValue() const
Definition: map_field.h:627
a
GLboolean GLboolean GLboolean GLboolean a
Definition: glcorearb.h:3228
google::protobuf::MapKey::SetUInt32Value
void SetUInt32Value(uint32 value)
Definition: map_field.h:407
google::protobuf.internal::MapFieldLite::NewEntry
EntryType * NewEntry() const
Definition: map_field_lite.h:94
google::protobuf::FieldDescriptor::CppType
CppType
Definition: src/google/protobuf/descriptor.h:553
google
Definition: data_proto2_to_proto3_util.h:11
message
GLenum GLuint GLenum GLsizei const GLchar * message
Definition: glcorearb.h:2695
google::protobuf::MapValueRef::data_
void * data_
Definition: map_field.h:705
google::protobuf::MapIterator::map_
internal::MapFieldBase * map_
Definition: map_field.h:773
google::protobuf.internal::MapField::MapFieldLiteType
MapFieldLite< Derived, Key, T, kKeyFieldType, kValueFieldType, default_enum_value > MapFieldLiteType
Definition: map_field.h:232
google::protobuf.internal::MapFieldBase::CopyIterator
virtual void CopyIterator(MapIterator *this_iterator, const MapIterator &other_iterator) const =0
map_field_lite.h
google::protobuf::MapValueRef::MutableMessageValue
Message * MutableMessageValue()
Definition: map_field.h:650
google::protobuf::MapValueRef
Definition: map_field.h:565
Value
struct Value Value
Definition: php/ext/google/protobuf/protobuf.h:667
google::protobuf.internal::MapField::ParseWithEnumValidation
const char * ParseWithEnumValidation(const char *ptr, ParseContext *ctx, bool(*is_valid)(int), uint32 field_num, Metadata *metadata)
Definition: map_field.h:289


libaditof
Author(s):
autogenerated on Wed May 21 2025 02:06:56