-
大小: 2.9MB文件类型: .zip金币: 1下载: 0 次发布日期: 2023-10-15
- 语言: 其他
- 标签: Protobuf vsprojects
资源简介
Protobuf的VS工程,大家可根据自己需要下载编译,如何编译大家可以看我的博客
代码片段和文件信息
// See README.txt for information and build instructions.
import com.example.tutorial.AddressBookProtos.AddressBook;
import com.example.tutorial.AddressBookProtos.Person;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.InputStreamReader;
import java.io.IOException;
import java.io.PrintStream;
class AddPerson {
// This function fills in a Person message based on user input.
static Person PromptForAddress(BufferedReader stdin
PrintStream stdout) throws IOException {
Person.Builder person = Person.newBuilder();
stdout.print(“Enter person ID: “);
person.setId(Integer.valueOf(stdin.readLine()));
stdout.print(“Enter name: “);
person.setName(stdin.readLine());
stdout.print(“Enter email address (blank for none): “);
String email = stdin.readLine();
if (email.length() > 0) {
person.setEmail(email);
}
while (true) {
stdout.print(“Enter a phone number (or leave blank to finish): “);
String number = stdin.readLine();
if (number.length() == 0) {
break;
}
Person.PhoneNumber.Builder phoneNumber =
Person.PhoneNumber.newBuilder().setNumber(number);
stdout.print(“Is this a mobile home or work phone? “);
String type = stdin.readLine();
if (type.equals(“mobile“)) {
phoneNumber.setType(Person.PhoneType.MOBILE);
} else if (type.equals(“home“)) {
phoneNumber.setType(Person.PhoneType.HOME);
} else if (type.equals(“work“)) {
phoneNumber.setType(Person.PhoneType.WORK);
} else {
stdout.println(“Unknown phone type. Using default.“);
}
person.addPhone(phoneNumber);
}
return person.build();
}
// Main function: Reads the entire address book from a file
// adds one person based on user input then writes it back out to the same
// file.
public static void main(String[] args) throws Exception {
if (args.length != 1) {
System.err.println(“Usage: AddPerson ADDRESS_BOOK_FILE“);
System.exit(-1);
}
AddressBook.Builder addressBook = AddressBook.newBuilder();
// Read the existing address book.
try {
FileInputStream input = new FileInputStream(args[0]);
try {
addressBook.mergeFrom(input);
} finally {
try { input.close(); } catch (Throwable ignore) {}
}
} catch (FileNotFoundException e) {
System.out.println(args[0] + “: File not found. Creating a new file.“);
}
// Add an address.
addressBook.addPerson(
PromptForAddress(new BufferedReader(new InputStreamReader(System.in))
System.out));
// Write the new address book back to disk.
FileOutputStream output = new FileOutputStream(args[0]);
try {
addressBook.build().writeTo(output);
} finally {
output.close();
}
}
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2014-07-21 09:49 Protobuf-master\
文件 25312 2014-07-21 09:49 Protobuf-master\CHANGES.txt
文件 3527 2014-07-21 09:49 Protobuf-master\CONTRIBUTORS.txt
文件 1732 2014-07-21 09:49 Protobuf-master\COPYING.txt
文件 9537 2014-07-21 09:49 Protobuf-master\INSTALL.txt
文件 15189 2014-07-21 09:49 Protobuf-master\Makefile.am
文件 41742 2014-07-21 09:49 Protobuf-master\Makefile.in
文件 5897 2014-07-21 09:49 Protobuf-master\README.txt
文件 36976 2014-07-21 09:49 Protobuf-master\aclocal.m4
文件 1519 2014-07-21 09:49 Protobuf-master\autogen.sh
文件 44906 2014-07-21 09:49 Protobuf-master\config.guess
文件 3709 2014-07-21 09:49 Protobuf-master\config.h.in
文件 35454 2014-07-21 09:49 Protobuf-master\config.sub
文件 599150 2014-07-21 09:49 Protobuf-master\configure
文件 4829 2014-07-21 09:49 Protobuf-master\configure.ac
文件 20334 2014-07-21 09:49 Protobuf-master\depcomp
目录 0 2014-07-21 09:49 Protobuf-master\editors\
文件 216 2014-07-21 09:49 Protobuf-master\editors\README.txt
文件 3731 2014-07-21 09:49 Protobuf-master\editors\proto.vim
文件 7798 2014-07-21 09:49 Protobuf-master\editors\protobuf-mode.el
目录 0 2014-07-21 09:49 Protobuf-master\examples\
文件 2975 2014-07-21 09:49 Protobuf-master\examples\AddPerson.java
文件 1604 2014-07-21 09:49 Protobuf-master\examples\ListPeople.java
文件 2299 2014-07-21 09:49 Protobuf-master\examples\Makefile
文件 1519 2014-07-21 09:49 Protobuf-master\examples\README.txt
文件 2617 2014-07-21 09:49 Protobuf-master\examples\add_person.cc
文件 1656 2014-07-21 09:49 Protobuf-master\examples\add_person.py
文件 637 2014-07-21 09:49 Protobuf-master\examples\addressbook.proto
文件 1977 2014-07-21 09:49 Protobuf-master\examples\list_people.cc
文件 1135 2014-07-21 09:49 Protobuf-master\examples\list_people.py
文件 1105 2014-07-21 09:49 Protobuf-master\generate_desc
............此处省略622个文件信息
相关资源
- protobuf-cpp-3.2.0.tar.gz
- stm32移植protobufnanopb-0.3.8-windows-x86操作
- NetDemo.unitypackage
- protobuf3在vs2005中的使用
- unity-protobuf3
- protobuf vs版本
- protobuf3-layaair_AS3-master
- Unity + Socket + Protobuff+异步+粘包拆包断
- protobuf-2.6.1.tar.gz
- google protobuf 中文翻译
- 最新的 libprotobuf.lib、libprotoc.lib和pr
- protobuf-cpp-3.1.0.tar.gz 下载192823
- protobuf-cpp-3.1.0.tar.gz 配置文件
- ProtobufTool_Rect
- protobuf/thrift/avro-序列化性能测试工程
-
typesc
ript.zip - protobuf-2.6.0以及protoc.exe
- protobuf解析查看工具.zip
- Protobuf.Syntax.Hightlighting.v2.0.0.sublime-p
- 已废弃资源,demo不必,描述中有解决
- protoc-gen-lua protobuf
- 集成Protobuffer3到ToLua
- protobuf-2.4.1.tar.gz
- 将protobuf移植到32位单片机.pdf
- protobuf-dt
- Google的protobuf,可以安装
- protobuf-decoder-master.zip
- protoc3.5protobuf3;.5
- protobuf-net的代码生成工具ProtoGen
- protobuf-wireshark测试消息
评论
共有 条评论