protobuf/src/google/protobuf/io/coded_stream.h
Go to the documentation of this file.
1 // Protocol Buffers - Google's data interchange format
2 // Copyright 2008 Google Inc. All rights reserved.
3 // https://developers.google.com/protocol-buffers/
4 //
5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are
7 // met:
8 //
9 // * Redistributions of source code must retain the above copyright
10 // notice, this list of conditions and the following disclaimer.
11 // * Redistributions in binary form must reproduce the above
12 // copyright notice, this list of conditions and the following disclaimer
13 // in the documentation and/or other materials provided with the
14 // distribution.
15 // * Neither the name of Google Inc. nor the names of its
16 // contributors may be used to endorse or promote products derived from
17 // this software without specific prior written permission.
18 //
19 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 
31 // Author: kenton@google.com (Kenton Varda)
32 // Based on original Protocol Buffers design by
33 // Sanjay Ghemawat, Jeff Dean, and others.
34 //
35 // This file contains the CodedInputStream and CodedOutputStream classes,
36 // which wrap a ZeroCopyInputStream or ZeroCopyOutputStream, respectively,
37 // and allow you to read or write individual pieces of data in various
38 // formats. In particular, these implement the varint encoding for
39 // integers, a simple variable-length encoding in which smaller numbers
40 // take fewer bytes.
41 //
42 // Typically these classes will only be used internally by the protocol
43 // buffer library in order to encode and decode protocol buffers. Clients
44 // of the library only need to know about this class if they wish to write
45 // custom message parsing or serialization procedures.
46 //
47 // CodedOutputStream example:
48 // // Write some data to "myfile". First we write a 4-byte "magic number"
49 // // to identify the file type, then write a length-delimited string. The
50 // // string is composed of a varint giving the length followed by the raw
51 // // bytes.
52 // int fd = open("myfile", O_CREAT | O_WRONLY);
53 // ZeroCopyOutputStream* raw_output = new FileOutputStream(fd);
54 // CodedOutputStream* coded_output = new CodedOutputStream(raw_output);
55 //
56 // int magic_number = 1234;
57 // char text[] = "Hello world!";
58 // coded_output->WriteLittleEndian32(magic_number);
59 // coded_output->WriteVarint32(strlen(text));
60 // coded_output->WriteRaw(text, strlen(text));
61 //
62 // delete coded_output;
63 // delete raw_output;
64 // close(fd);
65 //
66 // CodedInputStream example:
67 // // Read a file created by the above code.
68 // int fd = open("myfile", O_RDONLY);
69 // ZeroCopyInputStream* raw_input = new FileInputStream(fd);
70 // CodedInputStream* coded_input = new CodedInputStream(raw_input);
71 //
72 // coded_input->ReadLittleEndian32(&magic_number);
73 // if (magic_number != 1234) {
74 // cerr << "File not in expected format." << endl;
75 // return;
76 // }
77 //
78 // uint32_t size;
79 // coded_input->ReadVarint32(&size);
80 //
81 // char* text = new char[size + 1];
82 // coded_input->ReadRaw(buffer, size);
83 // text[size] = '\0';
84 //
85 // delete coded_input;
86 // delete raw_input;
87 // close(fd);
88 //
89 // cout << "Text is: " << text << endl;
90 // delete [] text;
91 //
92 // For those who are interested, varint encoding is defined as follows:
93 //
94 // The encoding operates on unsigned integers of up to 64 bits in length.
95 // Each byte of the encoded value has the format:
96 // * bits 0-6: Seven bits of the number being encoded.
97 // * bit 7: Zero if this is the last byte in the encoding (in which
98 // case all remaining bits of the number are zero) or 1 if
99 // more bytes follow.
100 // The first byte contains the least-significant 7 bits of the number, the
101 // second byte (if present) contains the next-least-significant 7 bits,
102 // and so on. So, the binary number 1011000101011 would be encoded in two
103 // bytes as "10101011 00101100".
104 //
105 // In theory, varint could be used to encode integers of any length.
106 // However, for practicality we set a limit at 64 bits. The maximum encoded
107 // length of a number is thus 10 bytes.
108 
109 #ifndef GOOGLE_PROTOBUF_IO_CODED_STREAM_H__
110 #define GOOGLE_PROTOBUF_IO_CODED_STREAM_H__
111 
112 
113 #include <assert.h>
114 
115 #include <atomic>
116 #include <climits>
117 #include <cstddef>
118 #include <cstring>
119 #include <limits>
120 #include <string>
121 #include <type_traits>
122 #include <utility>
123 
124 #ifdef _WIN32
125 // Assuming windows is always little-endian.
126 #if !defined(PROTOBUF_DISABLE_LITTLE_ENDIAN_OPT_FOR_TEST)
127 #define PROTOBUF_LITTLE_ENDIAN 1
128 #endif
129 #if defined(_MSC_VER) && _MSC_VER >= 1300 && !defined(__INTEL_COMPILER)
130 // If MSVC has "/RTCc" set, it will complain about truncating casts at
131 // runtime. This file contains some intentional truncating casts.
132 #pragma runtime_checks("c", off)
133 #endif
134 #else
135 #ifdef __APPLE__
136 #include <machine/endian.h> // __BYTE_ORDER
137 #elif defined(__FreeBSD__)
138 #include <sys/endian.h> // __BYTE_ORDER
139 #elif (defined(sun) || defined(__sun)) && (defined(__SVR4) || defined(__svr4__))
140 #include <sys/isa_defs.h> // __BYTE_ORDER
141 #elif defined(_AIX) || defined(__TOS_AIX__)
142 #include <sys/machine.h> // BYTE_ORDER
143 #else
144 #if !defined(__QNX__)
145 #include <endian.h> // __BYTE_ORDER
146 #endif
147 #endif
148 #if ((defined(__LITTLE_ENDIAN__) && !defined(__BIG_ENDIAN__)) || \
149  (defined(__BYTE_ORDER) && __BYTE_ORDER == __LITTLE_ENDIAN)) && \
150  !defined(PROTOBUF_DISABLE_LITTLE_ENDIAN_OPT_FOR_TEST)
151 #define PROTOBUF_LITTLE_ENDIAN 1
152 #endif
153 #endif
154 #include <google/protobuf/stubs/common.h>
155 #include <google/protobuf/stubs/logging.h>
156 #include <google/protobuf/stubs/strutil.h>
157 #include <google/protobuf/port.h>
158 #include <google/protobuf/stubs/port.h>
159 
160 
161 #include <google/protobuf/port_def.inc>
162 
163 namespace google {
164 namespace protobuf {
165 
166 class DescriptorPool;
167 class MessageFactory;
168 class ZeroCopyCodedInputStream;
169 
170 namespace internal {
172 class EpsCopyByteStream;
173 } // namespace internal
174 
175 namespace io {
176 
177 // Defined in this file.
178 class CodedInputStream;
179 class CodedOutputStream;
180 
181 // Defined in other files.
182 class ZeroCopyInputStream; // zero_copy_stream.h
183 class ZeroCopyOutputStream; // zero_copy_stream.h
184 
185 // Class which reads and decodes binary data which is composed of varint-
186 // encoded integers and fixed-width pieces. Wraps a ZeroCopyInputStream.
187 // Most users will not need to deal with CodedInputStream.
188 //
189 // Most methods of CodedInputStream that return a bool return false if an
190 // underlying I/O error occurs or if the data is malformed. Once such a
191 // failure occurs, the CodedInputStream is broken and is no longer useful.
192 // After a failure, callers also should assume writes to "out" args may have
193 // occurred, though nothing useful can be determined from those writes.
194 class PROTOBUF_EXPORT CodedInputStream {
195  public:
196  // Create a CodedInputStream that reads from the given ZeroCopyInputStream.
198 
199  // Create a CodedInputStream that reads from the given flat array. This is
200  // faster than using an ArrayInputStream. PushLimit(size) is implied by
201  // this constructor.
202  explicit CodedInputStream(const uint8_t* buffer, int size);
203 
204  // Destroy the CodedInputStream and position the underlying
205  // ZeroCopyInputStream at the first unread byte. If an error occurred while
206  // reading (causing a method to return false), then the exact position of
207  // the input stream may be anywhere between the last value that was read
208  // successfully and the stream's byte limit.
209  ~CodedInputStream();
210 
211  // Return true if this CodedInputStream reads from a flat array instead of
212  // a ZeroCopyInputStream.
213  inline bool IsFlat() const;
214 
215  // Skips a number of bytes. Returns false if an underlying read error
216  // occurs.
217  inline bool Skip(int count);
218 
219  // Sets *data to point directly at the unread part of the CodedInputStream's
220  // underlying buffer, and *size to the size of that buffer, but does not
221  // advance the stream's current position. This will always either produce
222  // a non-empty buffer or return false. If the caller consumes any of
223  // this data, it should then call Skip() to skip over the consumed bytes.
224  // This may be useful for implementing external fast parsing routines for
225  // types of data not covered by the CodedInputStream interface.
226  bool GetDirectBufferPointer(const void** data, int* size);
227 
228  // Like GetDirectBufferPointer, but this method is inlined, and does not
229  // attempt to Refresh() if the buffer is currently empty.
230  PROTOBUF_ALWAYS_INLINE
231  void GetDirectBufferPointerInline(const void** data, int* size);
232 
233  // Read raw bytes, copying them into the given buffer.
234  bool ReadRaw(void* buffer, int size);
235 
236  // Like ReadRaw, but reads into a string.
237  bool ReadString(std::string* buffer, int size);
238 
239 
240  // Read a 32-bit little-endian integer.
241  bool ReadLittleEndian32(uint32_t* value);
242  // Read a 64-bit little-endian integer.
243  bool ReadLittleEndian64(uint64_t* value);
244 
245  // These methods read from an externally provided buffer. The caller is
246  // responsible for ensuring that the buffer has sufficient space.
247  // Read a 32-bit little-endian integer.
248  static const uint8_t* ReadLittleEndian32FromArray(const uint8_t* buffer,
249  uint32_t* value);
250  // Read a 64-bit little-endian integer.
251  static const uint8_t* ReadLittleEndian64FromArray(const uint8_t* buffer,
252  uint64_t* value);
253 
254  // Read an unsigned integer with Varint encoding, truncating to 32 bits.
255  // Reading a 32-bit value is equivalent to reading a 64-bit one and casting
256  // it to uint32_t, but may be more efficient.
257  bool ReadVarint32(uint32_t* value);
258  // Read an unsigned integer with Varint encoding.
259  bool ReadVarint64(uint64_t* value);
260 
261  // Reads a varint off the wire into an "int". This should be used for reading
262  // sizes off the wire (sizes of strings, submessages, bytes fields, etc).
263  //
264  // The value from the wire is interpreted as unsigned. If its value exceeds
265  // the representable value of an integer on this platform, instead of
266  // truncating we return false. Truncating (as performed by ReadVarint32()
267  // above) is an acceptable approach for fields representing an integer, but
268  // when we are parsing a size from the wire, truncating the value would result
269  // in us misparsing the payload.
270  bool ReadVarintSizeAsInt(int* value);
271 
272  // Read a tag. This calls ReadVarint32() and returns the result, or returns
273  // zero (which is not a valid tag) if ReadVarint32() fails. Also, ReadTag
274  // (but not ReadTagNoLastTag) updates the last tag value, which can be checked
275  // with LastTagWas().
276  //
277  // Always inline because this is only called in one place per parse loop
278  // but it is called for every iteration of said loop, so it should be fast.
279  // GCC doesn't want to inline this by default.
280  PROTOBUF_ALWAYS_INLINE uint32_t ReadTag() {
281  return last_tag_ = ReadTagNoLastTag();
282  }
283 
284  PROTOBUF_ALWAYS_INLINE uint32_t ReadTagNoLastTag();
285 
286  // This usually a faster alternative to ReadTag() when cutoff is a manifest
287  // constant. It does particularly well for cutoff >= 127. The first part
288  // of the return value is the tag that was read, though it can also be 0 in
289  // the cases where ReadTag() would return 0. If the second part is true
290  // then the tag is known to be in [0, cutoff]. If not, the tag either is
291  // above cutoff or is 0. (There's intentional wiggle room when tag is 0,
292  // because that can arise in several ways, and for best performance we want
293  // to avoid an extra "is tag == 0?" check here.)
294  PROTOBUF_ALWAYS_INLINE
295  std::pair<uint32_t, bool> ReadTagWithCutoff(uint32_t cutoff) {
296  std::pair<uint32_t, bool> result = ReadTagWithCutoffNoLastTag(cutoff);
297  last_tag_ = result.first;
298  return result;
299  }
300 
301  PROTOBUF_ALWAYS_INLINE
302  std::pair<uint32_t, bool> ReadTagWithCutoffNoLastTag(uint32_t cutoff);
303 
304  // Usually returns true if calling ReadVarint32() now would produce the given
305  // value. Will always return false if ReadVarint32() would not return the
306  // given value. If ExpectTag() returns true, it also advances past
307  // the varint. For best performance, use a compile-time constant as the
308  // parameter.
309  // Always inline because this collapses to a small number of instructions
310  // when given a constant parameter, but GCC doesn't want to inline by default.
311  PROTOBUF_ALWAYS_INLINE bool ExpectTag(uint32_t expected);
312 
313  // Like above, except this reads from the specified buffer. The caller is
314  // responsible for ensuring that the buffer is large enough to read a varint
315  // of the expected size. For best performance, use a compile-time constant as
316  // the expected tag parameter.
317  //
318  // Returns a pointer beyond the expected tag if it was found, or NULL if it
319  // was not.
320  PROTOBUF_ALWAYS_INLINE
321  static const uint8_t* ExpectTagFromArray(const uint8_t* buffer,
322  uint32_t expected);
323 
324  // Usually returns true if no more bytes can be read. Always returns false
325  // if more bytes can be read. If ExpectAtEnd() returns true, a subsequent
326  // call to LastTagWas() will act as if ReadTag() had been called and returned
327  // zero, and ConsumedEntireMessage() will return true.
328  bool ExpectAtEnd();
329 
330  // If the last call to ReadTag() or ReadTagWithCutoff() returned the given
331  // value, returns true. Otherwise, returns false.
332  // ReadTagNoLastTag/ReadTagWithCutoffNoLastTag do not preserve the last
333  // returned value.
334  //
335  // This is needed because parsers for some types of embedded messages
336  // (with field type TYPE_GROUP) don't actually know that they've reached the
337  // end of a message until they see an ENDGROUP tag, which was actually part
338  // of the enclosing message. The enclosing message would like to check that
339  // tag to make sure it had the right number, so it calls LastTagWas() on
340  // return from the embedded parser to check.
341  bool LastTagWas(uint32_t expected);
342  void SetLastTag(uint32_t tag) { last_tag_ = tag; }
343 
344  // When parsing message (but NOT a group), this method must be called
345  // immediately after MergeFromCodedStream() returns (if it returns true)
346  // to further verify that the message ended in a legitimate way. For
347  // example, this verifies that parsing did not end on an end-group tag.
348  // It also checks for some cases where, due to optimizations,
349  // MergeFromCodedStream() can incorrectly return true.
350  bool ConsumedEntireMessage();
351  void SetConsumed() { legitimate_message_end_ = true; }
352 
353  // Limits ----------------------------------------------------------
354  // Limits are used when parsing length-delimited embedded messages.
355  // After the message's length is read, PushLimit() is used to prevent
356  // the CodedInputStream from reading beyond that length. Once the
357  // embedded message has been parsed, PopLimit() is called to undo the
358  // limit.
359 
360  // Opaque type used with PushLimit() and PopLimit(). Do not modify
361  // values of this type yourself. The only reason that this isn't a
362  // struct with private internals is for efficiency.
363  typedef int Limit;
364 
365  // Places a limit on the number of bytes that the stream may read,
366  // starting from the current position. Once the stream hits this limit,
367  // it will act like the end of the input has been reached until PopLimit()
368  // is called.
369  //
370  // As the names imply, the stream conceptually has a stack of limits. The
371  // shortest limit on the stack is always enforced, even if it is not the
372  // top limit.
373  //
374  // The value returned by PushLimit() is opaque to the caller, and must
375  // be passed unchanged to the corresponding call to PopLimit().
376  Limit PushLimit(int byte_limit);
377 
378  // Pops the last limit pushed by PushLimit(). The input must be the value
379  // returned by that call to PushLimit().
380  void PopLimit(Limit limit);
381 
382  // Returns the number of bytes left until the nearest limit on the
383  // stack is hit, or -1 if no limits are in place.
384  int BytesUntilLimit() const;
385 
386  // Returns current position relative to the beginning of the input stream.
387  int CurrentPosition() const;
388 
389  // Total Bytes Limit -----------------------------------------------
390  // To prevent malicious users from sending excessively large messages
391  // and causing memory exhaustion, CodedInputStream imposes a hard limit on
392  // the total number of bytes it will read.
393 
394  // Sets the maximum number of bytes that this CodedInputStream will read
395  // before refusing to continue. To prevent servers from allocating enormous
396  // amounts of memory to hold parsed messages, the maximum message length
397  // should be limited to the shortest length that will not harm usability.
398  // The default limit is INT_MAX (~2GB) and apps should set shorter limits
399  // if possible. An error will always be printed to stderr if the limit is
400  // reached.
401  //
402  // Note: setting a limit less than the current read position is interpreted
403  // as a limit on the current position.
404  //
405  // This is unrelated to PushLimit()/PopLimit().
406  void SetTotalBytesLimit(int total_bytes_limit);
407 
408  // The Total Bytes Limit minus the Current Position, or -1 if the total bytes
409  // limit is INT_MAX.
410  int BytesUntilTotalBytesLimit() const;
411 
412  // Recursion Limit -------------------------------------------------
413  // To prevent corrupt or malicious messages from causing stack overflows,
414  // we must keep track of the depth of recursion when parsing embedded
415  // messages and groups. CodedInputStream keeps track of this because it
416  // is the only object that is passed down the stack during parsing.
417 
418  // Sets the maximum recursion depth. The default is 100.
419  void SetRecursionLimit(int limit);
420  int RecursionBudget() { return recursion_budget_; }
421 
422  static int GetDefaultRecursionLimit() { return default_recursion_limit_; }
423 
424  // Increments the current recursion depth. Returns true if the depth is
425  // under the limit, false if it has gone over.
426  bool IncrementRecursionDepth();
427 
428  // Decrements the recursion depth if possible.
429  void DecrementRecursionDepth();
430 
431  // Decrements the recursion depth blindly. This is faster than
432  // DecrementRecursionDepth(). It should be used only if all previous
433  // increments to recursion depth were successful.
434  void UnsafeDecrementRecursionDepth();
435 
436  // Shorthand for make_pair(PushLimit(byte_limit), --recursion_budget_).
437  // Using this can reduce code size and complexity in some cases. The caller
438  // is expected to check that the second part of the result is non-negative (to
439  // bail out if the depth of recursion is too high) and, if all is well, to
440  // later pass the first part of the result to PopLimit() or similar.
441  std::pair<CodedInputStream::Limit, int> IncrementRecursionDepthAndPushLimit(
442  int byte_limit);
443 
444  // Shorthand for PushLimit(ReadVarint32(&length) ? length : 0).
445  Limit ReadLengthAndPushLimit();
446 
447  // Helper that is equivalent to: {
448  // bool result = ConsumedEntireMessage();
449  // PopLimit(limit);
450  // UnsafeDecrementRecursionDepth();
451  // return result; }
452  // Using this can reduce code size and complexity in some cases.
453  // Do not use unless the current recursion depth is greater than zero.
454  bool DecrementRecursionDepthAndPopLimit(Limit limit);
455 
456  // Helper that is equivalent to: {
457  // bool result = ConsumedEntireMessage();
458  // PopLimit(limit);
459  // return result; }
460  // Using this can reduce code size and complexity in some cases.
461  bool CheckEntireMessageConsumedAndPopLimit(Limit limit);
462 
463  // Extension Registry ----------------------------------------------
464  // ADVANCED USAGE: 99.9% of people can ignore this section.
465  //
466  // By default, when parsing extensions, the parser looks for extension
467  // definitions in the pool which owns the outer message's Descriptor.
468  // However, you may call SetExtensionRegistry() to provide an alternative
469  // pool instead. This makes it possible, for example, to parse a message
470  // using a generated class, but represent some extensions using
471  // DynamicMessage.
472 
473  // Set the pool used to look up extensions. Most users do not need to call
474  // this as the correct pool will be chosen automatically.
475  //
476  // WARNING: It is very easy to misuse this. Carefully read the requirements
477  // below. Do not use this unless you are sure you need it. Almost no one
478  // does.
479  //
480  // Let's say you are parsing a message into message object m, and you want
481  // to take advantage of SetExtensionRegistry(). You must follow these
482  // requirements:
483  //
484  // The given DescriptorPool must contain m->GetDescriptor(). It is not
485  // sufficient for it to simply contain a descriptor that has the same name
486  // and content -- it must be the *exact object*. In other words:
487  // assert(pool->FindMessageTypeByName(m->GetDescriptor()->full_name()) ==
488  // m->GetDescriptor());
489  // There are two ways to satisfy this requirement:
490  // 1) Use m->GetDescriptor()->pool() as the pool. This is generally useless
491  // because this is the pool that would be used anyway if you didn't call
492  // SetExtensionRegistry() at all.
493  // 2) Use a DescriptorPool which has m->GetDescriptor()->pool() as an
494  // "underlay". Read the documentation for DescriptorPool for more
495  // information about underlays.
496  //
497  // You must also provide a MessageFactory. This factory will be used to
498  // construct Message objects representing extensions. The factory's
499  // GetPrototype() MUST return non-NULL for any Descriptor which can be found
500  // through the provided pool.
501  //
502  // If the provided factory might return instances of protocol-compiler-
503  // generated (i.e. compiled-in) types, or if the outer message object m is
504  // a generated type, then the given factory MUST have this property: If
505  // GetPrototype() is given a Descriptor which resides in
506  // DescriptorPool::generated_pool(), the factory MUST return the same
507  // prototype which MessageFactory::generated_factory() would return. That
508  // is, given a descriptor for a generated type, the factory must return an
509  // instance of the generated class (NOT DynamicMessage). However, when
510  // given a descriptor for a type that is NOT in generated_pool, the factory
511  // is free to return any implementation.
512  //
513  // The reason for this requirement is that generated sub-objects may be
514  // accessed via the standard (non-reflection) extension accessor methods,
515  // and these methods will down-cast the object to the generated class type.
516  // If the object is not actually of that type, the results would be undefined.
517  // On the other hand, if an extension is not compiled in, then there is no
518  // way the code could end up accessing it via the standard accessors -- the
519  // only way to access the extension is via reflection. When using reflection,
520  // DynamicMessage and generated messages are indistinguishable, so it's fine
521  // if these objects are represented using DynamicMessage.
522  //
523  // Using DynamicMessageFactory on which you have called
524  // SetDelegateToGeneratedFactory(true) should be sufficient to satisfy the
525  // above requirement.
526  //
527  // If either pool or factory is NULL, both must be NULL.
528  //
529  // Note that this feature is ignored when parsing "lite" messages as they do
530  // not have descriptors.
531  void SetExtensionRegistry(const DescriptorPool* pool,
532  MessageFactory* factory);
533 
534  // Get the DescriptorPool set via SetExtensionRegistry(), or NULL if no pool
535  // has been provided.
536  const DescriptorPool* GetExtensionPool();
537 
538  // Get the MessageFactory set via SetExtensionRegistry(), or NULL if no
539  // factory has been provided.
540  MessageFactory* GetExtensionFactory();
541 
542  private:
544 
545  const uint8_t* buffer_;
546  const uint8_t* buffer_end_; // pointer to the end of the buffer.
548  int total_bytes_read_; // total bytes read from input_, including
549  // the current buffer
550 
551  // If total_bytes_read_ surpasses INT_MAX, we record the extra bytes here
552  // so that we can BackUp() on destruction.
553  int overflow_bytes_;
554 
555  // LastTagWas() stuff.
556  uint32_t last_tag_; // result of last ReadTag() or ReadTagWithCutoff().
557 
558  // This is set true by ReadTag{Fallback/Slow}() if it is called when exactly
559  // at EOF, or by ExpectAtEnd() when it returns true. This happens when we
560  // reach the end of a message and attempt to read another tag.
561  bool legitimate_message_end_;
562 
563  // See EnableAliasing().
564  bool aliasing_enabled_;
565 
566  // Limits
567  Limit current_limit_; // if position = -1, no limit is applied
568 
569  // For simplicity, if the current buffer crosses a limit (either a normal
570  // limit created by PushLimit() or the total bytes limit), buffer_size_
571  // only tracks the number of bytes before that limit. This field
572  // contains the number of bytes after it. Note that this implies that if
573  // buffer_size_ == 0 and buffer_size_after_limit_ > 0, we know we've
574  // hit a limit. However, if both are zero, it doesn't necessarily mean
575  // we aren't at a limit -- the buffer may have ended exactly at the limit.
576  int buffer_size_after_limit_;
577 
578  // Maximum number of bytes to read, period. This is unrelated to
579  // current_limit_. Set using SetTotalBytesLimit().
580  int total_bytes_limit_;
581 
582  // Current recursion budget, controlled by IncrementRecursionDepth() and
583  // similar. Starts at recursion_limit_ and goes down: if this reaches
584  // -1 we are over budget.
585  int recursion_budget_;
586  // Recursion depth limit, set by SetRecursionLimit().
587  int recursion_limit_;
588 
589  // See SetExtensionRegistry().
590  const DescriptorPool* extension_pool_;
591  MessageFactory* extension_factory_;
592 
593  // Private member functions.
594 
595  // Fallback when Skip() goes past the end of the current buffer.
596  bool SkipFallback(int count, int original_buffer_size);
597 
598  // Advance the buffer by a given number of bytes.
599  void Advance(int amount);
600 
601  // Back up input_ to the current buffer position.
602  void BackUpInputToCurrentPosition();
603 
604  // Recomputes the value of buffer_size_after_limit_. Must be called after
605  // current_limit_ or total_bytes_limit_ changes.
606  void RecomputeBufferLimits();
607 
608  // Writes an error message saying that we hit total_bytes_limit_.
609  void PrintTotalBytesLimitError();
610 
611  // Called when the buffer runs out to request more data. Implies an
612  // Advance(BufferSize()).
613  bool Refresh();
614 
615  // When parsing varints, we optimize for the common case of small values, and
616  // then optimize for the case when the varint fits within the current buffer
617  // piece. The Fallback method is used when we can't use the one-byte
618  // optimization. The Slow method is yet another fallback when the buffer is
619  // not large enough. Making the slow path out-of-line speeds up the common
620  // case by 10-15%. The slow path is fairly uncommon: it only triggers when a
621  // message crosses multiple buffers. Note: ReadVarint32Fallback() and
622  // ReadVarint64Fallback() are called frequently and generally not inlined, so
623  // they have been optimized to avoid "out" parameters. The former returns -1
624  // if it fails and the uint32_t it read otherwise. The latter has a bool
625  // indicating success or failure as part of its return type.
626  int64_t ReadVarint32Fallback(uint32_t first_byte_or_zero);
627  int ReadVarintSizeAsIntFallback();
628  std::pair<uint64_t, bool> ReadVarint64Fallback();
629  bool ReadVarint32Slow(uint32_t* value);
630  bool ReadVarint64Slow(uint64_t* value);
631  int ReadVarintSizeAsIntSlow();
632  bool ReadLittleEndian32Fallback(uint32_t* value);
633  bool ReadLittleEndian64Fallback(uint64_t* value);
634 
635  // Fallback/slow methods for reading tags. These do not update last_tag_,
636  // but will set legitimate_message_end_ if we are at the end of the input
637  // stream.
638  uint32_t ReadTagFallback(uint32_t first_byte_or_zero);
639  uint32_t ReadTagSlow();
640  bool ReadStringFallback(std::string* buffer, int size);
641 
642  // Return the size of the buffer.
643  int BufferSize() const;
644 
645  static const int kDefaultTotalBytesLimit = INT_MAX;
646 
647  static int default_recursion_limit_; // 100 by default.
648 
650  friend class google::protobuf::internal::EpsCopyByteStream;
651 };
652 
653 // EpsCopyOutputStream wraps a ZeroCopyOutputStream and exposes a new stream,
654 // which has the property you can write kSlopBytes (16 bytes) from the current
655 // position without bounds checks. The cursor into the stream is managed by
656 // the user of the class and is an explicit parameter in the methods. Careful
657 // use of this class, ie. keep ptr a local variable, eliminates the need to
658 // for the compiler to sync the ptr value between register and memory.
659 class PROTOBUF_EXPORT EpsCopyOutputStream {
660  public:
661  enum { kSlopBytes = 16 };
662 
663  // Initialize from a stream.
665  uint8_t** pp)
666  : end_(buffer_),
667  stream_(stream),
668  is_serialization_deterministic_(deterministic) {
669  *pp = buffer_;
670  }
671 
672  // Only for array serialization. No overflow protection, end_ will be the
673  // pointed to the end of the array. When using this the total size is already
674  // known, so no need to maintain the slop region.
675  EpsCopyOutputStream(void* data, int size, bool deterministic)
676  : end_(static_cast<uint8_t*>(data) + size),
677  buffer_end_(nullptr),
678  stream_(nullptr),
679  is_serialization_deterministic_(deterministic) {}
680 
681  // Initialize from stream but with the first buffer already given (eager).
683  bool deterministic, uint8_t** pp)
684  : stream_(stream), is_serialization_deterministic_(deterministic) {
685  *pp = SetInitialBuffer(data, size);
686  }
687 
688  // Flush everything that's written into the underlying ZeroCopyOutputStream
689  // and trims the underlying stream to the location of ptr.
690  uint8_t* Trim(uint8_t* ptr);
691 
692  // After this it's guaranteed you can safely write kSlopBytes to ptr. This
693  // will never fail! The underlying stream can produce an error. Use HadError
694  // to check for errors.
695  PROTOBUF_NODISCARD uint8_t* EnsureSpace(uint8_t* ptr) {
696  if (PROTOBUF_PREDICT_FALSE(ptr >= end_)) {
697  return EnsureSpaceFallback(ptr);
698  }
699  return ptr;
700  }
701 
702  uint8_t* WriteRaw(const void* data, int size, uint8_t* ptr) {
703  if (PROTOBUF_PREDICT_FALSE(end_ - ptr < size)) {
704  return WriteRawFallback(data, size, ptr);
705  }
707  return ptr + size;
708  }
709  // Writes the buffer specified by data, size to the stream. Possibly by
710  // aliasing the buffer (ie. not copying the data). The caller is responsible
711  // to make sure the buffer is alive for the duration of the
712  // ZeroCopyOutputStream.
713 #ifndef NDEBUG
714  PROTOBUF_NOINLINE
715 #endif
717  if (aliasing_enabled_) {
718  return WriteAliasedRaw(data, size, ptr);
719  } else {
720  return WriteRaw(data, size, ptr);
721  }
722  }
723 
724 
725 #ifndef NDEBUG
726  PROTOBUF_NOINLINE
727 #endif
729  uint8_t* ptr) {
730  std::ptrdiff_t size = s.size();
731  if (PROTOBUF_PREDICT_FALSE(
732  size >= 128 || end_ - ptr + 16 - TagSize(num << 3) - 1 < size)) {
733  return WriteStringMaybeAliasedOutline(num, s, ptr);
734  }
735  ptr = UnsafeVarint((num << 3) | 2, ptr);
736  *ptr++ = static_cast<uint8_t>(size);
737  std::memcpy(ptr, s.data(), size);
738  return ptr + size;
739  }
741  uint8_t* ptr) {
742  return WriteStringMaybeAliased(num, s, ptr);
743  }
744 
745  template <typename T>
746  PROTOBUF_ALWAYS_INLINE uint8_t* WriteString(uint32_t num, const T& s,
747  uint8_t* ptr) {
748  std::ptrdiff_t size = s.size();
749  if (PROTOBUF_PREDICT_FALSE(
750  size >= 128 || end_ - ptr + 16 - TagSize(num << 3) - 1 < size)) {
751  return WriteStringOutline(num, s, ptr);
752  }
753  ptr = UnsafeVarint((num << 3) | 2, ptr);
754  *ptr++ = static_cast<uint8_t>(size);
755  std::memcpy(ptr, s.data(), size);
756  return ptr + size;
757  }
758  template <typename T>
759 #ifndef NDEBUG
760  PROTOBUF_NOINLINE
761 #endif
763  return WriteString(num, s, ptr);
764  }
765 
766  template <typename T>
767  PROTOBUF_ALWAYS_INLINE uint8_t* WriteInt32Packed(int num, const T& r,
768  int size, uint8_t* ptr) {
769  return WriteVarintPacked(num, r, size, ptr, Encode64);
770  }
771  template <typename T>
772  PROTOBUF_ALWAYS_INLINE uint8_t* WriteUInt32Packed(int num, const T& r,
773  int size, uint8_t* ptr) {
774  return WriteVarintPacked(num, r, size, ptr, Encode32);
775  }
776  template <typename T>
777  PROTOBUF_ALWAYS_INLINE uint8_t* WriteSInt32Packed(int num, const T& r,
778  int size, uint8_t* ptr) {
779  return WriteVarintPacked(num, r, size, ptr, ZigZagEncode32);
780  }
781  template <typename T>
782  PROTOBUF_ALWAYS_INLINE uint8_t* WriteInt64Packed(int num, const T& r,
783  int size, uint8_t* ptr) {
784  return WriteVarintPacked(num, r, size, ptr, Encode64);
785  }
786  template <typename T>
787  PROTOBUF_ALWAYS_INLINE uint8_t* WriteUInt64Packed(int num, const T& r,
788  int size, uint8_t* ptr) {
789  return WriteVarintPacked(num, r, size, ptr, Encode64);
790  }
791  template <typename T>
792  PROTOBUF_ALWAYS_INLINE uint8_t* WriteSInt64Packed(int num, const T& r,
793  int size, uint8_t* ptr) {
794  return WriteVarintPacked(num, r, size, ptr, ZigZagEncode64);
795  }
796  template <typename T>
797  PROTOBUF_ALWAYS_INLINE uint8_t* WriteEnumPacked(int num, const T& r, int size,
798  uint8_t* ptr) {
799  return WriteVarintPacked(num, r, size, ptr, Encode64);
800  }
801 
802  template <typename T>
803  PROTOBUF_ALWAYS_INLINE uint8_t* WriteFixedPacked(int num, const T& r,
804  uint8_t* ptr) {
805  ptr = EnsureSpace(ptr);
806  constexpr auto element_size = sizeof(typename T::value_type);
807  auto size = r.size() * element_size;
808  ptr = WriteLengthDelim(num, size, ptr);
809  return WriteRawLittleEndian<element_size>(r.data(), static_cast<int>(size),
810  ptr);
811  }
812 
813  // Returns true if there was an underlying I/O error since this object was
814  // created.
815  bool HadError() const { return had_error_; }
816 
817  // Instructs the EpsCopyOutputStream to allow the underlying
818  // ZeroCopyOutputStream to hold pointers to the original structure instead of
819  // copying, if it supports it (i.e. output->AllowsAliasing() is true). If the
820  // underlying stream does not support aliasing, then enabling it has no
821  // affect. For now, this only affects the behavior of
822  // WriteRawMaybeAliased().
823  //
824  // NOTE: It is caller's responsibility to ensure that the chunk of memory
825  // remains live until all of the data has been consumed from the stream.
826  void EnableAliasing(bool enabled);
827 
828  // See documentation on CodedOutputStream::SetSerializationDeterministic.
830  is_serialization_deterministic_ = value;
831  }
832 
833  // See documentation on CodedOutputStream::IsSerializationDeterministic.
835  return is_serialization_deterministic_;
836  }
837 
838  // The number of bytes written to the stream at position ptr, relative to the
839  // stream's overall position.
840  int64_t ByteCount(uint8_t* ptr) const;
841 
842 
843  private:
845  uint8_t* buffer_end_ = buffer_;
846  uint8_t buffer_[2 * kSlopBytes];
848  bool had_error_ = false;
849  bool aliasing_enabled_ = false; // See EnableAliasing().
850  bool is_serialization_deterministic_;
851 
852  uint8_t* EnsureSpaceFallback(uint8_t* ptr);
853  inline uint8_t* Next();
854  int Flush(uint8_t* ptr);
855  std::ptrdiff_t GetSize(uint8_t* ptr) const {
856  GOOGLE_DCHECK(ptr <= end_ + kSlopBytes); // NOLINT
857  return end_ + kSlopBytes - ptr;
858  }
859 
861  had_error_ = true;
862  // We use the patch buffer to always guarantee space to write to.
863  end_ = buffer_ + kSlopBytes;
864  return buffer_;
865  }
866 
867  static constexpr int TagSize(uint32_t tag) {
868  return (tag < (1 << 7)) ? 1
869  : (tag < (1 << 14)) ? 2
870  : (tag < (1 << 21)) ? 3
871  : (tag < (1 << 28)) ? 4
872  : 5;
873  }
874 
875  PROTOBUF_ALWAYS_INLINE uint8_t* WriteTag(uint32_t num, uint32_t wt,
876  uint8_t* ptr) {
877  GOOGLE_DCHECK(ptr < end_); // NOLINT
878  return UnsafeVarint((num << 3) | wt, ptr);
879  }
880 
881  PROTOBUF_ALWAYS_INLINE uint8_t* WriteLengthDelim(int num, uint32_t size,
882  uint8_t* ptr) {
883  ptr = WriteTag(num, 2, ptr);
884  return UnsafeWriteSize(size, ptr);
885  }
886 
887  uint8_t* WriteRawFallback(const void* data, int size, uint8_t* ptr);
888 
889  uint8_t* WriteAliasedRaw(const void* data, int size, uint8_t* ptr);
890 
891  uint8_t* WriteStringMaybeAliasedOutline(uint32_t num, const std::string& s,
892  uint8_t* ptr);
893  uint8_t* WriteStringOutline(uint32_t num, const std::string& s, uint8_t* ptr);
894 
895  template <typename T, typename E>
896  PROTOBUF_ALWAYS_INLINE uint8_t* WriteVarintPacked(int num, const T& r,
897  int size, uint8_t* ptr,
898  const E& encode) {
899  ptr = EnsureSpace(ptr);
900  ptr = WriteLengthDelim(num, size, ptr);
901  auto it = r.data();
902  auto end = it + r.size();
903  do {
904  ptr = EnsureSpace(ptr);
905  ptr = UnsafeVarint(encode(*it++), ptr);
906  } while (it < end);
907  return ptr;
908  }
909 
910  static uint32_t Encode32(uint32_t v) { return v; }
911  static uint64_t Encode64(uint64_t v) { return v; }
913  return (static_cast<uint32_t>(v) << 1) ^ static_cast<uint32_t>(v >> 31);
914  }
916  return (static_cast<uint64_t>(v) << 1) ^ static_cast<uint64_t>(v >> 63);
917  }
918 
919  template <typename T>
920  PROTOBUF_ALWAYS_INLINE static uint8_t* UnsafeVarint(T value, uint8_t* ptr) {
921  static_assert(std::is_unsigned<T>::value,
922  "Varint serialization must be unsigned");
923  ptr[0] = static_cast<uint8_t>(value);
924  if (value < 0x80) {
925  return ptr + 1;
926  }
927  // Turn on continuation bit in the byte we just wrote.
928  ptr[0] |= static_cast<uint8_t>(0x80);
929  value >>= 7;
930  ptr[1] = static_cast<uint8_t>(value);
931  if (value < 0x80) {
932  return ptr + 2;
933  }
934  ptr += 2;
935  do {
936  // Turn on continuation bit in the byte we just wrote.
937  ptr[-1] |= static_cast<uint8_t>(0x80);
938  value >>= 7;
939  *ptr = static_cast<uint8_t>(value);
940  ++ptr;
941  } while (value >= 0x80);
942  return ptr;
943  }
944 
945  PROTOBUF_ALWAYS_INLINE static uint8_t* UnsafeWriteSize(uint32_t value,
946  uint8_t* ptr) {
947  while (PROTOBUF_PREDICT_FALSE(value >= 0x80)) {
948  *ptr = static_cast<uint8_t>(value | 0x80);
949  value >>= 7;
950  ++ptr;
951  }
952  *ptr++ = static_cast<uint8_t>(value);
953  return ptr;
954  }
955 
956  template <int S>
957  uint8_t* WriteRawLittleEndian(const void* data, int size, uint8_t* ptr);
958 #ifndef PROTOBUF_LITTLE_ENDIAN
959  uint8_t* WriteRawLittleEndian32(const void* data, int size, uint8_t* ptr);
960  uint8_t* WriteRawLittleEndian64(const void* data, int size, uint8_t* ptr);
961 #endif
962 
963  // These methods are for CodedOutputStream. Ideally they should be private
964  // but to match current behavior of CodedOutputStream as close as possible
965  // we allow it some functionality.
966  public:
968  auto ptr = static_cast<uint8_t*>(data);
969  if (size > kSlopBytes) {
970  end_ = ptr + size - kSlopBytes;
971  buffer_end_ = nullptr;
972  return ptr;
973  } else {
974  end_ = buffer_ + size;
975  buffer_end_ = ptr;
976  return buffer_;
977  }
978  }
979 
980  private:
981  // Needed by CodedOutputStream HadError. HadError needs to flush the patch
982  // buffers to ensure there is no error as of yet.
983  uint8_t* FlushAndResetBuffer(uint8_t*);
984 
985  // The following functions mimic the old CodedOutputStream behavior as close
986  // as possible. They flush the current state to the stream, behave as
987  // the old CodedOutputStream and then return to normal operation.
988  bool Skip(int count, uint8_t** pp);
989  bool GetDirectBufferPointer(void** data, int* size, uint8_t** pp);
990  uint8_t* GetDirectBufferForNBytesAndAdvance(int size, uint8_t** pp);
991 
992  friend class CodedOutputStream;
993 };
994 
995 template <>
996 inline uint8_t* EpsCopyOutputStream::WriteRawLittleEndian<1>(const void* data,
997  int size,
998  uint8_t* ptr) {
999  return WriteRaw(data, size, ptr);
1000 }
1001 template <>
1002 inline uint8_t* EpsCopyOutputStream::WriteRawLittleEndian<4>(const void* data,
1003  int size,
1004  uint8_t* ptr) {
1005 #ifdef PROTOBUF_LITTLE_ENDIAN
1006  return WriteRaw(data, size, ptr);
1007 #else
1008  return WriteRawLittleEndian32(data, size, ptr);
1009 #endif
1010 }
1011 template <>
1012 inline uint8_t* EpsCopyOutputStream::WriteRawLittleEndian<8>(const void* data,
1013  int size,
1014  uint8_t* ptr) {
1015 #ifdef PROTOBUF_LITTLE_ENDIAN
1016  return WriteRaw(data, size, ptr);
1017 #else
1018  return WriteRawLittleEndian64(data, size, ptr);
1019 #endif
1020 }
1021 
1022 // Class which encodes and writes binary data which is composed of varint-
1023 // encoded integers and fixed-width pieces. Wraps a ZeroCopyOutputStream.
1024 // Most users will not need to deal with CodedOutputStream.
1025 //
1026 // Most methods of CodedOutputStream which return a bool return false if an
1027 // underlying I/O error occurs. Once such a failure occurs, the
1028 // CodedOutputStream is broken and is no longer useful. The Write* methods do
1029 // not return the stream status, but will invalidate the stream if an error
1030 // occurs. The client can probe HadError() to determine the status.
1031 //
1032 // Note that every method of CodedOutputStream which writes some data has
1033 // a corresponding static "ToArray" version. These versions write directly
1034 // to the provided buffer, returning a pointer past the last written byte.
1035 // They require that the buffer has sufficient capacity for the encoded data.
1036 // This allows an optimization where we check if an output stream has enough
1037 // space for an entire message before we start writing and, if there is, we
1038 // call only the ToArray methods to avoid doing bound checks for each
1039 // individual value.
1040 // i.e., in the example above:
1041 //
1042 // CodedOutputStream* coded_output = new CodedOutputStream(raw_output);
1043 // int magic_number = 1234;
1044 // char text[] = "Hello world!";
1045 //
1046 // int coded_size = sizeof(magic_number) +
1047 // CodedOutputStream::VarintSize32(strlen(text)) +
1048 // strlen(text);
1049 //
1050 // uint8_t* buffer =
1051 // coded_output->GetDirectBufferForNBytesAndAdvance(coded_size);
1052 // if (buffer != nullptr) {
1053 // // The output stream has enough space in the buffer: write directly to
1054 // // the array.
1055 // buffer = CodedOutputStream::WriteLittleEndian32ToArray(magic_number,
1056 // buffer);
1057 // buffer = CodedOutputStream::WriteVarint32ToArray(strlen(text), buffer);
1058 // buffer = CodedOutputStream::WriteRawToArray(text, strlen(text), buffer);
1059 // } else {
1060 // // Make bound-checked writes, which will ask the underlying stream for
1061 // // more space as needed.
1062 // coded_output->WriteLittleEndian32(magic_number);
1063 // coded_output->WriteVarint32(strlen(text));
1064 // coded_output->WriteRaw(text, strlen(text));
1065 // }
1066 //
1067 // delete coded_output;
1068 class PROTOBUF_EXPORT CodedOutputStream {
1069  public:
1070  // Create an CodedOutputStream that writes to the given ZeroCopyOutputStream.
1073  CodedOutputStream(ZeroCopyOutputStream* stream, bool do_eager_refresh);
1074 
1075  // Destroy the CodedOutputStream and position the underlying
1076  // ZeroCopyOutputStream immediately after the last byte written.
1077  ~CodedOutputStream();
1078 
1079  // Returns true if there was an underlying I/O error since this object was
1080  // created. On should call Trim before this function in order to catch all
1081  // errors.
1082  bool HadError() {
1083  cur_ = impl_.FlushAndResetBuffer(cur_);
1084  GOOGLE_DCHECK(cur_);
1085  return impl_.HadError();
1086  }
1087 
1088  // Trims any unused space in the underlying buffer so that its size matches
1089  // the number of bytes written by this stream. The underlying buffer will
1090  // automatically be trimmed when this stream is destroyed; this call is only
1091  // necessary if the underlying buffer is accessed *before* the stream is
1092  // destroyed.
1093  void Trim() { cur_ = impl_.Trim(cur_); }
1094 
1095  // Skips a number of bytes, leaving the bytes unmodified in the underlying
1096  // buffer. Returns false if an underlying write error occurs. This is
1097  // mainly useful with GetDirectBufferPointer().
1098  // Note of caution, the skipped bytes may contain uninitialized data. The
1099  // caller must make sure that the skipped bytes are properly initialized,
1100  // otherwise you might leak bytes from your heap.
1101  bool Skip(int count) { return impl_.Skip(count, &cur_); }
1102 
1103  // Sets *data to point directly at the unwritten part of the
1104  // CodedOutputStream's underlying buffer, and *size to the size of that
1105  // buffer, but does not advance the stream's current position. This will
1106  // always either produce a non-empty buffer or return false. If the caller
1107  // writes any data to this buffer, it should then call Skip() to skip over
1108  // the consumed bytes. This may be useful for implementing external fast
1109  // serialization routines for types of data not covered by the
1110  // CodedOutputStream interface.
1111  bool GetDirectBufferPointer(void** data, int* size) {
1112  return impl_.GetDirectBufferPointer(data, size, &cur_);
1113  }
1114 
1115  // If there are at least "size" bytes available in the current buffer,
1116  // returns a pointer directly into the buffer and advances over these bytes.
1117  // The caller may then write directly into this buffer (e.g. using the
1118  // *ToArray static methods) rather than go through CodedOutputStream. If
1119  // there are not enough bytes available, returns NULL. The return pointer is
1120  // invalidated as soon as any other non-const method of CodedOutputStream
1121  // is called.
1123  return impl_.GetDirectBufferForNBytesAndAdvance(size, &cur_);
1124  }
1125 
1126  // Write raw bytes, copying them from the given buffer.
1127  void WriteRaw(const void* buffer, int size) {
1128  cur_ = impl_.WriteRaw(buffer, size, cur_);
1129  }
1130  // Like WriteRaw() but will try to write aliased data if aliasing is
1131  // turned on.
1132  void WriteRawMaybeAliased(const void* data, int size);
1133  // Like WriteRaw() but writing directly to the target array.
1134  // This is _not_ inlined, as the compiler often optimizes memcpy into inline
1135  // copy loops. Since this gets called by every field with string or bytes
1136  // type, inlining may lead to a significant amount of code bloat, with only a
1137  // minor performance gain.
1138  static uint8_t* WriteRawToArray(const void* buffer, int size,
1139  uint8_t* target);
1140 
1141  // Equivalent to WriteRaw(str.data(), str.size()).
1142  void WriteString(const std::string& str);
1143  // Like WriteString() but writing directly to the target array.
1144  static uint8_t* WriteStringToArray(const std::string& str, uint8_t* target);
1145  // Write the varint-encoded size of str followed by str.
1146  static uint8_t* WriteStringWithSizeToArray(const std::string& str,
1147  uint8_t* target);
1148 
1149 
1150  // Write a 32-bit little-endian integer.
1152  cur_ = impl_.EnsureSpace(cur_);
1153  SetCur(WriteLittleEndian32ToArray(value, Cur()));
1154  }
1155  // Like WriteLittleEndian32() but writing directly to the target array.
1156  static uint8_t* WriteLittleEndian32ToArray(uint32_t value, uint8_t* target);
1157  // Write a 64-bit little-endian integer.
1159  cur_ = impl_.EnsureSpace(cur_);
1160  SetCur(WriteLittleEndian64ToArray(value, Cur()));
1161  }
1162  // Like WriteLittleEndian64() but writing directly to the target array.
1163  static uint8_t* WriteLittleEndian64ToArray(uint64_t value, uint8_t* target);
1164 
1165  // Write an unsigned integer with Varint encoding. Writing a 32-bit value
1166  // is equivalent to casting it to uint64_t and writing it as a 64-bit value,
1167  // but may be more efficient.
1168  void WriteVarint32(uint32_t value);
1169  // Like WriteVarint32() but writing directly to the target array.
1170  static uint8_t* WriteVarint32ToArray(uint32_t value, uint8_t* target);
1171  // Like WriteVarint32() but writing directly to the target array, and with
1172  // the less common-case paths being out of line rather than inlined.
1173  static uint8_t* WriteVarint32ToArrayOutOfLine(uint32_t value,
1174  uint8_t* target);
1175  // Write an unsigned integer with Varint encoding.
1176  void WriteVarint64(uint64_t value);
1177  // Like WriteVarint64() but writing directly to the target array.
1178  static uint8_t* WriteVarint64ToArray(uint64_t value, uint8_t* target);
1179 
1180  // Equivalent to WriteVarint32() except when the value is negative,
1181  // in which case it must be sign-extended to a full 10 bytes.
1182  void WriteVarint32SignExtended(int32_t value);
1183  // Like WriteVarint32SignExtended() but writing directly to the target array.
1184  static uint8_t* WriteVarint32SignExtendedToArray(int32_t value,
1185  uint8_t* target);
1186 
1187  // This is identical to WriteVarint32(), but optimized for writing tags.
1188  // In particular, if the input is a compile-time constant, this method
1189  // compiles down to a couple instructions.
1190  // Always inline because otherwise the aforementioned optimization can't work,
1191  // but GCC by default doesn't want to inline this.
1192  void WriteTag(uint32_t value);
1193  // Like WriteTag() but writing directly to the target array.
1194  PROTOBUF_ALWAYS_INLINE
1195  static uint8_t* WriteTagToArray(uint32_t value, uint8_t* target);
1196 
1197  // Returns the number of bytes needed to encode the given value as a varint.
1198  static size_t VarintSize32(uint32_t value);
1199  // Returns the number of bytes needed to encode the given value as a varint.
1200  static size_t VarintSize64(uint64_t value);
1201 
1202  // If negative, 10 bytes. Otherwise, same as VarintSize32().
1203  static size_t VarintSize32SignExtended(int32_t value);
1204 
1205  // Same as above, plus one. The additional one comes at no compute cost.
1206  static size_t VarintSize32PlusOne(uint32_t value);
1207  static size_t VarintSize64PlusOne(uint64_t value);
1208  static size_t VarintSize32SignExtendedPlusOne(int32_t value);
1209 
1210  // Compile-time equivalent of VarintSize32().
1211  template <uint32_t Value>
1212  struct StaticVarintSize32 {
1213  static const size_t value = (Value < (1 << 7)) ? 1
1214  : (Value < (1 << 14)) ? 2
1215  : (Value < (1 << 21)) ? 3
1216  : (Value < (1 << 28)) ? 4
1217  : 5;
1218  };
1219 
1220  // Returns the total number of bytes written since this object was created.
1221  int ByteCount() const {
1222  return static_cast<int>(impl_.ByteCount(cur_) - start_count_);
1223  }
1224 
1225  // Instructs the CodedOutputStream to allow the underlying
1226  // ZeroCopyOutputStream to hold pointers to the original structure instead of
1227  // copying, if it supports it (i.e. output->AllowsAliasing() is true). If the
1228  // underlying stream does not support aliasing, then enabling it has no
1229  // affect. For now, this only affects the behavior of
1230  // WriteRawMaybeAliased().
1231  //
1232  // NOTE: It is caller's responsibility to ensure that the chunk of memory
1233  // remains live until all of the data has been consumed from the stream.
1234  void EnableAliasing(bool enabled) { impl_.EnableAliasing(enabled); }
1235 
1236  // Indicate to the serializer whether the user wants derministic
1237  // serialization. The default when this is not called comes from the global
1238  // default, controlled by SetDefaultSerializationDeterministic.
1239  //
1240  // What deterministic serialization means is entirely up to the driver of the
1241  // serialization process (i.e. the caller of methods like WriteVarint32). In
1242  // the case of serializing a proto buffer message using one of the methods of
1243  // MessageLite, this means that for a given binary equal messages will always
1244  // be serialized to the same bytes. This implies:
1245  //
1246  // * Repeated serialization of a message will return the same bytes.
1247  //
1248  // * Different processes running the same binary (including on different
1249  // machines) will serialize equal messages to the same bytes.
1250  //
1251  // Note that this is *not* canonical across languages. It is also unstable
1252  // across different builds with intervening message definition changes, due to
1253  // unknown fields. Users who need canonical serialization (e.g. persistent
1254  // storage in a canonical form, fingerprinting) should define their own
1255  // canonicalization specification and implement the serializer using
1256  // reflection APIs rather than relying on this API.
1258  impl_.SetSerializationDeterministic(value);
1259  }
1260 
1261  // Return whether the user wants deterministic serialization. See above.
1263  return impl_.IsSerializationDeterministic();
1264  }
1265 
1267  return default_serialization_deterministic_.load(
1268  std::memory_order_relaxed) != 0;
1269  }
1270 
1271  template <typename Func>
1272  void Serialize(const Func& func);
1273 
1274  uint8_t* Cur() const { return cur_; }
1275  void SetCur(uint8_t* ptr) { cur_ = ptr; }
1277 
1278  private:
1282  static std::atomic<bool> default_serialization_deterministic_;
1283 
1284  // See above. Other projects may use "friend" to allow them to call this.
1285  // After SetDefaultSerializationDeterministic() completes, all protocol
1286  // buffer serializations will be deterministic by default. Thread safe.
1287  // However, the meaning of "after" is subtle here: to be safe, each thread
1288  // that wants deterministic serialization by default needs to call
1289  // SetDefaultSerializationDeterministic() or ensure on its own that another
1290  // thread has done so.
1293  default_serialization_deterministic_.store(true, std::memory_order_relaxed);
1294  }
1295  // REQUIRES: value >= 0x80, and that (value & 7f) has been written to *target.
1296  static uint8_t* WriteVarint32ToArrayOutOfLineHelper(uint32_t value,
1297  uint8_t* target);
1299 };
1300 
1301 // inline methods ====================================================
1302 // The vast majority of varints are only one byte. These inline
1303 // methods optimize for that case.
1304 
1306  uint32_t v = 0;
1307  if (PROTOBUF_PREDICT_TRUE(buffer_ < buffer_end_)) {
1308  v = *buffer_;
1309  if (v < 0x80) {
1310  *value = v;
1311  Advance(1);
1312  return true;
1313  }
1314  }
1316  *value = static_cast<uint32_t>(result);
1317  return result >= 0;
1318 }
1319 
1321  if (PROTOBUF_PREDICT_TRUE(buffer_ < buffer_end_) && *buffer_ < 0x80) {
1322  *value = *buffer_;
1323  Advance(1);
1324  return true;
1325  }
1326  std::pair<uint64_t, bool> p = ReadVarint64Fallback();
1327  *value = p.first;
1328  return p.second;
1329 }
1330 
1331 inline bool CodedInputStream::ReadVarintSizeAsInt(int* value) {
1332  if (PROTOBUF_PREDICT_TRUE(buffer_ < buffer_end_)) {
1333  int v = *buffer_;
1334  if (v < 0x80) {
1335  *value = v;
1336  Advance(1);
1337  return true;
1338  }
1339  }
1341  return *value >= 0;
1342 }
1343 
1344 // static
1346  const uint8_t* buffer, uint32_t* value) {
1347 #if defined(PROTOBUF_LITTLE_ENDIAN)
1348  memcpy(value, buffer, sizeof(*value));
1349  return buffer + sizeof(*value);
1350 #else
1351  *value = (static_cast<uint32_t>(buffer[0])) |
1352  (static_cast<uint32_t>(buffer[1]) << 8) |
1353  (static_cast<uint32_t>(buffer[2]) << 16) |
1354  (static_cast<uint32_t>(buffer[3]) << 24);
1355  return buffer + sizeof(*value);
1356 #endif
1357 }
1358 // static
1360  const uint8_t* buffer, uint64_t* value) {
1361 #if defined(PROTOBUF_LITTLE_ENDIAN)
1362  memcpy(value, buffer, sizeof(*value));
1363  return buffer + sizeof(*value);
1364 #else
1365  uint32_t part0 = (static_cast<uint32_t>(buffer[0])) |
1366  (static_cast<uint32_t>(buffer[1]) << 8) |
1367  (static_cast<uint32_t>(buffer[2]) << 16) |
1368  (static_cast<uint32_t>(buffer[3]) << 24);
1369  uint32_t part1 = (static_cast<uint32_t>(buffer[4])) |
1370  (static_cast<uint32_t>(buffer[5]) << 8) |
1371  (static_cast<uint32_t>(buffer[6]) << 16) |
1372  (static_cast<uint32_t>(buffer[7]) << 24);
1373  *value = static_cast<uint64_t>(part0) | (static_cast<uint64_t>(part1) << 32);
1374  return buffer + sizeof(*value);
1375 #endif
1376 }
1377 
1379 #if defined(PROTOBUF_LITTLE_ENDIAN)
1380  if (PROTOBUF_PREDICT_TRUE(BufferSize() >= static_cast<int>(sizeof(*value)))) {
1382  return true;
1383  } else {
1385  }
1386 #else
1388 #endif
1389 }
1390 
1392 #if defined(PROTOBUF_LITTLE_ENDIAN)
1393  if (PROTOBUF_PREDICT_TRUE(BufferSize() >= static_cast<int>(sizeof(*value)))) {
1395  return true;
1396  } else {
1398  }
1399 #else
1401 #endif
1402 }
1403 
1405  uint32_t v = 0;
1406  if (PROTOBUF_PREDICT_TRUE(buffer_ < buffer_end_)) {
1407  v = *buffer_;
1408  if (v < 0x80) {
1409  Advance(1);
1410  return v;
1411  }
1412  }
1413  v = ReadTagFallback(v);
1414  return v;
1415 }
1416 
1417 inline std::pair<uint32_t, bool> CodedInputStream::ReadTagWithCutoffNoLastTag(
1418  uint32_t cutoff) {
1419  // In performance-sensitive code we can expect cutoff to be a compile-time
1420  // constant, and things like "cutoff >= kMax1ByteVarint" to be evaluated at
1421  // compile time.
1422  uint32_t first_byte_or_zero = 0;
1423  if (PROTOBUF_PREDICT_TRUE(buffer_ < buffer_end_)) {
1424  // Hot case: buffer_ non_empty, buffer_[0] in [1, 128).
1425  // TODO(gpike): Is it worth rearranging this? E.g., if the number of fields
1426  // is large enough then is it better to check for the two-byte case first?
1427  first_byte_or_zero = buffer_[0];
1428  if (static_cast<int8_t>(buffer_[0]) > 0) {
1429  const uint32_t kMax1ByteVarint = 0x7f;
1430  uint32_t tag = buffer_[0];
1431  Advance(1);
1432  return std::make_pair(tag, cutoff >= kMax1ByteVarint || tag <= cutoff);
1433  }
1434  // Other hot case: cutoff >= 0x80, buffer_ has at least two bytes available,
1435  // and tag is two bytes. The latter is tested by bitwise-and-not of the
1436  // first byte and the second byte.
1437  if (cutoff >= 0x80 && PROTOBUF_PREDICT_TRUE(buffer_ + 1 < buffer_end_) &&
1438  PROTOBUF_PREDICT_TRUE((buffer_[0] & ~buffer_[1]) >= 0x80)) {
1439  const uint32_t kMax2ByteVarint = (0x7f << 7) + 0x7f;
1440  uint32_t tag = (1u << 7) * buffer_[1] + (buffer_[0] - 0x80);
1441  Advance(2);
1442  // It might make sense to test for tag == 0 now, but it is so rare that
1443  // that we don't bother. A varint-encoded 0 should be one byte unless
1444  // the encoder lost its mind. The second part of the return value of
1445  // this function is allowed to be either true or false if the tag is 0,
1446  // so we don't have to check for tag == 0. We may need to check whether
1447  // it exceeds cutoff.
1448  bool at_or_below_cutoff = cutoff >= kMax2ByteVarint || tag <= cutoff;
1449  return std::make_pair(tag, at_or_below_cutoff);
1450  }
1451  }
1452  // Slow path
1453  const uint32_t tag = ReadTagFallback(first_byte_or_zero);
1454  return std::make_pair(tag, static_cast<uint32_t>(tag - 1) < cutoff);
1455 }
1456 
1457 inline bool CodedInputStream::LastTagWas(uint32_t expected) {
1458  return last_tag_ == expected;
1459 }
1460 
1462  return legitimate_message_end_;
1463 }
1464 
1465 inline bool CodedInputStream::ExpectTag(uint32_t expected) {
1466  if (expected < (1 << 7)) {
1467  if (PROTOBUF_PREDICT_TRUE(buffer_ < buffer_end_) &&
1468  buffer_[0] == expected) {
1469  Advance(1);
1470  return true;
1471  } else {
1472  return false;
1473  }
1474  } else if (expected < (1 << 14)) {
1475  if (PROTOBUF_PREDICT_TRUE(BufferSize() >= 2) &&
1476  buffer_[0] == static_cast<uint8_t>(expected | 0x80) &&
1477  buffer_[1] == static_cast<uint8_t>(expected >> 7)) {
1478  Advance(2);
1479  return true;
1480  } else {
1481  return false;
1482  }
1483  } else {
1484  // Don't bother optimizing for larger values.
1485  return false;
1486  }
1487 }
1488 
1490  const uint8_t* buffer, uint32_t expected) {
1491  if (expected < (1 << 7)) {
1492  if (buffer[0] == expected) {
1493  return buffer + 1;
1494  }
1495  } else if (expected < (1 << 14)) {
1496  if (buffer[0] == static_cast<uint8_t>(expected | 0x80) &&
1497  buffer[1] == static_cast<uint8_t>(expected >> 7)) {
1498  return buffer + 2;
1499  }
1500  }
1501  return nullptr;
1502 }
1503 
1504 inline void CodedInputStream::GetDirectBufferPointerInline(const void** data,
1505  int* size) {
1506  *data = buffer_;
1507  *size = static_cast<int>(buffer_end_ - buffer_);
1508 }
1509 
1510 inline bool CodedInputStream::ExpectAtEnd() {
1511  // If we are at a limit we know no more bytes can be read. Otherwise, it's
1512  // hard to say without calling Refresh(), and we'd rather not do that.
1513 
1514  if (buffer_ == buffer_end_ && ((buffer_size_after_limit_ != 0) ||
1516  last_tag_ = 0; // Pretend we called ReadTag()...
1517  legitimate_message_end_ = true; // ... and it hit EOF.
1518  return true;
1519  } else {
1520  return false;
1521  }
1522 }
1523 
1524 inline int CodedInputStream::CurrentPosition() const {
1526 }
1527 
1528 inline void CodedInputStream::Advance(int amount) { buffer_ += amount; }
1529 
1530 inline void CodedInputStream::SetRecursionLimit(int limit) {
1532  recursion_limit_ = limit;
1533 }
1534 
1537  return recursion_budget_ >= 0;
1538 }
1539 
1542 }
1543 
1547 }
1548 
1550  MessageFactory* factory) {
1552  extension_factory_ = factory;
1553 }
1554 
1556  return extension_pool_;
1557 }
1558 
1559 inline MessageFactory* CodedInputStream::GetExtensionFactory() {
1560  return extension_factory_;
1561 }
1562 
1563 inline int CodedInputStream::BufferSize() const {
1564  return static_cast<int>(buffer_end_ - buffer_);
1565 }
1566 
1568  : buffer_(nullptr),
1569  buffer_end_(nullptr),
1570  input_(input),
1571  total_bytes_read_(0),
1572  overflow_bytes_(0),
1573  last_tag_(0),
1574  legitimate_message_end_(false),
1575  aliasing_enabled_(false),
1576  current_limit_(std::numeric_limits<int32_t>::max()),
1577  buffer_size_after_limit_(0),
1578  total_bytes_limit_(kDefaultTotalBytesLimit),
1579  recursion_budget_(default_recursion_limit_),
1580  recursion_limit_(default_recursion_limit_),
1581  extension_pool_(nullptr),
1582  extension_factory_(nullptr) {
1583  // Eagerly Refresh() so buffer space is immediately available.
1584  Refresh();
1585 }
1586 
1588  : buffer_(buffer),
1589  buffer_end_(buffer + size),
1590  input_(nullptr),
1591  total_bytes_read_(size),
1592  overflow_bytes_(0),
1593  last_tag_(0),
1594  legitimate_message_end_(false),
1595  aliasing_enabled_(false),
1596  current_limit_(size),
1597  buffer_size_after_limit_(0),
1598  total_bytes_limit_(kDefaultTotalBytesLimit),
1599  recursion_budget_(default_recursion_limit_),
1600  recursion_limit_(default_recursion_limit_),
1601  extension_pool_(nullptr),
1602  extension_factory_(nullptr) {
1603  // Note that setting current_limit_ == size is important to prevent some
1604  // code paths from trying to access input_ and segfaulting.
1605 }
1606 
1607 inline bool CodedInputStream::IsFlat() const { return input_ == nullptr; }
1608 
1609 inline bool CodedInputStream::Skip(int count) {
1610  if (count < 0) return false; // security: count is often user-supplied
1611 
1612  const int original_buffer_size = BufferSize();
1613 
1614  if (count <= original_buffer_size) {
1615  // Just skipping within the current buffer. Easy.
1616  Advance(count);
1617  return true;
1618  }
1619 
1620  return SkipFallback(count, original_buffer_size);
1621 }
1622 
1624  uint8_t* target) {
1626 }
1627 
1630  target[0] = static_cast<uint8_t>(value);
1631  if (value < 0x80) {
1632  return target + 1;
1633  } else {
1635  }
1636 }
1637 
1639  uint8_t* target) {
1641 }
1642 
1644  WriteVarint64(static_cast<uint64_t>(value));
1645 }
1646 
1649  return WriteVarint64ToArray(static_cast<uint64_t>(value), target);
1650 }
1651 
1653  uint8_t* target) {
1654 #if defined(PROTOBUF_LITTLE_ENDIAN)
1655  memcpy(target, &value, sizeof(value));
1656 #else
1657  target[0] = static_cast<uint8_t>(value);
1658  target[1] = static_cast<uint8_t>(value >> 8);
1659  target[2] = static_cast<uint8_t>(value >> 16);
1660  target[3] = static_cast<uint8_t>(value >> 24);
1661 #endif
1662  return target + sizeof(value);
1663 }
1664 
1666  uint8_t* target) {
1667 #if defined(PROTOBUF_LITTLE_ENDIAN)
1668  memcpy(target, &value, sizeof(value));
1669 #else
1670  uint32_t part0 = static_cast<uint32_t>(value);
1671  uint32_t part1 = static_cast<uint32_t>(value >> 32);
1672 
1673  target[0] = static_cast<uint8_t>(part0);
1674  target[1] = static_cast<uint8_t>(part0 >> 8);
1675  target[2] = static_cast<uint8_t>(part0 >> 16);
1676  target[3] = static_cast<uint8_t>(part0 >> 24);
1677  target[4] = static_cast<uint8_t>(part1);
1678  target[5] = static_cast<uint8_t>(part1 >> 8);
1679  target[6] = static_cast<uint8_t>(part1 >> 16);
1680  target[7] = static_cast<uint8_t>(part1 >> 24);
1681 #endif
1682  return target + sizeof(value);
1683 }
1684 
1688 }
1689 
1693 }
1694 
1697 }
1698 
1700  uint8_t* target) {
1702 }
1703 
1705  // This computes value == 0 ? 1 : floor(log2(value)) / 7 + 1
1706  // Use an explicit multiplication to implement the divide of
1707  // a number in the 1..31 range.
1708  // Explicit OR 0x1 to avoid calling Bits::Log2FloorNonZero(0), which is
1709  // undefined.
1710  uint32_t log2value = Bits::Log2FloorNonZero(value | 0x1);
1711  return static_cast<size_t>((log2value * 9 + 73) / 64);
1712 }
1713 
1715  // Same as above, but one more.
1716  uint32_t log2value = Bits::Log2FloorNonZero(value | 0x1);
1717  return static_cast<size_t>((log2value * 9 + 73 + 64) / 64);
1718 }
1719 
1721  // This computes value == 0 ? 1 : floor(log2(value)) / 7 + 1
1722  // Use an explicit multiplication to implement the divide of
1723  // a number in the 1..63 range.
1724  // Explicit OR 0x1 to avoid calling Bits::Log2FloorNonZero(0), which is
1725  // undefined.
1726  uint32_t log2value = Bits::Log2FloorNonZero64(value | 0x1);
1727  return static_cast<size_t>((log2value * 9 + 73) / 64);
1728 }
1729 
1731  // Same as above, but one more.
1732  uint32_t log2value = Bits::Log2FloorNonZero64(value | 0x1);
1733  return static_cast<size_t>((log2value * 9 + 73 + 64) / 64);
1734 }
1735 
1737  return VarintSize64(static_cast<uint64_t>(int64_t{value}));
1738 }
1739 
1741  int32_t value) {
1742  return VarintSize64PlusOne(static_cast<uint64_t>(int64_t{value}));
1743 }
1744 
1745 inline void CodedOutputStream::WriteString(const std::string& str) {
1746  WriteRaw(str.data(), static_cast<int>(str.size()));
1747 }
1748 
1749 inline void CodedOutputStream::WriteRawMaybeAliased(const void* data,
1750  int size) {
1752 }
1753 
1754 inline uint8_t* CodedOutputStream::WriteRawToArray(const void* data, int size,
1755  uint8_t* target) {
1756  memcpy(target, data, size);
1757  return target + size;
1758 }
1759 
1761  uint8_t* target) {
1762  return WriteRawToArray(str.data(), static_cast<int>(str.size()), target);
1763 }
1764 
1765 } // namespace io
1766 } // namespace protobuf
1767 } // namespace google
1768 
1769 #if defined(_MSC_VER) && _MSC_VER >= 1300 && !defined(__INTEL_COMPILER)
1770 #pragma runtime_checks("c", restore)
1771 #endif // _MSC_VER && !defined(__INTEL_COMPILER)
1772 
1773 #include <google/protobuf/port_undef.inc>
1774 
1775 #endif // GOOGLE_PROTOBUF_IO_CODED_STREAM_H__
google::protobuf::io::CodedOutputStream::WriteStringToArray
static uint8 * WriteStringToArray(const std::string &str, uint8 *target)
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/coded_stream.h:1697
xds_interop_client.str
str
Definition: xds_interop_client.py:487
google::protobuf::io::CodedInputStream::buffer_
const uint8 * buffer_
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/coded_stream.h:537
ptr
char * ptr
Definition: abseil-cpp/absl/base/internal/low_level_alloc_test.cc:45
google::protobuf::io::CodedOutputStream::WriteRawMaybeAliased
void WriteRawMaybeAliased(const void *data, int size)
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/coded_stream.h:1686
google::protobuf::io::EpsCopyOutputStream::SetSerializationDeterministic
void SetSerializationDeterministic(bool value)
Definition: protobuf/src/google/protobuf/io/coded_stream.h:829
_gevent_test_main.result
result
Definition: _gevent_test_main.py:96
google::protobuf::io::CodedInputStream::ReadVarintSizeAsIntFallback
int ReadVarintSizeAsIntFallback()
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/coded_stream.cc:487
google::protobuf::io::EpsCopyOutputStream::WriteRaw
uint8_t * WriteRaw(const void *data, int size, uint8_t *ptr)
Definition: protobuf/src/google/protobuf/io/coded_stream.h:702
google::protobuf::io::CodedInputStream::buffer_size_after_limit_
int buffer_size_after_limit_
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/coded_stream.h:568
google::protobuf::io::CodedOutputStream::cur_
uint8_t * cur_
Definition: protobuf/src/google/protobuf/io/coded_stream.h:1280
google::protobuf::io::CodedInputStream::SetLastTag
void SetLastTag(uint32_t tag)
Definition: protobuf/src/google/protobuf/io/coded_stream.h:342
google::protobuf::io::CodedOutputStream::WriteRaw
void WriteRaw(const void *buffer, int size)
Definition: protobuf/src/google/protobuf/io/coded_stream.h:1127
google::protobuf::io::CodedOutputStream::SetCur
void SetCur(uint8 *ptr)
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/coded_stream.h:1241
regen-readme.it
it
Definition: regen-readme.py:15
google::protobuf::value
const Descriptor::ReservedRange value
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor.h:1954
google::protobuf::io::EpsCopyOutputStream::WriteUInt64Packed
PROTOBUF_ALWAYS_INLINE uint8_t * WriteUInt64Packed(int num, const T &r, int size, uint8_t *ptr)
Definition: protobuf/src/google/protobuf/io/coded_stream.h:787
google::protobuf::io::EpsCopyOutputStream::IsSerializationDeterministic
bool IsSerializationDeterministic() const
Definition: protobuf/src/google/protobuf/io/coded_stream.h:834
google::protobuf::io::CodedOutputStream::SetDefaultSerializationDeterministic
static void SetDefaultSerializationDeterministic()
Definition: protobuf/src/google/protobuf/io/coded_stream.h:1292
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS
#define GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(TypeName)
Definition: bloaty/third_party/protobuf/src/google/protobuf/stubs/macros.h:40
google::protobuf::io::CodedInputStream::CurrentPosition
int CurrentPosition() const
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/coded_stream.h:1487
google::protobuf::io::CodedOutputStream::Cur
uint8_t * Cur() const
Definition: protobuf/src/google/protobuf/io/coded_stream.h:1274
google::protobuf::io::CodedOutputStream::GetDirectBufferForNBytesAndAdvance
uint8_t * GetDirectBufferForNBytesAndAdvance(int size)
Definition: protobuf/src/google/protobuf/io/coded_stream.h:1122
google::protobuf::io::CodedInputStream::SetExtensionRegistry
void SetExtensionRegistry(const DescriptorPool *pool, MessageFactory *factory)
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/coded_stream.h:1512
google::protobuf::io::EpsCopyOutputStream::WriteSInt32Packed
PROTOBUF_ALWAYS_INLINE uint8_t * WriteSInt32Packed(int num, const T &r, int size, uint8_t *ptr)
Definition: protobuf/src/google/protobuf/io/coded_stream.h:777
google::protobuf::io::CodedInputStream::SetRecursionLimit
void SetRecursionLimit(int limit)
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/coded_stream.h:1493
google::protobuf::io::CodedOutputStream::SetCur
void SetCur(uint8_t *ptr)
Definition: protobuf/src/google/protobuf/io/coded_stream.h:1275
google::protobuf::io::CodedInputStream::ReadTagNoLastTag
PROTOBUF_ALWAYS_INLINE uint32 ReadTagNoLastTag()
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/coded_stream.h:1367
google::protobuf::io::CodedInputStream::ReadTagWithCutoff
PROTOBUF_ALWAYS_INLINE std::pair< uint32_t, bool > ReadTagWithCutoff(uint32_t cutoff)
Definition: protobuf/src/google/protobuf/io/coded_stream.h:295
stream_
std::unique_ptr< grpc::ClientReaderInterface< OrcaLoadReport > > stream_
Definition: orca_service_end2end_test.cc:89
grpc::protobuf::io::ZeroCopyInputStream
GRPC_CUSTOM_ZEROCOPYINPUTSTREAM ZeroCopyInputStream
Definition: include/grpcpp/impl/codegen/config_protobuf.h:101
false
#define false
Definition: setup_once.h:323
google::protobuf::io::CodedInputStream::IsFlat
bool IsFlat() const
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/coded_stream.h:1570
google::protobuf::io::CodedInputStream::IncrementRecursionDepth
bool IncrementRecursionDepth()
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/coded_stream.h:1498
google::protobuf::io::EpsCopyOutputStream::UnsafeVarint
static PROTOBUF_ALWAYS_INLINE uint8_t * UnsafeVarint(T value, uint8_t *ptr)
Definition: protobuf/src/google/protobuf/io/coded_stream.h:920
google::protobuf::io::CodedOutputStream::WriteVarint64ToArray
static uint8 * WriteVarint64ToArray(uint64 value, uint8 *target)
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/coded_stream.h:1591
google::protobuf::io::CodedOutputStream::WriteVarint64
void WriteVarint64(uint64 value)
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/coded_stream.h:1643
google::protobuf::io::CodedOutputStream::WriteVarint32SignExtendedToArray
static uint8 * WriteVarint32SignExtendedToArray(int32 value, uint8 *target)
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/coded_stream.h:1600
google::protobuf::io::EpsCopyOutputStream::UnsafeWriteSize
static PROTOBUF_ALWAYS_INLINE uint8_t * UnsafeWriteSize(uint32_t value, uint8_t *ptr)
Definition: protobuf/src/google/protobuf/io/coded_stream.h:945
google::protobuf::io::CodedOutputStream::VarintSize64
static size_t VarintSize64(uint64 value)
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/coded_stream.h:1664
google::protobuf::io::CodedOutputStream::WriteString
void WriteString(const std::string &str)
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/coded_stream.h:1682
GOOGLE_DCHECK
#define GOOGLE_DCHECK
Definition: bloaty/third_party/protobuf/src/google/protobuf/stubs/logging.h:194
google::protobuf::io::EpsCopyOutputStream::WriteRawMaybeAliased
uint8 * WriteRawMaybeAliased(const void *data, int size, uint8 *ptr)
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/coded_stream.h:704
google::protobuf::io::EpsCopyOutputStream::WriteInt32Packed
PROTOBUF_ALWAYS_INLINE uint8_t * WriteInt32Packed(int num, const T &r, int size, uint8_t *ptr)
Definition: protobuf/src/google/protobuf/io/coded_stream.h:767
google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic
static bool IsDefaultSerializationDeterministic()
Definition: protobuf/src/google/protobuf/io/coded_stream.h:1266
google::protobuf::io::CodedOutputStream::WriteLittleEndian32
void WriteLittleEndian32(uint32_t value)
Definition: protobuf/src/google/protobuf/io/coded_stream.h:1151
google::protobuf::io::CodedOutputStream::HadError
bool HadError()
Definition: protobuf/src/google/protobuf/io/coded_stream.h:1082
testing::internal::string
::std::string string
Definition: bloaty/third_party/protobuf/third_party/googletest/googletest/include/gtest/internal/gtest-port.h:881
google::protobuf::io::CodedInputStream::GetDefaultRecursionLimit
static int GetDefaultRecursionLimit()
Definition: protobuf/src/google/protobuf/io/coded_stream.h:422
google::protobuf::io::CodedOutputStream::Trim
void Trim()
Definition: protobuf/src/google/protobuf/io/coded_stream.h:1093
u
OPENSSL_EXPORT pem_password_cb void * u
Definition: pem.h:351
google::protobuf
Definition: bloaty/third_party/protobuf/benchmarks/util/data_proto2_to_proto3_util.h:12
google::protobuf::io::CodedOutputStream::cur_
uint8 * cur_
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/coded_stream.h:1246
google::protobuf::io::EpsCopyOutputStream::WriteRaw
uint8 * WriteRaw(const void *data, int size, uint8 *ptr)
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/coded_stream.h:693
grpc::protobuf::io::ZeroCopyOutputStream
GRPC_CUSTOM_ZEROCOPYOUTPUTSTREAM ZeroCopyOutputStream
Definition: include/grpcpp/impl/codegen/config_protobuf.h:100
google::protobuf::io::CodedOutputStream::WriteLittleEndian64
void WriteLittleEndian64(uint64_t value)
Definition: protobuf/src/google/protobuf/io/coded_stream.h:1158
google::protobuf::io::EpsCopyOutputStream::EpsCopyOutputStream
EpsCopyOutputStream(ZeroCopyOutputStream *stream, bool deterministic, uint8_t **pp)
Definition: protobuf/src/google/protobuf/io/coded_stream.h:664
google::protobuf::io::CodedOutputStream::SetSerializationDeterministic
void SetSerializationDeterministic(bool value)
Definition: protobuf/src/google/protobuf/io/coded_stream.h:1257
google::protobuf::io::CodedOutputStream::WriteLittleEndian64ToArray
static uint8 * WriteLittleEndian64ToArray(uint64 value, uint8 *target)
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/coded_stream.h:1618
google::protobuf::io::EpsCopyOutputStream::EpsCopyOutputStream
EpsCopyOutputStream(void *data, int size, bool deterministic)
Definition: protobuf/src/google/protobuf/io/coded_stream.h:675
google::protobuf::io::CodedInputStream::DecrementRecursionDepth
void DecrementRecursionDepth()
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/coded_stream.h:1503
xds_manager.p
p
Definition: xds_manager.py:60
google::protobuf::io::EpsCopyOutputStream::HadError
bool HadError() const
Definition: protobuf/src/google/protobuf/io/coded_stream.h:815
google::protobuf.internal::MapTestForceDeterministic
void MapTestForceDeterministic()
Definition: third_party/bloaty/third_party/protobuf/src/google/protobuf/map_test.cc:93
uint8_t
unsigned char uint8_t
Definition: stdint-msvc2008.h:78
google::protobuf::Bits::Log2FloorNonZero
static uint32 Log2FloorNonZero(uint32 n)
Definition: third_party/bloaty/third_party/protobuf/src/google/protobuf/stubs/port.h:313
google::protobuf::io::EpsCopyOutputStream::WriteBytesMaybeAliased
uint8_t * WriteBytesMaybeAliased(uint32_t num, const std::string &s, uint8_t *ptr)
Definition: protobuf/src/google/protobuf/io/coded_stream.h:740
IsFlat
static bool IsFlat(const absl::Cord &c)
Definition: abseil-cpp/absl/strings/cord_test.cc:951
google::protobuf::io::CodedInputStream::legitimate_message_end_
bool legitimate_message_end_
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/coded_stream.h:553
absl::base_internal::Next
static AllocList * Next(int i, AllocList *prev, LowLevelAlloc::Arena *arena)
Definition: abseil-cpp/absl/base/internal/low_level_alloc.cc:453
grpc._common.encode
def encode(s)
Definition: grpc/_common.py:68
google::protobuf::MessageFactory
Definition: bloaty/third_party/protobuf/src/google/protobuf/message.h:1066
ZigZagEncode32
#define ZigZagEncode32(x)
google::protobuf::io::EpsCopyOutputStream::WriteUInt32Packed
PROTOBUF_ALWAYS_INLINE uint8_t * WriteUInt32Packed(int num, const T &r, int size, uint8_t *ptr)
Definition: protobuf/src/google/protobuf/io/coded_stream.h:772
T
#define T(upbtypeconst, upbtype, ctype, default_value)
google::protobuf::io::CodedInputStream::ExpectAtEnd
bool ExpectAtEnd()
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/coded_stream.h:1473
true
#define true
Definition: setup_once.h:324
google::protobuf::io::EpsCopyOutputStream::WriteLengthDelim
PROTOBUF_ALWAYS_INLINE uint8_t * WriteLengthDelim(int num, uint32_t size, uint8_t *ptr)
Definition: protobuf/src/google/protobuf/io/coded_stream.h:881
google::protobuf::io::CodedOutputStream::WriteVarint32SignExtended
void WriteVarint32SignExtended(int32 value)
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/coded_stream.h:1596
input_
const uint8_t * input_
Definition: json_reader.cc:120
google::protobuf::io::EpsCopyOutputStream::Error
uint8_t * Error()
Definition: protobuf/src/google/protobuf/io/coded_stream.h:860
uint32_t
unsigned int uint32_t
Definition: stdint-msvc2008.h:80
google::protobuf::io::CodedOutputStream::VarintSize64PlusOne
static size_t VarintSize64PlusOne(uint64_t value)
Definition: protobuf/src/google/protobuf/io/coded_stream.h:1730
google::protobuf.internal::VarintSize64
static size_t VarintSize64(const T *data, const int n)
Definition: bloaty/third_party/protobuf/src/google/protobuf/wire_format_lite.cc:643
google::protobuf::io::EpsCopyOutputStream::WriteStringMaybeAliased
PROTOBUF_NOINLINE uint8_t * WriteStringMaybeAliased(uint32_t num, const std::string &s, uint8_t *ptr)
Definition: protobuf/src/google/protobuf/io/coded_stream.h:728
google::protobuf::io::EpsCopyOutputStream
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/coded_stream.h:651
buffer_
static uint8 buffer_[kBufferSize]
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/coded_stream_unittest.cc:136
memcpy
memcpy(mem, inblock.get(), min(CONTAINING_RECORD(inblock.get(), MEMBLOCK, data) ->size, size))
google::protobuf::io::CodedOutputStream::ByteCount
int ByteCount() const
Definition: protobuf/src/google/protobuf/io/coded_stream.h:1221
google::protobuf::io::EpsCopyOutputStream::WriteEnumPacked
PROTOBUF_ALWAYS_INLINE uint8_t * WriteEnumPacked(int num, const T &r, int size, uint8_t *ptr)
Definition: protobuf/src/google/protobuf/io/coded_stream.h:797
google::protobuf::io::CodedOutputStream::EnableAliasing
void EnableAliasing(bool enabled)
Definition: protobuf/src/google/protobuf/io/coded_stream.h:1234
google::protobuf::io::CodedOutputStream::CodedOutputStream
CodedOutputStream(ZeroCopyOutputStream *stream)
Definition: protobuf/src/google/protobuf/io/coded_stream.h:1071
google::protobuf::io::EpsCopyOutputStream::Encode32
static uint32_t Encode32(uint32_t v)
Definition: protobuf/src/google/protobuf/io/coded_stream.h:910
google::protobuf::io::CodedInputStream::ReadLittleEndian64
bool ReadLittleEndian64(uint64 *value)
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/coded_stream.h:1354
ZigZagEncode64
#define ZigZagEncode64(x)
end
char * end
Definition: abseil-cpp/absl/strings/internal/str_format/float_conversion.cc:1008
google::protobuf::io::EpsCopyOutputStream::GetSize
std::ptrdiff_t GetSize(uint8_t *ptr) const
Definition: protobuf/src/google/protobuf/io/coded_stream.h:855
google::protobuf::ZeroCopyCodedInputStream
Definition: bloaty/third_party/protobuf/src/google/protobuf/message_lite.cc:179
int64_t
signed __int64 int64_t
Definition: stdint-msvc2008.h:89
google::protobuf::io::EpsCopyOutputStream::EnsureSpace
void EnsureSpace(uint8 **ptr)
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/coded_stream.h:687
google::protobuf::io::CodedInputStream::GetDirectBufferPointerInline
PROTOBUF_ALWAYS_INLINE void GetDirectBufferPointerInline(const void **data, int *size)
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/coded_stream.h:1467
tag
static void * tag(intptr_t t)
Definition: bad_client.cc:318
max
int max
Definition: bloaty/third_party/zlib/examples/enough.c:170
absl::random_internal_nanobenchmark::Func
FuncOutput(*)(const void *, FuncInput) Func
Definition: abseil-cpp/absl/random/internal/nanobenchmark.h:68
google::protobuf::io::EpsCopyOutputStream::WriteSInt64Packed
PROTOBUF_ALWAYS_INLINE uint8_t * WriteSInt64Packed(int num, const T &r, int size, uint8_t *ptr)
Definition: protobuf/src/google/protobuf/io/coded_stream.h:792
impl_
std::shared_ptr< ExternalConnectionAcceptorImpl > impl_
Definition: external_connection_acceptor_impl.cc:43
google::protobuf::io::EpsCopyOutputStream::WriteString
PROTOBUF_ALWAYS_INLINE uint8_t * WriteString(uint32_t num, const T &s, uint8_t *ptr)
Definition: protobuf/src/google/protobuf/io/coded_stream.h:746
google::protobuf::io::CodedOutputStream::VarintSize32PlusOne
static size_t VarintSize32PlusOne(uint32_t value)
Definition: protobuf/src/google/protobuf/io/coded_stream.h:1714
google::protobuf::io::CodedInputStream::ConsumedEntireMessage
bool ConsumedEntireMessage()
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/coded_stream.h:1424
setup.v
v
Definition: third_party/bloaty/third_party/capstone/bindings/python/setup.py:42
google::protobuf::io::CodedInputStream::ReadVarint32
bool ReadVarint32(uint32 *value)
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/coded_stream.h:1268
google::protobuf::io::CodedInputStream::total_bytes_read_
int total_bytes_read_
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/coded_stream.h:540
google::protobuf::io::CodedInputStream::GetExtensionPool
const DescriptorPool * GetExtensionPool()
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/coded_stream.h:1518
google::protobuf::io::EpsCopyOutputStream::SetInitialBuffer
uint8_t * SetInitialBuffer(void *data, int size)
Definition: protobuf/src/google/protobuf/io/coded_stream.h:967
uint64_t
unsigned __int64 uint64_t
Definition: stdint-msvc2008.h:90
google::protobuf::io::CodedInputStream::buffer_end_
const uint8_t * buffer_end_
Definition: protobuf/src/google/protobuf/io/coded_stream.h:546
grpc::protobuf::io::CodedInputStream
GRPC_CUSTOM_CODEDINPUTSTREAM CodedInputStream
Definition: include/grpcpp/impl/codegen/config_protobuf.h:102
google::protobuf::io::CodedOutputStream::VarintSize32
static size_t VarintSize32(uint32 value)
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/coded_stream.h:1654
google::protobuf::DescriptorPool
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor.h:1539
google::protobuf::io::CodedOutputStream::VarintSize32SignExtended
static size_t VarintSize32SignExtended(int32 value)
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/coded_stream.h:1674
google::protobuf::io::EpsCopyOutputStream::ZigZagEncode64
static uint64_t ZigZagEncode64(int64_t v)
Definition: protobuf/src/google/protobuf/io/coded_stream.h:915
google::protobuf::io::CodedInputStream::LastTagWas
bool LastTagWas(uint32 expected)
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/coded_stream.h:1420
google::protobuf::io::CodedInputStream::SkipFallback
bool SkipFallback(int count, int original_buffer_size)
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/coded_stream.cc:202
google::protobuf::io::CodedOutputStream::WriteTagToArray
static PROTOBUF_ALWAYS_INLINE uint8 * WriteTagToArray(uint32 value, uint8 *target)
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/coded_stream.h:1650
absl::compare_internal::value_type
int8_t value_type
Definition: abseil-cpp/absl/types/compare.h:45
google::protobuf.internal::ExpectTag
bool ExpectTag(const char *ptr)
Definition: bloaty/third_party/protobuf/src/google/protobuf/parse_context.h:391
google::protobuf::io::CodedOutputStream::WriteRawToArray
static uint8 * WriteRawToArray(const void *buffer, int size, uint8 *target)
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/coded_stream.h:1691
io
google::protobuf::Bits::Log2FloorNonZero64
static uint32 Log2FloorNonZero64(uint64 n)
Definition: third_party/bloaty/third_party/protobuf/src/google/protobuf/stubs/port.h:325
data
char data[kBufferLength]
Definition: abseil-cpp/absl/strings/internal/str_format/float_conversion.cc:1006
grpc::protobuf::io::CodedOutputStream
GRPC_CUSTOM_CODEDOUTPUTSTREAM CodedOutputStream
Definition: src/compiler/config.h:55
buffer
char buffer[1024]
Definition: libuv/docs/code/idle-compute/main.c:8
google::protobuf::io::CodedInputStream::SetConsumed
void SetConsumed()
Definition: protobuf/src/google/protobuf/io/coded_stream.h:351
google::protobuf::io::EpsCopyOutputStream::WriteRawMaybeAliased
PROTOBUF_NOINLINE uint8_t * WriteRawMaybeAliased(const void *data, int size, uint8_t *ptr)
Definition: protobuf/src/google/protobuf/io/coded_stream.h:716
google::protobuf::io::CodedInputStream::ReadVarint32Fallback
int64 ReadVarint32Fallback(uint32 first_byte_or_zero)
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/coded_stream.cc:457
google::protobuf::io::CodedInputStream::ReadLittleEndian32
bool ReadLittleEndian32(uint32 *value)
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/coded_stream.h:1341
google::protobuf::io::CodedInputStream::input_
ZeroCopyInputStream * input_
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/coded_stream.h:539
google::protobuf::io::CodedOutputStream::EpsCopy
EpsCopyOutputStream * EpsCopy()
Definition: protobuf/src/google/protobuf/io/coded_stream.h:1276
google::protobuf::io::CodedInputStream::UnsafeDecrementRecursionDepth
void UnsafeDecrementRecursionDepth()
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/coded_stream.h:1507
google::protobuf::io::CodedInputStream::Advance
void Advance(int amount)
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/coded_stream.h:1491
google::protobuf::io::CodedInputStream::Skip
bool Skip(int count)
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/coded_stream.h:1572
google::protobuf::io::EpsCopyOutputStream::WriteBytes
PROTOBUF_NOINLINE uint8_t * WriteBytes(uint32_t num, const T &s, uint8_t *ptr)
Definition: protobuf/src/google/protobuf/io/coded_stream.h:762
google::protobuf::io::CodedOutputStream::WriteTag
void WriteTag(uint32 value)
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/coded_stream.h:1648
google::protobuf::io::CodedOutputStream
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/coded_stream.h:1044
google::protobuf::io::CodedOutputStream::WriteVarint32ToArrayOutOfLine
static uint8_t * WriteVarint32ToArrayOutOfLine(uint32_t value, uint8_t *target)
Definition: protobuf/src/google/protobuf/io/coded_stream.h:1628
value
const char * value
Definition: hpack_parser_table.cc:165
google::protobuf::io::ZeroCopyInputStream
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/zero_copy_stream.h:126
absl::Skip
static PerThreadSynch * Skip(PerThreadSynch *x)
Definition: abseil-cpp/absl/synchronization/mutex.cc:837
pp
const uint8_t ** pp
Definition: ssl_x509.cc:1020
google::protobuf::io::CodedInputStream::last_tag_
uint32 last_tag_
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/coded_stream.h:548
google::protobuf::io::CodedOutputStream::impl_
EpsCopyOutputStream impl_
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/coded_stream.h:1245
func
const EVP_CIPHER *(* func)(void)
Definition: cipher_extra.c:73
google::protobuf::io::CodedOutputStream::Cur
uint8 * Cur() const
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/coded_stream.h:1240
google::protobuf.internal::ReadVarint32
uint32_t ReadVarint32(const char **p)
Definition: protobuf/src/google/protobuf/parse_context.h:641
google::protobuf.internal::ReadTagFallback
std::pair< const char *, uint32 > ReadTagFallback(const char *p, uint32 res)
Definition: bloaty/third_party/protobuf/src/google/protobuf/parse_context.cc:370
count
int * count
Definition: bloaty/third_party/googletest/googlemock/test/gmock_stress_test.cc:96
google::protobuf::io::EpsCopyOutputStream::end_
uint8_t * end_
Definition: protobuf/src/google/protobuf/io/coded_stream.h:844
google::protobuf::io::EpsCopyOutputStream::WriteRawLittleEndian64
uint8 * WriteRawLittleEndian64(const void *data, int size, uint8 *ptr)
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/coded_stream.cc:887
google::protobuf::io::EpsCopyOutputStream::WriteTag
PROTOBUF_ALWAYS_INLINE uint8_t * WriteTag(uint32_t num, uint32_t wt, uint8_t *ptr)
Definition: protobuf/src/google/protobuf/io/coded_stream.h:875
google::protobuf::io::CodedOutputStream::WriteVarint32ToArrayOutOfLineHelper
static uint8_t * WriteVarint32ToArrayOutOfLineHelper(uint32_t value, uint8_t *target)
Definition: protobuf/src/google/protobuf/io/coded_stream.cc:954
google::protobuf::io::CodedOutputStream::IsSerializationDeterministic
bool IsSerializationDeterministic() const
Definition: protobuf/src/google/protobuf/io/coded_stream.h:1262
google::protobuf::io::CodedInputStream::ExpectTag
PROTOBUF_ALWAYS_INLINE bool ExpectTag(uint32 expected)
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/coded_stream.h:1428
google::protobuf::io::CodedInputStream::RecursionBudget
int RecursionBudget()
Definition: protobuf/src/google/protobuf/io/coded_stream.h:420
google::protobuf::io::CodedInputStream::recursion_limit_
int recursion_limit_
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/coded_stream.h:579
google::protobuf::io::EpsCopyOutputStream::Encode64
static uint64_t Encode64(uint64_t v)
Definition: protobuf/src/google/protobuf/io/coded_stream.h:911
google::protobuf::io::CodedInputStream::extension_pool_
const DescriptorPool * extension_pool_
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/coded_stream.h:582
google::protobuf::io::CodedInputStream::buffer_
const uint8_t * buffer_
Definition: protobuf/src/google/protobuf/io/coded_stream.h:545
fix_build_deps.r
r
Definition: fix_build_deps.py:491
std
Definition: grpcpp/impl/codegen/async_unary_call.h:407
google::protobuf::io::EpsCopyOutputStream::UnsafeVarint
static PROTOBUF_ALWAYS_INLINE uint8 * UnsafeVarint(T value, uint8 *ptr)
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/coded_stream.h:898
google::protobuf::io::ZeroCopyOutputStream
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/zero_copy_stream.h:183
google::protobuf::io::CodedInputStream
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/coded_stream.h:180
google::protobuf::io::CodedInputStream::last_tag_
uint32_t last_tag_
Definition: protobuf/src/google/protobuf/io/coded_stream.h:556
xds_manager.num
num
Definition: xds_manager.py:56
google::protobuf::io::CodedInputStream::ReadTag
PROTOBUF_ALWAYS_INLINE uint32_t ReadTag()
Definition: protobuf/src/google/protobuf/io/coded_stream.h:280
google::protobuf::io::CodedInputStream::buffer_end_
const uint8 * buffer_end_
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/coded_stream.h:538
google::protobuf::io::EpsCopyOutputStream::ZigZagEncode32
static uint32_t ZigZagEncode32(int32_t v)
Definition: protobuf/src/google/protobuf/io/coded_stream.h:912
google::protobuf::io::CodedInputStream::ReadTagFallback
uint32 ReadTagFallback(uint32 first_byte_or_zero)
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/coded_stream.cc:531
end_
const char *const end_
Definition: abseil-cpp/absl/time/internal/test_util.cc:100
google::protobuf::io::EpsCopyOutputStream::TagSize
static constexpr int TagSize(uint32_t tag)
Definition: protobuf/src/google/protobuf/io/coded_stream.h:867
input
std::string input
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/tokenizer_unittest.cc:197
google::protobuf::io::EpsCopyOutputStream::WriteInt64Packed
PROTOBUF_ALWAYS_INLINE uint8_t * WriteInt64Packed(int num, const T &r, int size, uint8_t *ptr)
Definition: protobuf/src/google/protobuf/io/coded_stream.h:782
pool
InternalDescriptorPool * pool
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/protobuf.h:807
google::protobuf::io::CodedOutputStream::WriteVarint32ToArray
static uint8 * WriteVarint32ToArray(uint32 value, uint8 *target)
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/coded_stream.h:1586
google::protobuf::io::CodedInputStream::ReadTagWithCutoffNoLastTag
PROTOBUF_ALWAYS_INLINE std::pair< uint32, bool > ReadTagWithCutoffNoLastTag(uint32 cutoff)
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/coded_stream.h:1380
google::protobuf::io::CodedInputStream::current_limit_
Limit current_limit_
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/coded_stream.h:559
google::protobuf::io::CodedInputStream::extension_factory_
MessageFactory * extension_factory_
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/coded_stream.h:583
google::protobuf::io::CodedInputStream::ReadLittleEndian64FromArray
static const uint8 * ReadLittleEndian64FromArray(const uint8 *buffer, uint64 *value)
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/coded_stream.h:1322
google::protobuf::io::CodedInputStream::ReadLittleEndian32Fallback
bool ReadLittleEndian32Fallback(uint32 *value)
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/coded_stream.cc:311
internal
Definition: benchmark/test/output_test_helper.cc:20
google::protobuf::io::EpsCopyOutputStream::WriteRawLittleEndian32
uint8 * WriteRawLittleEndian32(const void *data, int size, uint8 *ptr)
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/coded_stream.cc:864
google::protobuf::io::CodedInputStream::ReadLittleEndian64Fallback
bool ReadLittleEndian64Fallback(uint64 *value)
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/coded_stream.cc:328
google::protobuf::io::CodedInputStream::ReadLittleEndian32FromArray
static const uint8 * ReadLittleEndian32FromArray(const uint8 *buffer, uint32 *value)
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/coded_stream.h:1308
google::protobuf::io::CodedInputStream::Limit
int Limit
Definition: protobuf/src/google/protobuf/io/coded_stream.h:363
google::protobuf::io::CodedInputStream::ReadVarint64Fallback
std::pair< uint64, bool > ReadVarint64Fallback()
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/coded_stream.cc:597
google::protobuf::io::EpsCopyOutputStream::WriteVarintPacked
PROTOBUF_ALWAYS_INLINE uint8_t * WriteVarintPacked(int num, const T &r, int size, uint8_t *ptr, const E &encode)
Definition: protobuf/src/google/protobuf/io/coded_stream.h:896
int8_t
signed char int8_t
Definition: stdint-msvc2008.h:75
Value
struct Value Value
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/protobuf.h:676
google::protobuf::io::EpsCopyOutputStream::EpsCopyOutputStream
EpsCopyOutputStream(void *data, int size, ZeroCopyOutputStream *stream, bool deterministic, uint8_t **pp)
Definition: protobuf/src/google/protobuf/io/coded_stream.h:682
size
voidpf void uLong size
Definition: bloaty/third_party/zlib/contrib/minizip/ioapi.h:136
google::protobuf::io::CodedInputStream::recursion_budget_
int recursion_budget_
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/coded_stream.h:577
int32_t
signed int int32_t
Definition: stdint-msvc2008.h:77
DescriptorPool
Definition: bloaty/third_party/protobuf/ruby/ext/google/protobuf_c/protobuf.h:110
google::protobuf::io::EpsCopyOutputStream::WriteFixedPacked
PROTOBUF_ALWAYS_INLINE uint8_t * WriteFixedPacked(int num, const T &r, uint8_t *ptr)
Definition: protobuf/src/google/protobuf/io/coded_stream.h:803
google::protobuf::io::CodedOutputStream::Skip
bool Skip(int count)
Definition: protobuf/src/google/protobuf/io/coded_stream.h:1101
google::protobuf::io::EpsCopyOutputStream::EnsureSpace
PROTOBUF_NODISCARD uint8_t * EnsureSpace(uint8_t *ptr)
Definition: protobuf/src/google/protobuf/io/coded_stream.h:695
setup.target
target
Definition: third_party/bloaty/third_party/protobuf/python/setup.py:179
google::protobuf::io::CodedInputStream::CodedInputStream
CodedInputStream(ZeroCopyInputStream *input)
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/coded_stream.h:1530
google::protobuf::io::CodedOutputStream::VarintSize32SignExtendedPlusOne
static size_t VarintSize32SignExtendedPlusOne(int32_t value)
Definition: protobuf/src/google/protobuf/io/coded_stream.h:1740
google::protobuf::io::CodedOutputStream::WriteVarint32
void WriteVarint32(uint32 value)
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/coded_stream.h:1638
google
Definition: bloaty/third_party/protobuf/benchmarks/util/data_proto2_to_proto3_util.h:11
google::protobuf::io::CodedOutputStream::GetDirectBufferPointer
bool GetDirectBufferPointer(void **data, int *size)
Definition: protobuf/src/google/protobuf/io/coded_stream.h:1111
google::protobuf::io::CodedOutputStream::WriteLittleEndian32ToArray
static uint8 * WriteLittleEndian32ToArray(uint32 value, uint8 *target)
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/coded_stream.h:1605
google::protobuf::io::CodedInputStream::ExpectTagFromArray
static const PROTOBUF_ALWAYS_INLINE uint8 * ExpectTagFromArray(const uint8 *buffer, uint32 expected)
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/coded_stream.h:1452
google::protobuf::io::CodedInputStream::GetExtensionFactory
MessageFactory * GetExtensionFactory()
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/coded_stream.h:1522
google::protobuf::io::CodedInputStream::ReadVarintSizeAsInt
bool ReadVarintSizeAsInt(int *value)
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/coded_stream.h:1294
google::protobuf::io::CodedInputStream::BufferSize
int BufferSize() const
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/coded_stream.h:1526
google::protobuf.internal::ReadVarint64
uint64_t ReadVarint64(const char **p)
Definition: protobuf/src/google/protobuf/parse_context.h:635
google::protobuf::io::CodedInputStream::ReadVarint64
bool ReadVarint64(uint64 *value)
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/coded_stream.h:1283
google::protobuf::io::CodedOutputStream::start_count_
int64_t start_count_
Definition: protobuf/src/google/protobuf/io/coded_stream.h:1281
stream
voidpf stream
Definition: bloaty/third_party/zlib/contrib/minizip/ioapi.h:136


grpc
Author(s):
autogenerated on Fri May 16 2025 02:57:56