NAME
Protobuf::Descriptor::OneofDef - Descriptor for a Protocol Buffer oneof
VERSION
version 0.04
SYNOPSIS
my $pool = Protobuf::DescriptorPool->generated_pool;
my $msg_def = $pool->find_message_by_name('my.package.MyMessage');
my $oneof_def = $msg_def->find_oneof_by_name('my_oneof');
if ($oneof_def) {
print "Oneof Name: ", $oneof_def->name, "
";
foreach my $field ($oneof_def->fields) {
print " Field: ", $field->name, "
";
}
}
DESCRIPTION
This class represents the descriptor for a single oneof definition within a message. A oneof ensures that at most one of a set of fields can be set on a message instance.
Instances of this class are usually obtained from a Protobuf::Descriptor::MessageDef.
METHODS
full_name()
Returns the fully qualified name of the oneof.
name()
Returns the short name of the oneof.
field_count()
Returns the number of fields belonging to this oneof.
get_field($index)
Returns the Protobuf::Descriptor::Field at the given $index (0-based) within the oneof.
fields()
Returns a list of all Protobuf::Descriptor::Field objects belonging to this oneof.
is_synthetic()
Returns true if this oneof was synthesised for a proto3 optional field.
SEE ALSO
Protobuf, Protobuf::DescriptorPool, Protobuf::Descriptor, Protobuf::Descriptor::MessageDef
AUTHOR
C.J. Collier <cjac@google.com>
COPYRIGHT AND LICENSE
This software is copyright (c) 2026 by Google LLC.
This is free software; you can redistribute it and/or modify it under the terms of the BSD 3-Clause License.