Learn R Programming

RProtoBuf (version 0.2.6)

has-methods: Indicates if a message has the given field set

Description

This generic method, currently only implemented for Message indicates if the message has the given field set.

For non repeated fields, a call to the HasField method of the corresponding Message is issued.

For repeated fields, a call to the FieldSize method is issued, and the message is declared to have the field if the size is greater than 0.

NULL is returned if the descriptor for the message does not contain the given field at all.

Arguments

Examples

Run this code
unitest.proto.file <- system.file("unitTests", "data", "unittest.proto",
				  package = "RProtoBuf" )
readProtoFiles(file = unitest.proto.file)

test <- new(protobuf_unittest.TestAllTypes)
test$has("optional_int32")
# FALSE
test$add("repeated_int32", 1:10)
test$has("repeated_int32")
# TRUE
test$has("nonexistant")
# NULL

Run the code above in your browser using DataLab