protocol buffers Scalar Value Types

来源:互联网 发布:php隐藏域名跳转代码 编辑:程序博客网 时间:2024/05/01 00:22

https://developers.google.com/protocol-buffers/docs/proto



A scalar message field can have one of the following types – the table shows the type specified in the .proto file, and the corresponding type in the automatically generated class:

.proto TypeNotesC++ TypeJava TypePython Type[2]double doubledoublefloatfloat floatfloatfloatint32

Uses variable-length encoding. Inefficient for 

encoding negative numbers 

– if your field is likely to have negative values, 

use sint32 instead.

int32intintint64

Uses variable-length encoding. Inefficient for

 encoding negative numbers

 – if your field is likely to have negative values,

 use sint64 instead.

int64longint/long[3]uint32Uses variable-length encoding.uint32int[1]int/long[3]uint64Uses variable-length encoding.uint64long[1]int/long[3]sint32

Uses variable-length encoding. Signed int value.

 These more efficiently encode negative numbers 

than regular int32s.

int32intintsint64

Uses variable-length encoding. Signed int value

. These more efficiently encode negative numbers 

than regular int64s.

int64longint/long[3]fixed32

Always four bytes. More efficient than uint32 

if values

 are often greater than 228.

uint32int[1]intfixed64

Always eight bytes. More efficient than uint64

 if values are often greater than 256.

uint64long[1]int/long[3]sfixed32Always four bytes.int32intintsfixed64Always eight bytes.int64longint/long[3]bool boolbooleanbooleanstring

A string must always contain UTF-8 encoded

 or 7-bit ASCII text.

stringStringstr/unicode[4]bytesMay contain any arbitrary sequence of bytes.stringByteStringstr


0 0
原创粉丝点击