Go to the documentation of this file.
36 #include <google/protobuf/message_lite.h>
42 #include <google/protobuf/stubs/logging.h>
43 #include <google/protobuf/stubs/common.h>
44 #include <google/protobuf/stubs/stringprintf.h>
45 #include <google/protobuf/parse_context.h>
46 #include <google/protobuf/io/coded_stream.h>
47 #include <google/protobuf/io/zero_copy_stream.h>
48 #include <google/protobuf/io/zero_copy_stream_impl.h>
49 #include <google/protobuf/io/zero_copy_stream_impl_lite.h>
50 #include <google/protobuf/arena.h>
51 #include <google/protobuf/generated_message_table_driven.h>
52 #include <google/protobuf/generated_message_util.h>
53 #include <google/protobuf/repeated_field.h>
54 #include <google/protobuf/stubs/strutil.h>
55 #include <google/protobuf/stubs/stl_util.h>
56 #include <google/protobuf/stubs/mutex.h>
58 #include <google/protobuf/port_def.inc>
64 return "(cannot determine missing fields for lite message)";
69 return StrCat(
"MessageLite at 0x", strings::Hex(address));
80 void ByteSizeConsistencyError(
size_t byte_size_before_serialization,
81 size_t byte_size_after_serialization,
82 size_t bytes_produced_by_serialization,
84 GOOGLE_CHECK_EQ(byte_size_before_serialization, byte_size_after_serialization)
86 <<
" was modified concurrently during serialization.";
87 GOOGLE_CHECK_EQ(bytes_produced_by_serialization, byte_size_before_serialization)
88 <<
"Byte size calculation and serialization were inconsistent. This "
89 "may indicate a bug in protocol buffers or it may be caused by "
90 "concurrent modification of "
91 <<
message.GetTypeName() <<
".";
92 GOOGLE_LOG(
FATAL) <<
"This shouldn't be called if all the sizes are equal.";
109 result +=
" message of type \"";
111 result +=
"\" because it is missing required fields: ";
116 inline StringPiece as_string_view(
const void*
data,
int size) {
117 return StringPiece(
static_cast<const char*
>(
data),
size);
121 inline bool CheckFieldPresence(
const internal::ParseContext&
ctx,
128 return msg.IsInitializedWithErrors();
139 template <
bool aliasing>
147 if (PROTOBUF_PREDICT_TRUE(
ptr &&
ctx.EndedAtLimit())) {
148 return CheckFieldPresence(
ctx, *
msg, parse_flags);
153 template <
bool aliasing>
161 if (PROTOBUF_PREDICT_TRUE(
ptr &&
ctx.EndedAtEndOfStream())) {
162 return CheckFieldPresence(
ctx, *
msg, parse_flags);
167 template <
bool aliasing>
174 if (PROTOBUF_PREDICT_FALSE(!
ptr))
return false;
176 if (PROTOBUF_PREDICT_TRUE(
ctx.EndedAtLimit())) {
177 return CheckFieldPresence(
ctx, *
msg, parse_flags);
203 if (!cis_->GetDirectBufferPointer(
data,
size))
return false;
226 ctx.TrackCorrectEnding();
227 ctx.data().pool =
input->GetExtensionPool();
228 ctx.data().factory =
input->GetExtensionFactory();
230 if (PROTOBUF_PREDICT_FALSE(!
ptr))
return false;
232 if (!
ctx.EndedAtEndOfStream()) {
234 if (
ctx.IsExceedingLimit(
ptr))
return false;
237 input->SetConsumed();
239 return CheckFieldPresence(
ctx, *
this, parse_flags);
261 return ParseFrom<kParse>(
input);
266 return ParseFrom<kParsePartial>(
input);
270 io::FileInputStream
input(file_descriptor);
275 io::FileInputStream
input(file_descriptor);
280 io::IstreamInputStream zero_copy_input(
input);
285 io::IstreamInputStream zero_copy_input(
input);
291 return ParseFrom<kMergePartial>(internal::BoundedZCIS{
input,
size});
296 return ParseFrom<kMerge>(internal::BoundedZCIS{
input,
size});
301 return ParseFrom<kParse>(internal::BoundedZCIS{
input,
size});
306 return ParseFrom<kParsePartial>(internal::BoundedZCIS{
input,
size});
310 return ParseFrom<kParse>(
data);
314 return ParseFrom<kParsePartial>(
data);
318 return ParseFrom<kParse>(as_string_view(
data,
size));
322 return ParseFrom<kParsePartial>(as_string_view(
data,
size));
326 return ParseFrom<kMerge>(
data);
334 constexpr
bool debug =
false;
341 io::EpsCopyOutputStream
out(
349 io::EpsCopyOutputStream
out(
372 if (
size > INT_MAX) {
374 <<
" exceeded maximum protobuf size of 2GB: " <<
size;
378 int original_byte_count =
output->ByteCount();
383 int final_byte_count =
output->ByteCount();
385 if (final_byte_count - original_byte_count !=
static_cast<int64_t>(
size)) {
387 final_byte_count - original_byte_count, *
this);
402 if (
size > INT_MAX) {
404 <<
" exceeded maximum protobuf size of 2GB: " <<
size;
409 io::EpsCopyOutputStream
stream(
414 if (
stream.HadError())
return false;
419 io::FileOutputStream
output(file_descriptor);
424 io::FileOutputStream
output(file_descriptor);
430 io::OstreamOutputStream zero_copy_output(
output);
437 io::OstreamOutputStream zero_copy_output(
output);
449 if (byte_size > INT_MAX) {
451 <<
" exceeded maximum protobuf size of 2GB: " << byte_size;
479 if (byte_size > INT_MAX) {
481 <<
" exceeded maximum protobuf size of 2GB: " << byte_size;
484 if (
size <
static_cast<int64_t>(byte_size))
return false;
517 to->CheckTypeAndMergeFrom(
from);
528 void InternalMetadata::DoClear<std::string>() {
529 mutable_unknown_fields<std::string>()->clear();
533 void InternalMetadata::DoMergeFrom<std::string>(
const std::string& other) {
534 mutable_unknown_fields<std::string>()->append(other);
539 mutable_unknown_fields<std::string>()->swap(*other);
550 struct ShutdownData {
561 std::vector<
std::pair<void (*)(
const void*),
const void*>> functions;
566 void (*
func)() =
reinterpret_cast<void (*)()
>(
const_cast<void*
>(
arg));
577 shutdown_data->functions.push_back(std::make_pair(f,
arg));
584 static bool is_shutdown =
false;
595 #include <google/protobuf/port_undef.inc>
static ShutdownData * get()
static void RunZeroArgFunc(const void *arg)
virtual std::string GetTypeName() const =0
absl::string_view get(const Cont &c)
bool ParsePartialFromZeroCopyStream(io::ZeroCopyInputStream *input)
bool MergePartialFromBoundedZeroCopyStream(io::ZeroCopyInputStream *input, int size)
virtual int GetCachedSize() const =0
GRPC_CUSTOM_ZEROCOPYINPUTSTREAM ZeroCopyInputStream
bool ParseFromFileDescriptor(int file_descriptor)
bool ParseFromCodedStream(io::CodedInputStream *input)
static bool IsDefaultSerializationDeterministic()
bool SerializeToArray(void *data, int size) const
#define GOOGLE_CHECK_EQ(A, B)
bool AppendPartialToString(std::string *output) const
bool ParsePartialFromCodedStream(io::CodedInputStream *input)
bool SerializePartialToZeroCopyStream(io::ZeroCopyOutputStream *output) const
bool MergePartialFromCodedStream(io::CodedInputStream *input)
bool ParsePartialFromIstream(std::istream *input)
template bool MergeFromImpl< false >(StringPiece input, MessageLite *msg, MessageLite::ParseFlags parse_flags)
static struct test_ctx ctx
GRPC_CUSTOM_ZEROCOPYOUTPUTSTREAM ZeroCopyOutputStream
void STLStringResizeUninitializedAmortized(std::string *s, size_t new_size)
char * mutable_string_data(std::string *s)
void LogInitializationErrorMessage() const
string StrCat(const AlphaNum &a, const AlphaNum &b)
grpc_core::ScopedArenaPtr arena
bool MergeFromBoundedZeroCopyStream(io::ZeroCopyInputStream *input, int size)
void OnShutdown(void(*func)())
virtual uint8_t * _InternalSerialize(uint8_t *ptr, io::EpsCopyOutputStream *stream) const =0
bool ParsePartialFromString(const std::string &data)
bool SerializeToZeroCopyStream(io::ZeroCopyOutputStream *output) const
void SerializeWithCachedSizes(io::CodedOutputStream *output) const
void OnShutdownRun(void(*f)(const void *), const void *arg)
const std::string & ConstStringParam
bool ParsePartialFromFileDescriptor(int file_descriptor)
bool ParseFromBoundedZeroCopyStream(io::ZeroCopyInputStream *input, int size)
GRPC_CUSTOM_MESSAGELITE MessageLite
virtual std::string InitializationErrorString() const
bool MergeFromCodedStream(io::CodedInputStream *input)
bool SerializePartialToFileDescriptor(int file_descriptor) const
virtual const char * _InternalParse(const char *ptr, internal::ParseContext *ctx)
GRPC_CUSTOM_CODEDINPUTSTREAM CodedInputStream
uint8 * SerializeToArrayImpl(const MessageLite &msg, uint8 *target, int size)
bool SerializeToCodedStream(io::CodedOutputStream *output) const
bool ParseFromZeroCopyStream(io::ZeroCopyInputStream *input)
bool SerializeToString(std::string *output) const
bool ParseFromArray(const void *data, int size)
bool AppendToString(std::string *output) const
GRPC_CUSTOM_CODEDOUTPUTSTREAM CodedOutputStream
_W64 unsigned int uintptr_t
def Merge(text, message, allow_unknown_extension=False, allow_field_number=False, descriptor_pool=None, allow_unknown_field=False)
bool SerializePartialToCodedStream(io::CodedOutputStream *output) const
static const LogLevel ERROR
bool SerializePartialToOstream(std::ostream *output) const
bool SerializePartialToArray(void *data, int size) const
template bool MergeFromImpl< true >(StringPiece input, MessageLite *msg, MessageLite::ParseFlags parse_flags)
bool SerializeToOstream(std::ostream *output) const
bool ParsePartialFromBoundedZeroCopyStream(io::ZeroCopyInputStream *input, int size)
virtual size_t ByteSizeLong() const =0
virtual bool IsInitialized() const =0
bool SerializeToFileDescriptor(int file_descriptor) const
bool SerializePartialToString(std::string *output) const
std::string SerializeAsString() const
std::string SerializePartialAsString() const
bool MergeFromImpl(io::CodedInputStream *input, ParseFlags parse_flags)
bool ParseFromString(const std::string &data)
bool ParseFromIstream(std::istream *input)
uint8 * SerializeWithCachedSizesToArray(uint8 *target) const
bool MergeFromString(const std::string &data)
std::string DebugString() const
bool MergeFromImpl(StringPiece input, MessageLite *msg, MessageLite::ParseFlags parse_flags)
void ShutdownProtobufLibrary()
#define GOOGLE_LOG(LEVEL)
std::pair< std::string, std::string > pair
bool ParsePartialFromArray(const void *data, int size)
virtual MessageLite * New() const =0
grpc
Author(s):
autogenerated on Fri May 16 2025 02:59:26