protobuf/src/google/protobuf/generated_message_table_driven.cc
Go to the documentation of this file.
1 // Protocol Buffers - Google's data interchange format
2 // Copyright 2008 Google Inc. All rights reserved.
3 // https://developers.google.com/protocol-buffers/
4 //
5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are
7 // met:
8 //
9 // * Redistributions of source code must retain the above copyright
10 // notice, this list of conditions and the following disclaimer.
11 // * Redistributions in binary form must reproduce the above
12 // copyright notice, this list of conditions and the following disclaimer
13 // in the documentation and/or other materials provided with the
14 // distribution.
15 // * Neither the name of Google Inc. nor the names of its
16 // contributors may be used to endorse or promote products derived from
17 // this software without specific prior written permission.
18 //
19 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 
31 #include <google/protobuf/generated_message_table_driven.h>
32 
33 #include <type_traits>
34 
35 #include <google/protobuf/stubs/casts.h>
36 #include <google/protobuf/generated_message_table_driven_lite.h>
37 #include <google/protobuf/io/zero_copy_stream_impl_lite.h>
38 #include <google/protobuf/repeated_field.h>
39 #include <google/protobuf/wire_format.h>
40 #include <google/protobuf/wire_format_lite.h>
41 
42 namespace google {
43 namespace protobuf {
44 namespace internal {
45 
46 namespace {
47 
48 UnknownFieldSet* MutableUnknownFields(MessageLite* msg, int64_t arena_offset) {
49  return Raw<InternalMetadata>(msg, arena_offset)
50  ->mutable_unknown_fields<UnknownFieldSet>();
51 }
52 
53 struct UnknownFieldHandler {
54  // TODO(mvels): consider renaming UnknownFieldHandler to (TableDrivenTraits?),
55  // and conflating InternalMetaData into it, simplifying the template.
56  static constexpr bool IsLite() { return false; }
57 
58  static bool Skip(MessageLite* msg, const ParseTable& table,
60  GOOGLE_DCHECK(table.unknown_field_set);
61 
63  MutableUnknownFields(msg, table.arena_offset));
64  }
65 
66  static void Varint(MessageLite* msg, const ParseTable& table, int tag,
67  int value) {
68  GOOGLE_DCHECK(table.unknown_field_set);
69 
70  MutableUnknownFields(msg, table.arena_offset)
72  }
73 
74  static bool ParseExtension(MessageLite* msg, const ParseTable& table,
76  ExtensionSet* extensions = GetExtensionSet(msg, table.extension_offset);
77  if (extensions == nullptr) {
78  return false;
79  }
80 
81  const Message* prototype =
82  down_cast<const Message*>(table.default_instance());
83 
84  GOOGLE_DCHECK(prototype != nullptr);
85  GOOGLE_DCHECK(table.unknown_field_set);
86  UnknownFieldSet* unknown_fields =
87  MutableUnknownFields(msg, table.arena_offset);
88 
89  return extensions->ParseField(tag, input, prototype, unknown_fields);
90  }
91 };
92 
93 } // namespace
94 
95 bool MergePartialFromCodedStream(MessageLite* msg, const ParseTable& table,
97  return MergePartialFromCodedStreamImpl<UnknownFieldHandler>(msg, table,
98  input);
99 }
100 
101 } // namespace internal
102 } // namespace protobuf
103 } // namespace google
google::protobuf::IsLite
static bool IsLite(const FileDescriptor *file)
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor.cc:5777
google::protobuf::value
const Descriptor::ReservedRange value
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor.h:1954
GOOGLE_DCHECK
#define GOOGLE_DCHECK
Definition: bloaty/third_party/protobuf/src/google/protobuf/stubs/logging.h:194
google::protobuf
Definition: bloaty/third_party/protobuf/benchmarks/util/data_proto2_to_proto3_util.h:12
google::protobuf.internal::GetExtensionSet
ExtensionSet * GetExtensionSet(MessageLite *msg, int64 extension_offset)
Definition: bloaty/third_party/protobuf/src/google/protobuf/generated_message_table_driven_lite.h:94
google::protobuf::python::cmessage::UnknownFieldSet
static PyObject * UnknownFieldSet(CMessage *self)
Definition: bloaty/third_party/protobuf/python/google/protobuf/pyext/message.cc:2512
google::protobuf.internal::MergePartialFromCodedStream
bool MergePartialFromCodedStream(MessageLite *msg, const ParseTable &table, io::CodedInputStream *input)
Definition: bloaty/third_party/protobuf/src/google/protobuf/generated_message_table_driven.cc:96
int64_t
signed __int64 int64_t
Definition: stdint-msvc2008.h:89
tag
static void * tag(intptr_t t)
Definition: bad_client.cc:318
grpc::protobuf::MessageLite
GRPC_CUSTOM_MESSAGELITE MessageLite
Definition: include/grpcpp/impl/codegen/config_protobuf.h:79
grpc::protobuf::io::CodedInputStream
GRPC_CUSTOM_CODEDINPUTSTREAM CodedInputStream
Definition: include/grpcpp/impl/codegen/config_protobuf.h:102
conf.extensions
list extensions
Definition: doc/python/sphinx/conf.py:54
msg
std::string msg
Definition: client_interceptors_end2end_test.cc:372
google::protobuf.internal::WireFormatLite::GetTagFieldNumber
static int GetTagFieldNumber(uint32 tag)
Definition: bloaty/third_party/protobuf/src/google/protobuf/wire_format_lite.h:792
absl::Skip
static PerThreadSynch * Skip(PerThreadSynch *x)
Definition: abseil-cpp/absl/synchronization/mutex.cc:837
Varint
TypeAndValue Varint(uint64_t val)
Definition: upb/upb/util/compare_test.cc:71
input
std::string input
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/tokenizer_unittest.cc:197
internal
Definition: benchmark/test/output_test_helper.cc:20
table
uint8_t table[256]
Definition: hpack_parser.cc:456
google
Definition: bloaty/third_party/protobuf/benchmarks/util/data_proto2_to_proto3_util.h:11
Message
Definition: protobuf/php/ext/google/protobuf/message.c:53
google::protobuf.internal::WireFormat::SkipField
static bool SkipField(io::CodedInputStream *input, uint32 tag, UnknownFieldSet *unknown_fields)
Definition: bloaty/third_party/protobuf/src/google/protobuf/wire_format.cc:85


grpc
Author(s):
autogenerated on Fri May 16 2025 02:58:26