From 4de8f55113007fdc8e34107950e605fc0209d465 Mon Sep 17 00:00:00 2001 From: "jieluo@google.com" Date: Fri, 18 Jul 2014 00:47:59 +0000 Subject: down integrate to svn --- src/google/protobuf/wire_format.h | 36 ++++++++++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-) (limited to 'src/google/protobuf/wire_format.h') diff --git a/src/google/protobuf/wire_format.h b/src/google/protobuf/wire_format.h index 6cc90029..0c05c0d8 100644 --- a/src/google/protobuf/wire_format.h +++ b/src/google/protobuf/wire_format.h @@ -79,7 +79,7 @@ class LIBPROTOBUF_EXPORT WireFormat { static inline WireFormatLite::WireType WireTypeForField( const FieldDescriptor* field); - // Given a FieldSescriptor::Type return its WireType + // Given a FieldDescriptor::Type return its WireType static inline WireFormatLite::WireType WireTypeForFieldType( FieldDescriptor::Type type); @@ -180,7 +180,7 @@ class LIBPROTOBUF_EXPORT WireFormat { // of packed repeated fields. static uint32 MakeTag(const FieldDescriptor* field); - // Parse a single field. The input should start out positioned immidately + // Parse a single field. The input should start out positioned immediately // after the tag. static bool ParseAndMergeField( uint32 tag, @@ -228,14 +228,34 @@ class LIBPROTOBUF_EXPORT WireFormat { }; // Verifies that a string field is valid UTF8, logging an error if not. + // This function will not be called by newly generated protobuf code + // but remains present to support existing code. static void VerifyUTF8String(const char* data, int size, Operation op); + // The NamedField variant takes a field name in order to produce an + // informative error message if verification fails. + static void VerifyUTF8StringNamedField(const char* data, + int size, + Operation op, + const char* field_name); private: // Verifies that a string field is valid UTF8, logging an error if not. static void VerifyUTF8StringFallback( const char* data, int size, - Operation op); + Operation op, + const char* field_name); + + // Skip a MessageSet field. + static bool SkipMessageSetField(io::CodedInputStream* input, + uint32 field_number, + UnknownFieldSet* unknown_fields); + + // Parse a MessageSet field. + static bool ParseAndMergeMessageSetField(uint32 field_number, + const FieldDescriptor* field, + Message* message, + io::CodedInputStream* input); @@ -293,13 +313,21 @@ inline int WireFormat::TagSize(int field_number, FieldDescriptor::Type type) { inline void WireFormat::VerifyUTF8String(const char* data, int size, WireFormat::Operation op) { #ifdef GOOGLE_PROTOBUF_UTF8_VALIDATION_ENABLED - WireFormat::VerifyUTF8StringFallback(data, size, op); + WireFormat::VerifyUTF8StringFallback(data, size, op, NULL); #else // Avoid the compiler warning about unsued variables. (void)data; (void)size; (void)op; #endif } +inline void WireFormat::VerifyUTF8StringNamedField( + const char* data, int size, WireFormat::Operation op, + const char* field_name) { +#ifdef GOOGLE_PROTOBUF_UTF8_VALIDATION_ENABLED + WireFormat::VerifyUTF8StringFallback(data, size, op, field_name); +#endif +} + } // namespace internal } // namespace protobuf -- cgit v1.2.3