On Github Scooletz / Protoz
message Presentation {
required string author = 1;
required string topic = 2;
optional int32 attendees_count = 3 [default = 1]; // no of real attendees
optional int32 attendees_registered = 4; // no of registered attendees
repeated string tag = 5;
}
message Presentation {
required string author = 1;
required string topic = 2;
optional int32 attendees_count = 3 [default = 1]; // no of real attendees
optional int32 attendees_registered = 4; // no of registered attendees
repeated string tags = 5;
}
message Presentation {
required string author = 1;
required string topic = 2;
optional int32 attendees_count = 3; // no of real attendees
optional int32 attendees_registered = 4; // no of registered attendees
repeated string tags = 5;
}
.proto file can contain more than one message type
message Presentation {
required string author = 1;
required string topic = 2;
optional int32 attendees_count = 3; // no of real attendees
optional int32 attendees_registered = 4; // no of registered attendees
repeated string tags = 5;
}
message Author {
required string name = 1;
repeated string tags = 2;
}
a type declared can be used later
message Presentation {
required Author author = 1; // this isn't compatible with earlier version!
required string topic = 2;
optional int32 attendees_count = 3; // no of real attendees
optional int32 attendees_registered = 4; // no of registered attendees
repeated string tags = 5;
}
message Author {
required string name = 1;
repeated string tags = 2;
}
one can nest types to provide a scope/namespaces of messages
message Presentation {
message Author {
required string name = 1;
repeated string tags = 2;
}
required Author author = 1; // this isn't compatible with earlier version!
required string topic = 2;
optional int32 attendees_count = 3; // no of real attendees
optional int32 attendees_registered = 4; // no of registered attendees
repeated string tags = 5;
}
enum PresentationLevel {
option allow_alias = true;
EASY = 100;
MEDIUM = 200;
EXPERT = 300;
HARDCORE = 300; // alias, allowed by option above
}
some tools doesn't require to define extensions, but the standard does
message Presentation {
// ...
extensions 50 to 100;
}
extend Presentation {
optional string address = 51;
}
it's quite common to define a bag for your fields, to simplify future version changes
message Presentation {
// ...
extensions 50 to 100;
}
message Address {
extend Presentation {
optional Address address = 51;
}
optional string street = 1;
optional string city = 2;
}
package WGNET;
message Presentation {
// ...
extensions 50 to 100;
}
message Address {
extend Presentation {
optional Address address = 51;
}
optional string street = 1;
optional string city = 2;
}