Git Product home page Git Product logo

protobuf_use's Introduction

Protobuf_use

google protobuf的使用

1、什么是protobuf protobuf是灵活的,高效的,自动序列化结构化数据。类似XML,但是却更小更快更简单。你只需要定义一次数据结构然后你可以使用特定生成的源代码去很容易的写和读你的结构化数据,这些结构化数据来自各种各样的语言和各种各样的数据流。您甚至可以在不破坏已部署的程序的情况下更新数据结构,这些程序是根据“旧”格式编译的。

2、如何使用 通过在.proto文件中定义协议缓冲区消息类型,可以指定要序列化的信息的结构。每个协议缓冲区message都是一个小的信息逻辑记录,包含一系列名称-值对,下面是.proto最基本的示例,它定义包含了关于一个人的个人信息:

// ......................................................第一个.proto文件....................................................... message Person { required string name = 1; required int32 id = 2; optional string email = 3;

enum PhoneType { MOBILE = 0; HOME = 1; WORK = 2; } message PhoneNumber { required string number = 1; optional PhoneType type = 2 [default = HOME]; }

repeated PhoneNumber phone = 4;

// 表示扩展,如果其他的protobuf文件中import "xx/xx.proto";则可以扩展Preson字段,请看第二个文件 extensions 100 to 199; }

// ......................................................第二个.proto文件....................................................... import "第一个文件.proto"

extend Person { optional int32 age = 126; }

protobuf_use's People

Contributors

kaiwenk avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.