Home | History | Annotate | Download | only in protobuf
      1 // Protocol Buffers - Google's data interchange format
      2 // Copyright 2008 Google Inc.  All rights reserved.
      3 // https://developers.google.com/protocol-buffers/
      4 //
      5 // Redistribution and use in source and binary forms, with or without
      6 // modification, are permitted provided that the following conditions are
      7 // met:
      8 //
      9 //     * Redistributions of source code must retain the above copyright
     10 // notice, this list of conditions and the following disclaimer.
     11 //     * Redistributions in binary form must reproduce the above
     12 // copyright notice, this list of conditions and the following disclaimer
     13 // in the documentation and/or other materials provided with the
     14 // distribution.
     15 //     * Neither the name of Google Inc. nor the names of its
     16 // contributors may be used to endorse or promote products derived from
     17 // this software without specific prior written permission.
     18 //
     19 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     20 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     21 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
     22 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
     23 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
     24 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
     25 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     26 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     27 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     28 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
     29 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     30 
     31 syntax = "proto3";
     32 
     33 package google.protobuf;
     34 
     35 import "google/protobuf/any.proto";
     36 import "google/protobuf/source_context.proto";
     37 
     38 option csharp_namespace = "Google.Protobuf.WellKnownTypes";
     39 option java_package = "com.google.protobuf";
     40 option java_outer_classname = "TypeProto";
     41 option java_multiple_files = true;
     42 option java_generate_equals_and_hash = true;
     43 option objc_class_prefix = "GPB";
     44 
     45 // A protocol buffer message type.
     46 message Type {
     47   // The fully qualified message name.
     48   string name = 1;
     49   // The list of fields.
     50   repeated Field fields = 2;
     51   // The list of types appearing in `oneof` definitions in this type.
     52   repeated string oneofs = 3;
     53   // The protocol buffer options.
     54   repeated Option options = 4;
     55   // The source context.
     56   SourceContext source_context = 5;
     57   // The source syntax.
     58   Syntax syntax = 6;
     59 }
     60 
     61 // A single field of a message type.
     62 message Field {
     63   // Basic field types.
     64   enum Kind {
     65     // Field type unknown.
     66     TYPE_UNKNOWN        = 0;
     67     // Field type double.
     68     TYPE_DOUBLE         = 1;
     69     // Field type float.
     70     TYPE_FLOAT          = 2;
     71     // Field type int64.
     72     TYPE_INT64          = 3;
     73     // Field type uint64.
     74     TYPE_UINT64         = 4;
     75     // Field type int32.
     76     TYPE_INT32          = 5;
     77     // Field type fixed64.
     78     TYPE_FIXED64        = 6;
     79     // Field type fixed32.
     80     TYPE_FIXED32        = 7;
     81     // Field type bool.
     82     TYPE_BOOL           = 8;
     83     // Field type string.
     84     TYPE_STRING         = 9;
     85     // Field type group. Proto2 syntax only, and deprecated.
     86     TYPE_GROUP          = 10;
     87     // Field type message.
     88     TYPE_MESSAGE        = 11;
     89     // Field type bytes.
     90     TYPE_BYTES          = 12;
     91     // Field type uint32.
     92     TYPE_UINT32         = 13;
     93     // Field type enum.
     94     TYPE_ENUM           = 14;
     95     // Field type sfixed32.
     96     TYPE_SFIXED32       = 15;
     97     // Field type sfixed64.
     98     TYPE_SFIXED64       = 16;
     99     // Field type sint32.
    100     TYPE_SINT32         = 17;
    101     // Field type sint64.
    102     TYPE_SINT64         = 18;
    103   };
    104 
    105   // Whether a field is optional, required, or repeated.
    106   enum Cardinality {
    107     // For fields with unknown cardinality.
    108     CARDINALITY_UNKNOWN = 0;
    109     // For optional fields.
    110     CARDINALITY_OPTIONAL = 1;
    111     // For required fields. Proto2 syntax only.
    112     CARDINALITY_REQUIRED = 2;
    113     // For repeated fields.
    114     CARDINALITY_REPEATED = 3;
    115   };
    116 
    117   // The field type.
    118   Kind kind = 1;
    119   // The field cardinality.
    120   Cardinality cardinality = 2;
    121   // The field number.
    122   int32 number = 3;
    123   // The field name.
    124   string name = 4;
    125   // The field type URL, without the scheme, for message or enumeration
    126   // types. Example: `"type.googleapis.com/google.protobuf.Timestamp"`.
    127   string type_url = 6;
    128   // The index of the field type in `Type.oneofs`, for message or enumeration
    129   // types. The first type has index 1; zero means the type is not in the list.
    130   int32 oneof_index = 7;
    131   // Whether to use alternative packed wire representation.
    132   bool packed = 8;
    133   // The protocol buffer options.
    134   repeated Option options = 9;
    135   // The field JSON name.
    136   string json_name = 10;
    137   // The string value of the default value of this field. Proto2 syntax only.
    138   string default_value = 11;
    139 }
    140 
    141 // Enum type definition.
    142 message Enum {
    143   // Enum type name.
    144   string name = 1;
    145   // Enum value definitions.
    146   repeated EnumValue enumvalue = 2;
    147   // Protocol buffer options.
    148   repeated Option options = 3;
    149   // The source context.
    150   SourceContext source_context = 4;
    151   // The source syntax.
    152   Syntax syntax = 5;
    153 }
    154 
    155 // Enum value definition.
    156 message EnumValue {
    157   // Enum value name.
    158   string name = 1;
    159   // Enum value number.
    160   int32 number = 2;
    161   // Protocol buffer options.
    162   repeated Option options = 3;
    163 }
    164 
    165 // A protocol buffer option, which can be attached to a message, field,
    166 // enumeration, etc.
    167 message Option {
    168   // The option's name. For example, `"java_package"`.
    169   string name = 1;
    170   // The option's value. For example, `"com.google.protobuf"`.
    171   Any value = 2;
    172 }
    173 
    174 // The syntax in which a protocol buffer element is defined.
    175 enum Syntax {
    176   // Syntax `proto2`.
    177   SYNTAX_PROTO2 = 0;
    178   // Syntax `proto3`.
    179   SYNTAX_PROTO3 = 1;
    180 }
    181