class MessageLite
Defined at line 507 of file ../../third_party/protobuf/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
internal::GetTypeNameReturnType GetTypeName ()
Get the name of this message type, e.g. "foo.bar.BazProto".
void Clear ()
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.
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 AppendPartialToString (std::string * output)
Like AppendToString(), but allows missing required fields.
bool AppendToCord (absl::Cord * output)
Like SerializeToCord(), but appends to the data to the Cord's existing
contents. All required fields must be set.
bool AppendPartialToCord (absl::Cord * output)
Like AppendToCord(), but allows missing required fields.
size_t ByteSizeLong ()
int GetCachedSize ()
void MessageLite (const MessageLite & )
Defined at line 509 of file ../../third_party/protobuf/src/google/protobuf/message_lite.h
MessageLite & operator= (const MessageLite & )
Defined at line 510 of file ../../third_party/protobuf/src/google/protobuf/message_lite.h
void ~MessageLite ()
Defined at line 511 of file ../../third_party/protobuf/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 520 of file ../../third_party/protobuf/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 531 of file ../../third_party/protobuf/src/google/protobuf/message_lite.h
std::string ShortDebugString ()
Defined at line 565 of file ../../third_party/protobuf/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 568 of file ../../third_party/protobuf/src/google/protobuf/message_lite.h
int ByteSize ()
Legacy ByteSize() API.
Defined at line 768 of file ../../third_party/protobuf/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 775 of file ../../third_party/protobuf/src/google/protobuf/message_lite.h
bool IsInitializedWithErrors ()
Identical to IsInitialized() except that it logs an error message.
Defined at line 966 of file ../../third_party/protobuf/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 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 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 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. 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 ParsePartialFromString (absl::string_view data)
Like ParseFromString(), but accepts messages that are missing
required fields.
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 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 SerializePartialToString (std::string * output)
Like SerializeToString(), but allows missing required fields.
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 MergeFromCord (const absl::Cord & cord)
Reads a protocol buffer from a Cord and merges it into this message.
bool MergePartialFromCord (const absl::Cord & cord)
Like MergeFromCord(), but accepts messages that are missing
required fields.
bool ParseFromCord (const absl::Cord & cord)
Parse a protocol buffer contained in a Cord.
bool ParsePartialFromCord (const absl::Cord & cord)
Like ParseFromCord(), but accepts messages that are missing
required fields.
bool SerializeToCord (absl::Cord * output)
Serialize the message and store it in the given Cord. All required
fields must be set.
bool SerializePartialToCord (absl::Cord * output)
Like SerializeToCord(), but allows missing required fields.
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.
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)
void OnDemandRegisterArenaDtor (Arena * arena)
template <ParseFlags flags, typename T>
bool ParseFrom (const T & input)
Defined at line 1144 of file ../../third_party/protobuf/src/google/protobuf/message_lite.h
uint8_t * _InternalSerialize (uint8_t * ptr, io::EpsCopyOutputStream * stream)
Protected Methods
const internal::ClassData * GetClassData ()
internal::InternalVisibility internal_visibility ()
Message implementations require access to internally visible API.
Defined at line 816 of file ../../third_party/protobuf/src/google/protobuf/message_lite.h
template <typename T>
T * DefaultConstruct (Arena * arena)
Defined at line 821 of file ../../third_party/protobuf/src/google/protobuf/message_lite.h
template <typename T>
void * NewImpl (const void * , void * mem, Arena * arena)
Defined at line 826 of file ../../third_party/protobuf/src/google/protobuf/message_lite.h
template <typename T>
internal::MessageCreator GetNewImpl ()
Defined at line 830 of file ../../third_party/protobuf/src/google/protobuf/message_lite.h
template <typename T>
T * CopyConstruct (Arena * arena, const T & from)
Defined at line 856 of file ../../third_party/protobuf/src/google/protobuf/message_lite.h
const internal::TcParseTableBase * GetTcParseTable ()
Defined at line 860 of file ../../third_party/protobuf/src/google/protobuf/message_lite.h
void MessageLite ()
Defined at line 878 of file ../../third_party/protobuf/src/google/protobuf/message_lite.h
void MessageLite (Arena * arena)
Defined at line 879 of file ../../third_party/protobuf/src/google/protobuf/message_lite.h
void MessageLite (const internal::ClassData * )
Defined at line 880 of file ../../third_party/protobuf/src/google/protobuf/message_lite.h
void MessageLite (Arena * arena, const internal::ClassData * )
Defined at line 881 of file ../../third_party/protobuf/src/google/protobuf/message_lite.h
template <typename T>
auto GetClassDataGenerated ()
Defined at line 902 of file ../../third_party/protobuf/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 918 of file ../../third_party/protobuf/src/google/protobuf/message_lite.h
Enumerations
enum ParseFlags
| Name | Value |
|---|---|
| kMerge | 0 |
| kParse | 1 |
| kMergePartial | 2 |
| kParsePartial | 3 |
| kMergeWithAliasing | 4 |
| kParseWithAliasing | 5 |
| kMergePartialWithAliasing | 6 |
| kParsePartialWithAliasing | 7 |
Defined at line 925 of file ../../third_party/protobuf/src/google/protobuf/message_lite.h
Friends
const internal::ClassData * MessageLite (const MessageLite & msg)
template <typename Type>
class InternalHelper
class MessageCreator
class RustMapHelper
class WireFormatLite
class WeakFieldMap
class UntypedMapBase
class TcParseTableBase
class TcParser
class SwapFieldHelper
class LazyField
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)