Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-31 10:12:29

0001 // Protocol Buffers - Google's data interchange format
0002 // Copyright 2008 Google Inc.  All rights reserved.
0003 //
0004 // Use of this source code is governed by a BSD-style
0005 // license that can be found in the LICENSE file or at
0006 // https://developers.google.com/open-source/licenses/bsd
0007 
0008 // Author: kenton@google.com (Kenton Varda)
0009 //         atenasio@google.com (Chris Atenasio) (ZigZag transform)
0010 //         wink@google.com (Wink Saville) (refactored from wire_format.h)
0011 //  Based on original Protocol Buffers design by
0012 //  Sanjay Ghemawat, Jeff Dean, and others.
0013 //
0014 // This header is logically internal, but is made public because it is used
0015 // from protocol-compiler-generated code, which may reside in other components.
0016 
0017 #ifndef GOOGLE_PROTOBUF_WIRE_FORMAT_LITE_H__
0018 #define GOOGLE_PROTOBUF_WIRE_FORMAT_LITE_H__
0019 
0020 #include <limits>
0021 #include <string>
0022 
0023 #include "google/protobuf/stubs/common.h"
0024 #include "absl/base/casts.h"
0025 #include "absl/log/absl_check.h"
0026 #include "absl/strings/string_view.h"
0027 #include "google/protobuf/arenastring.h"
0028 #include "google/protobuf/io/coded_stream.h"
0029 #include "google/protobuf/message_lite.h"
0030 #include "google/protobuf/port.h"
0031 #include "google/protobuf/repeated_field.h"
0032 
0033 #ifndef NDEBUG
0034 #define GOOGLE_PROTOBUF_UTF8_VALIDATION_ENABLED
0035 #endif
0036 
0037 // Avoid conflict with iOS where <ConditionalMacros.h> #defines TYPE_BOOL.
0038 //
0039 // If some one needs the macro TYPE_BOOL in a file that includes this header,
0040 // it's possible to bring it back using push/pop_macro as follows.
0041 //
0042 // #pragma push_macro("TYPE_BOOL")
0043 // #include this header and/or all headers that need the macro to be undefined.
0044 // #pragma pop_macro("TYPE_BOOL")
0045 #undef TYPE_BOOL
0046 
0047 
0048 // Must be included last.
0049 #include "google/protobuf/port_def.inc"
0050 
0051 namespace google {
0052 namespace protobuf {
0053 namespace internal {
0054 
0055 // This class is for internal use by the protocol buffer library and by
0056 // protocol-compiler-generated message classes.  It must not be called
0057 // directly by clients.
0058 //
0059 // This class contains helpers for implementing the binary protocol buffer
0060 // wire format without the need for reflection. Use WireFormat when using
0061 // reflection.
0062 //
0063 // This class is really a namespace that contains only static methods.
0064 class PROTOBUF_EXPORT WireFormatLite {
0065  public:
0066   WireFormatLite() = delete;
0067   // -----------------------------------------------------------------
0068   // Helper constants and functions related to the format.  These are
0069   // mostly meant for internal and generated code to use.
0070 
0071   // The wire format is composed of a sequence of tag/value pairs, each
0072   // of which contains the value of one field (or one element of a repeated
0073   // field).  Each tag is encoded as a varint.  The lower bits of the tag
0074   // identify its wire type, which specifies the format of the data to follow.
0075   // The rest of the bits contain the field number.  Each type of field (as
0076   // declared by FieldDescriptor::Type, in descriptor.h) maps to one of
0077   // these wire types.  Immediately following each tag is the field's value,
0078   // encoded in the format specified by the wire type.  Because the tag
0079   // identifies the encoding of this data, it is possible to skip
0080   // unrecognized fields for forwards compatibility.
0081 
0082   enum WireType
0083 #ifndef SWIG
0084       : int
0085 #endif  // !SWIG
0086   {
0087     WIRETYPE_VARINT = 0,
0088     WIRETYPE_FIXED64 = 1,
0089     WIRETYPE_LENGTH_DELIMITED = 2,
0090     WIRETYPE_START_GROUP = 3,
0091     WIRETYPE_END_GROUP = 4,
0092     WIRETYPE_FIXED32 = 5,
0093   };
0094 
0095   // Lite alternative to FieldDescriptor::Type.  Must be kept in sync.
0096   enum FieldType {
0097     TYPE_DOUBLE = 1,
0098     TYPE_FLOAT = 2,
0099     TYPE_INT64 = 3,
0100     TYPE_UINT64 = 4,
0101     TYPE_INT32 = 5,
0102     TYPE_FIXED64 = 6,
0103     TYPE_FIXED32 = 7,
0104     TYPE_BOOL = 8,
0105     TYPE_STRING = 9,
0106     TYPE_GROUP = 10,
0107     TYPE_MESSAGE = 11,
0108     TYPE_BYTES = 12,
0109     TYPE_UINT32 = 13,
0110     TYPE_ENUM = 14,
0111     TYPE_SFIXED32 = 15,
0112     TYPE_SFIXED64 = 16,
0113     TYPE_SINT32 = 17,
0114     TYPE_SINT64 = 18,
0115     MAX_FIELD_TYPE = 18,
0116   };
0117 
0118   // Lite alternative to FieldDescriptor::CppType.  Must be kept in sync.
0119   enum CppType {
0120     CPPTYPE_INT32 = 1,
0121     CPPTYPE_INT64 = 2,
0122     CPPTYPE_UINT32 = 3,
0123     CPPTYPE_UINT64 = 4,
0124     CPPTYPE_DOUBLE = 5,
0125     CPPTYPE_FLOAT = 6,
0126     CPPTYPE_BOOL = 7,
0127     CPPTYPE_ENUM = 8,
0128     CPPTYPE_STRING = 9,
0129     CPPTYPE_MESSAGE = 10,
0130     MAX_CPPTYPE = 10,
0131   };
0132 
0133   // Helper method to get the CppType for a particular Type.
0134   static CppType FieldTypeToCppType(FieldType type);
0135 
0136   // Given a FieldDescriptor::Type return its WireType
0137   static inline WireFormatLite::WireType WireTypeForFieldType(
0138       WireFormatLite::FieldType type) {
0139     return kWireTypeForFieldType[type];
0140   }
0141 
0142   // Number of bits in a tag which identify the wire type.
0143   static constexpr int kTagTypeBits = 3;
0144   // Mask for those bits.
0145   static constexpr uint32_t kTagTypeMask = (1 << kTagTypeBits) - 1;
0146 
0147   // Helper functions for encoding and decoding tags.  (Inlined below and in
0148   // _inl.h)
0149   //
0150   // This is different from MakeTag(field->number(), field->type()) in the
0151   // case of packed repeated fields.
0152   constexpr static uint32_t MakeTag(int field_number, WireType type);
0153   static WireType GetTagWireType(uint32_t tag);
0154   static int GetTagFieldNumber(uint32_t tag);
0155 
0156   // Compute the byte size of a tag.  For groups, this includes both the start
0157   // and end tags.
0158   static inline size_t TagSize(int field_number,
0159                                WireFormatLite::FieldType type);
0160 
0161   // Skips a field value with the given tag.  The input should start
0162   // positioned immediately after the tag.  Skipped values are simply
0163   // discarded, not recorded anywhere.  See WireFormat::SkipField() for a
0164   // version that records to an UnknownFieldSet.
0165   static bool SkipField(io::CodedInputStream* input, uint32_t tag);
0166 
0167   // Skips a field value with the given tag.  The input should start
0168   // positioned immediately after the tag. Skipped values are recorded to a
0169   // CodedOutputStream.
0170   static bool SkipField(io::CodedInputStream* input, uint32_t tag,
0171                         io::CodedOutputStream* output);
0172 
0173   // Reads and ignores a message from the input.  Skipped values are simply
0174   // discarded, not recorded anywhere.  See WireFormat::SkipMessage() for a
0175   // version that records to an UnknownFieldSet.
0176   static bool SkipMessage(io::CodedInputStream* input);
0177 
0178   // Reads and ignores a message from the input.  Skipped values are recorded
0179   // to a CodedOutputStream.
0180   static bool SkipMessage(io::CodedInputStream* input,
0181                           io::CodedOutputStream* output);
0182 
0183   // This macro does the same thing as WireFormatLite::MakeTag(), but the
0184   // result is usable as a compile-time constant, which makes it usable
0185   // as a switch case or a template input.  WireFormatLite::MakeTag() is more
0186   // type-safe, though, so prefer it if possible.
0187 #define GOOGLE_PROTOBUF_WIRE_FORMAT_MAKE_TAG(FIELD_NUMBER, TYPE) \
0188   static_cast<uint32_t>((static_cast<uint32_t>(FIELD_NUMBER) << 3) | (TYPE))
0189 
0190   // These are the tags for the old MessageSet format, which was defined as:
0191   //   message MessageSet {
0192   //     repeated group Item = 1 {
0193   //       required int32 type_id = 2;
0194   //       required string message = 3;
0195   //     }
0196   //   }
0197   static constexpr int kMessageSetItemNumber = 1;
0198   static constexpr int kMessageSetTypeIdNumber = 2;
0199   static constexpr int kMessageSetMessageNumber = 3;
0200   static const int kMessageSetItemStartTag = GOOGLE_PROTOBUF_WIRE_FORMAT_MAKE_TAG(
0201       kMessageSetItemNumber, WireFormatLite::WIRETYPE_START_GROUP);
0202   static const int kMessageSetItemEndTag = GOOGLE_PROTOBUF_WIRE_FORMAT_MAKE_TAG(
0203       kMessageSetItemNumber, WireFormatLite::WIRETYPE_END_GROUP);
0204   static const int kMessageSetTypeIdTag = GOOGLE_PROTOBUF_WIRE_FORMAT_MAKE_TAG(
0205       kMessageSetTypeIdNumber, WireFormatLite::WIRETYPE_VARINT);
0206   static const int kMessageSetMessageTag = GOOGLE_PROTOBUF_WIRE_FORMAT_MAKE_TAG(
0207       kMessageSetMessageNumber, WireFormatLite::WIRETYPE_LENGTH_DELIMITED);
0208 
0209   // Byte size of all tags of a MessageSet::Item combined.
0210   static const size_t kMessageSetItemTagsSize;
0211 
0212   // Helper functions for converting between floats/doubles and IEEE-754
0213   // uint32s/uint64s so that they can be written.  (Assumes your platform
0214   // uses IEEE-754 floats.)
0215   static uint32_t EncodeFloat(float value);
0216   static float DecodeFloat(uint32_t value);
0217   static uint64_t EncodeDouble(double value);
0218   static double DecodeDouble(uint64_t value);
0219 
0220   // Helper functions for mapping signed integers to unsigned integers in
0221   // such a way that numbers with small magnitudes will encode to smaller
0222   // varints.  If you simply static_cast a negative number to an unsigned
0223   // number and varint-encode it, it will always take 10 bytes, defeating
0224   // the purpose of varint.  So, for the "sint32" and "sint64" field types,
0225   // we ZigZag-encode the values.
0226   static uint32_t ZigZagEncode32(int32_t n);
0227   static int32_t ZigZagDecode32(uint32_t n);
0228   static uint64_t ZigZagEncode64(int64_t n);
0229   static int64_t ZigZagDecode64(uint64_t n);
0230 
0231   // =================================================================
0232   // Methods for reading/writing individual field.
0233 
0234   // Read fields, not including tags.  The assumption is that you already
0235   // read the tag to determine what field to read.
0236 
0237   // For primitive fields, we just use a templatized routine parameterized by
0238   // the represented type and the FieldType. These are specialized with the
0239   // appropriate definition for each declared type.
0240   template <typename CType, enum FieldType DeclaredType>
0241   PROTOBUF_NDEBUG_INLINE static bool ReadPrimitive(io::CodedInputStream* input,
0242                                                    CType* value);
0243 
0244   // Reads repeated primitive values, with optimizations for repeats.
0245   // tag_size and tag should both be compile-time constants provided by the
0246   // protocol compiler.
0247   template <typename CType, enum FieldType DeclaredType>
0248   PROTOBUF_NDEBUG_INLINE static bool ReadRepeatedPrimitive(
0249       int tag_size, uint32_t tag, io::CodedInputStream* input,
0250       RepeatedField<CType>* value);
0251 
0252   // Identical to ReadRepeatedPrimitive, except will not inline the
0253   // implementation.
0254   template <typename CType, enum FieldType DeclaredType>
0255   static bool ReadRepeatedPrimitiveNoInline(int tag_size, uint32_t tag,
0256                                             io::CodedInputStream* input,
0257                                             RepeatedField<CType>* value);
0258 
0259   // Reads a primitive value directly from the provided buffer. It returns a
0260   // pointer past the segment of data that was read.
0261   //
0262   // This is only implemented for the types with fixed wire size, e.g.
0263   // float, double, and the (s)fixed* types.
0264   template <typename CType, enum FieldType DeclaredType>
0265   PROTOBUF_NDEBUG_INLINE static const uint8_t* ReadPrimitiveFromArray(
0266       const uint8_t* buffer, CType* value);
0267 
0268   // Reads a primitive packed field.
0269   //
0270   // This is only implemented for packable types.
0271   template <typename CType, enum FieldType DeclaredType>
0272   PROTOBUF_NDEBUG_INLINE static bool ReadPackedPrimitive(
0273       io::CodedInputStream* input, RepeatedField<CType>* value);
0274 
0275   // Identical to ReadPackedPrimitive, except will not inline the
0276   // implementation.
0277   template <typename CType, enum FieldType DeclaredType>
0278   static bool ReadPackedPrimitiveNoInline(io::CodedInputStream* input,
0279                                           RepeatedField<CType>* value);
0280 
0281   // Read a packed enum field. If the is_valid function is not nullptr, values
0282   // for which is_valid(value) returns false are silently dropped.
0283   static bool ReadPackedEnumNoInline(io::CodedInputStream* input,
0284                                      bool (*is_valid)(int),
0285                                      RepeatedField<int>* values);
0286 
0287   // Read a packed enum field. If the is_valid function is not nullptr, values
0288   // for which is_valid(value) returns false are appended to
0289   // unknown_fields_stream.
0290   static bool ReadPackedEnumPreserveUnknowns(
0291       io::CodedInputStream* input, int field_number, bool (*is_valid)(int),
0292       io::CodedOutputStream* unknown_fields_stream, RepeatedField<int>* values);
0293 
0294   // Read a string.  ReadString(..., std::string* value) requires an
0295   // existing std::string.
0296   static inline bool ReadString(io::CodedInputStream* input,
0297                                 std::string* value);
0298   // ReadString(..., std::string** p) is internal-only, and should only be
0299   // called from generated code. It starts by setting *p to "new std::string" if
0300   // *p == &GetEmptyStringAlreadyInited().  It then invokes
0301   // ReadString(io::CodedInputStream* input, *p).  This is useful for reducing
0302   // code size.
0303   static inline bool ReadString(io::CodedInputStream* input, std::string** p);
0304   // Analogous to ReadString().
0305   static bool ReadBytes(io::CodedInputStream* input, std::string* value);
0306   static bool ReadBytes(io::CodedInputStream* input, std::string** p);
0307 
0308   static inline bool ReadBytes(io::CodedInputStream* input, absl::Cord* value);
0309   static inline bool ReadBytes(io::CodedInputStream* input, absl::Cord** p);
0310 
0311   enum Operation {
0312     PARSE = 0,
0313     SERIALIZE = 1,
0314   };
0315 
0316   // Returns true if the data is valid UTF-8.
0317   static bool VerifyUtf8String(const char* data, int size, Operation op,
0318                                const char* field_name);
0319 
0320   template <typename MessageType>
0321   static inline bool ReadGroup(int field_number, io::CodedInputStream* input,
0322                                MessageType* value);
0323 
0324   template <typename MessageType>
0325   static inline bool ReadMessage(io::CodedInputStream* input,
0326                                  MessageType* value);
0327 
0328   template <typename MessageType>
0329   static inline bool ReadMessageNoVirtual(io::CodedInputStream* input,
0330                                           MessageType* value) {
0331     return ReadMessage(input, value);
0332   }
0333 
0334   // Write a tag.  The Write*() functions typically include the tag, so
0335   // normally there's no need to call this unless using the Write*NoTag()
0336   // variants.
0337   PROTOBUF_NDEBUG_INLINE static void WriteTag(int field_number, WireType type,
0338                                               io::CodedOutputStream* output);
0339 
0340   // Write fields, without tags.
0341   PROTOBUF_NDEBUG_INLINE static void WriteInt32NoTag(
0342       int32_t value, io::CodedOutputStream* output);
0343   PROTOBUF_NDEBUG_INLINE static void WriteInt64NoTag(
0344       int64_t value, io::CodedOutputStream* output);
0345   PROTOBUF_NDEBUG_INLINE static void WriteUInt32NoTag(
0346       uint32_t value, io::CodedOutputStream* output);
0347   PROTOBUF_NDEBUG_INLINE static void WriteUInt64NoTag(
0348       uint64_t value, io::CodedOutputStream* output);
0349   PROTOBUF_NDEBUG_INLINE static void WriteSInt32NoTag(
0350       int32_t value, io::CodedOutputStream* output);
0351   PROTOBUF_NDEBUG_INLINE static void WriteSInt64NoTag(
0352       int64_t value, io::CodedOutputStream* output);
0353   PROTOBUF_NDEBUG_INLINE static void WriteFixed32NoTag(
0354       uint32_t value, io::CodedOutputStream* output);
0355   PROTOBUF_NDEBUG_INLINE static void WriteFixed64NoTag(
0356       uint64_t value, io::CodedOutputStream* output);
0357   PROTOBUF_NDEBUG_INLINE static void WriteSFixed32NoTag(
0358       int32_t value, io::CodedOutputStream* output);
0359   PROTOBUF_NDEBUG_INLINE static void WriteSFixed64NoTag(
0360       int64_t value, io::CodedOutputStream* output);
0361   PROTOBUF_NDEBUG_INLINE static void WriteFloatNoTag(
0362       float value, io::CodedOutputStream* output);
0363   PROTOBUF_NDEBUG_INLINE static void WriteDoubleNoTag(
0364       double value, io::CodedOutputStream* output);
0365   PROTOBUF_NDEBUG_INLINE static void WriteBoolNoTag(
0366       bool value, io::CodedOutputStream* output);
0367   PROTOBUF_NDEBUG_INLINE static void WriteEnumNoTag(
0368       int value, io::CodedOutputStream* output);
0369 
0370   // Write array of primitive fields, without tags
0371   static void WriteFloatArray(const float* a, int n,
0372                               io::CodedOutputStream* output);
0373   static void WriteDoubleArray(const double* a, int n,
0374                                io::CodedOutputStream* output);
0375   static void WriteFixed32Array(const uint32_t* a, int n,
0376                                 io::CodedOutputStream* output);
0377   static void WriteFixed64Array(const uint64_t* a, int n,
0378                                 io::CodedOutputStream* output);
0379   static void WriteSFixed32Array(const int32_t* a, int n,
0380                                  io::CodedOutputStream* output);
0381   static void WriteSFixed64Array(const int64_t* a, int n,
0382                                  io::CodedOutputStream* output);
0383   static void WriteBoolArray(const bool* a, int n,
0384                              io::CodedOutputStream* output);
0385 
0386   // Write fields, including tags.
0387   static void WriteInt32(int field_number, int32_t value,
0388                          io::CodedOutputStream* output);
0389   static void WriteInt64(int field_number, int64_t value,
0390                          io::CodedOutputStream* output);
0391   static void WriteUInt32(int field_number, uint32_t value,
0392                           io::CodedOutputStream* output);
0393   static void WriteUInt64(int field_number, uint64_t value,
0394                           io::CodedOutputStream* output);
0395   static void WriteSInt32(int field_number, int32_t value,
0396                           io::CodedOutputStream* output);
0397   static void WriteSInt64(int field_number, int64_t value,
0398                           io::CodedOutputStream* output);
0399   static void WriteFixed32(int field_number, uint32_t value,
0400                            io::CodedOutputStream* output);
0401   static void WriteFixed64(int field_number, uint64_t value,
0402                            io::CodedOutputStream* output);
0403   static void WriteSFixed32(int field_number, int32_t value,
0404                             io::CodedOutputStream* output);
0405   static void WriteSFixed64(int field_number, int64_t value,
0406                             io::CodedOutputStream* output);
0407   static void WriteFloat(int field_number, float value,
0408                          io::CodedOutputStream* output);
0409   static void WriteDouble(int field_number, double value,
0410                           io::CodedOutputStream* output);
0411   static void WriteBool(int field_number, bool value,
0412                         io::CodedOutputStream* output);
0413   static void WriteEnum(int field_number, int value,
0414                         io::CodedOutputStream* output);
0415 
0416   static void WriteString(int field_number, const std::string& value,
0417                           io::CodedOutputStream* output);
0418   static void WriteBytes(int field_number, const std::string& value,
0419                          io::CodedOutputStream* output);
0420   static void WriteStringMaybeAliased(int field_number,
0421                                       const std::string& value,
0422                                       io::CodedOutputStream* output);
0423   static void WriteBytesMaybeAliased(int field_number, const std::string& value,
0424                                      io::CodedOutputStream* output);
0425 
0426   static void WriteGroup(int field_number, const MessageLite& value,
0427                          io::CodedOutputStream* output);
0428   static void WriteMessage(int field_number, const MessageLite& value,
0429                            io::CodedOutputStream* output);
0430   // Like above, but these will check if the output stream has enough
0431   // space to write directly to a flat array.
0432   static void WriteGroupMaybeToArray(int field_number, const MessageLite& value,
0433                                      io::CodedOutputStream* output);
0434   static void WriteMessageMaybeToArray(int field_number,
0435                                        const MessageLite& value,
0436                                        io::CodedOutputStream* output);
0437 
0438   // Like above, but de-virtualize the call to SerializeWithCachedSizes().  The
0439   // pointer must point at an instance of MessageType, *not* a subclass (or
0440   // the subclass must not override SerializeWithCachedSizes()).
0441   template <typename MessageType>
0442   static inline void WriteGroupNoVirtual(int field_number,
0443                                          const MessageType& value,
0444                                          io::CodedOutputStream* output);
0445   template <typename MessageType>
0446   static inline void WriteMessageNoVirtual(int field_number,
0447                                            const MessageType& value,
0448                                            io::CodedOutputStream* output);
0449 
0450   // Like above, but use only *ToArray methods of CodedOutputStream.
0451   PROTOBUF_NDEBUG_INLINE static uint8_t* WriteTagToArray(int field_number,
0452                                                          WireType type,
0453                                                          uint8_t* target);
0454 
0455   // Write fields, without tags.
0456   PROTOBUF_NDEBUG_INLINE static uint8_t* WriteInt32NoTagToArray(
0457       int32_t value, uint8_t* target);
0458   PROTOBUF_NDEBUG_INLINE static uint8_t* WriteInt64NoTagToArray(
0459       int64_t value, uint8_t* target);
0460   PROTOBUF_NDEBUG_INLINE static uint8_t* WriteUInt32NoTagToArray(
0461       uint32_t value, uint8_t* target);
0462   PROTOBUF_NDEBUG_INLINE static uint8_t* WriteUInt64NoTagToArray(
0463       uint64_t value, uint8_t* target);
0464   PROTOBUF_NDEBUG_INLINE static uint8_t* WriteSInt32NoTagToArray(
0465       int32_t value, uint8_t* target);
0466   PROTOBUF_NDEBUG_INLINE static uint8_t* WriteSInt64NoTagToArray(
0467       int64_t value, uint8_t* target);
0468   PROTOBUF_NDEBUG_INLINE static uint8_t* WriteFixed32NoTagToArray(
0469       uint32_t value, uint8_t* target);
0470   PROTOBUF_NDEBUG_INLINE static uint8_t* WriteFixed64NoTagToArray(
0471       uint64_t value, uint8_t* target);
0472   PROTOBUF_NDEBUG_INLINE static uint8_t* WriteSFixed32NoTagToArray(
0473       int32_t value, uint8_t* target);
0474   PROTOBUF_NDEBUG_INLINE static uint8_t* WriteSFixed64NoTagToArray(
0475       int64_t value, uint8_t* target);
0476   PROTOBUF_NDEBUG_INLINE static uint8_t* WriteFloatNoTagToArray(
0477       float value, uint8_t* target);
0478   PROTOBUF_NDEBUG_INLINE static uint8_t* WriteDoubleNoTagToArray(
0479       double value, uint8_t* target);
0480   PROTOBUF_NDEBUG_INLINE static uint8_t* WriteBoolNoTagToArray(bool value,
0481                                                                uint8_t* target);
0482   PROTOBUF_NDEBUG_INLINE static uint8_t* WriteEnumNoTagToArray(int value,
0483                                                                uint8_t* target);
0484 
0485   // Write fields, without tags.  These require that value.size() > 0.
0486   template <typename T>
0487   PROTOBUF_NDEBUG_INLINE static uint8_t* WritePrimitiveNoTagToArray(
0488       const RepeatedField<T>& value, uint8_t* (*Writer)(T, uint8_t*),
0489       uint8_t* target);
0490   template <typename T>
0491   PROTOBUF_NDEBUG_INLINE static uint8_t* WriteFixedNoTagToArray(
0492       const RepeatedField<T>& value, uint8_t* (*Writer)(T, uint8_t*),
0493       uint8_t* target);
0494 
0495   PROTOBUF_NDEBUG_INLINE static uint8_t* WriteInt32NoTagToArray(
0496       const RepeatedField<int32_t>& value, uint8_t* output);
0497   PROTOBUF_NDEBUG_INLINE static uint8_t* WriteInt64NoTagToArray(
0498       const RepeatedField<int64_t>& value, uint8_t* output);
0499   PROTOBUF_NDEBUG_INLINE static uint8_t* WriteUInt32NoTagToArray(
0500       const RepeatedField<uint32_t>& value, uint8_t* output);
0501   PROTOBUF_NDEBUG_INLINE static uint8_t* WriteUInt64NoTagToArray(
0502       const RepeatedField<uint64_t>& value, uint8_t* output);
0503   PROTOBUF_NDEBUG_INLINE static uint8_t* WriteSInt32NoTagToArray(
0504       const RepeatedField<int32_t>& value, uint8_t* output);
0505   PROTOBUF_NDEBUG_INLINE static uint8_t* WriteSInt64NoTagToArray(
0506       const RepeatedField<int64_t>& value, uint8_t* output);
0507   PROTOBUF_NDEBUG_INLINE static uint8_t* WriteFixed32NoTagToArray(
0508       const RepeatedField<uint32_t>& value, uint8_t* output);
0509   PROTOBUF_NDEBUG_INLINE static uint8_t* WriteFixed64NoTagToArray(
0510       const RepeatedField<uint64_t>& value, uint8_t* output);
0511   PROTOBUF_NDEBUG_INLINE static uint8_t* WriteSFixed32NoTagToArray(
0512       const RepeatedField<int32_t>& value, uint8_t* output);
0513   PROTOBUF_NDEBUG_INLINE static uint8_t* WriteSFixed64NoTagToArray(
0514       const RepeatedField<int64_t>& value, uint8_t* output);
0515   PROTOBUF_NDEBUG_INLINE static uint8_t* WriteFloatNoTagToArray(
0516       const RepeatedField<float>& value, uint8_t* output);
0517   PROTOBUF_NDEBUG_INLINE static uint8_t* WriteDoubleNoTagToArray(
0518       const RepeatedField<double>& value, uint8_t* output);
0519   PROTOBUF_NDEBUG_INLINE static uint8_t* WriteBoolNoTagToArray(
0520       const RepeatedField<bool>& value, uint8_t* output);
0521   PROTOBUF_NDEBUG_INLINE static uint8_t* WriteEnumNoTagToArray(
0522       const RepeatedField<int>& value, uint8_t* output);
0523 
0524   // Write fields, including tags.
0525   template <int field_number>
0526   PROTOBUF_NOINLINE static uint8_t* WriteInt32ToArrayWithField(
0527       ::google::protobuf::io::EpsCopyOutputStream* stream, int32_t value,
0528       uint8_t* target) {
0529     target = stream->EnsureSpace(target);
0530     return WriteInt32ToArray(field_number, value, target);
0531   }
0532 
0533   template <int field_number>
0534   PROTOBUF_NOINLINE static uint8_t* WriteInt64ToArrayWithField(
0535       ::google::protobuf::io::EpsCopyOutputStream* stream, int64_t value,
0536       uint8_t* target) {
0537     target = stream->EnsureSpace(target);
0538     return WriteInt64ToArray(field_number, value, target);
0539   }
0540 
0541   template <int field_number>
0542   PROTOBUF_NOINLINE static uint8_t* WriteEnumToArrayWithField(
0543       ::google::protobuf::io::EpsCopyOutputStream* stream, int value, uint8_t* target) {
0544     target = stream->EnsureSpace(target);
0545     return WriteEnumToArray(field_number, value, target);
0546   }
0547 
0548   PROTOBUF_NDEBUG_INLINE static uint8_t* WriteInt32ToArray(int field_number,
0549                                                            int32_t value,
0550                                                            uint8_t* target);
0551   PROTOBUF_NDEBUG_INLINE static uint8_t* WriteInt64ToArray(int field_number,
0552                                                            int64_t value,
0553                                                            uint8_t* target);
0554   PROTOBUF_NDEBUG_INLINE static uint8_t* WriteUInt32ToArray(int field_number,
0555                                                             uint32_t value,
0556                                                             uint8_t* target);
0557   PROTOBUF_NDEBUG_INLINE static uint8_t* WriteUInt64ToArray(int field_number,
0558                                                             uint64_t value,
0559                                                             uint8_t* target);
0560   PROTOBUF_NDEBUG_INLINE static uint8_t* WriteSInt32ToArray(int field_number,
0561                                                             int32_t value,
0562                                                             uint8_t* target);
0563   PROTOBUF_NDEBUG_INLINE static uint8_t* WriteSInt64ToArray(int field_number,
0564                                                             int64_t value,
0565                                                             uint8_t* target);
0566   PROTOBUF_NDEBUG_INLINE static uint8_t* WriteFixed32ToArray(int field_number,
0567                                                              uint32_t value,
0568                                                              uint8_t* target);
0569   PROTOBUF_NDEBUG_INLINE static uint8_t* WriteFixed64ToArray(int field_number,
0570                                                              uint64_t value,
0571                                                              uint8_t* target);
0572   PROTOBUF_NDEBUG_INLINE static uint8_t* WriteSFixed32ToArray(int field_number,
0573                                                               int32_t value,
0574                                                               uint8_t* target);
0575   PROTOBUF_NDEBUG_INLINE static uint8_t* WriteSFixed64ToArray(int field_number,
0576                                                               int64_t value,
0577                                                               uint8_t* target);
0578   PROTOBUF_NDEBUG_INLINE static uint8_t* WriteFloatToArray(int field_number,
0579                                                            float value,
0580                                                            uint8_t* target);
0581   PROTOBUF_NDEBUG_INLINE static uint8_t* WriteDoubleToArray(int field_number,
0582                                                             double value,
0583                                                             uint8_t* target);
0584   PROTOBUF_NDEBUG_INLINE static uint8_t* WriteBoolToArray(int field_number,
0585                                                           bool value,
0586                                                           uint8_t* target);
0587   PROTOBUF_NDEBUG_INLINE static uint8_t* WriteEnumToArray(int field_number,
0588                                                           int value,
0589                                                           uint8_t* target);
0590 
0591   template <typename T>
0592   PROTOBUF_NDEBUG_INLINE static uint8_t* WritePrimitiveToArray(
0593       int field_number, const RepeatedField<T>& value,
0594       uint8_t* (*Writer)(int, T, uint8_t*), uint8_t* target);
0595 
0596   PROTOBUF_NDEBUG_INLINE static uint8_t* WriteInt32ToArray(
0597       int field_number, const RepeatedField<int32_t>& value, uint8_t* output);
0598   PROTOBUF_NDEBUG_INLINE static uint8_t* WriteInt64ToArray(
0599       int field_number, const RepeatedField<int64_t>& value, uint8_t* output);
0600   PROTOBUF_NDEBUG_INLINE static uint8_t* WriteUInt32ToArray(
0601       int field_number, const RepeatedField<uint32_t>& value, uint8_t* output);
0602   PROTOBUF_NDEBUG_INLINE static uint8_t* WriteUInt64ToArray(
0603       int field_number, const RepeatedField<uint64_t>& value, uint8_t* output);
0604   PROTOBUF_NDEBUG_INLINE static uint8_t* WriteSInt32ToArray(
0605       int field_number, const RepeatedField<int32_t>& value, uint8_t* output);
0606   PROTOBUF_NDEBUG_INLINE static uint8_t* WriteSInt64ToArray(
0607       int field_number, const RepeatedField<int64_t>& value, uint8_t* output);
0608   PROTOBUF_NDEBUG_INLINE static uint8_t* WriteFixed32ToArray(
0609       int field_number, const RepeatedField<uint32_t>& value, uint8_t* output);
0610   PROTOBUF_NDEBUG_INLINE static uint8_t* WriteFixed64ToArray(
0611       int field_number, const RepeatedField<uint64_t>& value, uint8_t* output);
0612   PROTOBUF_NDEBUG_INLINE static uint8_t* WriteSFixed32ToArray(
0613       int field_number, const RepeatedField<int32_t>& value, uint8_t* output);
0614   PROTOBUF_NDEBUG_INLINE static uint8_t* WriteSFixed64ToArray(
0615       int field_number, const RepeatedField<int64_t>& value, uint8_t* output);
0616   PROTOBUF_NDEBUG_INLINE static uint8_t* WriteFloatToArray(
0617       int field_number, const RepeatedField<float>& value, uint8_t* output);
0618   PROTOBUF_NDEBUG_INLINE static uint8_t* WriteDoubleToArray(
0619       int field_number, const RepeatedField<double>& value, uint8_t* output);
0620   PROTOBUF_NDEBUG_INLINE static uint8_t* WriteBoolToArray(
0621       int field_number, const RepeatedField<bool>& value, uint8_t* output);
0622   PROTOBUF_NDEBUG_INLINE static uint8_t* WriteEnumToArray(
0623       int field_number, const RepeatedField<int>& value, uint8_t* output);
0624 
0625   PROTOBUF_NDEBUG_INLINE static uint8_t* WriteStringToArray(
0626       int field_number, const std::string& value, uint8_t* target);
0627   PROTOBUF_NDEBUG_INLINE static uint8_t* WriteBytesToArray(
0628       int field_number, const std::string& value, uint8_t* target);
0629 
0630   // Whether to serialize deterministically (e.g., map keys are
0631   // sorted) is a property of a CodedOutputStream, and in the process
0632   // of serialization, the "ToArray" variants may be invoked.  But they don't
0633   // have a CodedOutputStream available, so they get an additional parameter
0634   // telling them whether to serialize deterministically.
0635   static uint8_t* InternalWriteGroup(int field_number, const MessageLite& value,
0636                                      uint8_t* target,
0637                                      io::EpsCopyOutputStream* stream);
0638   static uint8_t* InternalWriteMessage(int field_number,
0639                                        const MessageLite& value,
0640                                        int cached_size, uint8_t* target,
0641                                        io::EpsCopyOutputStream* stream);
0642 
0643   // Like above, but de-virtualize the call to SerializeWithCachedSizes().
0644   template <typename MessageType>
0645   PROTOBUF_NDEBUG_INLINE static uint8_t* InternalWriteGroupNoVirtualToArray(
0646       int field_number, const MessageType& value, uint8_t* target);
0647   template <typename MessageType>
0648   PROTOBUF_NDEBUG_INLINE static uint8_t* InternalWriteMessageNoVirtualToArray(
0649       int field_number, const MessageType& value, uint8_t* target);
0650 
0651   // For backward-compatibility, the last four methods also have versions
0652   // that are non-deterministic always.
0653   PROTOBUF_NDEBUG_INLINE static uint8_t* WriteGroupToArray(
0654       int field_number, const MessageLite& value, uint8_t* target) {
0655     io::EpsCopyOutputStream stream(
0656         target,
0657         value.GetCachedSize() +
0658             static_cast<int>(2 * io::CodedOutputStream::VarintSize32(
0659                                      static_cast<uint32_t>(field_number) << 3)),
0660         io::CodedOutputStream::IsDefaultSerializationDeterministic());
0661     return InternalWriteGroup(field_number, value, target, &stream);
0662   }
0663   PROTOBUF_NDEBUG_INLINE static uint8_t* WriteMessageToArray(
0664       int field_number, const MessageLite& value, uint8_t* target) {
0665     int size = value.GetCachedSize();
0666     io::EpsCopyOutputStream stream(
0667         target,
0668         size + static_cast<int>(io::CodedOutputStream::VarintSize32(
0669                                     static_cast<uint32_t>(field_number) << 3) +
0670                                 io::CodedOutputStream::VarintSize32(size)),
0671         io::CodedOutputStream::IsDefaultSerializationDeterministic());
0672     return InternalWriteMessage(field_number, value, value.GetCachedSize(),
0673                                 target, &stream);
0674   }
0675 
0676   // Compute the byte size of a field.  The XxSize() functions do NOT include
0677   // the tag, so you must also call TagSize().  (This is because, for repeated
0678   // fields, you should only call TagSize() once and multiply it by the element
0679   // count, but you may have to call XxSize() for each individual element.)
0680   static inline size_t Int32Size(int32_t value);
0681   static inline size_t Int64Size(int64_t value);
0682   static inline size_t UInt32Size(uint32_t value);
0683   static inline size_t UInt64Size(uint64_t value);
0684   static inline size_t SInt32Size(int32_t value);
0685   static inline size_t SInt64Size(int64_t value);
0686   static inline size_t EnumSize(int value);
0687   static inline size_t Int32SizePlusOne(int32_t value);
0688   static inline size_t Int64SizePlusOne(int64_t value);
0689   static inline size_t UInt32SizePlusOne(uint32_t value);
0690   static inline size_t UInt64SizePlusOne(uint64_t value);
0691   static inline size_t SInt32SizePlusOne(int32_t value);
0692   static inline size_t SInt64SizePlusOne(int64_t value);
0693   static inline size_t EnumSizePlusOne(int value);
0694 
0695   static size_t Int32Size(const RepeatedField<int32_t>& value);
0696   static size_t Int64Size(const RepeatedField<int64_t>& value);
0697   static size_t UInt32Size(const RepeatedField<uint32_t>& value);
0698   static size_t UInt64Size(const RepeatedField<uint64_t>& value);
0699   static size_t SInt32Size(const RepeatedField<int32_t>& value);
0700   static size_t SInt64Size(const RepeatedField<int64_t>& value);
0701   static size_t EnumSize(const RepeatedField<int>& value);
0702 
0703   // These types always have the same size.
0704   static constexpr size_t kFixed32Size = 4;
0705   static constexpr size_t kFixed64Size = 8;
0706   static constexpr size_t kSFixed32Size = 4;
0707   static constexpr size_t kSFixed64Size = 8;
0708   static constexpr size_t kFloatSize = 4;
0709   static constexpr size_t kDoubleSize = 8;
0710   static constexpr size_t kBoolSize = 1;
0711 
0712   static inline size_t StringSize(const std::string& value);
0713   static inline size_t StringSize(const absl::Cord& value);
0714   static inline size_t BytesSize(const std::string& value);
0715   static inline size_t BytesSize(const absl::Cord& value);
0716   static inline size_t StringSize(absl::string_view value);
0717   static inline size_t BytesSize(absl::string_view value);
0718 
0719   template <typename MessageType>
0720   static inline size_t GroupSize(const MessageType& value);
0721   template <typename MessageType>
0722   static inline size_t MessageSize(const MessageType& value);
0723 
0724   // Like above, but de-virtualize the call to ByteSize().  The
0725   // pointer must point at an instance of MessageType, *not* a subclass (or
0726   // the subclass must not override ByteSize()).
0727   template <typename MessageType>
0728   static inline size_t GroupSizeNoVirtual(const MessageType& value);
0729   template <typename MessageType>
0730   static inline size_t MessageSizeNoVirtual(const MessageType& value);
0731 
0732   // Given the length of data, calculate the byte size of the data on the
0733   // wire if we encode the data as a length delimited field.
0734   static inline size_t LengthDelimitedSize(size_t length);
0735 
0736  private:
0737   // A helper method for the repeated primitive reader. This method has
0738   // optimizations for primitive types that have fixed size on the wire, and
0739   // can be read using potentially faster paths.
0740   template <typename CType, enum FieldType DeclaredType>
0741   PROTOBUF_NDEBUG_INLINE static bool ReadRepeatedFixedSizePrimitive(
0742       int tag_size, uint32_t tag, io::CodedInputStream* input,
0743       RepeatedField<CType>* value);
0744 
0745   // Like ReadRepeatedFixedSizePrimitive but for packed primitive fields.
0746   template <typename CType, enum FieldType DeclaredType>
0747   PROTOBUF_NDEBUG_INLINE static bool ReadPackedFixedSizePrimitive(
0748       io::CodedInputStream* input, RepeatedField<CType>* value);
0749 
0750   static const CppType kFieldTypeToCppTypeMap[];
0751   static const WireFormatLite::WireType kWireTypeForFieldType[];
0752   static void WriteSubMessageMaybeToArray(int size, const MessageLite& value,
0753                                           io::CodedOutputStream* output);
0754 };
0755 
0756 // A class which deals with unknown values.  The default implementation just
0757 // discards them.  WireFormat defines a subclass which writes to an
0758 // UnknownFieldSet.  This class is used by ExtensionSet::ParseField(), since
0759 // ExtensionSet is part of the lite library but UnknownFieldSet is not.
0760 class PROTOBUF_EXPORT FieldSkipper {
0761  public:
0762   FieldSkipper() {}
0763   virtual ~FieldSkipper() {}
0764 
0765   // Skip a field whose tag has already been consumed.
0766   virtual bool SkipField(io::CodedInputStream* input, uint32_t tag);
0767 
0768   // Skip an entire message or group, up to an end-group tag (which is consumed)
0769   // or end-of-stream.
0770   virtual bool SkipMessage(io::CodedInputStream* input);
0771 
0772   // Deal with an already-parsed unrecognized enum value.  The default
0773   // implementation does nothing, but the UnknownFieldSet-based implementation
0774   // saves it as an unknown varint.
0775   virtual void SkipUnknownEnum(int field_number, int value);
0776 };
0777 
0778 // Subclass of FieldSkipper which saves skipped fields to a CodedOutputStream.
0779 
0780 class PROTOBUF_EXPORT CodedOutputStreamFieldSkipper : public FieldSkipper {
0781  public:
0782   explicit CodedOutputStreamFieldSkipper(io::CodedOutputStream* unknown_fields)
0783       : unknown_fields_(unknown_fields) {}
0784   ~CodedOutputStreamFieldSkipper() override {}
0785 
0786   // implements FieldSkipper -----------------------------------------
0787   bool SkipField(io::CodedInputStream* input, uint32_t tag) override;
0788   bool SkipMessage(io::CodedInputStream* input) override;
0789   void SkipUnknownEnum(int field_number, int value) override;
0790 
0791  protected:
0792   io::CodedOutputStream* unknown_fields_;
0793 };
0794 
0795 // inline methods ====================================================
0796 
0797 inline WireFormatLite::CppType WireFormatLite::FieldTypeToCppType(
0798     FieldType type) {
0799   return kFieldTypeToCppTypeMap[type];
0800 }
0801 
0802 constexpr inline uint32_t WireFormatLite::MakeTag(int field_number,
0803                                                   WireType type) {
0804   return GOOGLE_PROTOBUF_WIRE_FORMAT_MAKE_TAG(field_number, type);
0805 }
0806 
0807 inline WireFormatLite::WireType WireFormatLite::GetTagWireType(uint32_t tag) {
0808   return static_cast<WireType>(tag & kTagTypeMask);
0809 }
0810 
0811 inline int WireFormatLite::GetTagFieldNumber(uint32_t tag) {
0812   return static_cast<int>(tag >> kTagTypeBits);
0813 }
0814 
0815 inline size_t WireFormatLite::TagSize(int field_number,
0816                                       WireFormatLite::FieldType type) {
0817   size_t result = io::CodedOutputStream::VarintSize32(
0818       static_cast<uint32_t>(field_number << kTagTypeBits));
0819   if (type == TYPE_GROUP) {
0820     // Groups have both a start and an end tag.
0821     return result * 2;
0822   } else {
0823     return result;
0824   }
0825 }
0826 
0827 inline uint32_t WireFormatLite::EncodeFloat(float value) {
0828   return absl::bit_cast<uint32_t>(value);
0829 }
0830 
0831 inline float WireFormatLite::DecodeFloat(uint32_t value) {
0832   return absl::bit_cast<float>(value);
0833 }
0834 
0835 inline uint64_t WireFormatLite::EncodeDouble(double value) {
0836   return absl::bit_cast<uint64_t>(value);
0837 }
0838 
0839 inline double WireFormatLite::DecodeDouble(uint64_t value) {
0840   return absl::bit_cast<double>(value);
0841 }
0842 
0843 // ZigZag Transform:  Encodes signed integers so that they can be
0844 // effectively used with varint encoding.
0845 //
0846 // varint operates on unsigned integers, encoding smaller numbers into
0847 // fewer bytes.  If you try to use it on a signed integer, it will treat
0848 // this number as a very large unsigned integer, which means that even
0849 // small signed numbers like -1 will take the maximum number of bytes
0850 // (10) to encode.  ZigZagEncode() maps signed integers to unsigned
0851 // in such a way that those with a small absolute value will have smaller
0852 // encoded values, making them appropriate for encoding using varint.
0853 //
0854 //       int32_t ->     uint32_t
0855 // -------------------------
0856 //           0 ->          0
0857 //          -1 ->          1
0858 //           1 ->          2
0859 //          -2 ->          3
0860 //         ... ->        ...
0861 //  2147483647 -> 4294967294
0862 // -2147483648 -> 4294967295
0863 //
0864 //        >> encode >>
0865 //        << decode <<
0866 
0867 inline uint32_t WireFormatLite::ZigZagEncode32(int32_t n) {
0868   // Note:  the right-shift must be arithmetic
0869   // Note:  left shift must be unsigned because of overflow
0870   return (static_cast<uint32_t>(n) << 1) ^ static_cast<uint32_t>(n >> 31);
0871 }
0872 
0873 inline int32_t WireFormatLite::ZigZagDecode32(uint32_t n) {
0874   // Note:  Using unsigned types prevent undefined behavior
0875   return static_cast<int32_t>((n >> 1) ^ (~(n & 1) + 1));
0876 }
0877 
0878 inline uint64_t WireFormatLite::ZigZagEncode64(int64_t n) {
0879   // Note:  the right-shift must be arithmetic
0880   // Note:  left shift must be unsigned because of overflow
0881   return (static_cast<uint64_t>(n) << 1) ^ static_cast<uint64_t>(n >> 63);
0882 }
0883 
0884 inline int64_t WireFormatLite::ZigZagDecode64(uint64_t n) {
0885   // Note:  Using unsigned types prevent undefined behavior
0886   return static_cast<int64_t>((n >> 1) ^ (~(n & 1) + 1));
0887 }
0888 
0889 // String is for UTF-8 text only, but, even so, ReadString() can simply
0890 // call ReadBytes().
0891 
0892 inline bool WireFormatLite::ReadString(io::CodedInputStream* input,
0893                                        std::string* value) {
0894   return ReadBytes(input, value);
0895 }
0896 
0897 inline bool WireFormatLite::ReadString(io::CodedInputStream* input,
0898                                        std::string** p) {
0899   return ReadBytes(input, p);
0900 }
0901 
0902 inline uint8_t* InternalSerializeUnknownMessageSetItemsToArray(
0903     const std::string& unknown_fields, uint8_t* target,
0904     io::EpsCopyOutputStream* stream) {
0905   return stream->WriteRaw(unknown_fields.data(),
0906                           static_cast<int>(unknown_fields.size()), target);
0907 }
0908 
0909 inline size_t ComputeUnknownMessageSetItemsSize(
0910     const std::string& unknown_fields) {
0911   return unknown_fields.size();
0912 }
0913 
0914 // Implementation details of ReadPrimitive.
0915 
0916 template <>
0917 inline bool WireFormatLite::ReadPrimitive<int32_t, WireFormatLite::TYPE_INT32>(
0918     io::CodedInputStream* input, int32_t* value) {
0919   uint32_t temp;
0920   if (!input->ReadVarint32(&temp)) return false;
0921   *value = static_cast<int32_t>(temp);
0922   return true;
0923 }
0924 template <>
0925 inline bool WireFormatLite::ReadPrimitive<int64_t, WireFormatLite::TYPE_INT64>(
0926     io::CodedInputStream* input, int64_t* value) {
0927   uint64_t temp;
0928   if (!input->ReadVarint64(&temp)) return false;
0929   *value = static_cast<int64_t>(temp);
0930   return true;
0931 }
0932 template <>
0933 inline bool
0934 WireFormatLite::ReadPrimitive<uint32_t, WireFormatLite::TYPE_UINT32>(
0935     io::CodedInputStream* input, uint32_t* value) {
0936   return input->ReadVarint32(value);
0937 }
0938 template <>
0939 inline bool
0940 WireFormatLite::ReadPrimitive<uint64_t, WireFormatLite::TYPE_UINT64>(
0941     io::CodedInputStream* input, uint64_t* value) {
0942   return input->ReadVarint64(value);
0943 }
0944 template <>
0945 inline bool WireFormatLite::ReadPrimitive<int32_t, WireFormatLite::TYPE_SINT32>(
0946     io::CodedInputStream* input, int32_t* value) {
0947   uint32_t temp;
0948   if (!input->ReadVarint32(&temp)) return false;
0949   *value = ZigZagDecode32(temp);
0950   return true;
0951 }
0952 template <>
0953 inline bool WireFormatLite::ReadPrimitive<int64_t, WireFormatLite::TYPE_SINT64>(
0954     io::CodedInputStream* input, int64_t* value) {
0955   uint64_t temp;
0956   if (!input->ReadVarint64(&temp)) return false;
0957   *value = ZigZagDecode64(temp);
0958   return true;
0959 }
0960 template <>
0961 inline bool
0962 WireFormatLite::ReadPrimitive<uint32_t, WireFormatLite::TYPE_FIXED32>(
0963     io::CodedInputStream* input, uint32_t* value) {
0964   return input->ReadLittleEndian32(value);
0965 }
0966 template <>
0967 inline bool
0968 WireFormatLite::ReadPrimitive<uint64_t, WireFormatLite::TYPE_FIXED64>(
0969     io::CodedInputStream* input, uint64_t* value) {
0970   return input->ReadLittleEndian64(value);
0971 }
0972 template <>
0973 inline bool
0974 WireFormatLite::ReadPrimitive<int32_t, WireFormatLite::TYPE_SFIXED32>(
0975     io::CodedInputStream* input, int32_t* value) {
0976   uint32_t temp;
0977   if (!input->ReadLittleEndian32(&temp)) return false;
0978   *value = static_cast<int32_t>(temp);
0979   return true;
0980 }
0981 template <>
0982 inline bool
0983 WireFormatLite::ReadPrimitive<int64_t, WireFormatLite::TYPE_SFIXED64>(
0984     io::CodedInputStream* input, int64_t* value) {
0985   uint64_t temp;
0986   if (!input->ReadLittleEndian64(&temp)) return false;
0987   *value = static_cast<int64_t>(temp);
0988   return true;
0989 }
0990 template <>
0991 inline bool WireFormatLite::ReadPrimitive<float, WireFormatLite::TYPE_FLOAT>(
0992     io::CodedInputStream* input, float* value) {
0993   uint32_t temp;
0994   if (!input->ReadLittleEndian32(&temp)) return false;
0995   *value = DecodeFloat(temp);
0996   return true;
0997 }
0998 template <>
0999 inline bool WireFormatLite::ReadPrimitive<double, WireFormatLite::TYPE_DOUBLE>(
1000     io::CodedInputStream* input, double* value) {
1001   uint64_t temp;
1002   if (!input->ReadLittleEndian64(&temp)) return false;
1003   *value = DecodeDouble(temp);
1004   return true;
1005 }
1006 template <>
1007 inline bool WireFormatLite::ReadPrimitive<bool, WireFormatLite::TYPE_BOOL>(
1008     io::CodedInputStream* input, bool* value) {
1009   uint64_t temp;
1010   if (!input->ReadVarint64(&temp)) return false;
1011   *value = temp != 0;
1012   return true;
1013 }
1014 template <>
1015 inline bool WireFormatLite::ReadPrimitive<int, WireFormatLite::TYPE_ENUM>(
1016     io::CodedInputStream* input, int* value) {
1017   uint32_t temp;
1018   if (!input->ReadVarint32(&temp)) return false;
1019   *value = static_cast<int>(temp);
1020   return true;
1021 }
1022 
1023 template <>
1024 inline const uint8_t*
1025 WireFormatLite::ReadPrimitiveFromArray<uint32_t, WireFormatLite::TYPE_FIXED32>(
1026     const uint8_t* buffer, uint32_t* value) {
1027   return io::CodedInputStream::ReadLittleEndian32FromArray(buffer, value);
1028 }
1029 template <>
1030 inline const uint8_t*
1031 WireFormatLite::ReadPrimitiveFromArray<uint64_t, WireFormatLite::TYPE_FIXED64>(
1032     const uint8_t* buffer, uint64_t* value) {
1033   return io::CodedInputStream::ReadLittleEndian64FromArray(buffer, value);
1034 }
1035 template <>
1036 inline const uint8_t*
1037 WireFormatLite::ReadPrimitiveFromArray<int32_t, WireFormatLite::TYPE_SFIXED32>(
1038     const uint8_t* buffer, int32_t* value) {
1039   uint32_t temp;
1040   buffer = io::CodedInputStream::ReadLittleEndian32FromArray(buffer, &temp);
1041   *value = static_cast<int32_t>(temp);
1042   return buffer;
1043 }
1044 template <>
1045 inline const uint8_t*
1046 WireFormatLite::ReadPrimitiveFromArray<int64_t, WireFormatLite::TYPE_SFIXED64>(
1047     const uint8_t* buffer, int64_t* value) {
1048   uint64_t temp;
1049   buffer = io::CodedInputStream::ReadLittleEndian64FromArray(buffer, &temp);
1050   *value = static_cast<int64_t>(temp);
1051   return buffer;
1052 }
1053 template <>
1054 inline const uint8_t*
1055 WireFormatLite::ReadPrimitiveFromArray<float, WireFormatLite::TYPE_FLOAT>(
1056     const uint8_t* buffer, float* value) {
1057   uint32_t temp;
1058   buffer = io::CodedInputStream::ReadLittleEndian32FromArray(buffer, &temp);
1059   *value = DecodeFloat(temp);
1060   return buffer;
1061 }
1062 template <>
1063 inline const uint8_t*
1064 WireFormatLite::ReadPrimitiveFromArray<double, WireFormatLite::TYPE_DOUBLE>(
1065     const uint8_t* buffer, double* value) {
1066   uint64_t temp;
1067   buffer = io::CodedInputStream::ReadLittleEndian64FromArray(buffer, &temp);
1068   *value = DecodeDouble(temp);
1069   return buffer;
1070 }
1071 
1072 template <typename CType, enum WireFormatLite::FieldType DeclaredType>
1073 inline bool WireFormatLite::ReadRepeatedPrimitive(
1074     int,  // tag_size, unused.
1075     uint32_t tag, io::CodedInputStream* input, RepeatedField<CType>* values) {
1076   CType value;
1077   if (!ReadPrimitive<CType, DeclaredType>(input, &value)) return false;
1078   values->Add(value);
1079   int elements_already_reserved = values->Capacity() - values->size();
1080   while (elements_already_reserved > 0 && input->ExpectTag(tag)) {
1081     if (!ReadPrimitive<CType, DeclaredType>(input, &value)) return false;
1082     values->AddAlreadyReserved(value);
1083     elements_already_reserved--;
1084   }
1085   return true;
1086 }
1087 
1088 template <typename CType, enum WireFormatLite::FieldType DeclaredType>
1089 inline bool WireFormatLite::ReadRepeatedFixedSizePrimitive(
1090     int tag_size, uint32_t tag, io::CodedInputStream* input,
1091     RepeatedField<CType>* values) {
1092   ABSL_DCHECK_EQ(UInt32Size(tag), static_cast<size_t>(tag_size));
1093   CType value;
1094   if (!ReadPrimitive<CType, DeclaredType>(input, &value)) return false;
1095   values->Add(value);
1096 
1097   // For fixed size values, repeated values can be read more quickly by
1098   // reading directly from a raw array.
1099   //
1100   // We can get a tight loop by only reading as many elements as can be
1101   // added to the RepeatedField without having to do any resizing. Additionally,
1102   // we only try to read as many elements as are available from the current
1103   // buffer space. Doing so avoids having to perform boundary checks when
1104   // reading the value: the maximum number of elements that can be read is
1105   // known outside of the loop.
1106   const void* void_pointer;
1107   int size;
1108   input->GetDirectBufferPointerInline(&void_pointer, &size);
1109   if (size > 0) {
1110     const uint8_t* buffer = reinterpret_cast<const uint8_t*>(void_pointer);
1111     // The number of bytes each type occupies on the wire.
1112     const int per_value_size = tag_size + static_cast<int>(sizeof(value));
1113 
1114     // parentheses around (std::min) prevents macro expansion of min(...)
1115     int elements_available =
1116         (std::min)(values->Capacity() - values->size(), size / per_value_size);
1117     int num_read = 0;
1118     while (num_read < elements_available &&
1119            (buffer = io::CodedInputStream::ExpectTagFromArray(buffer, tag)) !=
1120                nullptr) {
1121       buffer = ReadPrimitiveFromArray<CType, DeclaredType>(buffer, &value);
1122       values->AddAlreadyReserved(value);
1123       ++num_read;
1124     }
1125     const int read_bytes = num_read * per_value_size;
1126     if (read_bytes > 0) {
1127       input->Skip(read_bytes);
1128     }
1129   }
1130   return true;
1131 }
1132 
1133 // Specializations of ReadRepeatedPrimitive for the fixed size types, which use
1134 // the optimized code path.
1135 #define READ_REPEATED_FIXED_SIZE_PRIMITIVE(CPPTYPE, DECLARED_TYPE)        \
1136   template <>                                                             \
1137   inline bool WireFormatLite::ReadRepeatedPrimitive<                      \
1138       CPPTYPE, WireFormatLite::DECLARED_TYPE>(                            \
1139       int tag_size, uint32_t tag, io::CodedInputStream* input,            \
1140       RepeatedField<CPPTYPE>* values) {                                   \
1141     return ReadRepeatedFixedSizePrimitive<CPPTYPE,                        \
1142                                           WireFormatLite::DECLARED_TYPE>( \
1143         tag_size, tag, input, values);                                    \
1144   }
1145 
1146 READ_REPEATED_FIXED_SIZE_PRIMITIVE(uint32_t, TYPE_FIXED32)
1147 READ_REPEATED_FIXED_SIZE_PRIMITIVE(uint64_t, TYPE_FIXED64)
1148 READ_REPEATED_FIXED_SIZE_PRIMITIVE(int32_t, TYPE_SFIXED32)
1149 READ_REPEATED_FIXED_SIZE_PRIMITIVE(int64_t, TYPE_SFIXED64)
1150 READ_REPEATED_FIXED_SIZE_PRIMITIVE(float, TYPE_FLOAT)
1151 READ_REPEATED_FIXED_SIZE_PRIMITIVE(double, TYPE_DOUBLE)
1152 
1153 #undef READ_REPEATED_FIXED_SIZE_PRIMITIVE
1154 
1155 template <typename CType, enum WireFormatLite::FieldType DeclaredType>
1156 bool WireFormatLite::ReadRepeatedPrimitiveNoInline(
1157     int tag_size, uint32_t tag, io::CodedInputStream* input,
1158     RepeatedField<CType>* value) {
1159   return ReadRepeatedPrimitive<CType, DeclaredType>(tag_size, tag, input,
1160                                                     value);
1161 }
1162 
1163 template <typename CType, enum WireFormatLite::FieldType DeclaredType>
1164 inline bool WireFormatLite::ReadPackedPrimitive(io::CodedInputStream* input,
1165                                                 RepeatedField<CType>* values) {
1166   int length;
1167   if (!input->ReadVarintSizeAsInt(&length)) return false;
1168   io::CodedInputStream::Limit limit = input->PushLimit(length);
1169   while (input->BytesUntilLimit() > 0) {
1170     CType value;
1171     if (!ReadPrimitive<CType, DeclaredType>(input, &value)) return false;
1172     values->Add(value);
1173   }
1174   input->PopLimit(limit);
1175   return true;
1176 }
1177 
1178 template <typename CType, enum WireFormatLite::FieldType DeclaredType>
1179 inline bool WireFormatLite::ReadPackedFixedSizePrimitive(
1180     io::CodedInputStream* input, RepeatedField<CType>* values) {
1181   int length;
1182   if (!input->ReadVarintSizeAsInt(&length)) return false;
1183   const int old_entries = values->size();
1184   const int new_entries = length / static_cast<int>(sizeof(CType));
1185   const int new_bytes = new_entries * static_cast<int>(sizeof(CType));
1186   if (new_bytes != length) return false;
1187   // We would *like* to pre-allocate the buffer to write into (for
1188   // speed), but *must* avoid performing a very large allocation due
1189   // to a malicious user-supplied "length" above.  So we have a fast
1190   // path that pre-allocates when the "length" is less than a bound.
1191   // We determine the bound by calling BytesUntilTotalBytesLimit() and
1192   // BytesUntilLimit().  These return -1 to mean "no limit set".
1193   // There are four cases:
1194   // TotalBytesLimit  Limit
1195   // -1               -1     Use slow path.
1196   // -1               >= 0   Use fast path if length <= Limit.
1197   // >= 0             -1     Use slow path.
1198   // >= 0             >= 0   Use fast path if length <= min(both limits).
1199   int64_t bytes_limit = input->BytesUntilTotalBytesLimit();
1200   if (bytes_limit == -1) {
1201     bytes_limit = input->BytesUntilLimit();
1202   } else {
1203     // parentheses around (std::min) prevents macro expansion of min(...)
1204     bytes_limit =
1205         (std::min)(bytes_limit, static_cast<int64_t>(input->BytesUntilLimit()));
1206   }
1207   if (bytes_limit >= new_bytes) {
1208     // Fast-path that pre-allocates *values to the final size.
1209 #if defined(ABSL_IS_LITTLE_ENDIAN)
1210     values->Resize(old_entries + new_entries, 0);
1211     // values->mutable_data() may change after Resize(), so do this after:
1212     void* dest = reinterpret_cast<void*>(values->mutable_data() + old_entries);
1213     if (!input->ReadRaw(dest, new_bytes)) {
1214       values->Truncate(old_entries);
1215       return false;
1216     }
1217 #else
1218     values->Reserve(old_entries + new_entries);
1219     CType value;
1220     for (int i = 0; i < new_entries; ++i) {
1221       if (!ReadPrimitive<CType, DeclaredType>(input, &value)) return false;
1222       values->AddAlreadyReserved(value);
1223     }
1224 #endif
1225   } else {
1226     // This is the slow-path case where "length" may be too large to
1227     // safely allocate.  We read as much as we can into *values
1228     // without pre-allocating "length" bytes.
1229     CType value;
1230     for (int i = 0; i < new_entries; ++i) {
1231       if (!ReadPrimitive<CType, DeclaredType>(input, &value)) return false;
1232       values->Add(value);
1233     }
1234   }
1235   return true;
1236 }
1237 
1238 // Specializations of ReadPackedPrimitive for the fixed size types, which use
1239 // an optimized code path.
1240 #define READ_REPEATED_PACKED_FIXED_SIZE_PRIMITIVE(CPPTYPE, DECLARED_TYPE)      \
1241   template <>                                                                  \
1242   inline bool                                                                  \
1243   WireFormatLite::ReadPackedPrimitive<CPPTYPE, WireFormatLite::DECLARED_TYPE>( \
1244       io::CodedInputStream * input, RepeatedField<CPPTYPE> * values) {         \
1245     return ReadPackedFixedSizePrimitive<CPPTYPE,                               \
1246                                         WireFormatLite::DECLARED_TYPE>(        \
1247         input, values);                                                        \
1248   }
1249 
1250 READ_REPEATED_PACKED_FIXED_SIZE_PRIMITIVE(uint32_t, TYPE_FIXED32)
1251 READ_REPEATED_PACKED_FIXED_SIZE_PRIMITIVE(uint64_t, TYPE_FIXED64)
1252 READ_REPEATED_PACKED_FIXED_SIZE_PRIMITIVE(int32_t, TYPE_SFIXED32)
1253 READ_REPEATED_PACKED_FIXED_SIZE_PRIMITIVE(int64_t, TYPE_SFIXED64)
1254 READ_REPEATED_PACKED_FIXED_SIZE_PRIMITIVE(float, TYPE_FLOAT)
1255 READ_REPEATED_PACKED_FIXED_SIZE_PRIMITIVE(double, TYPE_DOUBLE)
1256 
1257 #undef READ_REPEATED_PACKED_FIXED_SIZE_PRIMITIVE
1258 
1259 template <typename CType, enum WireFormatLite::FieldType DeclaredType>
1260 bool WireFormatLite::ReadPackedPrimitiveNoInline(io::CodedInputStream* input,
1261                                                  RepeatedField<CType>* values) {
1262   return ReadPackedPrimitive<CType, DeclaredType>(input, values);
1263 }
1264 
1265 inline bool WireFormatLite::ReadBytes(io::CodedInputStream* input,
1266                                       absl::Cord* value) {
1267   int length;
1268   return input->ReadVarintSizeAsInt(&length) && input->ReadCord(value, length);
1269 }
1270 
1271 inline bool WireFormatLite::ReadBytes(io::CodedInputStream* input,
1272                                       absl::Cord** p) {
1273   return ReadBytes(input, *p);
1274 }
1275 
1276 
1277 template <typename MessageType>
1278 inline bool WireFormatLite::ReadGroup(int field_number,
1279                                       io::CodedInputStream* input,
1280                                       MessageType* value) {
1281   if (!input->IncrementRecursionDepth()) return false;
1282   if (!value->MergePartialFromCodedStream(input)) return false;
1283   input->UnsafeDecrementRecursionDepth();
1284   // Make sure the last thing read was an end tag for this group.
1285   if (!input->LastTagWas(MakeTag(field_number, WIRETYPE_END_GROUP))) {
1286     return false;
1287   }
1288   return true;
1289 }
1290 template <typename MessageType>
1291 inline bool WireFormatLite::ReadMessage(io::CodedInputStream* input,
1292                                         MessageType* value) {
1293   int length;
1294   if (!input->ReadVarintSizeAsInt(&length)) return false;
1295   std::pair<io::CodedInputStream::Limit, int> p =
1296       input->IncrementRecursionDepthAndPushLimit(length);
1297   if (p.second < 0 || !value->MergePartialFromCodedStream(input)) return false;
1298   // Make sure that parsing stopped when the limit was hit, not at an endgroup
1299   // tag.
1300   return input->DecrementRecursionDepthAndPopLimit(p.first);
1301 }
1302 
1303 // ===================================================================
1304 
1305 inline void WireFormatLite::WriteTag(int field_number, WireType type,
1306                                      io::CodedOutputStream* output) {
1307   output->WriteTag(MakeTag(field_number, type));
1308 }
1309 
1310 inline void WireFormatLite::WriteInt32NoTag(int32_t value,
1311                                             io::CodedOutputStream* output) {
1312   output->WriteVarint32SignExtended(value);
1313 }
1314 inline void WireFormatLite::WriteInt64NoTag(int64_t value,
1315                                             io::CodedOutputStream* output) {
1316   output->WriteVarint64(static_cast<uint64_t>(value));
1317 }
1318 inline void WireFormatLite::WriteUInt32NoTag(uint32_t value,
1319                                              io::CodedOutputStream* output) {
1320   output->WriteVarint32(value);
1321 }
1322 inline void WireFormatLite::WriteUInt64NoTag(uint64_t value,
1323                                              io::CodedOutputStream* output) {
1324   output->WriteVarint64(value);
1325 }
1326 inline void WireFormatLite::WriteSInt32NoTag(int32_t value,
1327                                              io::CodedOutputStream* output) {
1328   output->WriteVarint32(ZigZagEncode32(value));
1329 }
1330 inline void WireFormatLite::WriteSInt64NoTag(int64_t value,
1331                                              io::CodedOutputStream* output) {
1332   output->WriteVarint64(ZigZagEncode64(value));
1333 }
1334 inline void WireFormatLite::WriteFixed32NoTag(uint32_t value,
1335                                               io::CodedOutputStream* output) {
1336   output->WriteLittleEndian32(value);
1337 }
1338 inline void WireFormatLite::WriteFixed64NoTag(uint64_t value,
1339                                               io::CodedOutputStream* output) {
1340   output->WriteLittleEndian64(value);
1341 }
1342 inline void WireFormatLite::WriteSFixed32NoTag(int32_t value,
1343                                                io::CodedOutputStream* output) {
1344   output->WriteLittleEndian32(static_cast<uint32_t>(value));
1345 }
1346 inline void WireFormatLite::WriteSFixed64NoTag(int64_t value,
1347                                                io::CodedOutputStream* output) {
1348   output->WriteLittleEndian64(static_cast<uint64_t>(value));
1349 }
1350 inline void WireFormatLite::WriteFloatNoTag(float value,
1351                                             io::CodedOutputStream* output) {
1352   output->WriteLittleEndian32(EncodeFloat(value));
1353 }
1354 inline void WireFormatLite::WriteDoubleNoTag(double value,
1355                                              io::CodedOutputStream* output) {
1356   output->WriteLittleEndian64(EncodeDouble(value));
1357 }
1358 inline void WireFormatLite::WriteBoolNoTag(bool value,
1359                                            io::CodedOutputStream* output) {
1360   output->WriteVarint32(value ? 1 : 0);
1361 }
1362 inline void WireFormatLite::WriteEnumNoTag(int value,
1363                                            io::CodedOutputStream* output) {
1364   output->WriteVarint32SignExtended(value);
1365 }
1366 
1367 // See comment on ReadGroupNoVirtual to understand the need for this template
1368 // parameter name.
1369 template <typename MessageType_WorkAroundCppLookupDefect>
1370 inline void WireFormatLite::WriteGroupNoVirtual(
1371     int field_number, const MessageType_WorkAroundCppLookupDefect& value,
1372     io::CodedOutputStream* output) {
1373   WriteTag(field_number, WIRETYPE_START_GROUP, output);
1374   value.MessageType_WorkAroundCppLookupDefect::SerializeWithCachedSizes(output);
1375   WriteTag(field_number, WIRETYPE_END_GROUP, output);
1376 }
1377 template <typename MessageType_WorkAroundCppLookupDefect>
1378 inline void WireFormatLite::WriteMessageNoVirtual(
1379     int field_number, const MessageType_WorkAroundCppLookupDefect& value,
1380     io::CodedOutputStream* output) {
1381   WriteTag(field_number, WIRETYPE_LENGTH_DELIMITED, output);
1382   output->WriteVarint32(
1383       value.MessageType_WorkAroundCppLookupDefect::GetCachedSize());
1384   value.MessageType_WorkAroundCppLookupDefect::SerializeWithCachedSizes(output);
1385 }
1386 
1387 // ===================================================================
1388 
1389 inline uint8_t* WireFormatLite::WriteTagToArray(int field_number, WireType type,
1390                                                 uint8_t* target) {
1391   return io::CodedOutputStream::WriteTagToArray(MakeTag(field_number, type),
1392                                                 target);
1393 }
1394 
1395 inline uint8_t* WireFormatLite::WriteInt32NoTagToArray(int32_t value,
1396                                                        uint8_t* target) {
1397   return io::CodedOutputStream::WriteVarint32SignExtendedToArray(value, target);
1398 }
1399 inline uint8_t* WireFormatLite::WriteInt64NoTagToArray(int64_t value,
1400                                                        uint8_t* target) {
1401   return io::CodedOutputStream::WriteVarint64ToArray(
1402       static_cast<uint64_t>(value), target);
1403 }
1404 inline uint8_t* WireFormatLite::WriteUInt32NoTagToArray(uint32_t value,
1405                                                         uint8_t* target) {
1406   return io::CodedOutputStream::WriteVarint32ToArray(value, target);
1407 }
1408 inline uint8_t* WireFormatLite::WriteUInt64NoTagToArray(uint64_t value,
1409                                                         uint8_t* target) {
1410   return io::CodedOutputStream::WriteVarint64ToArray(value, target);
1411 }
1412 inline uint8_t* WireFormatLite::WriteSInt32NoTagToArray(int32_t value,
1413                                                         uint8_t* target) {
1414   return io::CodedOutputStream::WriteVarint32ToArray(ZigZagEncode32(value),
1415                                                      target);
1416 }
1417 inline uint8_t* WireFormatLite::WriteSInt64NoTagToArray(int64_t value,
1418                                                         uint8_t* target) {
1419   return io::CodedOutputStream::WriteVarint64ToArray(ZigZagEncode64(value),
1420                                                      target);
1421 }
1422 inline uint8_t* WireFormatLite::WriteFixed32NoTagToArray(uint32_t value,
1423                                                          uint8_t* target) {
1424   return io::CodedOutputStream::WriteLittleEndian32ToArray(value, target);
1425 }
1426 inline uint8_t* WireFormatLite::WriteFixed64NoTagToArray(uint64_t value,
1427                                                          uint8_t* target) {
1428   return io::CodedOutputStream::WriteLittleEndian64ToArray(value, target);
1429 }
1430 inline uint8_t* WireFormatLite::WriteSFixed32NoTagToArray(int32_t value,
1431                                                           uint8_t* target) {
1432   return io::CodedOutputStream::WriteLittleEndian32ToArray(
1433       static_cast<uint32_t>(value), target);
1434 }
1435 inline uint8_t* WireFormatLite::WriteSFixed64NoTagToArray(int64_t value,
1436                                                           uint8_t* target) {
1437   return io::CodedOutputStream::WriteLittleEndian64ToArray(
1438       static_cast<uint64_t>(value), target);
1439 }
1440 inline uint8_t* WireFormatLite::WriteFloatNoTagToArray(float value,
1441                                                        uint8_t* target) {
1442   return io::CodedOutputStream::WriteLittleEndian32ToArray(EncodeFloat(value),
1443                                                            target);
1444 }
1445 inline uint8_t* WireFormatLite::WriteDoubleNoTagToArray(double value,
1446                                                         uint8_t* target) {
1447   return io::CodedOutputStream::WriteLittleEndian64ToArray(EncodeDouble(value),
1448                                                            target);
1449 }
1450 inline uint8_t* WireFormatLite::WriteBoolNoTagToArray(bool value,
1451                                                       uint8_t* target) {
1452   return io::CodedOutputStream::WriteVarint32ToArray(value ? 1 : 0, target);
1453 }
1454 inline uint8_t* WireFormatLite::WriteEnumNoTagToArray(int value,
1455                                                       uint8_t* target) {
1456   return io::CodedOutputStream::WriteVarint32SignExtendedToArray(value, target);
1457 }
1458 
1459 template <typename T>
1460 inline uint8_t* WireFormatLite::WritePrimitiveNoTagToArray(
1461     const RepeatedField<T>& value, uint8_t* (*Writer)(T, uint8_t*),
1462     uint8_t* target) {
1463   const int n = value.size();
1464   ABSL_DCHECK_GT(n, 0);
1465 
1466   const T* ii = value.data();
1467   int i = 0;
1468   do {
1469     target = Writer(ii[i], target);
1470   } while (++i < n);
1471 
1472   return target;
1473 }
1474 
1475 template <typename T>
1476 inline uint8_t* WireFormatLite::WriteFixedNoTagToArray(
1477     const RepeatedField<T>& value, uint8_t* (*Writer)(T, uint8_t*),
1478     uint8_t* target) {
1479 #if defined(ABSL_IS_LITTLE_ENDIAN)
1480   (void)Writer;
1481 
1482   const int n = value.size();
1483   ABSL_DCHECK_GT(n, 0);
1484 
1485   const T* ii = value.data();
1486   const int bytes = n * static_cast<int>(sizeof(ii[0]));
1487   memcpy(target, ii, static_cast<size_t>(bytes));
1488   return target + bytes;
1489 #else
1490   return WritePrimitiveNoTagToArray(value, Writer, target);
1491 #endif
1492 }
1493 
1494 inline uint8_t* WireFormatLite::WriteInt32NoTagToArray(
1495     const RepeatedField<int32_t>& value, uint8_t* target) {
1496   return WritePrimitiveNoTagToArray(value, WriteInt32NoTagToArray, target);
1497 }
1498 inline uint8_t* WireFormatLite::WriteInt64NoTagToArray(
1499     const RepeatedField<int64_t>& value, uint8_t* target) {
1500   return WritePrimitiveNoTagToArray(value, WriteInt64NoTagToArray, target);
1501 }
1502 inline uint8_t* WireFormatLite::WriteUInt32NoTagToArray(
1503     const RepeatedField<uint32_t>& value, uint8_t* target) {
1504   return WritePrimitiveNoTagToArray(value, WriteUInt32NoTagToArray, target);
1505 }
1506 inline uint8_t* WireFormatLite::WriteUInt64NoTagToArray(
1507     const RepeatedField<uint64_t>& value, uint8_t* target) {
1508   return WritePrimitiveNoTagToArray(value, WriteUInt64NoTagToArray, target);
1509 }
1510 inline uint8_t* WireFormatLite::WriteSInt32NoTagToArray(
1511     const RepeatedField<int32_t>& value, uint8_t* target) {
1512   return WritePrimitiveNoTagToArray(value, WriteSInt32NoTagToArray, target);
1513 }
1514 inline uint8_t* WireFormatLite::WriteSInt64NoTagToArray(
1515     const RepeatedField<int64_t>& value, uint8_t* target) {
1516   return WritePrimitiveNoTagToArray(value, WriteSInt64NoTagToArray, target);
1517 }
1518 inline uint8_t* WireFormatLite::WriteFixed32NoTagToArray(
1519     const RepeatedField<uint32_t>& value, uint8_t* target) {
1520   return WriteFixedNoTagToArray(value, WriteFixed32NoTagToArray, target);
1521 }
1522 inline uint8_t* WireFormatLite::WriteFixed64NoTagToArray(
1523     const RepeatedField<uint64_t>& value, uint8_t* target) {
1524   return WriteFixedNoTagToArray(value, WriteFixed64NoTagToArray, target);
1525 }
1526 inline uint8_t* WireFormatLite::WriteSFixed32NoTagToArray(
1527     const RepeatedField<int32_t>& value, uint8_t* target) {
1528   return WriteFixedNoTagToArray(value, WriteSFixed32NoTagToArray, target);
1529 }
1530 inline uint8_t* WireFormatLite::WriteSFixed64NoTagToArray(
1531     const RepeatedField<int64_t>& value, uint8_t* target) {
1532   return WriteFixedNoTagToArray(value, WriteSFixed64NoTagToArray, target);
1533 }
1534 inline uint8_t* WireFormatLite::WriteFloatNoTagToArray(
1535     const RepeatedField<float>& value, uint8_t* target) {
1536   return WriteFixedNoTagToArray(value, WriteFloatNoTagToArray, target);
1537 }
1538 inline uint8_t* WireFormatLite::WriteDoubleNoTagToArray(
1539     const RepeatedField<double>& value, uint8_t* target) {
1540   return WriteFixedNoTagToArray(value, WriteDoubleNoTagToArray, target);
1541 }
1542 inline uint8_t* WireFormatLite::WriteBoolNoTagToArray(
1543     const RepeatedField<bool>& value, uint8_t* target) {
1544   return WritePrimitiveNoTagToArray(value, WriteBoolNoTagToArray, target);
1545 }
1546 inline uint8_t* WireFormatLite::WriteEnumNoTagToArray(
1547     const RepeatedField<int>& value, uint8_t* target) {
1548   return WritePrimitiveNoTagToArray(value, WriteEnumNoTagToArray, target);
1549 }
1550 
1551 inline uint8_t* WireFormatLite::WriteInt32ToArray(int field_number,
1552                                                   int32_t value,
1553                                                   uint8_t* target) {
1554   target = WriteTagToArray(field_number, WIRETYPE_VARINT, target);
1555   return WriteInt32NoTagToArray(value, target);
1556 }
1557 inline uint8_t* WireFormatLite::WriteInt64ToArray(int field_number,
1558                                                   int64_t value,
1559                                                   uint8_t* target) {
1560   target = WriteTagToArray(field_number, WIRETYPE_VARINT, target);
1561   return WriteInt64NoTagToArray(value, target);
1562 }
1563 inline uint8_t* WireFormatLite::WriteUInt32ToArray(int field_number,
1564                                                    uint32_t value,
1565                                                    uint8_t* target) {
1566   target = WriteTagToArray(field_number, WIRETYPE_VARINT, target);
1567   return WriteUInt32NoTagToArray(value, target);
1568 }
1569 inline uint8_t* WireFormatLite::WriteUInt64ToArray(int field_number,
1570                                                    uint64_t value,
1571                                                    uint8_t* target) {
1572   target = WriteTagToArray(field_number, WIRETYPE_VARINT, target);
1573   return WriteUInt64NoTagToArray(value, target);
1574 }
1575 inline uint8_t* WireFormatLite::WriteSInt32ToArray(int field_number,
1576                                                    int32_t value,
1577                                                    uint8_t* target) {
1578   target = WriteTagToArray(field_number, WIRETYPE_VARINT, target);
1579   return WriteSInt32NoTagToArray(value, target);
1580 }
1581 inline uint8_t* WireFormatLite::WriteSInt64ToArray(int field_number,
1582                                                    int64_t value,
1583                                                    uint8_t* target) {
1584   target = WriteTagToArray(field_number, WIRETYPE_VARINT, target);
1585   return WriteSInt64NoTagToArray(value, target);
1586 }
1587 inline uint8_t* WireFormatLite::WriteFixed32ToArray(int field_number,
1588                                                     uint32_t value,
1589                                                     uint8_t* target) {
1590   target = WriteTagToArray(field_number, WIRETYPE_FIXED32, target);
1591   return WriteFixed32NoTagToArray(value, target);
1592 }
1593 inline uint8_t* WireFormatLite::WriteFixed64ToArray(int field_number,
1594                                                     uint64_t value,
1595                                                     uint8_t* target) {
1596   target = WriteTagToArray(field_number, WIRETYPE_FIXED64, target);
1597   return WriteFixed64NoTagToArray(value, target);
1598 }
1599 inline uint8_t* WireFormatLite::WriteSFixed32ToArray(int field_number,
1600                                                      int32_t value,
1601                                                      uint8_t* target) {
1602   target = WriteTagToArray(field_number, WIRETYPE_FIXED32, target);
1603   return WriteSFixed32NoTagToArray(value, target);
1604 }
1605 inline uint8_t* WireFormatLite::WriteSFixed64ToArray(int field_number,
1606                                                      int64_t value,
1607                                                      uint8_t* target) {
1608   target = WriteTagToArray(field_number, WIRETYPE_FIXED64, target);
1609   return WriteSFixed64NoTagToArray(value, target);
1610 }
1611 inline uint8_t* WireFormatLite::WriteFloatToArray(int field_number, float value,
1612                                                   uint8_t* target) {
1613   target = WriteTagToArray(field_number, WIRETYPE_FIXED32, target);
1614   return WriteFloatNoTagToArray(value, target);
1615 }
1616 inline uint8_t* WireFormatLite::WriteDoubleToArray(int field_number,
1617                                                    double value,
1618                                                    uint8_t* target) {
1619   target = WriteTagToArray(field_number, WIRETYPE_FIXED64, target);
1620   return WriteDoubleNoTagToArray(value, target);
1621 }
1622 inline uint8_t* WireFormatLite::WriteBoolToArray(int field_number, bool value,
1623                                                  uint8_t* target) {
1624   target = WriteTagToArray(field_number, WIRETYPE_VARINT, target);
1625   return WriteBoolNoTagToArray(value, target);
1626 }
1627 inline uint8_t* WireFormatLite::WriteEnumToArray(int field_number, int value,
1628                                                  uint8_t* target) {
1629   target = WriteTagToArray(field_number, WIRETYPE_VARINT, target);
1630   return WriteEnumNoTagToArray(value, target);
1631 }
1632 
1633 template <typename T>
1634 inline uint8_t* WireFormatLite::WritePrimitiveToArray(
1635     int field_number, const RepeatedField<T>& value,
1636     uint8_t* (*Writer)(int, T, uint8_t*), uint8_t* target) {
1637   const int n = value.size();
1638   if (n == 0) {
1639     return target;
1640   }
1641 
1642   const T* ii = value.data();
1643   int i = 0;
1644   do {
1645     target = Writer(field_number, ii[i], target);
1646   } while (++i < n);
1647 
1648   return target;
1649 }
1650 
1651 inline uint8_t* WireFormatLite::WriteInt32ToArray(
1652     int field_number, const RepeatedField<int32_t>& value, uint8_t* target) {
1653   return WritePrimitiveToArray(field_number, value, WriteInt32ToArray, target);
1654 }
1655 inline uint8_t* WireFormatLite::WriteInt64ToArray(
1656     int field_number, const RepeatedField<int64_t>& value, uint8_t* target) {
1657   return WritePrimitiveToArray(field_number, value, WriteInt64ToArray, target);
1658 }
1659 inline uint8_t* WireFormatLite::WriteUInt32ToArray(
1660     int field_number, const RepeatedField<uint32_t>& value, uint8_t* target) {
1661   return WritePrimitiveToArray(field_number, value, WriteUInt32ToArray, target);
1662 }
1663 inline uint8_t* WireFormatLite::WriteUInt64ToArray(
1664     int field_number, const RepeatedField<uint64_t>& value, uint8_t* target) {
1665   return WritePrimitiveToArray(field_number, value, WriteUInt64ToArray, target);
1666 }
1667 inline uint8_t* WireFormatLite::WriteSInt32ToArray(
1668     int field_number, const RepeatedField<int32_t>& value, uint8_t* target) {
1669   return WritePrimitiveToArray(field_number, value, WriteSInt32ToArray, target);
1670 }
1671 inline uint8_t* WireFormatLite::WriteSInt64ToArray(
1672     int field_number, const RepeatedField<int64_t>& value, uint8_t* target) {
1673   return WritePrimitiveToArray(field_number, value, WriteSInt64ToArray, target);
1674 }
1675 inline uint8_t* WireFormatLite::WriteFixed32ToArray(
1676     int field_number, const RepeatedField<uint32_t>& value, uint8_t* target) {
1677   return WritePrimitiveToArray(field_number, value, WriteFixed32ToArray,
1678                                target);
1679 }
1680 inline uint8_t* WireFormatLite::WriteFixed64ToArray(
1681     int field_number, const RepeatedField<uint64_t>& value, uint8_t* target) {
1682   return WritePrimitiveToArray(field_number, value, WriteFixed64ToArray,
1683                                target);
1684 }
1685 inline uint8_t* WireFormatLite::WriteSFixed32ToArray(
1686     int field_number, const RepeatedField<int32_t>& value, uint8_t* target) {
1687   return WritePrimitiveToArray(field_number, value, WriteSFixed32ToArray,
1688                                target);
1689 }
1690 inline uint8_t* WireFormatLite::WriteSFixed64ToArray(
1691     int field_number, const RepeatedField<int64_t>& value, uint8_t* target) {
1692   return WritePrimitiveToArray(field_number, value, WriteSFixed64ToArray,
1693                                target);
1694 }
1695 inline uint8_t* WireFormatLite::WriteFloatToArray(
1696     int field_number, const RepeatedField<float>& value, uint8_t* target) {
1697   return WritePrimitiveToArray(field_number, value, WriteFloatToArray, target);
1698 }
1699 inline uint8_t* WireFormatLite::WriteDoubleToArray(
1700     int field_number, const RepeatedField<double>& value, uint8_t* target) {
1701   return WritePrimitiveToArray(field_number, value, WriteDoubleToArray, target);
1702 }
1703 inline uint8_t* WireFormatLite::WriteBoolToArray(
1704     int field_number, const RepeatedField<bool>& value, uint8_t* target) {
1705   return WritePrimitiveToArray(field_number, value, WriteBoolToArray, target);
1706 }
1707 inline uint8_t* WireFormatLite::WriteEnumToArray(
1708     int field_number, const RepeatedField<int>& value, uint8_t* target) {
1709   return WritePrimitiveToArray(field_number, value, WriteEnumToArray, target);
1710 }
1711 inline uint8_t* WireFormatLite::WriteStringToArray(int field_number,
1712                                                    const std::string& value,
1713                                                    uint8_t* target) {
1714   // String is for UTF-8 text only
1715   // WARNING:  In wire_format.cc, both strings and bytes are handled by
1716   //   WriteString() to avoid code duplication.  If the implementations become
1717   //   different, you will need to update that usage.
1718   target = WriteTagToArray(field_number, WIRETYPE_LENGTH_DELIMITED, target);
1719   return io::CodedOutputStream::WriteStringWithSizeToArray(value, target);
1720 }
1721 inline uint8_t* WireFormatLite::WriteBytesToArray(int field_number,
1722                                                   const std::string& value,
1723                                                   uint8_t* target) {
1724   target = WriteTagToArray(field_number, WIRETYPE_LENGTH_DELIMITED, target);
1725   return io::CodedOutputStream::WriteStringWithSizeToArray(value, target);
1726 }
1727 
1728 
1729 // See comment on ReadGroupNoVirtual to understand the need for this template
1730 // parameter name.
1731 template <typename MessageType_WorkAroundCppLookupDefect>
1732 inline uint8_t* WireFormatLite::InternalWriteGroupNoVirtualToArray(
1733     int field_number, const MessageType_WorkAroundCppLookupDefect& value,
1734     uint8_t* target) {
1735   target = WriteTagToArray(field_number, WIRETYPE_START_GROUP, target);
1736   target = value.MessageType_WorkAroundCppLookupDefect::
1737                SerializeWithCachedSizesToArray(target);
1738   return WriteTagToArray(field_number, WIRETYPE_END_GROUP, target);
1739 }
1740 template <typename MessageType_WorkAroundCppLookupDefect>
1741 inline uint8_t* WireFormatLite::InternalWriteMessageNoVirtualToArray(
1742     int field_number, const MessageType_WorkAroundCppLookupDefect& value,
1743     uint8_t* target) {
1744   target = WriteTagToArray(field_number, WIRETYPE_LENGTH_DELIMITED, target);
1745   target = io::CodedOutputStream::WriteVarint32ToArray(
1746       static_cast<uint32_t>(
1747           value.MessageType_WorkAroundCppLookupDefect::GetCachedSize()),
1748       target);
1749   return value
1750       .MessageType_WorkAroundCppLookupDefect::SerializeWithCachedSizesToArray(
1751           target);
1752 }
1753 
1754 // ===================================================================
1755 
1756 inline size_t WireFormatLite::Int32Size(int32_t value) {
1757   return io::CodedOutputStream::VarintSize32SignExtended(value);
1758 }
1759 inline size_t WireFormatLite::Int64Size(int64_t value) {
1760   return io::CodedOutputStream::VarintSize64(static_cast<uint64_t>(value));
1761 }
1762 inline size_t WireFormatLite::UInt32Size(uint32_t value) {
1763   return io::CodedOutputStream::VarintSize32(value);
1764 }
1765 inline size_t WireFormatLite::UInt64Size(uint64_t value) {
1766   return io::CodedOutputStream::VarintSize64(value);
1767 }
1768 inline size_t WireFormatLite::SInt32Size(int32_t value) {
1769   return io::CodedOutputStream::VarintSize32(ZigZagEncode32(value));
1770 }
1771 inline size_t WireFormatLite::SInt64Size(int64_t value) {
1772   return io::CodedOutputStream::VarintSize64(ZigZagEncode64(value));
1773 }
1774 inline size_t WireFormatLite::EnumSize(int value) {
1775   return io::CodedOutputStream::VarintSize32SignExtended(value);
1776 }
1777 inline size_t WireFormatLite::Int32SizePlusOne(int32_t value) {
1778   return io::CodedOutputStream::VarintSize32SignExtendedPlusOne(value);
1779 }
1780 inline size_t WireFormatLite::Int64SizePlusOne(int64_t value) {
1781   return io::CodedOutputStream::VarintSize64PlusOne(
1782       static_cast<uint64_t>(value));
1783 }
1784 inline size_t WireFormatLite::UInt32SizePlusOne(uint32_t value) {
1785   return io::CodedOutputStream::VarintSize32PlusOne(value);
1786 }
1787 inline size_t WireFormatLite::UInt64SizePlusOne(uint64_t value) {
1788   return io::CodedOutputStream::VarintSize64PlusOne(value);
1789 }
1790 inline size_t WireFormatLite::SInt32SizePlusOne(int32_t value) {
1791   return io::CodedOutputStream::VarintSize32PlusOne(ZigZagEncode32(value));
1792 }
1793 inline size_t WireFormatLite::SInt64SizePlusOne(int64_t value) {
1794   return io::CodedOutputStream::VarintSize64PlusOne(ZigZagEncode64(value));
1795 }
1796 inline size_t WireFormatLite::EnumSizePlusOne(int value) {
1797   return io::CodedOutputStream::VarintSize32SignExtendedPlusOne(value);
1798 }
1799 
1800 inline size_t WireFormatLite::StringSize(const std::string& value) {
1801   return LengthDelimitedSize(value.size());
1802 }
1803 inline size_t WireFormatLite::BytesSize(const std::string& value) {
1804   return LengthDelimitedSize(value.size());
1805 }
1806 
1807 inline size_t WireFormatLite::BytesSize(const absl::Cord& value) {
1808   return LengthDelimitedSize(value.size());
1809 }
1810 
1811 inline size_t WireFormatLite::StringSize(const absl::Cord& value) {
1812   return LengthDelimitedSize(value.size());
1813 }
1814 
1815 inline size_t WireFormatLite::StringSize(const absl::string_view value) {
1816   // WARNING:  In wire_format.cc, both strings and bytes are handled by
1817   //   StringSize() to avoid code duplication.  If the implementations become
1818   //   different, you will need to update that usage.
1819   return LengthDelimitedSize(value.size());
1820 }
1821 inline size_t WireFormatLite::BytesSize(const absl::string_view value) {
1822   return LengthDelimitedSize(value.size());
1823 }
1824 
1825 template <typename MessageType>
1826 inline size_t WireFormatLite::GroupSize(const MessageType& value) {
1827   return value.ByteSizeLong();
1828 }
1829 template <typename MessageType>
1830 inline size_t WireFormatLite::MessageSize(const MessageType& value) {
1831   return LengthDelimitedSize(value.ByteSizeLong());
1832 }
1833 
1834 // See comment on ReadGroupNoVirtual to understand the need for this template
1835 // parameter name.
1836 template <typename MessageType_WorkAroundCppLookupDefect>
1837 inline size_t WireFormatLite::GroupSizeNoVirtual(
1838     const MessageType_WorkAroundCppLookupDefect& value) {
1839   return value.MessageType_WorkAroundCppLookupDefect::ByteSizeLong();
1840 }
1841 template <typename MessageType_WorkAroundCppLookupDefect>
1842 inline size_t WireFormatLite::MessageSizeNoVirtual(
1843     const MessageType_WorkAroundCppLookupDefect& value) {
1844   return LengthDelimitedSize(
1845       value.MessageType_WorkAroundCppLookupDefect::ByteSizeLong());
1846 }
1847 
1848 inline size_t WireFormatLite::LengthDelimitedSize(size_t length) {
1849   // The static_cast here prevents an error in certain compiler configurations
1850   // but is not technically correct--if length is too large to fit in a uint32_t
1851   // then it will be silently truncated. We will need to fix this if we ever
1852   // decide to start supporting serialized messages greater than 2 GiB in size.
1853   return length +
1854          io::CodedOutputStream::VarintSize32(static_cast<uint32_t>(length));
1855 }
1856 
1857 template <typename MS>
1858 bool ParseMessageSetItemImpl(io::CodedInputStream* input, MS ms) {
1859   // This method parses a group which should contain two fields:
1860   //   required int32 type_id = 2;
1861   //   required data message = 3;
1862 
1863   uint32_t last_type_id = 0;
1864 
1865   // If we see message data before the type_id, we'll append it to this so
1866   // we can parse it later.
1867   std::string message_data;
1868 
1869   enum class State { kNoTag, kHasType, kHasPayload, kDone };
1870   State state = State::kNoTag;
1871 
1872   while (true) {
1873     const uint32_t tag = input->ReadTagNoLastTag();
1874     if (tag == 0) return false;
1875 
1876     switch (tag) {
1877       case WireFormatLite::kMessageSetTypeIdTag: {
1878         uint32_t type_id;
1879         // We should fail parsing if type id is 0.
1880         if (!input->ReadVarint32(&type_id) || type_id == 0) return false;
1881         if (state == State::kNoTag) {
1882           last_type_id = type_id;
1883           state = State::kHasType;
1884         } else if (state == State::kHasPayload) {
1885           // We saw some message data before the type_id.  Have to parse it
1886           // now.
1887           io::CodedInputStream sub_input(
1888               reinterpret_cast<const uint8_t*>(message_data.data()),
1889               static_cast<int>(message_data.size()));
1890           sub_input.SetRecursionLimit(input->RecursionBudget());
1891           if (!ms.ParseField(type_id, &sub_input)) {
1892             return false;
1893           }
1894           message_data.clear();
1895           state = State::kDone;
1896         }
1897 
1898         break;
1899       }
1900 
1901       case WireFormatLite::kMessageSetMessageTag: {
1902         if (state == State::kHasType) {
1903           // Already saw type_id, so we can parse this directly.
1904           if (!ms.ParseField(last_type_id, input)) {
1905             return false;
1906           }
1907           state = State::kDone;
1908         } else if (state == State::kNoTag) {
1909           // We haven't seen a type_id yet.  Append this data to message_data.
1910           uint32_t length;
1911           if (!input->ReadVarint32(&length)) return false;
1912           if (static_cast<int32_t>(length) < 0) return false;
1913           uint32_t size = static_cast<uint32_t>(
1914               length + io::CodedOutputStream::VarintSize32(length));
1915           message_data.resize(size);
1916           auto ptr = reinterpret_cast<uint8_t*>(&message_data[0]);
1917           ptr = io::CodedOutputStream::WriteVarint32ToArray(length, ptr);
1918           if (!input->ReadRaw(ptr, length)) return false;
1919           state = State::kHasPayload;
1920         } else {
1921           if (!ms.SkipField(tag, input)) return false;
1922         }
1923 
1924         break;
1925       }
1926 
1927       case WireFormatLite::kMessageSetItemEndTag: {
1928         return true;
1929       }
1930 
1931       default: {
1932         if (!ms.SkipField(tag, input)) return false;
1933       }
1934     }
1935   }
1936 }
1937 
1938 }  // namespace internal
1939 }  // namespace protobuf
1940 }  // namespace google
1941 
1942 #include "google/protobuf/port_undef.inc"
1943 
1944 #endif  // GOOGLE_PROTOBUF_WIRE_FORMAT_LITE_H__