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

Side by Side Diff: third_party/protobuf/src/google/protobuf/message.h

Issue 2495533002: third_party/protobuf: Update to HEAD (83d681ee2c) (Closed)
Patch Set: Update to new HEAD (b7632464b4) + restore GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER Created 4 years, 1 month 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 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 // adds descriptors and reflection on top of that. 172 // adds descriptors and reflection on top of that.
173 // 173 //
174 // The methods of this class that are virtual but not pure-virtual have 174 // The methods of this class that are virtual but not pure-virtual have
175 // default implementations based on reflection. Message classes which are 175 // default implementations based on reflection. Message classes which are
176 // optimized for speed will want to override these with faster implementations, 176 // optimized for speed will want to override these with faster implementations,
177 // but classes optimized for code size may be happy with keeping them. See 177 // but classes optimized for code size may be happy with keeping them. See
178 // the optimize_for option in descriptor.proto. 178 // the optimize_for option in descriptor.proto.
179 class LIBPROTOBUF_EXPORT Message : public MessageLite { 179 class LIBPROTOBUF_EXPORT Message : public MessageLite {
180 public: 180 public:
181 inline Message() {} 181 inline Message() {}
182 virtual ~Message(); 182 virtual ~Message() {}
183 183
184 // Basic Operations ------------------------------------------------ 184 // Basic Operations ------------------------------------------------
185 185
186 // Construct a new instance of the same type. Ownership is passed to the 186 // Construct a new instance of the same type. Ownership is passed to the
187 // caller. (This is also defined in MessageLite, but is defined again here 187 // caller. (This is also defined in MessageLite, but is defined again here
188 // for return-type covariance.) 188 // for return-type covariance.)
189 virtual Message* New() const = 0; 189 virtual Message* New() const = 0;
190 190
191 // Construct a new instance on the arena. Ownership is passed to the caller 191 // Construct a new instance on the arena. Ownership is passed to the caller
192 // if arena is a NULL. Default implementation allows for API compatibility 192 // if arena is a NULL. Default implementation allows for API compatibility
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 // MessageLite because they are not supported by the lite library. 264 // MessageLite because they are not supported by the lite library.
265 265
266 // Parse a protocol buffer from a file descriptor. If successful, the entire 266 // Parse a protocol buffer from a file descriptor. If successful, the entire
267 // input will be consumed. 267 // input will be consumed.
268 bool ParseFromFileDescriptor(int file_descriptor); 268 bool ParseFromFileDescriptor(int file_descriptor);
269 // Like ParseFromFileDescriptor(), but accepts messages that are missing 269 // Like ParseFromFileDescriptor(), but accepts messages that are missing
270 // required fields. 270 // required fields.
271 bool ParsePartialFromFileDescriptor(int file_descriptor); 271 bool ParsePartialFromFileDescriptor(int file_descriptor);
272 // Parse a protocol buffer from a C++ istream. If successful, the entire 272 // Parse a protocol buffer from a C++ istream. If successful, the entire
273 // input will be consumed. 273 // input will be consumed.
274 bool ParseFromIstream(istream* input); 274 bool ParseFromIstream(std::istream* input);
275 // Like ParseFromIstream(), but accepts messages that are missing 275 // Like ParseFromIstream(), but accepts messages that are missing
276 // required fields. 276 // required fields.
277 bool ParsePartialFromIstream(istream* input); 277 bool ParsePartialFromIstream(std::istream* input);
278 278
279 // Serialize the message and write it to the given file descriptor. All 279 // Serialize the message and write it to the given file descriptor. All
280 // required fields must be set. 280 // required fields must be set.
281 bool SerializeToFileDescriptor(int file_descriptor) const; 281 bool SerializeToFileDescriptor(int file_descriptor) const;
282 // Like SerializeToFileDescriptor(), but allows missing required fields. 282 // Like SerializeToFileDescriptor(), but allows missing required fields.
283 bool SerializePartialToFileDescriptor(int file_descriptor) const; 283 bool SerializePartialToFileDescriptor(int file_descriptor) const;
284 // Serialize the message and write it to the given C++ ostream. All 284 // Serialize the message and write it to the given C++ ostream. All
285 // required fields must be set. 285 // required fields must be set.
286 bool SerializeToOstream(ostream* output) const; 286 bool SerializeToOstream(std::ostream* output) const;
287 // Like SerializeToOstream(), but allows missing required fields. 287 // Like SerializeToOstream(), but allows missing required fields.
288 bool SerializePartialToOstream(ostream* output) const; 288 bool SerializePartialToOstream(std::ostream* output) const;
289 289
290 290
291 // Reflection-based methods ---------------------------------------- 291 // Reflection-based methods ----------------------------------------
292 // These methods are pure-virtual in MessageLite, but Message provides 292 // These methods are pure-virtual in MessageLite, but Message provides
293 // reflection-based default implementations. 293 // reflection-based default implementations.
294 294
295 virtual string GetTypeName() const; 295 virtual string GetTypeName() const;
296 virtual void Clear(); 296 virtual void Clear();
297 virtual bool IsInitialized() const; 297 virtual bool IsInitialized() const;
298 virtual void CheckTypeAndMergeFrom(const MessageLite& other); 298 virtual void CheckTypeAndMergeFrom(const MessageLite& other);
299 virtual bool MergePartialFromCodedStream(io::CodedInputStream* input); 299 virtual bool MergePartialFromCodedStream(io::CodedInputStream* input);
300 virtual int ByteSize() const; 300 virtual size_t ByteSizeLong() const;
301 virtual void SerializeWithCachedSizes(io::CodedOutputStream* output) const; 301 virtual void SerializeWithCachedSizes(io::CodedOutputStream* output) const;
302 302
303 private: 303 private:
304 // This is called only by the default implementation of ByteSize(), to 304 // This is called only by the default implementation of ByteSize(), to
305 // update the cached size. If you override ByteSize(), you do not need 305 // update the cached size. If you override ByteSize(), you do not need
306 // to override this. If you do not override ByteSize(), you MUST override 306 // to override this. If you do not override ByteSize(), you MUST override
307 // this; the default implementation will crash. 307 // this; the default implementation will crash.
308 // 308 //
309 // The method is private because subclasses should never call it; only 309 // The method is private because subclasses should never call it; only
310 // override it. Yes, C++ lets you do that. Crazy, huh? 310 // override it. Yes, C++ lets you do that. Crazy, huh?
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
578 int value) const; 578 int value) const;
579 579
580 // Get a mutable pointer to a field with a message type. If a MessageFactory 580 // Get a mutable pointer to a field with a message type. If a MessageFactory
581 // is provided, it will be used to construct instances of the sub-message; 581 // is provided, it will be used to construct instances of the sub-message;
582 // otherwise, the default factory is used. If the field is an extension that 582 // otherwise, the default factory is used. If the field is an extension that
583 // does not live in the same pool as the containing message's descriptor (e.g. 583 // does not live in the same pool as the containing message's descriptor (e.g.
584 // it lives in an overlay pool), then a MessageFactory must be provided. 584 // it lives in an overlay pool), then a MessageFactory must be provided.
585 // If you have no idea what that meant, then you probably don't need to worry 585 // If you have no idea what that meant, then you probably don't need to worry
586 // about it (don't provide a MessageFactory). WARNING: If the 586 // about it (don't provide a MessageFactory). WARNING: If the
587 // FieldDescriptor is for a compiled-in extension, then 587 // FieldDescriptor is for a compiled-in extension, then
588 // factory->GetPrototype(field->message_type() MUST return an instance of the 588 // factory->GetPrototype(field->message_type()) MUST return an instance of
589 // compiled-in class for this type, NOT DynamicMessage. 589 // the compiled-in class for this type, NOT DynamicMessage.
590 virtual Message* MutableMessage(Message* message, 590 virtual Message* MutableMessage(Message* message,
591 const FieldDescriptor* field, 591 const FieldDescriptor* field,
592 MessageFactory* factory = NULL) const = 0; 592 MessageFactory* factory = NULL) const = 0;
593 // Replaces the message specified by 'field' with the already-allocated object 593 // Replaces the message specified by 'field' with the already-allocated object
594 // sub_message, passing ownership to the message. If the field contained a 594 // sub_message, passing ownership to the message. If the field contained a
595 // message, that message is deleted. If sub_message is NULL, the field is 595 // message, that message is deleted. If sub_message is NULL, the field is
596 // cleared. 596 // cleared.
597 virtual void SetAllocatedMessage(Message* message, 597 virtual void SetAllocatedMessage(Message* message,
598 Message* sub_message, 598 Message* sub_message,
599 const FieldDescriptor* field) const = 0; 599 const FieldDescriptor* field) const = 0;
(...skipping 541 matching lines...) Expand 10 before | Expand all | Expand 10 after
1141 Message* message, const FieldDescriptor* field) const { 1141 Message* message, const FieldDescriptor* field) const {
1142 return static_cast<RepeatedPtrField<PB>* >( 1142 return static_cast<RepeatedPtrField<PB>* >(
1143 MutableRawRepeatedField(message, field, 1143 MutableRawRepeatedField(message, field,
1144 FieldDescriptor::CPPTYPE_MESSAGE, -1, 1144 FieldDescriptor::CPPTYPE_MESSAGE, -1,
1145 PB::default_instance().GetDescriptor())); 1145 PB::default_instance().GetDescriptor()));
1146 } 1146 }
1147 } // namespace protobuf 1147 } // namespace protobuf
1148 1148
1149 } // namespace google 1149 } // namespace google
1150 #endif // GOOGLE_PROTOBUF_MESSAGE_H__ 1150 #endif // GOOGLE_PROTOBUF_MESSAGE_H__
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698