temporal | 40ee551 | 2008-07-10 02:12:20 +0000 | [diff] [blame] | 1 | // See README.txt for information and build instructions. |
Tim Swast | bc47234 | 2015-12-01 17:07:18 -0800 | [diff] [blame] | 2 | // |
| 3 | // Note: START and END tags are used in comments to define sections used in |
| 4 | // tutorials. They are not part of the syntax for Protocol Buffers. |
| 5 | // |
| 6 | // To get an in-depth walkthrough of this file and the related examples, see: |
| 7 | // https://developers.google.com/protocol-buffers/docs/tutorials |
temporal | 40ee551 | 2008-07-10 02:12:20 +0000 | [diff] [blame] | 8 | |
Tim Swast | bc47234 | 2015-12-01 17:07:18 -0800 | [diff] [blame] | 9 | // [START declaration] |
Jan Tattermusch | 69c1407 | 2015-07-20 14:32:57 -0700 | [diff] [blame] | 10 | syntax = "proto3"; |
temporal | 40ee551 | 2008-07-10 02:12:20 +0000 | [diff] [blame] | 11 | package tutorial; |
Tim Swast | bc47234 | 2015-12-01 17:07:18 -0800 | [diff] [blame] | 12 | // [END declaration] |
temporal | 40ee551 | 2008-07-10 02:12:20 +0000 | [diff] [blame] | 13 | |
Tim Swast | bc47234 | 2015-12-01 17:07:18 -0800 | [diff] [blame] | 14 | // [START java_declaration] |
temporal | 40ee551 | 2008-07-10 02:12:20 +0000 | [diff] [blame] | 15 | option java_package = "com.example.tutorial"; |
| 16 | option java_outer_classname = "AddressBookProtos"; |
Tim Swast | bc47234 | 2015-12-01 17:07:18 -0800 | [diff] [blame] | 17 | // [END java_declaration] |
temporal | 40ee551 | 2008-07-10 02:12:20 +0000 | [diff] [blame] | 18 | |
Tim Swast | bc47234 | 2015-12-01 17:07:18 -0800 | [diff] [blame] | 19 | // [START csharp_declaration] |
| 20 | option csharp_namespace = "Google.Protobuf.Examples.AddressBook"; |
| 21 | // [END csharp_declaration] |
| 22 | |
| 23 | // [START messages] |
temporal | 40ee551 | 2008-07-10 02:12:20 +0000 | [diff] [blame] | 24 | message Person { |
Jan Tattermusch | 69c1407 | 2015-07-20 14:32:57 -0700 | [diff] [blame] | 25 | string name = 1; |
Tim Swast | bc47234 | 2015-12-01 17:07:18 -0800 | [diff] [blame] | 26 | int32 id = 2; // Unique ID number for this person. |
Jan Tattermusch | 69c1407 | 2015-07-20 14:32:57 -0700 | [diff] [blame] | 27 | string email = 3; |
temporal | 40ee551 | 2008-07-10 02:12:20 +0000 | [diff] [blame] | 28 | |
| 29 | enum PhoneType { |
| 30 | MOBILE = 0; |
| 31 | HOME = 1; |
| 32 | WORK = 2; |
| 33 | } |
| 34 | |
| 35 | message PhoneNumber { |
Jan Tattermusch | 69c1407 | 2015-07-20 14:32:57 -0700 | [diff] [blame] | 36 | string number = 1; |
| 37 | PhoneType type = 2; |
temporal | 40ee551 | 2008-07-10 02:12:20 +0000 | [diff] [blame] | 38 | } |
| 39 | |
Jan Tattermusch | 69c1407 | 2015-07-20 14:32:57 -0700 | [diff] [blame] | 40 | repeated PhoneNumber phones = 4; |
temporal | 40ee551 | 2008-07-10 02:12:20 +0000 | [diff] [blame] | 41 | } |
| 42 | |
| 43 | // Our address book file is just one of these. |
| 44 | message AddressBook { |
Jan Tattermusch | b0e5ba6 | 2015-07-20 15:24:08 -0700 | [diff] [blame] | 45 | repeated Person people = 1; |
temporal | 40ee551 | 2008-07-10 02:12:20 +0000 | [diff] [blame] | 46 | } |
Tim Swast | bc47234 | 2015-12-01 17:07:18 -0800 | [diff] [blame] | 47 | // [END messages] |