summaryrefslogtreecommitdiff
path: root/example/fruit.proto
blob: b119652cb629c0e4ae3c6a0a255361de5f18e670 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
syntax = "proto3";

// this file is called "fruit.proto"
//
// for autogenpb to work, you must have:
//
// "Fruit" must exist. you can put anything in it
//
// and
//
// "Fruits"  MUST EXIST and start exactly this way
// It must be "Fruit" + 's' and must match the name of this file: "fruit.proto"

package main;

import "google/protobuf/timestamp.proto"; // Import the well-known type for Timestamp

message Apple {
	string name                     = 1;    // `autogenpb:unique` // generates SortByxxx() and AppendUnique() functions
	string genus                    = 2;    // `autogenpb:unique` // generates same thing here but SortByGenus()
        google.protobuf.Timestamp ctime = 3;    // when the apple was born
}

message Apples {
	string name                     = 1;    // `autogenpb:unique` // generates SortByxxx() and AppendUnique() functions
	string genus                    = 2;    // `autogenpb:unique` // generates same thing here but SortByGenus()
        repeated Apple  apples          = 3;
}

message Pear {                        // `autogenpb:nomutex`
	string   name	        = 1;    // `autogenpb:sort`
	string   favorite       = 2;    // `autogenpb:sort` `autogenpb:unique`
}

message Pears {                        // `autogenpb:nomutex`
	string   name	        = 1;    // `autogenpb:sort`
	string   favorite       = 2;    // `autogenpb:sort` `autogenpb:unique`
        repeated Pear  pears    = 3;
}

message Banana {                        // `autogenpb:nomutex`
	repeated string   name  = 1;    // `autogenpb:sort`
	string   favorite       = 2;    // `autogenpb:sort` `autogenpb:unique`
	string   country        = 3;    // `autogenpb:sort`
}

message Basket {                        // `autogenpb:nomutex`
	repeated string   name  = 1;    // `autogenpb:sort` `autogenpb:unique`
	string   favorite       = 2;    // `autogenpb:sort` `autogenpb:unique`
	int64    price          = 3;    // `autogenpb:sort`
        repeated Banana banna   = 4;
        repeated Pear   pears   = 5;
        repeated Apple  stacks  = 6;
}

// "Fruit" must exist. you can put anything in it
message Fruit {
        string brand            = 1;    // `autogenpb:unique` `autogenpb:sort`
        Apple apples            = 2;
        repeated Pear  pears    = 3;
        string UPC              = 4;    // `autogenpb:sort` `autogenpb:unique`
        string city             = 5;    // `autogenpb:sort`
        Pears notpears          = 6;
        Pears fakepears         = 7;
        repeated Basket  gifts  = 8;
}

// "Fruits"  MUST EXIST and start exactly this way
// It must be "Fruit" + 's' and must match the name of this file: "fruit.proto"
message Fruits {	        	// `autogenpb:marshal` `autogenpb:mutex`
	string   uuid	        = 1;    // `autogenpb:uuid:be926ad9-f07f-484c-adf2-d96eeabf3079`
	string   version        = 2;    // `autogenpb:version:v0.0.1`
	repeated Fruit Fruits   = 3;    // THIS MUST BE "Fruit" and then "Fruit" + "s"
        // you can add additional things here but the three lines above must conform to the standard above
        int64    cost           = 4;
        map<string, string> junk = 5;
}