Protobuf 2.6.0 发布,此版本现已提供下载,更新内容如下:
常规更新
-
添加 oneofs(unions) 功能。Fields in the same oneof will share
memory and at most one field can be set at the same time. Use the
oneof keyword to define a oneof like:message SampleMessage { oneof test_oneof { string name = 4; YourMessage sub_message = 9; } } -
Files, services, enums, messages, methods and enum values can be marked
as deprecated now. -
解析 Java 和 C++ 文本格式 protos 时, 添加对 list values 的支持,包括 lists of messages
For example: foo: [1, 2, 3]
C++
-
Enhanced customization on TestFormat printing.
-
Added SwapFields() in reflection API to swap a subset of fields.
Added SetAllocatedMessage() in reflection API. -
Repeated primitive extensions are now packable. The
[packed=true] option only affects serializers. Therefore, it is
possible to switch a repeated extension field to packed format
without breaking backwards-compatibility. -
Various speed optimizations.
Java
-
writeTo() method in ByteString can now write a substring to an
output stream. Added endWith() method for ByteString. -
ByteString and ByteBuffer are now supported in CodedInputStream
and CodedOutputStream. -
java_generate_equals_and_hash can now be used with the LITE_RUNTIME.
Python
-
新的 C++-backed 扩展模块 (aka "cpp api v2") 替代了旧版的 ("cpp api v1"),比纯 Python 代码更快,解决了许多 bug,建议所有使用纯 Python 的用户都升级!
-
Descriptors 现在包括 enum_types_by_name 和 extension_types_by_name dict
属性 -
支持 Python 3.
Protocol Buffers (ProtocolBuffer/ protobuf )是Google公司开发的一种数据描述语言,类似于XML能够将结构化数据序列化,可用于数据存储、通信协议等方面。现阶段支持C++、JAVA、Python等三种编程语言。
为什么不只用XML?同XML相比,Protocol buffers在序列化结构化数据方面有许多优点(google官方提出):
-
更简单
-
数据描述文件只需原来的1/10至1/3
-
解析速度是原来的20倍至100倍
-
减少了二义性
-
生成了更容易在编程中使用的数据访问类
Google大概是2008年7月8日将其作为开源项目对外公布,说是后续还要开源的项目有不少都会用到Protocol Buffers。
Protocol Buffers 的详细介绍:请点这里
Protocol Buffers 的下载地址:请点这里
本文永久更新链接地址:http://www.linuxidc.com/Linux/2014-09/107284.htm
