Learn R Programming

RProtoBuf (version 0.4.3)

FieldDescriptor-class: Class "FieldDescriptor"

Description

R representation of message type field descriptor. This is a thin wrapper around the C++ class FieldDescriptor

Arguments

Objects from the Class

Objects typically are retrieved from FieldDescriptor

Slots

pointer:
external pointer to the FieldDescriptor c++ object
name:
name of the field within the message type
full_name:
Fully qualified name of the field
type:
Fully qualified name of the type that contains this field

Methods

show
signature(object = "FieldDescriptor"): small description
as.character
signature(x = "FieldDescriptor"): returns the debug string of the field descriptor. This is retrieved by a call to the DebugString method of the FieldDescriptor object.
toString
signature(x = "FieldDescriptor"): same as as.character
$
signature(x = "FieldDescriptor"): used to invoke pseudo methods
containing_type
signature(object = "FieldDescriptor") : returns a Descriptor of the message type that contains this field descriptor.
is_extension
signature(object = "FieldDescriptor") : indicates if this is an extension.
number
signature(object = "FieldDescriptor") : gets the declared tag number of this field.
type
signature(object = "FieldDescriptor") : type of this field.
cpp_type
signature(object = "FieldDescriptor") : c++ type of this field.
label
signature(object = "FieldDescriptor") : label of this field.
is_required
signature(object = "FieldDescriptor") : is this field required.
is_optional
signature(object = "FieldDescriptor") : is this field optional.
is_repeated
signature(object = "FieldDescriptor") : is this field repeated.
has_default_value
signature(object = "FieldDescriptor") : indicates if this field has a default value.
default_value
signature(object = "FieldDescriptor") : the default value of this field.
message_type
signature(object = "FieldDescriptor") : the Descriptor for the associated message type. Generates an error if this field is not a message type field.
enum_type
signature(object = "FieldDescriptor") : the EnumDescriptor for the associated enum type.Generates an error if this field is not an enum type field

References

The FieldDescriptor C++ class

See Also

Descriptor

Examples

Run this code
## Not run: 
# # example proto file supplied with this package
# proto.file <- system.file( "proto", "addressbook.proto", package = "RProtoBuf" ) 
# 
# # reading a proto file and creating the descriptor
# Person <- P( "tutorial.Person", file = proto.file )
# ## End(Not run)


# field descriptor object
Person$email

# debug string
as.character( Person$email )

# or as a pseudo method
Person$email$as.character()

Person$email$is_required()
Person$email$is_optional()
Person$email$is_repeated()

Person$email$has_default_value()
Person$email$default_value()

Person$email$is_extension()

# Get the default values
has_default_value(Person$id)
has_default_value(Person$email)
has_default_value(Person$phone)
default_value(Person$id)
default_value(Person$email)
default_value(Person$phone)

# Get the types of field descriptors
type(Person$id)
type(Person$id, as.string=TRUE)
cpp_type(Person$email)
cpp_type(Person$email, TRUE)

# Get the label of a field descriptor
label(Person$id)
label(Person$email)
label(Person$phone)
label(Person$id, TRUE)
label(Person$email, TRUE)
label(Person$phone, TRUE)
LABEL_OPTIONAL
LABEL_REQUIRED
LABEL_REPEATED

# Test if a field is optional
is_optional(Person$id)
is_optional(Person$email)
is_optional(Person$phone)

# Test if a field is repeated
is_repeated(Person$id)
is_repeated(Person$email)
is_repeated(Person$phone)

# Test if a field is required
is_required(Person$id)
is_required(Person$email)
is_required(Person$phone)

# Return the class of a message field
message_type(Person$phone)

Run the code above in your browser using DataLab