找回密码
 注册
查看: 315|回复: 0

R语言 RProtoBuf包 Message-class()函数中文帮助文档(中英文对照)

[复制链接]
发表于 2012-9-28 20:14:40 | 显示全部楼层 |阅读模式
Message-class(RProtoBuf)
Message-class()所属R语言包:RProtoBuf

                                        Class "Message"
                                         类的“信息”

                                         译者:生物统计家园网 机器人LoveR

描述----------Description----------

R representation of protocol buffer messages. This is a thin wrapper around the Message c++ class that holds the actual message as an external pointer.
ŕ表示,协议的缓冲区消息。这是一个薄的包装MessageC + +类,用于保存实际的消息作为外部指针。


类对象----------Objects from the Class----------

Objects are typically created by the new function invoked  on a Descriptor object.
创建对象通常是由new函数调用一个描述符对象。


插槽----------Slots----------




pointer: external pointer to the c++ Message object
pointer:外部指针在C + +Message对象




type: fully qualified name of the message type
type:完全合格的名称的消息类型


方法----------Methods----------




as.character signature(x = "Message"): returns the debug string of the message.
as.character signature(x = "Message"):返回字符串的消息调试。




toString signature(x = "Message"): same as as.character
的toString signature(x = "Message"):as.character




$<- signature(x = "Message"): set the value of a field of the message.
$ < -  signature(x = "Message"):设置值的字段的信息。




$ signature(x = "Message"): gets the value of a field.  Primitive types are brough back to R as R objects of the closest matching R type.
“$signature(x = "Message"):”得到的字段值。原始类型是布拉夫最匹配的R型R为R对象。




[[ signature(x = "Message"): extracts a field identified by its name or declared tag number
[[signature(x = "Message")方向:提取领域通过名称标识或声明的标签号码




[[<- signature(x = "Message"): replace the value of a field identified by its name or declared tag number
[< -  signature(x = "Message"):更换一个字段的值,根据其名称确定或声明的标签数




serialize signature(object = "Message"): serialize a message. If the  "connection" argument is NULL, the payload of the message is returned as a raw vector,  if the "connection" argument is a binary writable connection, the payload is written into the  connection. If "connection" is a character vector, the message is sent to
序列signature(object = "Message"):序列化的消息。如果“连接”的说法是NULL,有效载荷的消息,则返回为原料的向量,如果“连接”参数是一个二进制写的连接,有效载荷写入到连接中。如果“连接”是一个字符向量,该消息被发送到




show signature(object = "Message"): displays a short text about the message
显示signature(object = "Message"):显示一个简短的文字有关的消息




update signature(object = "Message"): set several fields of the message at once
更新signature(object = "Message"):一次设置多个领域的消息




length signature(x = "Message"): The number of fields actually contained in the message.  A field counts in these two situations: the field is repeated and the field size is greater than 0,
长度signature(x = "Message")领域中实际包含的信息的数量。在这两种情况下:甲字段计数重复字段的字段大小是大于0,




str signature(object = "Message"): displays the structure of the message
str的signature(object = "Message"):显示的消息的结构




identical signature(x = "Message", y = "Message"): Test if two messages are exactly identical
相同的signature(x = "Message", y = "Message"):如果两个消息是完全相同的测试




== signature(e1 = "Message", e2 = "Message"): Same as identical
==signature(e1 = "Message", e2 = "Message"):同identical




!= signature(e1 = "Message", e2 = "Message"): Negation of identical
!=signature(e1 = "Message", e2 = "Message")否定identical




all.equal signature(e1 = "Message", e2 = "Message"): Test near equality
all.equal signature(e1 = "Message", e2 = "Message"):附近的平等测试


(作者)----------Author(s)----------


Romain Francois &lt;francoisromain@free.fr&gt;



参考文献----------References----------

http://code.google.com/apis/protocolbuffers/docs/reference/cpp/google.protobuf.message.html

参见----------See Also----------

P creates objects of class Descriptor that  can be used to create messages.
P创建的对象的类描述符,可用于创建消息。


实例----------Examples----------


## 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 )
PhoneNumber <- P( "tutorial.Person.PhoneNumber" )

# creating a prototype message from the descriptor[创建一个原型消息从描述符]
p <- new( Person )
p$email # not set, returns default value[没有设置,则返回默认值]
p$id    # not set, returns default value[没有设置,则返回默认值]
as.character( p ) # empty[空的]
has( p, "email" ) # is the "email" field set[是“电子邮件”字段设置]
has( p, "phone" ) # is the "email" field set[是“电子邮件”字段设置]
length( p )       # number of fields actually set[实际设置的字段数]

# update several fields at once[一次更新多个字段]
romain <- update( new( Person ),
        email = "francoisromain@free.fr",
        id = 1,
        name = "Romain Francois",
        phone = new( PhoneNumber , number = "+33(0)...", type = "MOBILE" )
        )

# supply parameters to the constructor[提供参数的构造函数]
dirk <- new( Person,
        email = "edd@debian.org",
        id = 2,
        name = "Dirk Eddelbuettel" )
# update the phone repeated field with a list of PhoneNumber messages[更新手机重复字段的列表的******消息]
dirk$phone <- list(
        new( PhoneNumber , number = "+01...", type = "MOBILE" ),
        new( PhoneNumber , number = "+01...", type = "HOME" ) )
       
# with/within style[/在样式]
saptarshi <- within( new(Person), {
        id <- 3
        name <- "Saptarshi Guha"
        email <- "saptarshi.guha@gmail.com"
} )

# make an addressbook[您的地址簿中]
book <- new( tutorial.AddressBook, person = list( romain, dirk, saptarshi ) )

# serialize the message to a file[序列化消息到一个文件]
tf <- tempfile( )
serialize( book, tf )

# the payload of the message[的消息的有效载荷]
serialize( book, NULL )

# read the file into a new message[文件读入到一个新的消息]
m <- tutorial.AddressBook$read( tf )
writeLines( as.character( m ) )
sapply( m$person, function(p) p$name )

## End(Not run)[#(不执行)]

转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。


注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

手机版|小黑屋|生物统计家园 网站价格

GMT+8, 2024-11-26 15:34 , Processed in 0.027889 second(s), 15 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表