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 20 matching lines...) Expand all Loading... |
31 #ifndef GOOGLE_PROTOBUF_MAP_FIELD_LITE_H__ | 31 #ifndef GOOGLE_PROTOBUF_MAP_FIELD_LITE_H__ |
32 #define GOOGLE_PROTOBUF_MAP_FIELD_LITE_H__ | 32 #define GOOGLE_PROTOBUF_MAP_FIELD_LITE_H__ |
33 | 33 |
34 #include <google/protobuf/map.h> | 34 #include <google/protobuf/map.h> |
35 #include <google/protobuf/map_entry_lite.h> | 35 #include <google/protobuf/map_entry_lite.h> |
36 | 36 |
37 namespace google { | 37 namespace google { |
38 namespace protobuf { | 38 namespace protobuf { |
39 namespace internal { | 39 namespace internal { |
40 | 40 |
41 // This class provides access to map field using generated api. It is used for | 41 // This class provides accesss to map field using generated api. It is used for |
42 // internal generated message implentation only. Users should never use this | 42 // internal generated message implentation only. Users should never use this |
43 // directly. | 43 // directly. |
44 template <typename Key, typename T, | 44 template <typename Key, typename T, |
45 WireFormatLite::FieldType key_wire_type, | 45 WireFormatLite::FieldType key_wire_type, |
46 WireFormatLite::FieldType value_wire_type, | 46 WireFormatLite::FieldType value_wire_type, |
47 int default_enum_value = 0> | 47 int default_enum_value = 0> |
48 class MapFieldLite { | 48 class MapFieldLite { |
49 // Define message type for internal repeated field. | 49 // Define message type for internal repeated field. |
50 typedef MapEntryLite<Key, T, key_wire_type, value_wire_type, | 50 typedef MapEntryLite<Key, T, key_wire_type, value_wire_type, |
51 default_enum_value> EntryType; | 51 default_enum_value> EntryType; |
52 | 52 |
53 public: | 53 public: |
54 MapFieldLite(); | 54 MapFieldLite(); |
55 explicit MapFieldLite(Arena* arena); | 55 explicit MapFieldLite(Arena* arena); |
56 virtual ~MapFieldLite(); | 56 virtual ~MapFieldLite(); |
57 | 57 |
58 // Accessors | 58 // Accessors |
59 virtual const Map<Key, T>& GetMap() const; | 59 virtual const Map<Key, T>& GetMap() const; |
60 virtual Map<Key, T>* MutableMap(); | 60 virtual Map<Key, T>* MutableMap(); |
61 | 61 |
62 // Convenient methods for generated message implementation. | 62 // Convenient methods for generated message implementation. |
63 virtual int size() const; | 63 virtual int size() const; |
64 virtual void Clear(); | 64 virtual void Clear(); |
65 virtual void MergeFrom(const MapFieldLite& other); | 65 virtual void MergeFrom(const MapFieldLite& other); |
66 virtual void Swap(MapFieldLite* other); | 66 virtual void Swap(MapFieldLite* other); |
67 | 67 |
68 // Set default enum value only for proto2 map field whose value is enum type. | 68 // Set default enum value only for proto2 map field whose value is enum type. |
69 void SetDefaultEnumValue(); | 69 void SetDefaultEnumValue(); |
70 | 70 |
71 // Used in the implementation of parsing. Caller should take the ownership iff | 71 // Used in the implementation of parsing. Caller should take the ownership. |
72 // arena_ is NULL. | |
73 EntryType* NewEntry() const; | 72 EntryType* NewEntry() const; |
74 // Used in the implementation of serializing enum value type. Caller should | 73 // Used in the implementation of serializing enum value type. Caller should |
75 // take the ownership iff arena_ is NULL. | 74 // take the ownership. |
76 EntryType* NewEnumEntryWrapper(const Key& key, const T t) const; | 75 EntryType* NewEnumEntryWrapper(const Key& key, const T t) const; |
77 // Used in the implementation of serializing other value types. Caller should | 76 // Used in the implementation of serializing other value types. Caller should |
78 // take the ownership iff arena_ is NULL. | 77 // take the ownership. |
79 EntryType* NewEntryWrapper(const Key& key, const T& t) const; | 78 EntryType* NewEntryWrapper(const Key& key, const T& t) const; |
80 | 79 |
81 protected: | 80 protected: |
82 // Convenient methods to get internal google::protobuf::Map | 81 // Convenient methods to get internal google::protobuf::Map |
83 virtual const Map<Key, T>& GetInternalMap() const; | 82 virtual const Map<Key, T>& GetInternalMap() const; |
84 virtual Map<Key, T>* MutableInternalMap(); | 83 virtual Map<Key, T>* MutableInternalMap(); |
85 | 84 |
86 private: | 85 private: |
87 typedef void DestructorSkippable_; | 86 typedef void DestructorSkippable_; |
88 | 87 |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 if (!it->second.IsInitialized()) return false; | 269 if (!it->second.IsInitialized()) return false; |
271 } | 270 } |
272 return true; | 271 return true; |
273 } | 272 } |
274 | 273 |
275 } // namespace internal | 274 } // namespace internal |
276 } // namespace protobuf | 275 } // namespace protobuf |
277 | 276 |
278 } // namespace google | 277 } // namespace google |
279 #endif // GOOGLE_PROTOBUF_MAP_FIELD_LITE_H__ | 278 #endif // GOOGLE_PROTOBUF_MAP_FIELD_LITE_H__ |
OLD | NEW |