39#ifndef GOOGLE_PROTOBUF_MESSAGE_LITE_H__
40#define GOOGLE_PROTOBUF_MESSAGE_LITE_H__
46#include <google/protobuf/stubs/common.h>
47#include <google/protobuf/stubs/logging.h>
48#include <google/protobuf/io/coded_stream.h>
50#include <google/protobuf/stubs/once.h>
51#include <google/protobuf/port.h>
52#include <google/protobuf/stubs/strutil.h>
53#include <google/protobuf/explicitly_constructed.h>
54#include <google/protobuf/metadata_lite.h>
55#include <google/protobuf/stubs/hash.h>
58#include <google/protobuf/port_def.inc>
62#error "You cannot SWIG proto headers"
71class FastReflectionMessageMutator;
72class FastReflectionStringSetter;
77class CodedInputStream;
78class CodedOutputStream;
79class ZeroCopyInputStream;
80class ZeroCopyOutputStream;
92class RepeatedPtrFieldBase;
97template <
typename Type>
98class GenericTypeHandler;
116 return static_cast<unsigned int>(size);
123 GOOGLE_DCHECK_LE(size,
static_cast<size_t>(INT_MAX));
124 return static_cast<int>(size);
130PROTOBUF_EXPORT
extern ExplicitlyConstructedArenaString
187 Arena*
GetArena()
const {
return _internal_metadata_.user_arena(); }
233 io::CodedInputStream* input);
237 io::CodedInputStream* input);
241 io::ZeroCopyInputStream* input);
245 io::ZeroCopyInputStream* input);
249 int file_descriptor);
253 int file_descriptor);
260 std::istream* input);
270 io::ZeroCopyInputStream* input,
int size);
274 io::ZeroCopyInputStream* input,
int size);
284 ConstStringParam data);
380 PROTOBUF_DEPRECATED_MSG(
"Please use ByteSizeLong() instead")
387 output->SetCur(_InternalSerialize(output->Cur(), output->EpsCopy()));
416 internal::ParseContext* ) {
423 template <
typename T>
425 return Arena::CreateMaybeMessage<T>(arena);
428 inline explicit MessageLite(Arena* arena,
bool is_message_owned =
false)
429 : _internal_metadata_(arena, is_message_owned) {}
454 kMergeWithAliasing = 4,
455 kParseWithAliasing = 5,
456 kMergePartialWithAliasing = 6,
457 kParsePartialWithAliasing = 7
460 template <ParseFlags flags,
typename T>
461 bool ParseFrom(
const T& input);
466 uint8_t* ptr, io::EpsCopyOutputStream* stream)
const = 0;
470 if (IsInitialized())
return true;
471 LogInitializationErrorMessage();
476 friend class FastReflectionMessageMutator;
477 friend class FastReflectionStringSetter;
480 friend class internal::ExtensionSet;
481 friend class internal::LazyField;
482 friend class internal::SwapFieldHelper;
483 friend class internal::TcParser;
484 friend class internal::WeakFieldMap;
485 friend class internal::WireFormatLite;
487 template <
typename Type>
488 friend class Arena::InternalHelper;
489 template <
typename Type>
492 void LogInitializationErrorMessage()
const;
494 bool MergeFromImpl(io::CodedInputStream* input,
ParseFlags parse_flags);
537template <
bool alias,
typename T>
540 return input.template MergeInto<alias>(msg, parse_flags);
545template <MessageLite::ParseFlags flags,
typename T>
549 return internal::MergeFromImpl<alias>(input,
this, flags);
581 OnShutdownRun([](
const void* pp) {
delete static_cast<const T*
>(pp); }, p);
589#include <google/protobuf/port_undef.inc>
PROTOBUF_ATTRIBUTE_REINITIALIZES bool ParsePartialFromIstream(std::istream *input)
bool SerializePartialToFileDescriptor(int file_descriptor) const
bool MergeFromCodedStream(io::CodedInputStream *input)
bool MergeFromString(ConstStringParam data)
std::string ShortDebugString() const
std::string Utf8DebugString() const
uint8_t * SerializeWithCachedSizesToArray(uint8_t *target) const
bool SerializePartialToOstream(std::ostream *output) const
PROTOBUF_ATTRIBUTE_REINITIALIZES bool ParseFromCodedStream(io::CodedInputStream *input)
bool AppendToString(std::string *output) const
virtual void OnDemandRegisterArenaDtor(Arena *)
PROTOBUF_ATTRIBUTE_REINITIALIZES bool ParsePartialFromCodedStream(io::CodedInputStream *input)
bool SerializePartialToArray(void *data, int size) const
virtual const char * _InternalParse(const char *, internal::ParseContext *)
void SerializeWithCachedSizes(io::CodedOutputStream *output) const
PROTOBUF_ATTRIBUTE_REINITIALIZES bool ParsePartialFromFileDescriptor(int file_descriptor)
static T * CreateMaybeMessage(Arena *arena)
virtual ~MessageLite()=default
virtual int GetCachedSize() const =0
PROTOBUF_ATTRIBUTE_REINITIALIZES bool ParseFromZeroCopyStream(io::ZeroCopyInputStream *input)
Arena * GetArenaForAllocation() const
virtual std::string GetTypeName() const =0
MessageLite(Arena *arena, bool is_message_owned=false)
bool SerializePartialToCodedStream(io::CodedOutputStream *output) const
bool ParseFrom(const T &input)
PROTOBUF_ATTRIBUTE_REINITIALIZES bool ParseFromString(ConstStringParam data)
std::string DebugString() const
virtual void CheckTypeAndMergeFrom(const MessageLite &other)=0
PROTOBUF_ATTRIBUTE_REINITIALIZES bool ParsePartialFromArray(const void *data, int size)
std::string SerializePartialAsString() const
bool IsInitializedWithErrors() const
bool SerializeToOstream(std::ostream *output) const
MessageLite * New() const
bool MergePartialFromBoundedZeroCopyStream(io::ZeroCopyInputStream *input, int size)
bool AppendPartialToString(std::string *output) const
bool SerializeToString(std::string *output) const
bool SerializePartialToString(std::string *output) const
std::string SerializeAsString() const
bool MergeFromBoundedZeroCopyStream(io::ZeroCopyInputStream *input, int size)
bool SerializeToCodedStream(io::CodedOutputStream *output) const
virtual std::string InitializationErrorString() const
virtual uint8_t * _InternalSerialize(uint8_t *ptr, io::EpsCopyOutputStream *stream) const =0
PROTOBUF_ATTRIBUTE_REINITIALIZES bool ParsePartialFromBoundedZeroCopyStream(io::ZeroCopyInputStream *input, int size)
PROTOBUF_ATTRIBUTE_REINITIALIZES bool ParseFromArray(const void *data, int size)
PROTOBUF_ATTRIBUTE_REINITIALIZES bool ParseFromBoundedZeroCopyStream(io::ZeroCopyInputStream *input, int size)
bool SerializePartialToZeroCopyStream(io::ZeroCopyOutputStream *output) const
bool SerializeToArray(void *data, int size) const
PROTOBUF_ATTRIBUTE_REINITIALIZES bool ParseFromIstream(std::istream *input)
Arena * GetOwningArena() const
virtual size_t ByteSizeLong() const =0
PROTOBUF_ATTRIBUTE_REINITIALIZES bool ParsePartialFromZeroCopyStream(io::ZeroCopyInputStream *input)
bool SerializeToZeroCopyStream(io::ZeroCopyOutputStream *output) const
PROTOBUF_ATTRIBUTE_REINITIALIZES bool ParsePartialFromString(ConstStringParam data)
bool MergePartialFromCodedStream(io::CodedInputStream *input)
PROTOBUF_ATTRIBUTE_REINITIALIZES bool ParseFromFileDescriptor(int file_descriptor)
virtual MessageLite * New(Arena *arena) const =0
internal::InternalMetadata _internal_metadata_
virtual bool IsInitialized() const =0
bool SerializeToFileDescriptor(int file_descriptor) const
PROTOBUF_EXPORT size_t StringSpaceUsedExcludingSelfLong(const std::string &str)
PROTOBUF_EXPORT constexpr const std::string & GetEmptyStringAlreadyInited()
PROTOBUF_EXPORT void OnShutdown(void(*func)())
T * OnShutdownDelete(T *p)
int ToCachedSize(size_t size)
template bool MergeFromImpl< false >(StringPiece input, MessageLite *msg, MessageLite::ParseFlags parse_flags)
bool MergeFromImpl(StringPiece input, MessageLite *msg, MessageLite::ParseFlags parse_flags)
size_t FromIntSize(int size)
template bool MergeFromImpl< true >(StringPiece input, MessageLite *msg, MessageLite::ParseFlags parse_flags)
int ToIntSize(size_t size)
PROTOBUF_EXPORT void OnShutdownRun(void(*f)(const void *), const void *arg)
PROTOBUF_EXPORT ExplicitlyConstructedArenaString fixed_address_empty_string
PROTOBUF_EXPORT void ShutdownProtobufLibrary()
io::ZeroCopyInputStream * zcis