Protocol Buffers - Google's data interchange format
===================================================
[![Build Status](https://travis-ci.org/google/protobuf.svg?branch=master)](https://travis-ci.org/google/protobuf)
Copyright 2008 Google Inc.
This directory contains the Java Protocol Buffers Nano runtime library.
**Nano is no longer supported by protobuf team. We recommend Android users to
use protobuf lite runtime instead.**
Installation - With Maven
-------------------------
The Protocol Buffers build is managed using Maven. If you would
rather build without Maven, see below.
1) Install Apache Maven if you don't have it:
http://maven.apache.org/
2) Build the C++ code, or obtain a binary distribution of protoc. If
you install a binary distribution, make sure that it is the same
version as this package. If in doubt, run:
$ protoc --version
You will need to place the protoc executable in ../src. (If you
built it yourself, it should already be there.)
3) Run the tests:
$ mvn test
If some tests fail, this library may not work correctly on your
system. Continue at your own risk.
4) Install the library into your Maven repository:
$ mvn install
5) If you do not use Maven to manage your own build, you can build a
.jar file to use:
$ mvn package
The .jar will be placed in the "target" directory.
Installation - Without Maven
----------------------------
If you would rather not install Maven to build the library, you may
follow these instructions instead. Note that these instructions skip
running unit tests.
1) Build the C++ code, or obtain a binary distribution of protoc. If
you install a binary distribution, make sure that it is the same
version as this package. If in doubt, run:
$ protoc --version
If you built the C++ code without installing, the compiler binary
should be located in ../src.
2) Invoke protoc to build DescriptorProtos.java:
$ protoc --java_out=src/main/java -I../src \
../src/google/protobuf/descriptor.proto
3) Compile the code in src/main/java using whatever means you prefer.
4) Install the classes wherever you prefer.
Nano version
------------
JavaNano is a special code generator and runtime library designed specially for
resource-restricted systems, like Android. It is very resource-friendly in both
the amount of code and the runtime overhead. Here is an overview of JavaNano
features compared with the official Java protobuf:
- No descriptors or message builders.
- All messages are mutable; fields are public Java fields.
- For optional fields only, encapsulation behind setter/getter/hazzer/
clearer functions is opt-in, which provide proper 'has' state support.
- For proto2, if not opted in, has state (field presence) is not available.
Serialization outputs all fields not equal to their defaults
(see important implications below).
The behavior is consistent with proto3 semantics.
- Required fields (proto2 only) are always serialized.
- Enum constants are integers; protection against invalid values only
when parsing from the wire.
- Enum constants can be generated into container interfaces bearing
the enum's name (so the referencing code is in Java style).
- CodedInputByteBufferNano can only take byte[] (not InputStream).
- Similarly CodedOutputByteBufferNano can only write to byte[].
- Repeated fields are in arrays, not ArrayList or Vector. Null array
elements are allowed and silently ignored.
- Full support for serializing/deserializing repeated packed fields.
- Support extensions (in proto2).
- Unset messages/groups are null, not an immutable empty default
instance.
- toByteArray(...) and mergeFrom(...) are now static functions of
MessageNano.
- The 'bytes' type translates to the Java type byte[].
The generated messages are not thread-safe for writes, but may be
used simultaneously from multiple threads in a read-only manner.
In other words, an appropriate synchronization mechanism (such as
a ReadWriteLock) must be used to ensure that a message, its
ancestors, and descendants are not accessed by any other threads
while the message is being modified. Field reads, getter methods
(but not getExtension(...)), toByteArray(...), writeTo(...),
getCachedSize(), and getSerializedSize() are all considered read-only
operations.
IMPORTANT: If you have fields with defaults and opt out of accessors
How fields with defaults are serialized has changed. Because we don't
keep "has" state, any field equal to its default is assumed to be not
set and therefore is not serialized. Consider the situation where we
change the default value of a field. Senders compiled against an older
version of the proto continue to match against the old default, and
don't send values to the receiver even though the receiver assumes the
new default value. Therefore, think carefully about the implications
of changing the default value. Alternatively, turn on accessors and
enjoy the benefit of the explicit has() checks.
IMPORTANT: If you have "bytes" fields with non-empty defaults
Because the byte buffer is now of mutable type byte[], the default
static final cannot be exposed through a public field. Each time a
message's constructor or clear() function is called, the default value
(kept in a private byte[]) is cloned. This causes a small memory
penalty. This is not a problem if the field has no default or is an
empty default.
Nano Generator options
----------------------
```
java_package -> <file-name>|<package-name>
java_outer_classname -> <file-name>|<package-name>
java_multiple_files -> true or false
java_nano_generate_has -> true or false [DEPRECATED]
optional_field_style -> default or accessors
enum_style -> c or java
ignore_services -> true or false
parcelable_messages -> true or false
generate_intdefs -> true or false
```
**java_package=\<file-name\>|\<package-name\>** (no default)
This allows overriding the 'java_package' option value
for the given file from the command line. Use multiple
java_package options to override the option for multiple
files. The final Java package for each file is the value
of this command line option if present, or the value of
the same option defined in the file if present, or the
proto package if present, or the default Java package.
**java_outer_classname=\<file-name\>|\<outer-classname\>** (no default)
This allows overriding the 'java_outer_classname' option
for the given file from the command line. Use multiple
java_outer_classname options to override the option for
multiple files. The final Java outer class name for each
file is the value of this command line option if present,
or the value of the same option defined in the file if
present, or the file name converted to CamelCase. This
outer class will nest all classes and integer constants
generated from file-scope messages and enums.
**java_multiple_files={true,false}** (no default)
This allows overriding the 'java_multiple_files' option
in all source files and their imported files from the
command line. The final value of this option for each
file is the value defined in this command line option, or
the value of the same option defined in the file if
present, or false. This specifies whether to generate
package-level classes for the file-scope messages in the
same Java package as the outer class (instead of nested
classes in the outer class). File-scope enum constants
are still generated as integer constants in the outer
class. This affects the fully qualified references in the
Java code. NOTE: because the command line option
overrides the value for all files and their imported
files, using this option inconsistently may result in
incorrect references to the imported messages and enum
constants.
**java_nano_generate_has={true,false}** (default: false)
DEPRECATED. Use optional_field_style=accessors.
If true, generates a publ
没有合适的资源?快使用搜索试试~ 我知道了~
protobuf-3.5.1.1.zip
共1887个文件
h:312个
cc:279个
proto:274个
需积分: 10 17 下载量 122 浏览量
2020-08-05
15:36:42
上传
评论
收藏 6.18MB ZIP 举报
温馨提示
ProtoBuf 是结构数据序列化方法,可简单类比于 XML,其具有以下特点: 语言无关、平台无关。即 ProtoBuf 支持 Java、C++、Python 等多种语言,支持多个平台高效。即比 XML 更小(3 ~ 10倍)、更快(20 ~ 100倍)、更为简单 扩展性、兼容性好。你可以更新数据结构,而不影响和破坏原有的旧程序
资源推荐
资源详情
资源评论
收起资源包目录
protobuf-3.5.1.1.zip (1887个子文件)
configure.ac 7KB
Makefile.am 80KB
Makefile.am 55KB
Makefile.am 22KB
Makefile.am 3KB
bad_utf8_string 3B
appveyor.bat 995B
build_packages.bat 198B
BUILD 34KB
BUILD 3KB
BUILD 765B
gmock.BUILD 616B
six.BUILD 227B
protobuf.bzl 13KB
upb.c 486KB
upb.c 486KB
message.c 87KB
defs.c 58KB
encode_decode.c 58KB
encode_decode.c 48KB
storage.c 39KB
def.c 35KB
storage.c 30KB
map.c 26KB
type_check.c 22KB
repeated_field.c 21KB
message.c 21KB
map.c 19KB
array.c 18KB
protobuf.c 13KB
protobuf.c 5KB
utf8.c 3KB
wrap_memcpy.c 2KB
descriptor.pb.cc 549KB
descriptor_unittest.cc 266KB
descriptor.cc 265KB
test_util.cc 180KB
cpp_message.cc 153KB
js_generator.cc 125KB
map_test.cc 117KB
parser_unittest.cc 108KB
type.pb.cc 102KB
message.cc 102KB
message_differencer_unittest.cc 101KB
wrappers.pb.cc 99KB
test_util_lite.cc 89KB
conformance_test.cc 88KB
generated_message_reflection.cc 87KB
protostream_objectwriter_test.cc 85KB
command_line_interface_unittest.cc 81KB
strutil.cc 80KB
cpp_unittest.cc 78KB
command_line_interface.cc 77KB
map_test_util.cc 76KB
parser.cc 76KB
text_format.cc 75KB
extension_set.cc 72KB
plugin.pb.cc 69KB
descriptor.cc 67KB
message_differencer.cc 64KB
api.pb.cc 60KB
text_format_unittest.cc 57KB
repeated_field_unittest.cc 55KB
python_generator.cc 55KB
descriptor_containers.cc 54KB
wire_format.cc 54KB
objectivec_helpers.cc 54KB
java_message.cc 53KB
struct.pb.cc 53KB
extension_set_unittest.cc 52KB
arena_unittest.cc 51KB
cpp_file.cc 49KB
coded_stream_unittest.cc 48KB
php_generator.cc 47KB
wire_format_unittest.cc 47KB
java_message_field.cc 46KB
protostream_objectwriter.cc 42KB
cpp_string_field.cc 42KB
protostream_objectsource.cc 41KB
generated_message_reflection_unittest.cc 41KB
java_message_lite.cc 40KB
cpp_message_field.cc 39KB
java_string_field.cc 37KB
tokenizer.cc 37KB
tokenizer_unittest.cc 37KB
map_container.cc 36KB
java_enum_field.cc 36KB
java_enum_field_lite.cc 35KB
java_message_field_lite.cc 34KB
javanano_primitive_field.cc 34KB
java_map_field_lite.cc 34KB
java_string_field_lite.cc 33KB
protostream_objectsource_test.cc 33KB
java_primitive_field_lite.cc 33KB
lite_unittest.cc 32KB
field_mask_util_test.cc 32KB
cpp_helpers.cc 32KB
java_primitive_field.cc 32KB
dynamic_message.cc 31KB
strutil_unittest.cc 31KB
共 1887 条
- 1
- 2
- 3
- 4
- 5
- 6
- 19
资源评论
LYXRhythm
- 粉丝: 37
- 资源: 16
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功