| OLD | NEW |
| 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 // Old version of MSVC doesn't like definitions of inline constants, GCC | 54 // Old version of MSVC doesn't like definitions of inline constants, GCC |
| 55 // requires them. | 55 // requires them. |
| 56 const int WireFormatLite::kMessageSetItemStartTag; | 56 const int WireFormatLite::kMessageSetItemStartTag; |
| 57 const int WireFormatLite::kMessageSetItemEndTag; | 57 const int WireFormatLite::kMessageSetItemEndTag; |
| 58 const int WireFormatLite::kMessageSetTypeIdTag; | 58 const int WireFormatLite::kMessageSetTypeIdTag; |
| 59 const int WireFormatLite::kMessageSetMessageTag; | 59 const int WireFormatLite::kMessageSetMessageTag; |
| 60 | 60 |
| 61 #endif | 61 #endif |
| 62 | 62 |
| 63 // IBM xlC requires prefixing constants with WireFormatLite:: | 63 // IBM xlC requires prefixing constants with WireFormatLite:: |
| 64 const size_t WireFormatLite::kMessageSetItemTagsSize = | 64 const int WireFormatLite::kMessageSetItemTagsSize = |
| 65 io::CodedOutputStream::StaticVarintSize32< | 65 io::CodedOutputStream::StaticVarintSize32< |
| 66 WireFormatLite::kMessageSetItemStartTag>::value + | 66 WireFormatLite::kMessageSetItemStartTag>::value + |
| 67 io::CodedOutputStream::StaticVarintSize32< | 67 io::CodedOutputStream::StaticVarintSize32< |
| 68 WireFormatLite::kMessageSetItemEndTag>::value + | 68 WireFormatLite::kMessageSetItemEndTag>::value + |
| 69 io::CodedOutputStream::StaticVarintSize32< | 69 io::CodedOutputStream::StaticVarintSize32< |
| 70 WireFormatLite::kMessageSetTypeIdTag>::value + | 70 WireFormatLite::kMessageSetTypeIdTag>::value + |
| 71 io::CodedOutputStream::StaticVarintSize32< | 71 io::CodedOutputStream::StaticVarintSize32< |
| 72 WireFormatLite::kMessageSetMessageTag>::value; | 72 WireFormatLite::kMessageSetMessageTag>::value; |
| 73 | 73 |
| 74 const WireFormatLite::CppType | 74 const WireFormatLite::CppType |
| (...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 459 value.SerializeWithCachedSizes(output); | 459 value.SerializeWithCachedSizes(output); |
| 460 } | 460 } |
| 461 | 461 |
| 462 void WireFormatLite::WriteGroupMaybeToArray(int field_number, | 462 void WireFormatLite::WriteGroupMaybeToArray(int field_number, |
| 463 const MessageLite& value, | 463 const MessageLite& value, |
| 464 io::CodedOutputStream* output) { | 464 io::CodedOutputStream* output) { |
| 465 WriteTag(field_number, WIRETYPE_START_GROUP, output); | 465 WriteTag(field_number, WIRETYPE_START_GROUP, output); |
| 466 const int size = value.GetCachedSize(); | 466 const int size = value.GetCachedSize(); |
| 467 uint8* target = output->GetDirectBufferForNBytesAndAdvance(size); | 467 uint8* target = output->GetDirectBufferForNBytesAndAdvance(size); |
| 468 if (target != NULL) { | 468 if (target != NULL) { |
| 469 uint8* end = value.InternalSerializeWithCachedSizesToArray( | 469 uint8* end = value.SerializeWithCachedSizesToArray(target); |
| 470 output->IsSerializationDeterministic(), target); | |
| 471 GOOGLE_DCHECK_EQ(end - target, size); | 470 GOOGLE_DCHECK_EQ(end - target, size); |
| 472 } else { | 471 } else { |
| 473 value.SerializeWithCachedSizes(output); | 472 value.SerializeWithCachedSizes(output); |
| 474 } | 473 } |
| 475 WriteTag(field_number, WIRETYPE_END_GROUP, output); | 474 WriteTag(field_number, WIRETYPE_END_GROUP, output); |
| 476 } | 475 } |
| 477 | 476 |
| 478 void WireFormatLite::WriteMessageMaybeToArray(int field_number, | 477 void WireFormatLite::WriteMessageMaybeToArray(int field_number, |
| 479 const MessageLite& value, | 478 const MessageLite& value, |
| 480 io::CodedOutputStream* output) { | 479 io::CodedOutputStream* output) { |
| 481 WriteTag(field_number, WIRETYPE_LENGTH_DELIMITED, output); | 480 WriteTag(field_number, WIRETYPE_LENGTH_DELIMITED, output); |
| 482 const int size = value.GetCachedSize(); | 481 const int size = value.GetCachedSize(); |
| 483 output->WriteVarint32(size); | 482 output->WriteVarint32(size); |
| 484 uint8* target = output->GetDirectBufferForNBytesAndAdvance(size); | 483 uint8* target = output->GetDirectBufferForNBytesAndAdvance(size); |
| 485 if (target != NULL) { | 484 if (target != NULL) { |
| 486 uint8* end = value.InternalSerializeWithCachedSizesToArray( | 485 uint8* end = value.SerializeWithCachedSizesToArray(target); |
| 487 output->IsSerializationDeterministic(), target); | |
| 488 GOOGLE_DCHECK_EQ(end - target, size); | 486 GOOGLE_DCHECK_EQ(end - target, size); |
| 489 } else { | 487 } else { |
| 490 value.SerializeWithCachedSizes(output); | 488 value.SerializeWithCachedSizes(output); |
| 491 } | 489 } |
| 492 } | 490 } |
| 493 | 491 |
| 494 GOOGLE_ATTRIBUTE_ALWAYS_INLINE static bool ReadBytesToString( | 492 GOOGLE_ATTRIBUTE_ALWAYS_INLINE static bool ReadBytesToString( |
| 495 io::CodedInputStream* input, string* value); | 493 io::CodedInputStream* input, string* value); |
| 496 inline static bool ReadBytesToString(io::CodedInputStream* input, | 494 inline static bool ReadBytesToString(io::CodedInputStream* input, |
| 497 string* value) { | 495 string* value) { |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 536 << "buffer. Use the 'bytes' type if you intend to send raw " | 534 << "buffer. Use the 'bytes' type if you intend to send raw " |
| 537 << "bytes. "; | 535 << "bytes. "; |
| 538 return false; | 536 return false; |
| 539 } | 537 } |
| 540 return true; | 538 return true; |
| 541 } | 539 } |
| 542 | 540 |
| 543 } // namespace internal | 541 } // namespace internal |
| 544 } // namespace protobuf | 542 } // namespace protobuf |
| 545 } // namespace google | 543 } // namespace google |
| OLD | NEW |