| 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 721 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 732 int value) const; | 732 int value) const; |
| 733 // See MutableMessage() for comments on the "factory" parameter. | 733 // See MutableMessage() for comments on the "factory" parameter. |
| 734 virtual Message* AddMessage(Message* message, | 734 virtual Message* AddMessage(Message* message, |
| 735 const FieldDescriptor* field, | 735 const FieldDescriptor* field, |
| 736 MessageFactory* factory = NULL) const = 0; | 736 MessageFactory* factory = NULL) const = 0; |
| 737 | 737 |
| 738 // Appends an already-allocated object 'new_entry' to the repeated field | 738 // Appends an already-allocated object 'new_entry' to the repeated field |
| 739 // specifyed by 'field' passing ownership to the message. | 739 // specifyed by 'field' passing ownership to the message. |
| 740 // TODO(tmarek): Make virtual after all subclasses have been | 740 // TODO(tmarek): Make virtual after all subclasses have been |
| 741 // updated. | 741 // updated. |
| 742 virtual void AddAllocatedMessage(Message* message, | 742 virtual void AddAllocatedMessage(Message* /* message */, |
| 743 const FieldDescriptor* field, | 743 const FieldDescriptor* /*field */, |
| 744 Message* new_entry) const {} | 744 Message* /* new_entry */) const {} |
| 745 | 745 |
| 746 | 746 |
| 747 // Get a RepeatedFieldRef object that can be used to read the underlying | 747 // Get a RepeatedFieldRef object that can be used to read the underlying |
| 748 // repeated field. The type parameter T must be set according to the | 748 // repeated field. The type parameter T must be set according to the |
| 749 // field's cpp type. The following table shows the mapping from cpp type | 749 // field's cpp type. The following table shows the mapping from cpp type |
| 750 // to acceptable T. | 750 // to acceptable T. |
| 751 // | 751 // |
| 752 // field->cpp_type() T | 752 // field->cpp_type() T |
| 753 // CPPTYPE_INT32 int32 | 753 // CPPTYPE_INT32 int32 |
| 754 // CPPTYPE_UINT32 uint32 | 754 // CPPTYPE_UINT32 uint32 |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 940 // file here is not possible because it would cause a circular include cycle. | 940 // file here is not possible because it would cause a circular include cycle. |
| 941 // We use 1 routine rather than 2 (const vs mutable) because it is private | 941 // We use 1 routine rather than 2 (const vs mutable) because it is private |
| 942 // and mutable a repeated string field doesn't change the message. | 942 // and mutable a repeated string field doesn't change the message. |
| 943 void* MutableRawRepeatedString( | 943 void* MutableRawRepeatedString( |
| 944 Message* message, const FieldDescriptor* field, bool is_string) const; | 944 Message* message, const FieldDescriptor* field, bool is_string) const; |
| 945 | 945 |
| 946 friend class MapReflectionTester; | 946 friend class MapReflectionTester; |
| 947 // TODO(jieluo) - make the map APIs pure virtual after updating | 947 // TODO(jieluo) - make the map APIs pure virtual after updating |
| 948 // all the subclasses. | 948 // all the subclasses. |
| 949 // Returns true if key is in map. Returns false if key is not in map field. | 949 // Returns true if key is in map. Returns false if key is not in map field. |
| 950 virtual bool ContainsMapKey(const Message& message, | 950 virtual bool ContainsMapKey(const Message& /* message*/, |
| 951 const FieldDescriptor* field, | 951 const FieldDescriptor* /* field */, |
| 952 const MapKey& key) const { | 952 const MapKey& /* key */) const { |
| 953 return false; | 953 return false; |
| 954 } | 954 } |
| 955 | 955 |
| 956 // If key is in map field: Saves the value pointer to val and returns | 956 // If key is in map field: Saves the value pointer to val and returns |
| 957 // false. If key in not in map field: Insert the key into map, saves | 957 // false. If key in not in map field: Insert the key into map, saves |
| 958 // value pointer to val and retuns true. | 958 // value pointer to val and retuns true. |
| 959 virtual bool InsertOrLookupMapValue(Message* message, | 959 virtual bool InsertOrLookupMapValue(Message* /* message */, |
| 960 const FieldDescriptor* field, | 960 const FieldDescriptor* /* field */, |
| 961 const MapKey& key, | 961 const MapKey& /* key */, |
| 962 MapValueRef* val) const { | 962 MapValueRef* /* val */) const { |
| 963 return false; | 963 return false; |
| 964 } | 964 } |
| 965 | 965 |
| 966 // Delete and returns true if key is in the map field. Returns false | 966 // Delete and returns true if key is in the map field. Returns false |
| 967 // otherwise. | 967 // otherwise. |
| 968 virtual bool DeleteMapValue(Message* message, | 968 virtual bool DeleteMapValue(Message* /* mesage */, |
| 969 const FieldDescriptor* field, | 969 const FieldDescriptor* /* field */, |
| 970 const MapKey& key) const { | 970 const MapKey& /* key */) const { |
| 971 return false; | 971 return false; |
| 972 } | 972 } |
| 973 | 973 |
| 974 // Returns a MapIterator referring to the first element in the map field. | 974 // Returns a MapIterator referring to the first element in the map field. |
| 975 // If the map field is empty, this function returns the same as | 975 // If the map field is empty, this function returns the same as |
| 976 // reflection::MapEnd. Mutation to the field may invalidate the iterator. | 976 // reflection::MapEnd. Mutation to the field may invalidate the iterator. |
| 977 virtual MapIterator MapBegin( | 977 virtual MapIterator MapBegin( |
| 978 Message* message, | 978 Message* message, |
| 979 const FieldDescriptor* field) const; | 979 const FieldDescriptor* field) const; |
| 980 | 980 |
| 981 // Returns a MapIterator referring to the theoretical element that would | 981 // Returns a MapIterator referring to the theoretical element that would |
| 982 // follow the last element in the map field. It does not point to any | 982 // follow the last element in the map field. It does not point to any |
| 983 // real element. Mutation to the field may invalidate the iterator. | 983 // real element. Mutation to the field may invalidate the iterator. |
| 984 virtual MapIterator MapEnd( | 984 virtual MapIterator MapEnd( |
| 985 Message* message, | 985 Message* message, |
| 986 const FieldDescriptor* field) const; | 986 const FieldDescriptor* field) const; |
| 987 | 987 |
| 988 // Get the number of <key, value> pair of a map field. The result may be | 988 // Get the number of <key, value> pair of a map field. The result may be |
| 989 // different from FieldSize which can have duplicate keys. | 989 // different from FieldSize which can have duplicate keys. |
| 990 virtual int MapSize(const Message& message, | 990 virtual int MapSize(const Message& /* message */, |
| 991 const FieldDescriptor* field) const { | 991 const FieldDescriptor* /* field */) const { |
| 992 return 0; | 992 return 0; |
| 993 } | 993 } |
| 994 | 994 |
| 995 // Help method for MapIterator. | 995 // Help method for MapIterator. |
| 996 friend class MapIterator; | 996 friend class MapIterator; |
| 997 virtual internal::MapFieldBase* MapData( | 997 virtual internal::MapFieldBase* MapData( |
| 998 Message* message, const FieldDescriptor* field) const { | 998 Message* /* message */, const FieldDescriptor* /* field */) const { |
| 999 return NULL; | 999 return NULL; |
| 1000 } | 1000 } |
| 1001 | 1001 |
| 1002 GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(Reflection); | 1002 GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(Reflection); |
| 1003 }; | 1003 }; |
| 1004 | 1004 |
| 1005 // Abstract interface for a factory for message objects. | 1005 // Abstract interface for a factory for message objects. |
| 1006 class LIBPROTOBUF_EXPORT MessageFactory { | 1006 class LIBPROTOBUF_EXPORT MessageFactory { |
| 1007 public: | 1007 public: |
| 1008 inline MessageFactory() {} | 1008 inline MessageFactory() {} |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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__ |
| OLD | NEW |