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

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

Issue 2600753002: Reverts third_party/protobuf: Update to HEAD (f52e188fe4) (Closed)
Patch Set: Created 3 years, 12 months 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 #include <google/protobuf/stubs/logging.h> 45 #include <google/protobuf/stubs/logging.h>
46 46
47 namespace google { 47 namespace google {
48 namespace protobuf { 48 namespace protobuf {
49 namespace io { 49 namespace io {
50 class CodedInputStream; // coded_stream.h 50 class CodedInputStream; // coded_stream.h
51 class CodedOutputStream; // coded_stream.h 51 class CodedOutputStream; // coded_stream.h
52 class ZeroCopyInputStream; // zero_copy_stream.h 52 class ZeroCopyInputStream; // zero_copy_stream.h
53 } 53 }
54 namespace internal { 54 namespace internal {
55 class InternalMetadataWithArena; // metadata.h
56 class WireFormat; // wire_format.h 55 class WireFormat; // wire_format.h
57 class MessageSetFieldSkipperUsingCord; 56 class MessageSetFieldSkipperUsingCord;
58 // extension_set_heavy.cc 57 // extension_set_heavy.cc
59 } 58 }
60 59
61 class Message; // message.h 60 class Message; // message.h
62 class UnknownField; // below 61 class UnknownField; // below
63 62
64 // An UnknownFieldSet contains fields that were encountered while parsing a 63 // An UnknownFieldSet contains fields that were encountered while parsing a
65 // message but were not defined by its type. Keeping track of these can be 64 // message but were not defined by its type. Keeping track of these can be
(...skipping 20 matching lines...) Expand all
86 85
87 // Is this set empty? 86 // Is this set empty?
88 inline bool empty() const; 87 inline bool empty() const;
89 88
90 // Merge the contents of some other UnknownFieldSet with this one. 89 // Merge the contents of some other UnknownFieldSet with this one.
91 void MergeFrom(const UnknownFieldSet& other); 90 void MergeFrom(const UnknownFieldSet& other);
92 91
93 // Similar to above, but this function will destroy the contents of other. 92 // Similar to above, but this function will destroy the contents of other.
94 void MergeFromAndDestroy(UnknownFieldSet* other); 93 void MergeFromAndDestroy(UnknownFieldSet* other);
95 94
96 // Merge the contents an UnknownFieldSet with the UnknownFieldSet in
97 // *metadata, if there is one. If *metadata doesn't have an UnknownFieldSet
98 // then add one to it and make it be a copy of the first arg.
99 static void MergeToInternalMetdata(
100 const UnknownFieldSet& other,
101 internal::InternalMetadataWithArena* metadata);
102
103 // Swaps the contents of some other UnknownFieldSet with this one. 95 // Swaps the contents of some other UnknownFieldSet with this one.
104 inline void Swap(UnknownFieldSet* x); 96 inline void Swap(UnknownFieldSet* x);
105 97
106 // Computes (an estimate of) the total number of bytes currently used for 98 // Computes (an estimate of) the total number of bytes currently used for
107 // storing the unknown fields in memory. Does NOT include 99 // storing the unknown fields in memory. Does NOT include
108 // sizeof(*this) in the calculation. 100 // sizeof(*this) in the calculation.
109 int SpaceUsedExcludingSelf() const; 101 int SpaceUsedExcludingSelf() const;
110 102
111 // Version of SpaceUsed() including sizeof(*this). 103 // Version of SpaceUsed() including sizeof(*this).
112 int SpaceUsed() const; 104 int SpaceUsed() const;
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 class LIBPROTOBUF_EXPORT UnknownField { 168 class LIBPROTOBUF_EXPORT UnknownField {
177 public: 169 public:
178 enum Type { 170 enum Type {
179 TYPE_VARINT, 171 TYPE_VARINT,
180 TYPE_FIXED32, 172 TYPE_FIXED32,
181 TYPE_FIXED64, 173 TYPE_FIXED64,
182 TYPE_LENGTH_DELIMITED, 174 TYPE_LENGTH_DELIMITED,
183 TYPE_GROUP 175 TYPE_GROUP
184 }; 176 };
185 177
186 // The field's field number, as seen on the wire. 178 // The field's tag number, as seen on the wire.
187 inline int number() const; 179 inline int number() const;
188 180
189 // The field type. 181 // The field type.
190 inline Type type() const; 182 inline Type type() const;
191 183
192 // Accessors ------------------------------------------------------- 184 // Accessors -------------------------------------------------------
193 // Each method works only for UnknownFields of the corresponding type. 185 // Each method works only for UnknownFields of the corresponding type.
194 186
195 inline uint64 varint() const; 187 inline uint64 varint() const;
196 inline uint32 fixed32() const; 188 inline uint32 fixed32() const;
197 inline uint64 fixed64() const; 189 inline uint64 fixed64() const;
198 inline const string& length_delimited() const; 190 inline const string& length_delimited() const;
199 inline const UnknownFieldSet& group() const; 191 inline const UnknownFieldSet& group() const;
200 192
201 inline void set_varint(uint64 value); 193 inline void set_varint(uint64 value);
202 inline void set_fixed32(uint32 value); 194 inline void set_fixed32(uint32 value);
203 inline void set_fixed64(uint64 value); 195 inline void set_fixed64(uint64 value);
204 inline void set_length_delimited(const string& value); 196 inline void set_length_delimited(const string& value);
205 inline string* mutable_length_delimited(); 197 inline string* mutable_length_delimited();
206 inline UnknownFieldSet* mutable_group(); 198 inline UnknownFieldSet* mutable_group();
207 199
208 // Serialization API. 200 // Serialization API.
209 // These methods can take advantage of the underlying implementation and may 201 // These methods can take advantage of the underlying implementation and may
210 // archieve a better performance than using getters to retrieve the data and 202 // archieve a better performance than using getters to retrieve the data and
211 // do the serialization yourself. 203 // do the serialization yourself.
212 void SerializeLengthDelimitedNoTag(io::CodedOutputStream* output) const; 204 void SerializeLengthDelimitedNoTag(io::CodedOutputStream* output) const;
213 uint8* SerializeLengthDelimitedNoTagToArray(uint8* target) const; 205 uint8* SerializeLengthDelimitedNoTagToArray(uint8* target) const;
214 206
215 inline size_t GetLengthDelimitedSize() const; 207 inline int GetLengthDelimitedSize() const;
216 208
217 private: 209 private:
218 friend class UnknownFieldSet; 210 friend class UnknownFieldSet;
219 211
220 // If this UnknownField contains a pointer, delete it. 212 // If this UnknownField contains a pointer, delete it.
221 void Delete(); 213 void Delete();
222 214
223 // Reset all the underlying pointers to NULL. A special function to be only 215 // Reset all the underlying pointers to NULL. A special function to be only
224 // used while merging from a temporary UFS. 216 // used while merging from a temporary UFS.
225 void Reset(); 217 void Reset();
(...skipping 16 matching lines...) Expand all
242 uint32 fixed32_; 234 uint32 fixed32_;
243 uint64 fixed64_; 235 uint64 fixed64_;
244 mutable union LengthDelimited length_delimited_; 236 mutable union LengthDelimited length_delimited_;
245 UnknownFieldSet* group_; 237 UnknownFieldSet* group_;
246 }; 238 };
247 }; 239 };
248 240
249 // =================================================================== 241 // ===================================================================
250 // inline implementations 242 // inline implementations
251 243
252 inline UnknownFieldSet::UnknownFieldSet() : fields_(NULL) {}
253
254 inline UnknownFieldSet::~UnknownFieldSet() { Clear(); }
255
256 inline void UnknownFieldSet::ClearAndFreeMemory() { Clear(); }
257
258 inline void UnknownFieldSet::Clear() { 244 inline void UnknownFieldSet::Clear() {
259 if (fields_ != NULL) { 245 if (fields_) {
260 ClearFallback(); 246 ClearFallback();
261 } 247 }
262 } 248 }
263 249
264 inline bool UnknownFieldSet::empty() const { 250 inline bool UnknownFieldSet::empty() const {
265 // Invariant: fields_ is never empty if present. 251 // Invariant: fields_ is never empty if present.
266 return !fields_; 252 return !fields_;
267 } 253 }
268 254
269 inline void UnknownFieldSet::Swap(UnknownFieldSet* x) { 255 inline void UnknownFieldSet::Swap(UnknownFieldSet* x) {
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 } 317 }
332 inline string* UnknownField::mutable_length_delimited() { 318 inline string* UnknownField::mutable_length_delimited() {
333 assert(type() == TYPE_LENGTH_DELIMITED); 319 assert(type() == TYPE_LENGTH_DELIMITED);
334 return length_delimited_.string_value_; 320 return length_delimited_.string_value_;
335 } 321 }
336 inline UnknownFieldSet* UnknownField::mutable_group() { 322 inline UnknownFieldSet* UnknownField::mutable_group() {
337 assert(type() == TYPE_GROUP); 323 assert(type() == TYPE_GROUP);
338 return group_; 324 return group_;
339 } 325 }
340 326
341 inline size_t UnknownField::GetLengthDelimitedSize() const { 327 inline int UnknownField::GetLengthDelimitedSize() const {
342 GOOGLE_DCHECK_EQ(TYPE_LENGTH_DELIMITED, type()); 328 GOOGLE_DCHECK_EQ(TYPE_LENGTH_DELIMITED, type());
343 return length_delimited_.string_value_->size(); 329 return static_cast<int>(length_delimited_.string_value_->size());
344 } 330 }
345 331
346 inline void UnknownField::SetType(Type type) { 332 inline void UnknownField::SetType(Type type) {
347 type_ = type; 333 type_ = type;
348 } 334 }
349 335
350 336
351 } // namespace protobuf 337 } // namespace protobuf
352 338
353 } // namespace google 339 } // namespace google
354 #endif // GOOGLE_PROTOBUF_UNKNOWN_FIELD_SET_H__ 340 #endif // GOOGLE_PROTOBUF_UNKNOWN_FIELD_SET_H__
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698