class MessageLite
Defined at line 746 of file ../../third_party/protobuf/src/src/google/protobuf/message_lite.h
Interface to light weight protocol messages.
This interface is implemented by all protocol message objects. Non-lite
messages additionally implement the Message interface, which is a
subclass of MessageLite. Use MessageLite instead when you only need
the subset of features which it supports -- namely, nothing that uses
descriptors or reflection. You can instruct the protocol compiler
to generate classes which implement only MessageLite, not the full
Message interface, by adding the following line to the .proto file:
option optimize_for = LITE_RUNTIME;
This is particularly useful on resource-constrained systems where
the full protocol buffers runtime library is too big.
Note that on non-constrained systems (e.g. servers) when you need
to link in lots of protocol definitions, a better way to reduce
total code footprint is to use optimize_for = CODE_SIZE. This
will make the generated code smaller while still supporting all the
same features (at the expense of speed). optimize_for = LITE_RUNTIME
is best when you only have a small number of message types linked
into your binary, in which case the size of the protocol buffers
runtime itself is the biggest problem.
Users must not derive from this class. Only the protocol compiler and
the internal library are allowed to create subclasses.
Protected Members
InternalMetadata _internal_metadata_
Public Methods
absl::string_view GetTypeName ()
Get the name of this message type, e.g. "foo.bar.BazProto".
void Clear ()
void MessageLite (const MessageLite & )
Defined at line 748 of file ../../third_party/protobuf/src/src/google/protobuf/message_lite.h
bool ParseFromCodedStream (io::CodedInputStream * input)
Fill the message with a protocol buffer parsed from the given input
stream. Returns false on a read error or if the input is in the wrong
format. A successful return does not indicate the entire input is
consumed, ensure you call ConsumedEntireMessage() to check that if
applicable.
bool ParseFromCord (const absl::Cord & data)
Parse a protocol buffer contained in a Cord.
Defined at line 1023 of file ../../third_party/protobuf/src/src/google/protobuf/message_lite.h
bool ParsePartialFromCodedStream (io::CodedInputStream * input)
Like ParseFromCodedStream(), but accepts messages that are missing
required fields.
bool ParseFromZeroCopyStream (io::ZeroCopyInputStream * input)
Read a protocol buffer from the given zero-copy input stream. If
successful, the entire input will be consumed.
bool ParsePartialFromCord (const absl::Cord & data)
Like ParseFromCord(), but accepts messages that are missing
required fields.
Defined at line 1030 of file ../../third_party/protobuf/src/src/google/protobuf/message_lite.h
bool AppendToCord (absl::Cord * output)
Like SerializeToCord(), but appends to the data to the Cord's existing
contents. All required fields must be set.
Defined at line 1059 of file ../../third_party/protobuf/src/src/google/protobuf/message_lite.h
bool AppendPartialToCord (absl::Cord * output)
Like AppendToCord(), but allows missing required fields.
Defined at line 1063 of file ../../third_party/protobuf/src/src/google/protobuf/message_lite.h
int ByteSize ()
Legacy ByteSize() API.
Defined at line 1083 of file ../../third_party/protobuf/src/src/google/protobuf/message_lite.h
bool ParsePartialFromZeroCopyStream (io::ZeroCopyInputStream * input)
Like ParseFromZeroCopyStream(), but accepts messages that are missing
required fields.
bool ParseFromFileDescriptor (int file_descriptor)
Parse a protocol buffer from a file descriptor. If successful, the entire
input will be consumed.
bool ParsePartialFromFileDescriptor (int file_descriptor)
Like ParseFromFileDescriptor(), but accepts messages that are missing
required fields.
bool ParseFromIstream (std::istream * input)
Parse a protocol buffer from a C++ istream. If successful, the entire
input will be consumed.
bool ParsePartialFromIstream (std::istream * input)
Like ParseFromIstream(), but accepts messages that are missing
required fields.
bool MergePartialFromBoundedZeroCopyStream (io::ZeroCopyInputStream * input, int size)
Read a protocol buffer from the given zero-copy input stream, expecting
the message to be exactly "size" bytes long. If successful, exactly
this many bytes will have been consumed from the input.
bool MergeFromBoundedZeroCopyStream (io::ZeroCopyInputStream * input, int size)
Like ParseFromBoundedZeroCopyStream(), but accepts messages that are
missing required fields.
bool ParseFromBoundedZeroCopyStream (io::ZeroCopyInputStream * input, int size)
bool ParsePartialFromBoundedZeroCopyStream (io::ZeroCopyInputStream * input, int size)
Like ParseFromBoundedZeroCopyStream(), but accepts messages that are
missing required fields.
bool ParseFromString (absl::string_view data)
Parses a protocol buffer contained in a string or Cord. Returns true on
success. This function takes a string in the (non-human-readable) binary
wire format, matching the encoding output by
MessageLite::SerializeToString(). If you'd like to convert a human-readable
string into a protocol buffer object, see
google::protobuf::TextFormat::ParseFromString().
bool ParseFromString (const absl::Cord & data)
bool ParsePartialFromString (absl::string_view data)
Like ParseFromString(), but accepts messages that are missing
required fields.
bool ParsePartialFromString (const absl::Cord & data)
bool ParseFromArray (const void * data, int size)
Parse a protocol buffer contained in an array of bytes.
bool ParsePartialFromArray (const void * data, int size)
Like ParseFromArray(), but accepts messages that are missing
required fields.
bool MergeFromCodedStream (io::CodedInputStream * input)
Reads a protocol buffer from the stream and merges it into this
Message. Singular fields read from the what is
already in the Message and repeated fields are appended to those
already present.
It is the responsibility of the caller to call input->LastTagWas()
(for groups) or input->ConsumedEntireMessage() (for non-groups) after
this returns to verify that the message's end was delimited correctly.
ParseFromCodedStream() is implemented as Clear() followed by
MergeFromCodedStream().
bool MergePartialFromCodedStream (io::CodedInputStream * input)
Like MergeFromCodedStream(), but succeeds even if required fields are
missing in the input.
MergeFromCodedStream() is just implemented as MergePartialFromCodedStream()
followed by IsInitialized().
bool MergeFromString (absl::string_view data)
Merge a protocol buffer contained in a string.
bool MergeFromString (const absl::Cord & data)
bool MergePartialFromString (absl::string_view data)
Like MergeFromString(), but accepts messages that are missing required
fields.
bool MergePartialFromString (const absl::Cord & data)
bool SerializeToCodedStream (io::CodedOutputStream * output)
Write a protocol buffer of this message to the given output. Returns
false on a write error. If the message is missing required fields,
this may ABSL_CHECK-fail.
bool SerializePartialToCodedStream (io::CodedOutputStream * output)
Like SerializeToCodedStream(), but allows missing required fields.
bool SerializeToZeroCopyStream (io::ZeroCopyOutputStream * output)
Write the message to the given zero-copy output stream. All required
fields must be set.
bool SerializePartialToZeroCopyStream (io::ZeroCopyOutputStream * output)
Like SerializeToZeroCopyStream(), but allows missing required fields.
bool SerializeToString (std::string * output)
Serialize the message and store it in the given string. All required
fields must be set.
bool SerializeToString (absl::Cord * output)
Serialize the message and store it in the given Cord. All required
fields must be set.
bool SerializePartialToString (std::string * output)
Like SerializeToString(), but allows missing required fields.
bool SerializePartialToString (absl::Cord * output)
bool SerializeToArray (void * data, int size)
Serialize the message and store it in the given byte array. All required
fields must be set.
bool SerializePartialToArray (void * data, int size)
Like SerializeToArray(), but allows missing required fields.
std::string SerializeAsString ()
Make a string encoding the message. Is equivalent to calling
SerializeToString() on a string and using that. Returns the empty
string if SerializeToString() would have returned an error.
Note: If you intend to generate many such strings, you may
reduce heap fragmentation by instead re-using the same string
object with calls to SerializeToString().
std::string SerializePartialAsString ()
Like SerializeAsString(), but allows missing required fields.
bool SerializeToFileDescriptor (int file_descriptor)
Serialize the message and write it to the given file descriptor. All
required fields must be set.
bool SerializePartialToFileDescriptor (int file_descriptor)
Like SerializeToFileDescriptor(), but allows missing required fields.
bool SerializeToOstream (std::ostream * output)
Serialize the message and write it to the given C++ ostream. All
required fields must be set.
bool SerializePartialToOstream (std::ostream * output)
Like SerializeToOstream(), but allows missing required fields.
bool AppendToString (std::string * output)
Like SerializeToString(), but appends to the data to the string's
existing contents. All required fields must be set.
bool AppendToString (absl::Cord * output)
bool AppendPartialToString (std::string * output)
Like AppendToString(), but allows missing required fields.
bool AppendPartialToString (absl::Cord * output)
int GetCachedSize ()
MessageLite & operator= (const MessageLite & )
Defined at line 749 of file ../../third_party/protobuf/src/src/google/protobuf/message_lite.h
void ~MessageLite ()
Defined at line 750 of file ../../third_party/protobuf/src/src/google/protobuf/message_lite.h
MessageLite * New ()
Construct a new instance of the same type. Ownership is passed to the
caller.
Defined at line 759 of file ../../third_party/protobuf/src/src/google/protobuf/message_lite.h
Arena * GetArena ()
Returns the arena, if any, that directly owns this message and its internal
memory (Arena::Own is different in that the arena doesn't directly own the
internal memory). This method is used in proto's implementation for
swapping, moving and setting allocated, for deciding whether the ownership
of this message or its internal memory could be changed.
Defined at line 770 of file ../../third_party/protobuf/src/src/google/protobuf/message_lite.h
bool MergeFromCord (const absl::Cord & data)
Reads a protocol buffer from a Cord and merges it into this message.
Defined at line 1012 of file ../../third_party/protobuf/src/src/google/protobuf/message_lite.h
bool MergePartialFromCord (const absl::Cord & data)
Like MergeFromCord(), but accepts messages that are missing
required fields.
Defined at line 1017 of file ../../third_party/protobuf/src/src/google/protobuf/message_lite.h
MessageLite * New (Arena * arena)
Construct a new instance on the arena. Ownership is passed to the caller
if arena is a nullptr.
bool IsInitialized ()
Quickly check if all required fields have values set.
std::string InitializationErrorString ()
This is not implemented for Lite messages -- it just returns "(cannot
determine missing fields for lite message)". However, it is implemented
for full messages. See message.h.
void CheckTypeAndMergeFrom (const MessageLite & other)
If |other| is the exact same class as this, calls MergeFrom(). Otherwise,
results are undefined (probably crash).
std::string DebugString ()
These methods return a human-readable summary of the message. Note that
since the MessageLite interface does not support reflection, there is very
little information that these methods can provide. They are shadowed by
methods of the same name on the Message interface which provide much more
information. The methods here are intended primarily to facilitate code
reuse for logic that needs to interoperate with both full and lite protos.
The format of the returned string is subject to change, so please do not
assume it will remain stable over time.
std::string ShortDebugString ()
Defined at line 804 of file ../../third_party/protobuf/src/src/google/protobuf/message_lite.h
std::string Utf8DebugString ()
MessageLite::DebugString is already Utf8 Safe. This is to add compatibility
with Message.
Defined at line 807 of file ../../third_party/protobuf/src/src/google/protobuf/message_lite.h
absl::Cord SerializeAsCord ()
Make a Cord encoding the message. Is equivalent to calling
SerializeToCord() on a Cord and using that. Returns an empty
Cord if SerializeToCord() would have returned an error.
absl::Cord SerializePartialAsCord ()
Like SerializeAsCord(), but allows missing required fields.
size_t ByteSizeLong ()
bool SerializeToCord (absl::Cord * output)
Serialize the message and store it in the given Cord. All required
fields must be set.
Defined at line 1038 of file ../../third_party/protobuf/src/src/google/protobuf/message_lite.h
bool SerializePartialToCord (absl::Cord * output)
Like SerializeToCord(), but allows missing required fields.
Defined at line 1044 of file ../../third_party/protobuf/src/src/google/protobuf/message_lite.h
void SerializeWithCachedSizes (io::CodedOutputStream * output)
Serializes the message without recomputing the size. The message must not
have changed since the last call to ByteSize(), and the value returned by
ByteSize must be non-negative. Otherwise the results are undefined.
Defined at line 1093 of file ../../third_party/protobuf/src/src/google/protobuf/message_lite.h
uint8_t * SerializeWithCachedSizesToArray (uint8_t * target)
Like SerializeWithCachedSizes, but writes directly to *target, returning
a pointer to the byte immediately after the last byte written. "target"
must point at a byte array of at least ByteSize() bytes. Whether to use
deterministic serialization, e.g., maps in sorted order, is determined by
CodedOutputStream::IsDefaultSerializationDeterministic().
const char * _InternalParse (const char * ptr, internal::ParseContext * ctx)
bool IsInitializedWithErrors ()
Identical to IsInitialized() except that it logs an error message.
Defined at line 1318 of file ../../third_party/protobuf/src/src/google/protobuf/message_lite.h
template <ParseFlags flags, typename T>
bool ParseFrom (const T & input)
Defined at line 1542 of file ../../third_party/protobuf/src/src/google/protobuf/message_lite.h
uint8_t * _InternalSerialize (uint8_t * ptr, io::EpsCopyOutputStream * stream)
Protected Methods
void CheckHasBitConsistency ()
template <typename T>
T * DefaultConstruct (Arena * arena)
Defined at line 1139 of file ../../third_party/protobuf/src/src/google/protobuf/message_lite.h
template <typename T>
T * CopyConstruct (Arena * arena, const T & from)
Defined at line 1169 of file ../../third_party/protobuf/src/src/google/protobuf/message_lite.h
MessageLite * CopyConstruct (Arena * arena, const MessageLite & from)
As above, but for fields that use base class type. Eg foreign weak fields.
template <typename T>
void * NewImpl (const void *,void *mem,Arena *arena)
Defined at line 1144 of file ../../third_party/protobuf/src/src/google/protobuf/message_lite.h
template <typename T>
internal::MessageCreator GetNewImpl ()
Defined at line 1148 of file ../../third_party/protobuf/src/src/google/protobuf/message_lite.h
Message * CopyConstruct (Arena * arena, const Message & from)
Defined at line 1176 of file ../../third_party/protobuf/src/src/google/protobuf/message_lite.h
void MergeFromWithClassData (const MessageLite & other, const internal::ClassData * data)
`CheckTypeAndMergeFrom()` and should be preferred by friended internal
callers that have the right `ClassData` handy.
REQUIRES: Both `this` and `other` are the exact same class as represented
by `data`. If there is a mismatch, CHECK-fails in debug builds or causes UB
in release builds (probably a crash).
Defined at line 1187 of file ../../third_party/protobuf/src/src/google/protobuf/message_lite.h
const internal::TcParseTableBase * GetTcParseTable ()
Defined at line 1197 of file ../../third_party/protobuf/src/src/google/protobuf/message_lite.h
void MessageLite ()
Defined at line 1215 of file ../../third_party/protobuf/src/src/google/protobuf/message_lite.h
void MessageLite (Arena * arena)
Defined at line 1216 of file ../../third_party/protobuf/src/src/google/protobuf/message_lite.h
void MessageLite (const internal::ClassData * )
Defined at line 1217 of file ../../third_party/protobuf/src/src/google/protobuf/message_lite.h
void MessageLite (Arena * arena, const internal::ClassData * )
Defined at line 1218 of file ../../third_party/protobuf/src/src/google/protobuf/message_lite.h
const internal::CachedSize & AccessCachedSize ()
Return the cached size object as described by
ClassData::cached_size_offset.
Defined at line 1246 of file ../../third_party/protobuf/src/src/google/protobuf/message_lite.h
void ClearHasBit (uint32_t & cached_has_bits, uint32_t has_bit_mask)
Defined at line 1259 of file ../../third_party/protobuf/src/src/google/protobuf/message_lite.h
bool CheckHasBit (uint32_t cached_has_bits, uint32_t has_bit_mask)
Defined at line 1264 of file ../../third_party/protobuf/src/src/google/protobuf/message_lite.h
bool BatchCheckHasBit (uint32_t cached_has_bits, uint32_t batch_has_bits_mask)
Defined at line 1269 of file ../../third_party/protobuf/src/src/google/protobuf/message_lite.h
const internal::ClassData * GetClassData ()
internal::InternalVisibility internal_visibility ()
Message implementations require access to internally visible API.
Defined at line 1134 of file ../../third_party/protobuf/src/src/google/protobuf/message_lite.h
void SetHasBit (uint32_t & cached_has_bits, uint32_t has_bit_mask)
The following methods should be used to access has bits. They enable
measuring the cost of checking/setting has bits with inline frame data.
Defined at line 1254 of file ../../third_party/protobuf/src/src/google/protobuf/message_lite.h
Enumerations
enum ParseFlags
| Name | Value | Comments |
|---|---|---|
| kMerge | 0 |
Merge vs. Parse: |
| kParse | 1 |
Merge vs. Parse: |
| kMergePartial | 2 |
Default behaviour vs. Partial: |
| kParsePartial | 3 |
Default behaviour vs. Partial: |
| kMergeWithAliasing | 4 |
Default behaviour vs. Aliasing: |
| kParseWithAliasing | 5 |
Default behaviour vs. Aliasing: |
| kMergePartialWithAliasing | 6 |
Default behaviour vs. Aliasing: |
| kParsePartialWithAliasing | 7 |
Default behaviour vs. Aliasing: |
Defined at line 1277 of file ../../third_party/protobuf/src/src/google/protobuf/message_lite.h
Friends
void MessageLite (Message * lhs, Message * rhs)
void MessageLite (MessageLite * lhs, MessageLite * rhs)
template <typename Type>
const internal::ClassData * MessageLite (const Type & msg)
template <typename Type>
class FallbackMessageTraits
template <typename Type>
class InternalHelper
template <typename Type>
class GenericTypeHandler
class RepeatedPtrFieldBase
class MessageCreator
class RustMapHelper
class WireFormatLite
class WeakFieldMap
class UntypedMapBase
class TcParseTableBase
class PrivateAccess
class TcParser
class SwapFieldHelper
class LazyField
template <typename T, size_t kFieldOffset>
class InternalMetadataOffsetHelper
class InternalMetadataOffset
class HasBitsTestPeer
class ExtensionSet
class DescriptorPoolExtensionFinder
class MessageTableTester
class TypeId
class Reflection
class Message
class FastReflectionStringSetter
class AssignDescriptorsHelper
class FastReflectionMessageMutator
template <typename Sink>
void MessageLite (Sink & sinkconst google::protobuf::MessageLite & msg)