class Message

Defined at line 250 of file ../../third_party/protobuf/src/google/protobuf/message.h

Abstract interface for protocol messages.

See also MessageLite, which contains most every-day operations. Message

adds descriptors and reflection on top of that.

The methods of this class that are virtual but not pure-virtual have

default implementations based on reflection. Message classes which are

optimized for speed will want to override these with faster implementations,

but classes optimized for code size may be happy with keeping them. See

the optimize_for option in descriptor.proto.

Users must not derive from this class. Only the protocol compiler and

the internal library are allowed to create subclasses.

Protected Members

static DescriptorMethods kDescriptorMethods

Public Methods

void CopyFrom (const Message & from)

Make this message into a copy of the given message. The given message

must have the same descriptor, but need not necessarily be the same class.

By default this is just implemented as "Clear(); MergeFrom(from);".

void MergeFrom (const Message & from)

Merge the fields from the given message into this message. Singular

fields will be overwritten, if specified in from, except for embedded

messages which will be merged. Repeated fields will be concatenated.

The given message must be of the same type as this message (i.e. the

exact same class).

void CheckInitialized ()

Verifies that IsInitialized() returns true. ABSL_CHECK-fails otherwise,

with a nice error message.

void FindInitializationErrors (std::vector<std::string> * errors)

Slowly build a list of all required fields that are not set.

This is much, much slower than IsInitialized() as it is implemented

purely via reflection. Generally, you should not call this unless you

have already determined that an error exists by calling IsInitialized().

std::string InitializationErrorString ()

Like FindInitializationErrors, but joins all the strings, delimited by

commas, and returns them.

void DiscardUnknownFields ()

Clears all unknown fields from this message and all embedded messages.

Normally, if unknown tag numbers are encountered when parsing a message,

the tag and value are stored in the message's UnknownFieldSet and

then written back out when the message is serialized. This allows servers

which simply route messages to other servers to pass through messages

that have new field definitions which they don't yet know about. However,

this behavior can have security implications. To avoid it, call this

method after parsing.

See Reflection::GetUnknownFields() for more on unknown fields.

std::string DebugString ()

Generates a human-readable form of this message for debugging purposes.

Note that the format and content of a debug string is not guaranteed, may

change without notice, and should not be depended on. Code that does

anything except display a string to assist in debugging should use

TextFormat instead.

void Clear ()
size_t ByteSizeLong ()
void Message (const Message & )

Defined at line 252 of file ../../third_party/protobuf/src/google/protobuf/message.h

Message * New ()

Construct a new instance of the same type. Ownership is passed to the

caller. (This is also defined in MessageLite, but is defined again here

for return-type covariance.)

Defined at line 260 of file ../../third_party/protobuf/src/google/protobuf/message.h

Message * New (Arena * arena)

Construct a new instance on the arena. Ownership is passed to the caller

if arena is a nullptr.

Defined at line 264 of file ../../third_party/protobuf/src/google/protobuf/message.h

const Descriptor * GetDescriptor ()

Get a non-owning pointer to a Descriptor for this message's type. This

describes what fields the message contains, the types of those fields, etc.

This object remains property of the Message.

Defined at line 363 of file ../../third_party/protobuf/src/google/protobuf/message.h

const Reflection * GetReflection ()

Get a non-owning pointer to the Reflection interface for this Message,

which can be used to read and modify the fields of the Message dynamically

(in other words, without knowing the message type at compile time). This

object remains property of the Message.

Defined at line 369 of file ../../third_party/protobuf/src/google/protobuf/message.h

std::string ShortDebugString ()

Like DebugString(), but with less whitespace.

std::string Utf8DebugString ()

Like DebugString(), but do not escape UTF-8 byte sequences.

void PrintDebugString ()

Convenience function useful in GDB. Prints DebugString() to stdout.

int SpaceUsed ()

Defined at line 319 of file ../../third_party/protobuf/src/google/protobuf/message.h

size_t SpaceUsedLong ()

Computes (an estimate of) the total number of bytes currently used for

storing the message in memory.

SpaceUsed() is noticeably slower than ByteSize(), as it is implemented

using reflection (rather than the generated code implementation for

ByteSize()). Like ByteSize(), its CPU time is linear in the number of

fields defined for the proto.

Note: The precise value of this method should never be depended on, and can

change substantially due to internal details. In debug builds, this will

include a random fuzz factor to prevent these dependencies.

uint8_t * _InternalSerialize (uint8_t * target, io::EpsCopyOutputStream * stream)
Message & operator= (const Message & )

Defined at line 253 of file ../../third_party/protobuf/src/google/protobuf/message.h

Protected Methods

Metadata GetMetadata ()

Get a struct containing the metadata for the Message, which is used in turn

to implement GetDescriptor() and GetReflection() above.

Metadata GetMetadataImpl (const internal::ClassDataFull & data)
bool IsInitializedImpl (const MessageLite & )

For CODE_SIZE types

size_t ComputeUnknownFieldsSize (size_t total_size, const internal::CachedSize * cached_size)
size_t MaybeComputeUnknownFieldsSize (size_t total_size, const internal::CachedSize * cached_size)
absl::string_view GetTypeNameImpl (const internal::ClassData * data)

Reflection based version for reflection based types.

void MergeImpl (MessageLite & to, const MessageLite & from)
void ClearImpl ()
size_t ByteSizeLongImpl (const MessageLite & msg)
const internal::TcParseTableBase * GetTcParseTableImpl (const MessageLite & msg)
void Message ()

Defined at line 373 of file ../../third_party/protobuf/src/google/protobuf/message.h

uint8_t * _InternalSerializeImpl (const MessageLite & msg, uint8_t * target, io::EpsCopyOutputStream * stream)
size_t SpaceUsedLongImpl (const MessageLite & msg_lite)

Friends

template <typename Sink>
void Message (Sink & sinkconst google::protobuf::Message & message)