Protocol Buffers

unknown_field_set.h

#include <google/protobuf/unknown_field_set.h>
namespace google::protobuf

Contains classes used to keep track of unrecognized fields seen while parsing a protocol message.

Classes in this file

An UnknownFieldSet contains fields that were encountered while parsing a message but were not defined by its type.
Represents one field in an UnknownFieldSet.

class UnknownFieldSet

#include <google/protobuf/unknown_field_set.h>
namespace google::protobuf

An UnknownFieldSet contains fields that were encountered while parsing a message but were not defined by its type.

Keeping track of these can be useful, especially in that they may be written if the message is serialized again without being cleared in between. This means that software which simply receives messages and forwards them to other servers does not need to be updated every time a new field is added to the message definition.

To get the UnknownFieldSet attached to any message, call Reflection::GetUnknownFields().

This class is necessarily tied to the protocol buffer wire format, unlike the Reflection interface which is independent of any serialization scheme.

Members

UnknownFieldSet()
~UnknownFieldSet()
void
Clear()
Remove all fields.
void
ClearAndFreeMemory()
Remove all fields and deallocate internal data objects.
bool
empty() const
Is this set empty?
void
MergeFrom(const UnknownFieldSet & other)
Merge the contents of some other UnknownFieldSet with this one.
void
Swap(UnknownFieldSet * x)
Swaps the contents of some other UnknownFieldSet with this one.
int
SpaceUsedExcludingSelf() const
Computes (an estimate of) the total number of bytes currently used for storing the unknown fields in memory. more...
int
SpaceUsed() const
Version of SpaceUsed() including sizeof(*this).
int
field_count() const
Returns the number of fields present in the UnknownFieldSet.
const UnknownField &
field(int index) const
Get a field in the set, where 0 <= index < field_count(). more...
UnknownField *
mutable_field(int index)
Get a mutable pointer to a field in the set, where 0 <= index < field_count(). more...
bool
MergeFromCodedStream(io::CodedInputStream * input)
bool
ParseFromCodedStream(io::CodedInputStream * input)
bool
ParseFromZeroCopyStream(io::ZeroCopyInputStream * input)
bool
ParseFromArray(const void * data, int size)
bool
ParseFromString(const string & data)

Adding fields

void
AddVarint(int number, uint64 value)
void
AddFixed32(int number, uint32 value)
void
AddFixed64(int number, uint64 value)
void
AddLengthDelimited(int number, const string & value)
string *
AddLengthDelimited(int number)
UnknownFieldSet *
AddGroup(int number)
void
AddField(const UnknownField & field)
Adds an unknown field from another set.
void
DeleteSubrange(int start, int num)
Delete fields with indices in the range [[]start . more...
void
DeleteByNumber(int number)
Delete all fields with a specific field number. more...

int UnknownFieldSet::SpaceUsedExcludingSelf() const

Computes (an estimate of) the total number of bytes currently used for storing the unknown fields in memory.

Does NOT include sizeof(*this) in the calculation.


const UnknownField &
    UnknownFieldSet::field(
        int index) const

Get a field in the set, where 0 <= index < field_count().

The fields appear in the order in which they were added.


UnknownField * UnknownFieldSet::mutable_field(
        int index)

Get a mutable pointer to a field in the set, where 0 <= index < field_count().

The fields appear in the order in which they were added.


void UnknownFieldSet::DeleteSubrange(
        int start,
        int num)

Delete fields with indices in the range [[]start .

. start+num-1]. Caution: implementation moves all fields with indices [[]start+num .. ].


void UnknownFieldSet::DeleteByNumber(
        int number)

Delete all fields with a specific field number.

The order of left fields is preserved. Caution: implementation moves all fields after the first deleted field.

class UnknownField

#include <google/protobuf/unknown_field_set.h>
namespace google::protobuf

Represents one field in an UnknownFieldSet.

Members

enum
Type
uint64
varint_
uint32
fixed32_
uint64
fixed64_
string *
string_value_
union google::protobuf::UnknownField::@2::@4
length_delimited_
UnknownFieldSet *
group_
int
number() const
The field's tag number, as seen on the wire.
Type
type() const
The field type.

Accessors

Each method works only for UnknownFields of the corresponding type.
uint64
varint() const
uint32
fixed32() const
uint64
fixed64() const
const string &
length_delimited() const
const UnknownFieldSet &
group() const
void
set_varint(uint64 value)
void
set_fixed32(uint32 value)
void
set_fixed64(uint64 value)
void
set_length_delimited(const string & value)
string *
mutable_length_delimited()
UnknownFieldSet *
mutable_group()
void
SerializeLengthDelimitedNoTag(io::CodedOutputStream * output) const
Serialization API. more...
uint8 *
SerializeLengthDelimitedNoTagToArray(uint8 * target) const
int
GetLengthDelimitedSize() const

enum UnknownField::Type {
  TYPE_VARINT,
  TYPE_FIXED32,
  TYPE_FIXED64,
  TYPE_LENGTH_DELIMITED,
  TYPE_GROUP
}

TYPE_VARINT
TYPE_FIXED32
TYPE_FIXED64
TYPE_LENGTH_DELIMITED
TYPE_GROUP

void UnknownField::SerializeLengthDelimitedNoTag(
        io::CodedOutputStream * output) const

Serialization API.

These methods can take advantage of the underlying implementation and may archieve a better performance than using getters to retrieve the data and do the serialization yourself.

Authentication required

You need to be signed in with Google+ to do that.

Signing you in...

Google Developers needs your permission to do that.