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

Side by Side Diff: third_party/protobuf/src/google/protobuf/stubs/map_util.h

Issue 2495533002: third_party/protobuf: Update to HEAD (83d681ee2c) (Closed)
Patch Set: Make chrome settings proto generated file a component 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 2014 Google Inc. All rights reserved. 2 // Copyright 2014 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 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 // we do not need a version of this function taking a non const collection. 201 // we do not need a version of this function taking a non const collection.
202 return it->second.get(); 202 return it->second.get();
203 } 203 }
204 204
205 // Same as above, but dies if the key is not found. 205 // Same as above, but dies if the key is not found.
206 template <class Collection> 206 template <class Collection>
207 typename Collection::value_type::second_type::element_type& 207 typename Collection::value_type::second_type::element_type&
208 FindLinkedPtrOrDie(const Collection& collection, 208 FindLinkedPtrOrDie(const Collection& collection,
209 const typename Collection::value_type::first_type& key) { 209 const typename Collection::value_type::first_type& key) {
210 typename Collection::const_iterator it = collection.find(key); 210 typename Collection::const_iterator it = collection.find(key);
211 CHECK(it != collection.end()) << "key not found: " << key; 211 GOOGLE_CHECK(it != collection.end()) << "key not found: " << key;
212 // Since linked_ptr::operator*() is a const member returning a non const, 212 // Since linked_ptr::operator*() is a const member returning a non const,
213 // we do not need a version of this function taking a non const collection. 213 // we do not need a version of this function taking a non const collection.
214 return *it->second; 214 return *it->second;
215 } 215 }
216 216
217 // Finds the value associated with the given key and copies it to *value (if not 217 // Finds the value associated with the given key and copies it to *value (if not
218 // NULL). Returns false if the key was not found, true otherwise. 218 // NULL). Returns false if the key was not found, true otherwise.
219 template <class Collection, class Key, class Value> 219 template <class Collection, class Key, class Value>
220 bool FindCopy(const Collection& collection, 220 bool FindCopy(const Collection& collection,
221 const Key& key, 221 const Key& key,
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 const typename Collection::value_type::first_type& key, 330 const typename Collection::value_type::first_type& key,
331 const typename Collection::value_type::second_type& value) { 331 const typename Collection::value_type::second_type& value) {
332 return InsertIfNotPresent( 332 return InsertIfNotPresent(
333 collection, typename Collection::value_type(key, value)); 333 collection, typename Collection::value_type(key, value));
334 } 334 }
335 335
336 // Same as above except dies if the key already exists in the collection. 336 // Same as above except dies if the key already exists in the collection.
337 template <class Collection> 337 template <class Collection>
338 void InsertOrDie(Collection* const collection, 338 void InsertOrDie(Collection* const collection,
339 const typename Collection::value_type& value) { 339 const typename Collection::value_type& value) {
340 CHECK(InsertIfNotPresent(collection, value)) << "duplicate value: " << value; 340 GOOGLE_CHECK(InsertIfNotPresent(collection, value))
341 << "duplicate value: " << value;
341 } 342 }
342 343
343 // Same as above except doesn't log the value on error. 344 // Same as above except doesn't log the value on error.
344 template <class Collection> 345 template <class Collection>
345 void InsertOrDieNoPrint(Collection* const collection, 346 void InsertOrDieNoPrint(Collection* const collection,
346 const typename Collection::value_type& value) { 347 const typename Collection::value_type& value) {
347 CHECK(InsertIfNotPresent(collection, value)) << "duplicate value."; 348 GOOGLE_CHECK(InsertIfNotPresent(collection, value)) << "duplicate value.";
348 } 349 }
349 350
350 // Inserts the key-value pair into the collection. Dies if key was already 351 // Inserts the key-value pair into the collection. Dies if key was already
351 // present. 352 // present.
352 template <class Collection> 353 template <class Collection>
353 void InsertOrDie(Collection* const collection, 354 void InsertOrDie(Collection* const collection,
354 const typename Collection::value_type::first_type& key, 355 const typename Collection::value_type::first_type& key,
355 const typename Collection::value_type::second_type& data) { 356 const typename Collection::value_type::second_type& data) {
356 GOOGLE_CHECK(InsertIfNotPresent(collection, key, data)) 357 GOOGLE_CHECK(InsertIfNotPresent(collection, key, data))
357 << "duplicate key: " << key; 358 << "duplicate key: " << key;
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after
760 for (typename MapContainer::const_iterator it = map_container.begin(); 761 for (typename MapContainer::const_iterator it = map_container.begin();
761 it != map_container.end(); ++it) { 762 it != map_container.end(); ++it) {
762 value_container->push_back(it->second); 763 value_container->push_back(it->second);
763 } 764 }
764 } 765 }
765 766
766 } // namespace protobuf 767 } // namespace protobuf
767 } // namespace google 768 } // namespace google
768 769
769 #endif // GOOGLE_PROTOBUF_STUBS_MAP_UTIL_H__ 770 #endif // GOOGLE_PROTOBUF_STUBS_MAP_UTIL_H__
OLDNEW
« no previous file with comments | « third_party/protobuf/src/google/protobuf/stubs/int128.cc ('k') | third_party/protobuf/src/google/protobuf/stubs/mathlimits.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698