31 #ifndef GOOGLE_PROTOBUF_MAP_FIELD_INL_H__ 32 #define GOOGLE_PROTOBUF_MAP_FIELD_INL_H__ 51 return map_key.GetInt32Value();
55 return map_key.GetUInt32Value();
59 return map_key.GetInt64Value();
63 return map_key.GetUInt64Value();
67 return map_key.GetBoolValue();
71 return map_key.GetStringValue();
79 map_key->SetInt32Value(value);
83 map_key->SetUInt32Value(value);
87 map_key->SetInt64Value(value);
91 map_key->SetUInt64Value(value);
95 map_key->SetBoolValue(value);
99 map_key->SetStringValue(value);
103 template <
typename Key,
typename T>
111 template <
typename Key,
typename T>
113 InternalGetIterator(map_iter) = GetMap().begin();
114 SetMapIteratorValue(map_iter);
117 template <
typename Key,
typename T>
119 InternalGetIterator(map_iter) = GetMap().end();
122 template <
typename Key,
typename T>
126 return InternalGetIterator(&a) == InternalGetIterator(&b);
129 template <
typename Key,
typename T>
132 ++InternalGetIterator(map_iter);
133 SetMapIteratorValue(map_iter);
136 template <
typename Key,
typename T>
143 template <
typename Key,
typename T>
150 template <
typename Key,
typename T>
154 InternalGetIterator(this_iter) = InternalGetIterator(&that_iter);
155 this_iter->key_.SetType(that_iter.key_.
type());
158 this_iter->value_.SetType(
159 static_cast<FieldDescriptor::CppType>(that_iter.value_.type_));
160 SetMapIteratorValue(this_iter);
165 template <
typename Key,
typename T,
168 int default_enum_value>
170 : default_entry_(
NULL) {}
172 template <
typename Key,
typename T,
175 int default_enum_value>
179 MapFieldLite<
Key, T, kKeyFieldType, kValueFieldType, default_enum_value>(
181 default_entry_(
NULL) {}
183 template <
typename Key,
typename T,
186 int default_enum_value>
191 template <
typename Key,
typename T,
194 int default_enum_value>
198 MapFieldLite<
Key, T, kKeyFieldType, kValueFieldType, default_enum_value>(
202 template <
typename Key,
typename T,
205 int default_enum_value>
207 default_enum_value>::~MapField() {}
209 template <
typename Key,
typename T,
212 int default_enum_value>
216 MapFieldBase::SyncMapWithRepeatedField();
217 return MapFieldLiteType::GetInternalMap().size();
220 template <
typename Key,
typename T,
223 int default_enum_value>
227 MapFieldBase::SyncMapWithRepeatedField();
228 MapFieldLiteType::MutableInternalMap()->clear();
229 MapFieldBase::SetMapDirty();
232 template <
typename Key,
typename T,
235 int default_enum_value>
237 default_enum_value>::SetMapIteratorValue(
242 if (iter == map.
end())
return;
244 map_iter->value_.SetValue(&iter->
second);
247 template <
typename Key,
typename T,
250 int default_enum_value>
252 default_enum_value>::ContainsMapKey(
253 const MapKey& map_key)
const {
255 const Key&
key = UnwrapMapKey<Key>(map_key);
257 return iter != map.
end();
260 template <
typename Key,
typename T,
263 int default_enum_value>
265 default_enum_value>::InsertOrLookupMapValue(
271 const Key&
key = UnwrapMapKey<Key>(map_key);
273 if (map->
end() == iter) {
274 val->SetValue(&((*map)[key]));
279 val->SetValue(&(iter->second));
283 template <
typename Key,
typename T,
286 int default_enum_value>
288 default_enum_value>::DeleteMapValue(
290 const Key&
key = UnwrapMapKey<Key>(map_key);
291 return MutableMap()->erase(key);
294 template <
typename Key,
typename T,
297 int default_enum_value>
300 default_enum_value>::GetMap()
const {
301 MapFieldBase::SyncMapWithRepeatedField();
302 return MapFieldLiteType::GetInternalMap();
305 template <
typename Key,
typename T,
308 int default_enum_value>
311 default_enum_value>::MutableMap() {
312 MapFieldBase::SyncMapWithRepeatedField();
314 MapFieldBase::SetMapDirty();
318 template <
typename Key,
typename T,
321 int default_enum_value>
327 MapFieldBase::SyncMapWithRepeatedField();
330 MapFieldBase::SetMapDirty();
333 template <
typename Key,
typename T,
336 int default_enum_value>
339 default_enum_value>::Swap(
343 MapFieldLiteType::Swap(other);
347 template <
typename Key,
typename T,
350 int default_enum_value>
353 default_enum_value>::SetEntryDescriptor(
358 template <
typename Key,
typename T,
361 int default_enum_value>
364 default_enum_value>::SetAssignDescriptorCallback(
void (*
callback)()) {
365 MapFieldBase::assign_descriptor_callback_ =
callback;
368 template <
typename Key,
typename T,
371 int default_enum_value>
374 default_enum_value>::GetInternalMap()
const {
375 return MapFieldLiteType::GetInternalMap();
378 template <
typename Key,
typename T,
381 int default_enum_value>
384 default_enum_value>::MutableInternalMap() {
385 return MapFieldLiteType::MutableInternalMap();
388 template <
typename Key,
typename T,
391 int default_enum_value>
394 default_enum_value>::SyncRepeatedFieldWithMapNoLock()
const {
395 if (MapFieldBase::repeated_field_ ==
NULL) {
396 if (MapFieldBase::arena_ ==
NULL) {
399 MapFieldBase::repeated_field_ =
400 Arena::CreateMessage<RepeatedPtrField<Message> >(
401 MapFieldBase::arena_);
407 MapFieldBase::repeated_field_);
409 repeated_field->
Clear();
412 it != map.end(); ++it) {
413 InitDefaultEntryOnce();
417 repeated_field->AddAllocated(new_entry);
423 template <
typename Key,
typename T,
426 int default_enum_value>
429 default_enum_value>::SyncMapWithRepeatedFieldNoLock()
const {
433 MapFieldBase::repeated_field_);
437 repeated_field->begin(); it != repeated_field->end(); ++it) {
443 (*map)[it->key()] =
static_cast<CastValueType
>(it->value());
447 template <
typename Key,
typename T,
450 int default_enum_value>
453 default_enum_value>::SpaceUsedExcludingSelfNoLock()
const {
455 if (MapFieldBase::repeated_field_ !=
NULL) {
456 size += MapFieldBase::repeated_field_->SpaceUsedExcludingSelf();
459 size +=
sizeof(*map);
461 it != map->
end(); ++it) {
462 size += KeyTypeHandler::SpaceUsedInMap(it->first);
463 size += ValueTypeHandler::SpaceUsedInMap(it->second);
468 template <
typename Key,
typename T,
471 int default_enum_value>
474 default_enum_value>::InitDefaultEntryOnce()
476 if (default_entry_ ==
NULL) {
477 MapFieldBase::InitMetadataOnce();
480 MessageFactory::generated_factory()->GetPrototype(
481 *MapFieldBase::entry_descriptor_));
489 #endif // GOOGLE_PROTOBUF_MAP_FIELD_INL_H__ uint64 UnwrapMapKey< uint64 >(const MapKey &map_key)
Definition: map_field_inl.h:62
void SetMapKey< bool >(MapKey *map_key, const bool &value)
Definition: map_field_inl.h:94
void MapBegin(MapIterator *map_iter) const
Definition: map_field_inl.h:112
#define size
Definition: float-mm.c:27
Definition: message.h:179
EGLStreamKHR EGLint EGLint EGLint size
Definition: eglext.h:984
void SetMapKey< string >(MapKey *map_key, const string &value)
Definition: map_field_inl.h:98
void MapEnd(MapIterator *map_iter) const
Definition: map_field_inl.h:118
iterator begin()
Definition: map.h:1475
void SetMapKey(MapKey *map_key, const T &value)
KeyMapEntryAccessorType * mutable_key()
Definition: map_entry_lite.h:110
typename detail::make_map< Ts... >::type map
Definition: Brigand.h:223
AVCFAssetRef CFArrayRef AVCFAssetLoadValuesCompletionCallback callback
Definition: AVFoundationCFSoftLinking.h:99
const Descriptor * descriptor
Definition: descriptor.cc:271
iterator end()
Definition: map.h:1479
void SetMapKey< uint64 >(MapKey *map_key, const uint64 &value)
Definition: map_field_inl.h:90
FieldDescriptor::CppType type() const
Definition: map.h:111
Definition: command_line_interface.h:56
MapField()
Definition: map_field_inl.h:169
void Clear()
Definition: repeated_field.h:1934
Definition: descriptor.h:172
int32 UnwrapMapKey< int32 >(const MapKey &map_key)
Definition: map_field_inl.h:50
volatile Atomic32 state_
Definition: map_field.h:150
void clear()
Definition: map.h:1610
Clear
Definition: python_message.py:1326
const FieldDescriptor const OneofDescriptor value
Definition: descriptor.h:1717
Map< Key, T >::const_iterator & InternalGetIterator(const MapIterator *map_iter) const
Definition: map_field_inl.h:105
int32_t int32
Definition: port.h:130
TestSubObjConstructor T
Definition: TestTypedefs.idl:84
EGLAttrib * value
Definition: eglext.h:120
const_iterator find(const key_type &key) const
Definition: map.h:1528
T UnwrapMapKey(const MapKey &map_key)
uint32_t uint32
Definition: port.h:135
Definition: __init__.py:1
void SyncMapWithRepeatedField() const
Definition: map_field.cc:131
uint64_t uint64
Definition: port.h:136
GLboolean GLboolean GLboolean GLboolean a
Definition: gl2ext.h:306
T second
Definition: map.h:491
Definition: document.h:393
result
Definition: target-blank-opener-post-window.php:5
ValueMapEntryAccessorType * mutable_value()
Definition: map_entry_lite.h:114
bool UnwrapMapKey< bool >(const MapKey &map_key)
Definition: map_field_inl.h:66
#define GOOGLE_CHECK(EXPRESSION)
Definition: logging.h:151
int64_t int64
Definition: port.h:131
const
Definition: upload.py:398
#define NULL
Definition: common_types.h:41
Key
Definition: keyboard.h:10
RepeatedPtrField< Message > * repeated_field_
Definition: map_field.h:139
void SetMapKey< int32 >(MapKey *map_key, const int32 &value)
Definition: map_field_inl.h:78
GLboolean GLboolean GLboolean b
Definition: gl2ext.h:306
const Key first
Definition: map.h:490
Definition: gflags_completions.h:115
int64 UnwrapMapKey< int64 >(const MapKey &map_key)
Definition: map_field_inl.h:58
To down_cast(From *f)
Definition: casts.h:81
CFArrayRef CFTypeRef key
Definition: AVFoundationCFSoftLinking.h:129
void SetMapKey< uint32 >(MapKey *map_key, const uint32 &value)
Definition: map_field_inl.h:82
Definition: map_field.h:327
GLuint GLsizei GLsizei GLfloat * val
Definition: gl2ext.h:3301
void swap(optional< T > &x, optional< T > &y) __NOEXCEPT_(__NOEXCEPT_(x.swap(y)))
Definition: Optional.h:1047
string UnwrapMapKey< string >(const MapKey &map_key)
Definition: map_field_inl.h:70
uint32 UnwrapMapKey< uint32 >(const MapKey &map_key)
Definition: map_field_inl.h:54
MergeFrom
Definition: python_message.py:1259
#define T(a)
Definition: row_common.cc:1964
bool EqualIterator(const MapIterator &a, const MapIterator &b) const
Definition: map_field_inl.h:123
Definition: map_entry_lite.h:63
void SetMapKey< int64 >(MapKey *map_key, const int64 &value)
Definition: map_field_inl.h:86