diff options
Diffstat (limited to 'src/google/protobuf/message.cc')
-rw-r--r-- | src/google/protobuf/message.cc | 55 |
1 files changed, 8 insertions, 47 deletions
diff --git a/src/google/protobuf/message.cc b/src/google/protobuf/message.cc index 1324ed9..0409a94 100644 --- a/src/google/protobuf/message.cc +++ b/src/google/protobuf/message.cc @@ -1,6 +1,6 @@ // Protocol Buffers - Google's data interchange format // Copyright 2008 Google Inc. All rights reserved. -// https://developers.google.com/protocol-buffers/ +// http://code.google.com/p/protobuf/ // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are @@ -32,7 +32,7 @@ // Based on original Protocol Buffers design by // Sanjay Ghemawat, Jeff Dean, and others. -#include <iostream> +#include <istream> #include <stack> #include <google/protobuf/stubs/hash.h> @@ -44,12 +44,11 @@ #include <google/protobuf/io/zero_copy_stream_impl.h> #include <google/protobuf/descriptor.pb.h> #include <google/protobuf/descriptor.h> -#include <google/protobuf/generated_message_util.h> #include <google/protobuf/reflection_ops.h> #include <google/protobuf/wire_format.h> #include <google/protobuf/stubs/strutil.h> -#include <google/protobuf/stubs/map_util.h> -#include <google/protobuf/stubs/stl_util.h> +#include <google/protobuf/stubs/map-util.h> +#include <google/protobuf/stubs/stl_util-inl.h> namespace google { namespace protobuf { @@ -75,7 +74,7 @@ void Message::CheckTypeAndMergeFrom(const MessageLite& other) { void Message::CopyFrom(const Message& from) { const Descriptor* descriptor = GetDescriptor(); GOOGLE_CHECK_EQ(from.GetDescriptor(), descriptor) - << ": Tried to copy from a message with a different type. " + << ": Tried to copy from a message with a different type." "to: " << descriptor->full_name() << ", " "from:" << from.GetDescriptor()->full_name(); ReflectionOps::Copy(from, this); @@ -100,7 +99,7 @@ void Message::FindInitializationErrors(vector<string>* errors) const { string Message::InitializationErrorString() const { vector<string> errors; FindInitializationErrors(&errors); - return Join(errors, ", "); + return JoinStrings(errors, ", "); } void Message::CheckInitialized() const { @@ -149,7 +148,7 @@ int Message::ByteSize() const { return size; } -void Message::SetCachedSize(int /* size */) const { +void Message::SetCachedSize(int size) const { GOOGLE_LOG(FATAL) << "Message class \"" << GetDescriptor()->full_name() << "\" implements neither SetCachedSize() nor ByteSize(). " "Must implement one or the other."; @@ -183,46 +182,9 @@ bool Message::SerializePartialToOstream(ostream* output) const { } -// ============================================================================= -// Reflection and associated Template Specializations - Reflection::~Reflection() {} -#define HANDLE_TYPE(TYPE, CPPTYPE, CTYPE) \ -template<> \ -const RepeatedField<TYPE>& Reflection::GetRepeatedField<TYPE>( \ - const Message& message, const FieldDescriptor* field) const { \ - return *static_cast<RepeatedField<TYPE>* >( \ - MutableRawRepeatedField(const_cast<Message*>(&message), \ - field, CPPTYPE, CTYPE, NULL)); \ -} \ - \ -template<> \ -RepeatedField<TYPE>* Reflection::MutableRepeatedField<TYPE>( \ - Message* message, const FieldDescriptor* field) const { \ - return static_cast<RepeatedField<TYPE>* >( \ - MutableRawRepeatedField(message, field, CPPTYPE, CTYPE, NULL)); \ -} - -HANDLE_TYPE(int32, FieldDescriptor::CPPTYPE_INT32, -1); -HANDLE_TYPE(int64, FieldDescriptor::CPPTYPE_INT64, -1); -HANDLE_TYPE(uint32, FieldDescriptor::CPPTYPE_UINT32, -1); -HANDLE_TYPE(uint64, FieldDescriptor::CPPTYPE_UINT64, -1); -HANDLE_TYPE(float, FieldDescriptor::CPPTYPE_FLOAT, -1); -HANDLE_TYPE(double, FieldDescriptor::CPPTYPE_DOUBLE, -1); -HANDLE_TYPE(bool, FieldDescriptor::CPPTYPE_BOOL, -1); - - -#undef HANDLE_TYPE - -void* Reflection::MutableRawRepeatedString( - Message* message, const FieldDescriptor* field, bool is_string) const { - return MutableRawRepeatedField(message, field, - FieldDescriptor::CPPTYPE_STRING, FieldOptions::STRING, NULL); -} - - -// ============================================================================= +// =================================================================== // MessageFactory MessageFactory::~MessageFactory() {} @@ -296,7 +258,6 @@ void GeneratedMessageFactory::RegisterType(const Descriptor* descriptor, } } - const Message* GeneratedMessageFactory::GetPrototype(const Descriptor* type) { { ReaderMutexLock lock(&mutex_); |