protobuf 2.5.0


protobuf-2.5.0版本c++, 亲测可以编译, 给需要的小伙伴
资源截图
代码片段和文件信息
// 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();
    }
  }
}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件      36976  2013-02-27 02:04  protobuf-2.5.0aclocal.m4

     文件       1519  2013-02-27 01:56  protobuf-2.5.0autogen.sh

     文件      25840  2013-02-27 02:12  protobuf-2.5.0CHANGES.txt

     文件      44826  2013-02-27 02:04  protobuf-2.5.0config.guess

     文件       3709  2013-02-27 02:04  protobuf-2.5.0config.h.in

     文件      35454  2013-02-27 02:04  protobuf-2.5.0config.sub

     文件     599150  2013-02-27 02:04  protobuf-2.5.0configure

     文件       4829  2013-02-27 01:58  protobuf-2.5.0configure.ac

     文件       3617  2013-02-27 02:12  protobuf-2.5.0CONTRIBUTORS.txt

     文件       1765  2013-02-27 02:12  protobuf-2.5.0COPYING.txt

     文件      20334  2013-02-27 02:04  protobuf-2.5.0depcomp

     文件       3731  2013-02-27 01:56  protobuf-2.5.0editorsproto.vim

     文件       7798  2013-02-27 01:56  protobuf-2.5.0editorsprotobuf-mode.el

     文件        221  2013-02-27 02:12  protobuf-2.5.0editorsREADME.txt

     文件       2975  2013-02-27 01:56  protobuf-2.5.0examplesAddPerson.java

     文件        637  2013-02-27 01:56  protobuf-2.5.0examplesaddressbook.proto

     文件       2617  2013-02-27 01:56  protobuf-2.5.0examplesadd_person.cc

     文件       1656  2013-02-27 01:56  protobuf-2.5.0examplesadd_person.py

     文件       1604  2013-02-27 01:56  protobuf-2.5.0examplesListPeople.java

     文件       1977  2013-02-27 01:56  protobuf-2.5.0exampleslist_people.cc

     文件       1135  2013-02-27 01:56  protobuf-2.5.0exampleslist_people.py

     文件       2299  2013-02-27 01:56  protobuf-2.5.0examplesMakefile

     文件       1548  2013-02-27 02:12  protobuf-2.5.0examplesREADME.txt

     文件       1105  2013-02-27 01:56  protobuf-2.5.0generate_descriptor_proto.sh

     文件      43769  2013-02-27 02:04  protobuf-2.5.0gtestaclocal.m4

     文件      44826  2013-02-27 02:04  protobuf-2.5.0gtestuild-auxconfig.guess

     文件       1841  2013-02-27 02:04  protobuf-2.5.0gtestuild-auxconfig.h.in

     文件      35454  2013-02-27 02:04  protobuf-2.5.0gtestuild-auxconfig.sub

     文件      20334  2013-02-27 02:04  protobuf-2.5.0gtestuild-auxdepcomp

     文件      13998  2013-02-27 02:04  protobuf-2.5.0gtestuild-auxinstall-sh

............此处省略924个文件信息

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件举报,一经查实,本站将立刻删除。

发表评论

评论列表(条)