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

Side by Side Diff: third_party/protobuf/src/google/protobuf/map_type_handler.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 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 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 static const WireFormatLite::WireType kWireType = 151 static const WireFormatLite::WireType kWireType =
152 MapWireFieldTypeTraits<WireFormatLite::TYPE_MESSAGE, Type>::kWireType; 152 MapWireFieldTypeTraits<WireFormatLite::TYPE_MESSAGE, Type>::kWireType;
153 // Whether wire type is for message. 153 // Whether wire type is for message.
154 static const bool kIsMessage = 154 static const bool kIsMessage =
155 MapWireFieldTypeTraits<WireFormatLite::TYPE_MESSAGE, Type>::kIsMessage; 155 MapWireFieldTypeTraits<WireFormatLite::TYPE_MESSAGE, Type>::kIsMessage;
156 // Whether wire type is for enum. 156 // Whether wire type is for enum.
157 static const bool kIsEnum = 157 static const bool kIsEnum =
158 MapWireFieldTypeTraits<WireFormatLite::TYPE_MESSAGE, Type>::kIsEnum; 158 MapWireFieldTypeTraits<WireFormatLite::TYPE_MESSAGE, Type>::kIsEnum;
159 159
160 // Functions used in parsing and serialization. =================== 160 // Functions used in parsing and serialization. ===================
161 static inline int ByteSize(const MapEntryAccessorType& value); 161 static inline size_t ByteSize(const MapEntryAccessorType& value);
162 static inline int GetCachedSize(const MapEntryAccessorType& value); 162 static inline int GetCachedSize(const MapEntryAccessorType& value);
163 static inline bool Read(io::CodedInputStream* input, 163 static inline bool Read(io::CodedInputStream* input,
164 MapEntryAccessorType* value); 164 MapEntryAccessorType* value);
165 static inline void Write(int field, const MapEntryAccessorType& value, 165 static inline void Write(int field, const MapEntryAccessorType& value,
166 io::CodedOutputStream* output); 166 io::CodedOutputStream* output);
167 static inline uint8* InternalWriteToArray(int field,
168 const MapEntryAccessorType& value,
169 bool deterministic, uint8* target);
167 static inline uint8* WriteToArray(int field, 170 static inline uint8* WriteToArray(int field,
168 const MapEntryAccessorType& value, 171 const MapEntryAccessorType& value,
169 uint8* output); 172 uint8* target);
170 173
171 // Functions to manipulate data on memory. ======================== 174 // Functions to manipulate data on memory. ========================
172 static inline const Type& GetExternalReference(const Type* value); 175 static inline const Type& GetExternalReference(const Type* value);
173 static inline void DeleteNoArena(const Type* x); 176 static inline void DeleteNoArena(const Type* x);
174 static inline void Merge(const Type& from, Type** to, Arena* arena); 177 static inline void Merge(const Type& from, Type** to, Arena* arena);
175 static inline void Clear(Type** value, Arena* arena); 178 static inline void Clear(Type** value, Arena* arena);
176 static inline void ClearMaybeByDefaultEnum(Type** value, Arena* arena, 179 static inline void ClearMaybeByDefaultEnum(Type** value, Arena* arena,
177 int default_enum_value); 180 int default_enum_value);
178 static inline void Initialize(Type** x, Arena* arena); 181 static inline void Initialize(Type** x, Arena* arena);
179 182
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 Type>::kIsMessage; \ 216 Type>::kIsMessage; \
214 static const bool kIsEnum = \ 217 static const bool kIsEnum = \
215 MapWireFieldTypeTraits<WireFormatLite::TYPE_##FieldType, \ 218 MapWireFieldTypeTraits<WireFormatLite::TYPE_##FieldType, \
216 Type>::kIsEnum; \ 219 Type>::kIsEnum; \
217 static inline int ByteSize(const MapEntryAccessorType& value); \ 220 static inline int ByteSize(const MapEntryAccessorType& value); \
218 static inline int GetCachedSize(const MapEntryAccessorType& value); \ 221 static inline int GetCachedSize(const MapEntryAccessorType& value); \
219 static inline bool Read(io::CodedInputStream* input, \ 222 static inline bool Read(io::CodedInputStream* input, \
220 MapEntryAccessorType* value); \ 223 MapEntryAccessorType* value); \
221 static inline void Write(int field, const MapEntryAccessorType& value, \ 224 static inline void Write(int field, const MapEntryAccessorType& value, \
222 io::CodedOutputStream* output); \ 225 io::CodedOutputStream* output); \
226 static inline uint8* InternalWriteToArray( \
227 int field, \
228 const MapEntryAccessorType& value, \
229 bool deterministic, \
230 uint8* target); \
223 static inline uint8* WriteToArray(int field, \ 231 static inline uint8* WriteToArray(int field, \
224 const MapEntryAccessorType& value, \ 232 const MapEntryAccessorType& value, \
225 uint8* output); \ 233 uint8* target) { \
234 return InternalWriteToArray(field, value, false, target); \
235 } \
226 static inline const MapEntryAccessorType& GetExternalReference( \ 236 static inline const MapEntryAccessorType& GetExternalReference( \
227 const TypeOnMemory& value); \ 237 const TypeOnMemory& value); \
228 static inline void DeleteNoArena(const TypeOnMemory& x); \ 238 static inline void DeleteNoArena(const TypeOnMemory& x); \
229 static inline void Merge(const MapEntryAccessorType& from, \ 239 static inline void Merge(const MapEntryAccessorType& from, \
230 TypeOnMemory* to, Arena* arena); \ 240 TypeOnMemory* to, Arena* arena); \
231 static inline void Clear(TypeOnMemory* value, Arena* arena); \ 241 static inline void Clear(TypeOnMemory* value, Arena* arena); \
232 static inline void ClearMaybeByDefaultEnum(TypeOnMemory* value, \ 242 static inline void ClearMaybeByDefaultEnum(TypeOnMemory* value, \
233 Arena* arena, \ 243 Arena* arena, \
234 int default_enum); \ 244 int default_enum); \
235 static inline int SpaceUsedInMapEntry(const TypeOnMemory& value); \ 245 static inline int SpaceUsedInMapEntry(const TypeOnMemory& value); \
(...skipping 23 matching lines...) Expand all
259 MAP_HANDLER(DOUBLE) 269 MAP_HANDLER(DOUBLE)
260 MAP_HANDLER(FLOAT) 270 MAP_HANDLER(FLOAT)
261 MAP_HANDLER(FIXED64) 271 MAP_HANDLER(FIXED64)
262 MAP_HANDLER(FIXED32) 272 MAP_HANDLER(FIXED32)
263 MAP_HANDLER(SFIXED64) 273 MAP_HANDLER(SFIXED64)
264 MAP_HANDLER(SFIXED32) 274 MAP_HANDLER(SFIXED32)
265 MAP_HANDLER(BOOL) 275 MAP_HANDLER(BOOL)
266 #undef MAP_HANDLER 276 #undef MAP_HANDLER
267 277
268 template <typename Type> 278 template <typename Type>
269 inline int 279 inline size_t
270 MapTypeHandler<WireFormatLite::TYPE_MESSAGE, Type>::ByteSize( 280 MapTypeHandler<WireFormatLite::TYPE_MESSAGE, Type>::ByteSize(
271 const MapEntryAccessorType& value) { 281 const MapEntryAccessorType& value) {
272 return WireFormatLite::MessageSizeNoVirtual(value); 282 return WireFormatLite::MessageSizeNoVirtual(value);
273 } 283 }
274 284
275 #define GOOGLE_PROTOBUF_BYTE_SIZE(FieldType, DeclaredType) \ 285 #define GOOGLE_PROTOBUF_BYTE_SIZE(FieldType, DeclaredType) \
276 template <typename Type> \ 286 template <typename Type> \
277 inline int MapTypeHandler<WireFormatLite::TYPE_##FieldType, Type>::ByteSize( \ 287 inline int MapTypeHandler<WireFormatLite::TYPE_##FieldType, Type>::ByteSize( \
278 const MapEntryAccessorType& value) { \ 288 const MapEntryAccessorType& value) { \
279 return WireFormatLite::DeclaredType##Size(value); \ 289 return WireFormatLite::DeclaredType##Size(value); \
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 365
356 template <typename Type> 366 template <typename Type>
357 inline void MapTypeHandler<WireFormatLite::TYPE_MESSAGE, Type>::Write( 367 inline void MapTypeHandler<WireFormatLite::TYPE_MESSAGE, Type>::Write(
358 int field, const MapEntryAccessorType& value, 368 int field, const MapEntryAccessorType& value,
359 io::CodedOutputStream* output) { 369 io::CodedOutputStream* output) {
360 WireFormatLite::WriteMessageMaybeToArray(field, value, output); 370 WireFormatLite::WriteMessageMaybeToArray(field, value, output);
361 } 371 }
362 372
363 template <typename Type> 373 template <typename Type>
364 inline uint8* 374 inline uint8*
365 MapTypeHandler<WireFormatLite::TYPE_MESSAGE, Type>::WriteToArray( 375 MapTypeHandler<WireFormatLite::TYPE_MESSAGE, Type>::InternalWriteToArray(
366 int field, const MapEntryAccessorType& value, uint8* output) { 376 int field, const MapEntryAccessorType& value, bool deterministic,
367 return WireFormatLite::WriteMessageToArray(field, value, output); 377 uint8* target) {
378 return WireFormatLite::InternalWriteMessageToArray(field, value,
379 deterministic, target);
368 } 380 }
369 381
370 #define WRITE_METHOD(FieldType, DeclaredType) \ 382 #define WRITE_METHOD(FieldType, DeclaredType) \
371 template <typename Type> \ 383 template <typename Type> \
372 inline void MapTypeHandler<WireFormatLite::TYPE_##FieldType, Type>::Write( \ 384 inline void MapTypeHandler<WireFormatLite::TYPE_##FieldType, Type>::Write( \
373 int field, const MapEntryAccessorType& value, \ 385 int field, const MapEntryAccessorType& value, \
374 io::CodedOutputStream* output) { \ 386 io::CodedOutputStream* output) { \
375 return WireFormatLite::Write##DeclaredType(field, value, output); \ 387 return WireFormatLite::Write##DeclaredType(field, value, output); \
376 } \ 388 } \
377 template <typename Type> \ 389 template <typename Type> \
378 inline uint8* \ 390 inline uint8* \
379 MapTypeHandler<WireFormatLite::TYPE_##FieldType, Type>::WriteToArray( \ 391 MapTypeHandler<WireFormatLite::TYPE_##FieldType, \
380 int field, const MapEntryAccessorType& value, uint8* output) { \ 392 Type>::InternalWriteToArray( \
381 return WireFormatLite::Write##DeclaredType##ToArray(field, value, output); \ 393 int field, const MapEntryAccessorType& value, bool, uint8* target) { \
394 return WireFormatLite::Write##DeclaredType##ToArray(field, value, target); \
382 } 395 }
383 396
384 WRITE_METHOD(STRING , String) 397 WRITE_METHOD(STRING , String)
385 WRITE_METHOD(BYTES , Bytes) 398 WRITE_METHOD(BYTES , Bytes)
386 WRITE_METHOD(INT64 , Int64) 399 WRITE_METHOD(INT64 , Int64)
387 WRITE_METHOD(UINT64 , UInt64) 400 WRITE_METHOD(UINT64 , UInt64)
388 WRITE_METHOD(INT32 , Int32) 401 WRITE_METHOD(INT32 , Int32)
389 WRITE_METHOD(UINT32 , UInt32) 402 WRITE_METHOD(UINT32 , UInt32)
390 WRITE_METHOD(SINT64 , SInt64) 403 WRITE_METHOD(SINT64 , SInt64)
391 WRITE_METHOD(SINT32 , SInt32) 404 WRITE_METHOD(SINT32 , SInt32)
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
536 } 549 }
537 550
538 // Definition for string/bytes handler 551 // Definition for string/bytes handler
539 552
540 #define STRING_OR_BYTES_HANDLER_FUNCTIONS(FieldType) \ 553 #define STRING_OR_BYTES_HANDLER_FUNCTIONS(FieldType) \
541 template <typename Type> \ 554 template <typename Type> \
542 inline const typename MapTypeHandler<WireFormatLite::TYPE_##FieldType, \ 555 inline const typename MapTypeHandler<WireFormatLite::TYPE_##FieldType, \
543 Type>::MapEntryAccessorType& \ 556 Type>::MapEntryAccessorType& \
544 MapTypeHandler<WireFormatLite::TYPE_##FieldType, \ 557 MapTypeHandler<WireFormatLite::TYPE_##FieldType, \
545 Type>::GetExternalReference(const TypeOnMemory& value) { \ 558 Type>::GetExternalReference(const TypeOnMemory& value) { \
546 return value.Get(&::google::protobuf::internal::GetEmptyString()); \ 559 return value.Get(); \
547 } \ 560 } \
548 template <typename Type> \ 561 template <typename Type> \
549 inline int \ 562 inline int \
550 MapTypeHandler<WireFormatLite::TYPE_##FieldType, Type>::SpaceUsedInMapEntry( \ 563 MapTypeHandler<WireFormatLite::TYPE_##FieldType, Type>::SpaceUsedInMapEntry( \
551 const TypeOnMemory& value) { \ 564 const TypeOnMemory& value) { \
552 return sizeof(value); \ 565 return sizeof(value); \
553 } \ 566 } \
554 template <typename Type> \ 567 template <typename Type> \
555 inline int MapTypeHandler<WireFormatLite::TYPE_##FieldType, \ 568 inline int MapTypeHandler<WireFormatLite::TYPE_##FieldType, \
556 Type>::SpaceUsedInMap(const TypeOnMemory& value) { \ 569 Type>::SpaceUsedInMap(const TypeOnMemory& value) { \
557 return sizeof(value); \ 570 return sizeof(value); \
558 } \ 571 } \
559 template <typename Type> \ 572 template <typename Type> \
560 inline int MapTypeHandler<WireFormatLite::TYPE_##FieldType, \ 573 inline int MapTypeHandler<WireFormatLite::TYPE_##FieldType, \
561 Type>::SpaceUsedInMap(const string& value) { \ 574 Type>::SpaceUsedInMap(const string& value) { \
562 return sizeof(value); \ 575 return sizeof(value); \
563 } \ 576 } \
564 template <typename Type> \ 577 template <typename Type> \
565 inline void MapTypeHandler<WireFormatLite::TYPE_##FieldType, Type>::Clear( \ 578 inline void MapTypeHandler<WireFormatLite::TYPE_##FieldType, Type>::Clear( \
566 TypeOnMemory* value, Arena* arena) { \ 579 TypeOnMemory* value, Arena* arena) { \
567 value->ClearToEmpty(&::google::protobuf::internal::GetEmptyString(), arena); \ 580 value->ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInit ed(), \
581 arena); \
568 } \ 582 } \
569 template <typename Type> \ 583 template <typename Type> \
570 inline void \ 584 inline void MapTypeHandler<WireFormatLite::TYPE_##FieldType, Type>:: \
571 MapTypeHandler<WireFormatLite::TYPE_##FieldType, \ 585 ClearMaybeByDefaultEnum(TypeOnMemory* value, Arena* arena, \
572 Type>::ClearMaybeByDefaultEnum(TypeOnMemory* value, \ 586 int default_enum) { \
573 Arena* arena, \
574 int default_enum) { \
575 Clear(value, arena); \ 587 Clear(value, arena); \
576 } \ 588 } \
577 template <typename Type> \ 589 template <typename Type> \
578 inline void MapTypeHandler<WireFormatLite::TYPE_##FieldType, Type>::Merge( \ 590 inline void MapTypeHandler<WireFormatLite::TYPE_##FieldType, Type>::Merge( \
579 const MapEntryAccessorType& from, TypeOnMemory* to, Arena* arena) { \ 591 const MapEntryAccessorType& from, TypeOnMemory* to, Arena* arena) { \
580 to->Set(&::google::protobuf::internal::GetEmptyString(), from, arena); \ 592 to->Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from, arena); \
581 } \ 593 } \
582 template <typename Type> \ 594 template <typename Type> \
583 void MapTypeHandler<WireFormatLite::TYPE_##FieldType, Type>::DeleteNoArena( \ 595 void MapTypeHandler<WireFormatLite::TYPE_##FieldType, Type>::DeleteNoArena( \
584 TypeOnMemory& value) { \ 596 TypeOnMemory& value) { \
585 value.DestroyNoArena(&::google::protobuf::internal::GetEmptyString()); \ 597 value.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyIni ted()); \
586 } \ 598 } \
587 template <typename Type> \ 599 template <typename Type> \
588 inline void MapTypeHandler<WireFormatLite::TYPE_##FieldType, \ 600 inline void MapTypeHandler<WireFormatLite::TYPE_##FieldType, \
589 Type>::AssignDefaultValue(TypeOnMemory* value) {} \ 601 Type>::AssignDefaultValue(TypeOnMemory* value) {} \
590 template <typename Type> \ 602 template <typename Type> \
591 inline void \ 603 inline void \
592 MapTypeHandler<WireFormatLite::TYPE_##FieldType, Type>::Initialize( \ 604 MapTypeHandler<WireFormatLite::TYPE_##FieldType, Type>::Initialize( \
593 TypeOnMemory* value, Arena* arena) { \ 605 TypeOnMemory* value, Arena* arena) { \
594 value->UnsafeSetDefault(&::google::protobuf::internal::GetEmptyString()); \ 606 value->UnsafeSetDefault( \
607 &::google::protobuf::internal::GetEmptyStringAlreadyInited()); \
595 } \ 608 } \
596 template <typename Type> \ 609 template <typename Type> \
597 inline void \ 610 inline void MapTypeHandler<WireFormatLite::TYPE_##FieldType, Type>:: \
598 MapTypeHandler<WireFormatLite::TYPE_##FieldType, \ 611 InitializeMaybeByDefaultEnum(TypeOnMemory* value, \
599 Type>::InitializeMaybeByDefaultEnum(TypeOnMemory* value, \ 612 int default_enum_value, Arena* arena) { \
600 int default_enum_value, \
601 Arena* arena) { \
602 Initialize(value, arena); \ 613 Initialize(value, arena); \
603 } \ 614 } \
604 template <typename Type> \ 615 template <typename Type> \
605 inline typename MapTypeHandler<WireFormatLite::TYPE_##FieldType, \ 616 inline typename MapTypeHandler<WireFormatLite::TYPE_##FieldType, \
606 Type>::MapEntryAccessorType* \ 617 Type>::MapEntryAccessorType* \
607 MapTypeHandler<WireFormatLite::TYPE_##FieldType, Type>::EnsureMutable( \ 618 MapTypeHandler<WireFormatLite::TYPE_##FieldType, Type>::EnsureMutable( \
608 TypeOnMemory* value, Arena* arena) { \ 619 TypeOnMemory* value, Arena* arena) { \
609 return value->Mutable(&::google::protobuf::internal::GetEmptyString(), arena ); \ 620 return value->Mutable(&::google::protobuf::internal::GetEmptyStringAlreadyIn ited(), \
621 arena); \
610 } \ 622 } \
611 template <typename Type> \ 623 template <typename Type> \
612 inline const typename MapTypeHandler<WireFormatLite::TYPE_##FieldType, \ 624 inline const typename MapTypeHandler<WireFormatLite::TYPE_##FieldType, \
613 Type>::MapEntryAccessorType& \ 625 Type>::MapEntryAccessorType& \
614 MapTypeHandler<WireFormatLite::TYPE_##FieldType, \ 626 MapTypeHandler<WireFormatLite::TYPE_##FieldType, \
615 Type>::DefaultIfNotInitialized(const TypeOnMemory& value, \ 627 Type>::DefaultIfNotInitialized(const TypeOnMemory& value, \
616 const TypeOnMemory& \ 628 const TypeOnMemory& \
617 default_value) { \ 629 default_value) { \
618 return value.Get(&::google::protobuf::internal::GetEmptyString()); \ 630 return value.Get(); \
619 } \ 631 } \
620 template <typename Type> \ 632 template <typename Type> \
621 inline bool MapTypeHandler<WireFormatLite::TYPE_##FieldType, \ 633 inline bool MapTypeHandler<WireFormatLite::TYPE_##FieldType, \
622 Type>::IsInitialized(const TypeOnMemory& value) { \ 634 Type>::IsInitialized(const TypeOnMemory& value) { \
623 return true; \ 635 return true; \
624 } 636 }
625 STRING_OR_BYTES_HANDLER_FUNCTIONS(STRING) 637 STRING_OR_BYTES_HANDLER_FUNCTIONS(STRING)
626 STRING_OR_BYTES_HANDLER_FUNCTIONS(BYTES) 638 STRING_OR_BYTES_HANDLER_FUNCTIONS(BYTES)
627 #undef STRING_OR_BYTES_HANDLER_FUNCTIONS 639 #undef STRING_OR_BYTES_HANDLER_FUNCTIONS
628 640
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
718 PRIMITIVE_HANDLER_FUNCTIONS(SFIXED64) 730 PRIMITIVE_HANDLER_FUNCTIONS(SFIXED64)
719 PRIMITIVE_HANDLER_FUNCTIONS(SFIXED32) 731 PRIMITIVE_HANDLER_FUNCTIONS(SFIXED32)
720 PRIMITIVE_HANDLER_FUNCTIONS(BOOL) 732 PRIMITIVE_HANDLER_FUNCTIONS(BOOL)
721 #undef PRIMITIVE_HANDLER_FUNCTIONS 733 #undef PRIMITIVE_HANDLER_FUNCTIONS
722 734
723 } // namespace internal 735 } // namespace internal
724 } // namespace protobuf 736 } // namespace protobuf
725 737
726 } // namespace google 738 } // namespace google
727 #endif // GOOGLE_PROTOBUF_TYPE_HANDLER_H__ 739 #endif // GOOGLE_PROTOBUF_TYPE_HANDLER_H__
OLDNEW
« no previous file with comments | « third_party/protobuf/src/google/protobuf/map_test_util.cc ('k') | third_party/protobuf/src/google/protobuf/map_unittest.proto » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698