zoukankan      html  css  js  c++  java
  • probotuf 标量数值类型

    标量数值类型

    一个标量消息字段可以含有一个如下的类型——该表格展示了定义于.proto文件中的类型,以及与之对应的、在自动生成的访问类中定义的类型:

    .proto类型

    Java 类型

    C++类型

    备注

    double

    double

    double

    float

    float

    float

    int32

    int

    int32

    使用可变长编码方式。编码负数时不够高效——如果你的字段可能含有负数,那么请使用sint32

    int64

    long

    int64

    使用可变长编码方式。编码负数时不够高效——如果你的字段可能含有负数,那么请使用sint64

    uint32

    int[1]

    uint32

    Uses variable-length encoding.

    uint64

    long[1]

    uint64

    Uses variable-length encoding.

    sint32

    int

    int32

    使用可变长编码方式。有符号的整型值。编码时比通常的int32高效。

    sint64

    long

    int64

    使用可变长编码方式。有符号的整型值。编码时比通常的int64高效。

    fixed32

    int[1]

    uint32

    总是4个字节。如果数值总是比总是比228大的话,这个类型会比uint32高效。

    fixed64

    long[1]

    uint64

    总是8个字节。如果数值总是比总是比256大的话,这个类型会比uint64高效。

    sfixed32

    int

    int32

    总是4个字节。

    sfixed64

    long

    int64

    总是8个字节。

    bool

    boolean

    bool

    string

    String

    string

    一个字符串必须是UTF-8编码或者7-bit ASCII编码的文本。

    bytes

    ByteString

    string

    可能包含任意顺序的字节数据。

    你可以在文章http://code.google.com/apis/protocolbuffers/docs/encoding.html 中,找到更多“序列化消息时各种类型如何编码的信息。

    原文

    http://www.cnblogs.com/dkblog/archive/2012/03/27/2419010.html

  • 相关阅读:
    石子游戏2
    礼物的最大价值
    CF512D. Fox And Travelling
    arc099F
    CF504E. Misha and LCP on Tree(长链剖分求k级祖先)
    agc031D
    CF555E. Case of Computer Network
    agc023D
    CF1406E. Deleting Numbers
    CF585F. Digits of Number Pi
  • 原文地址:https://www.cnblogs.com/mydomain/p/3189561.html
Copyright © 2011-2022 走看看