with: with and within methods for protocol buffer messages

with.MessageR Documentation

with and within methods for protocol buffer messages

Description

Convenience wrapper that allow getting and setting fields of protocol buffer messages from within the object

Usage

## S3 method for class 'Message'
with(data, expr, ...)
## S3 method for class 'Message'
within(data, expr, ...)

Arguments

data

A protocol buffer message, instance of Message

expr

R expression to evaluate

...

ignored

Details

The expression is evaluated in an environment that allows to set and get fields of the message

The fields of the message are mapped to active bindings (see makeActiveBinding) so that they can be accessed and modified from within the environment.

Value

with returns the value of the expression and within returns the data argument.

Author(s)

Romain Francois <francoisromain@free.fr>

Examples

## Not run: 
proto.file <- system.file( "proto", "addressbook.proto", package = "RProtoBuf" ) 
Person <- P( "tutorial.Person", file = proto.file )

## End(Not run)

romain <- within( new( Person ), {
	email <- "francoisromain@free.fr"
	id <- 10L
} )

RProtoBuf documentation built on Nov. 3, 2022, 9:06 a.m.