Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Private Attributes | Static Private Attributes | List of all members
google.protobuf.descriptor.FieldDescriptor Class Reference
Inheritance diagram for google.protobuf.descriptor.FieldDescriptor:
Inheritance graph
[legend]

Public Member Functions

def __init__ (self, name, full_name, index, number, type, cpp_type, label, default_value, message_type, enum_type, containing_type, is_extension, extension_scope, options=None, serialized_options=None, has_default_value=True, containing_oneof=None, json_name=None, file=None)
 
def __init__ (self, name, full_name, index, number, type, cpp_type, label, default_value, message_type, enum_type, containing_type, is_extension, extension_scope, options=None, serialized_options=None, has_default_value=True, containing_oneof=None, json_name=None, file=None, create_key=None)
 
def __new__ (cls, name, full_name, index, number, type, cpp_type, label, default_value, message_type, enum_type, containing_type, is_extension, extension_scope, options=None, serialized_options=None, has_default_value=True, containing_oneof=None, json_name=None, file=None)
 
def __new__ (cls, name, full_name, index, number, type, cpp_type, label, default_value, message_type, enum_type, containing_type, is_extension, extension_scope, options=None, serialized_options=None, has_default_value=True, containing_oneof=None, json_name=None, file=None, create_key=None)
 
def camelcase_name (self)
 
def camelcase_name (self)
 
- Public Member Functions inherited from google.protobuf.descriptor.DescriptorBase
def __init__ (self, options, serialized_options, options_class_name)
 
def __init__ (self, options, serialized_options, options_class_name)
 
def GetOptions (self)
 
def GetOptions (self)
 
- Public Member Functions inherited from google.protobuf.descriptor.DescriptorMetaclass
def __instancecheck__ (cls, obj)
 
def __instancecheck__ (cls, obj)
 

Static Public Member Functions

def ProtoTypeToCppProtoType (proto_type)
 
def ProtoTypeToCppProtoType (proto_type)
 

Public Attributes

 containing_oneof
 
 containing_type
 
 cpp_type
 
 default_value
 
 enum_type
 
 extension_scope
 
 file
 
 full_name
 
 has_default_value
 
 index
 
 is_extension
 
 json_name
 
 label
 
 message_type
 
 name
 
 number
 
 type
 
- Public Attributes inherited from google.protobuf.descriptor.DescriptorBase
 has_options
 

Static Public Attributes

int CPPTYPE_BOOL = 7
 
int CPPTYPE_DOUBLE = 5
 
int CPPTYPE_ENUM = 8
 
int CPPTYPE_FLOAT = 6
 
int CPPTYPE_INT32 = 1
 
int CPPTYPE_INT64 = 2
 
int CPPTYPE_MESSAGE = 10
 
int CPPTYPE_STRING = 9
 
int CPPTYPE_UINT32 = 3
 
int CPPTYPE_UINT64 = 4
 
int FIRST_RESERVED_FIELD_NUMBER = 19000
 
int LABEL_OPTIONAL = 1
 
int LABEL_REPEATED = 3
 
int LABEL_REQUIRED = 2
 
int LAST_RESERVED_FIELD_NUMBER = 19999
 
int MAX_CPPTYPE = 10
 
tuple MAX_FIELD_NUMBER = (1 << 29) - 1
 
int MAX_LABEL = 3
 
int MAX_TYPE = 18
 
int TYPE_BOOL = 8
 
int TYPE_BYTES = 12
 
int TYPE_DOUBLE = 1
 
int TYPE_ENUM = 14
 
int TYPE_FIXED32 = 7
 
int TYPE_FIXED64 = 6
 
int TYPE_FLOAT = 2
 
int TYPE_GROUP = 10
 
int TYPE_INT32 = 5
 
int TYPE_INT64 = 3
 
int TYPE_MESSAGE = 11
 
int TYPE_SFIXED32 = 15
 
int TYPE_SFIXED64 = 16
 
int TYPE_SINT32 = 17
 
int TYPE_SINT64 = 18
 
int TYPE_STRING = 9
 
int TYPE_UINT32 = 13
 
int TYPE_UINT64 = 4
 

Private Attributes

 _camelcase_name
 
 _cdescriptor
 

Static Private Attributes

 _C_DESCRIPTOR_CLASS = _message.FieldDescriptor
 
dictionary _PYTHON_TO_CPP_PROTO_TYPE_MAP
 

Detailed Description

Descriptor for a single field in a .proto file.

A FieldDescriptor instance has the following attributes:

  name: (str) Name of this field, exactly as it appears in .proto.
  full_name: (str) Name of this field, including containing scope.  This is
    particularly relevant for extensions.
  camelcase_name: (str) Camelcase name of this field.
  index: (int) Dense, 0-indexed index giving the order that this
    field textually appears within its message in the .proto file.
  number: (int) Tag number declared for this field in the .proto file.

  type: (One of the TYPE_* constants below) Declared type.
  cpp_type: (One of the CPPTYPE_* constants below) C++ type used to
    represent this field.

  label: (One of the LABEL_* constants below) Tells whether this
    field is optional, required, or repeated.
  has_default_value: (bool) True if this field has a default value defined,
    otherwise false.
  default_value: (Varies) Default value of this field.  Only
    meaningful for non-repeated scalar fields.  Repeated fields
    should always set this to [], and non-repeated composite
    fields should always set this to None.

  containing_type: (Descriptor) Descriptor of the protocol message
    type that contains this field.  Set by the Descriptor constructor
    if we're passed into one.
    Somewhat confusingly, for extension fields, this is the
    descriptor of the EXTENDED message, not the descriptor
    of the message containing this field.  (See is_extension and
    extension_scope below).
  message_type: (Descriptor) If a composite field, a descriptor
    of the message type contained in this field.  Otherwise, this is None.
  enum_type: (EnumDescriptor) If this field contains an enum, a
    descriptor of that enum.  Otherwise, this is None.

  is_extension: True iff this describes an extension field.
  extension_scope: (Descriptor) Only meaningful if is_extension is True.
    Gives the message that immediately contains this extension field.
    Will be None iff we're a top-level (file-level) extension field.

  options: (descriptor_pb2.FieldOptions) Protocol message field options or
    None to use default field options.

  containing_oneof: (OneofDescriptor) If the field is a member of a oneof
    union, contains its descriptor. Otherwise, None.

  file: (FileDescriptor) Reference to file descriptor.
Descriptor for a single field in a .proto file.

Attributes:
  name (str): Name of this field, exactly as it appears in .proto.
  full_name (str): Name of this field, including containing scope.  This is
    particularly relevant for extensions.
  index (int): Dense, 0-indexed index giving the order that this
    field textually appears within its message in the .proto file.
  number (int): Tag number declared for this field in the .proto file.

  type (int): (One of the TYPE_* constants below) Declared type.
  cpp_type (int): (One of the CPPTYPE_* constants below) C++ type used to
    represent this field.

  label (int): (One of the LABEL_* constants below) Tells whether this
    field is optional, required, or repeated.
  has_default_value (bool): True if this field has a default value defined,
    otherwise false.
  default_value (Varies): Default value of this field.  Only
    meaningful for non-repeated scalar fields.  Repeated fields
    should always set this to [], and non-repeated composite
    fields should always set this to None.

  containing_type (Descriptor): Descriptor of the protocol message
    type that contains this field.  Set by the Descriptor constructor
    if we're passed into one.
    Somewhat confusingly, for extension fields, this is the
    descriptor of the EXTENDED message, not the descriptor
    of the message containing this field.  (See is_extension and
    extension_scope below).
  message_type (Descriptor): If a composite field, a descriptor
    of the message type contained in this field.  Otherwise, this is None.
  enum_type (EnumDescriptor): If this field contains an enum, a
    descriptor of that enum.  Otherwise, this is None.

  is_extension: True iff this describes an extension field.
  extension_scope (Descriptor): Only meaningful if is_extension is True.
    Gives the message that immediately contains this extension field.
    Will be None iff we're a top-level (file-level) extension field.

  options (descriptor_pb2.FieldOptions): Protocol message field options or
    None to use default field options.

  containing_oneof (OneofDescriptor): If the field is a member of a oneof
    union, contains its descriptor. Otherwise, None.

  file (FileDescriptor): Reference to file descriptor.

Definition at line 392 of file bloaty/third_party/protobuf/python/google/protobuf/descriptor.py.

Constructor & Destructor Documentation

◆ __init__() [1/2]

def google.protobuf.descriptor.FieldDescriptor.__init__ (   self,
  name,
  full_name,
  index,
  number,
  type,
  cpp_type,
  label,
  default_value,
  message_type,
  enum_type,
  containing_type,
  is_extension,
  extension_scope,
  options = None,
  serialized_options = None,
  has_default_value = True,
  containing_oneof = None,
  json_name = None,
  file = None 
)
The arguments are as described in the description of FieldDescriptor
attributes above.

Note that containing_type may be None, and may be set later if necessary
(to deal with circular references between message types, for example).
Likewise for extension_scope.

Definition at line 536 of file bloaty/third_party/protobuf/python/google/protobuf/descriptor.py.

◆ __init__() [2/2]

def google.protobuf.descriptor.FieldDescriptor.__init__ (   self,
  name,
  full_name,
  index,
  number,
  type,
  cpp_type,
  label,
  default_value,
  message_type,
  enum_type,
  containing_type,
  is_extension,
  extension_scope,
  options = None,
  serialized_options = None,
  has_default_value = True,
  containing_oneof = None,
  json_name = None,
  file = None,
  create_key = None 
)
The arguments are as described in the description of FieldDescriptor
attributes above.

Note that containing_type may be None, and may be set later if necessary
(to deal with circular references between message types, for example).
Likewise for extension_scope.

Definition at line 562 of file protobuf/python/google/protobuf/descriptor.py.

Member Function Documentation

◆ __new__() [1/2]

def google.protobuf.descriptor.FieldDescriptor.__new__ (   cls,
  name,
  full_name,
  index,
  number,
  type,
  cpp_type,
  label,
  default_value,
  message_type,
  enum_type,
  containing_type,
  is_extension,
  extension_scope,
  options = None,
  serialized_options = None,
  has_default_value = True,
  containing_oneof = None,
  json_name = None,
  file = None 
)

◆ __new__() [2/2]

def google.protobuf.descriptor.FieldDescriptor.__new__ (   cls,
  name,
  full_name,
  index,
  number,
  type,
  cpp_type,
  label,
  default_value,
  message_type,
  enum_type,
  containing_type,
  is_extension,
  extension_scope,
  options = None,
  serialized_options = None,
  has_default_value = True,
  containing_oneof = None,
  json_name = None,
  file = None,
  create_key = None 
)

◆ camelcase_name() [1/2]

def google.protobuf.descriptor.FieldDescriptor.camelcase_name (   self)

◆ camelcase_name() [2/2]

def google.protobuf.descriptor.FieldDescriptor.camelcase_name (   self)
Camelcase name of this field.

Returns:
  str: the name in CamelCase.

Definition at line 610 of file protobuf/python/google/protobuf/descriptor.py.

◆ ProtoTypeToCppProtoType() [1/2]

def google.protobuf.descriptor.FieldDescriptor.ProtoTypeToCppProtoType (   proto_type)
static
Converts from a Python proto type to a C++ Proto Type.

The Python ProtocolBuffer classes specify both the 'Python' datatype and the
'C++' datatype - and they're not the same. This helper method should
translate from one to another.

Args:
  proto_type: the Python proto type (descriptor.FieldDescriptor.TYPE_*)
Returns:
  descriptor.FieldDescriptor.CPPTYPE_*, the C++ type.
Raises:
  TypeTransformationError: when the Python proto type isn't known.

Definition at line 587 of file bloaty/third_party/protobuf/python/google/protobuf/descriptor.py.

◆ ProtoTypeToCppProtoType() [2/2]

def google.protobuf.descriptor.FieldDescriptor.ProtoTypeToCppProtoType (   proto_type)
static
Converts from a Python proto type to a C++ Proto Type.

The Python ProtocolBuffer classes specify both the 'Python' datatype and the
'C++' datatype - and they're not the same. This helper method should
translate from one to another.

Args:
  proto_type: the Python proto type (descriptor.FieldDescriptor.TYPE_*)
Returns:
  int: descriptor.FieldDescriptor.CPPTYPE_*, the C++ type.
Raises:
  TypeTransformationError: when the Python proto type isn't known.

Definition at line 621 of file protobuf/python/google/protobuf/descriptor.py.

Member Data Documentation

◆ _C_DESCRIPTOR_CLASS

google.protobuf.descriptor.FieldDescriptor._C_DESCRIPTOR_CLASS = _message.FieldDescriptor
staticprivate

◆ _camelcase_name

google.protobuf.descriptor.FieldDescriptor._camelcase_name
private

◆ _cdescriptor

google.protobuf.descriptor.FieldDescriptor._cdescriptor
private

◆ _PYTHON_TO_CPP_PROTO_TYPE_MAP

dictionary FieldDescriptor._PYTHON_TO_CPP_PROTO_TYPE_MAP
staticprivate
Initial value:
= {
TYPE_DOUBLE: CPPTYPE_DOUBLE,
TYPE_FLOAT: CPPTYPE_FLOAT,
TYPE_ENUM: CPPTYPE_ENUM,
TYPE_INT64: CPPTYPE_INT64,
TYPE_SINT64: CPPTYPE_INT64,
TYPE_SFIXED64: CPPTYPE_INT64,
TYPE_UINT64: CPPTYPE_UINT64,
TYPE_FIXED64: CPPTYPE_UINT64,
TYPE_INT32: CPPTYPE_INT32,
TYPE_SFIXED32: CPPTYPE_INT32,
TYPE_SINT32: CPPTYPE_INT32,
TYPE_UINT32: CPPTYPE_UINT32,
TYPE_FIXED32: CPPTYPE_UINT32,
TYPE_BYTES: CPPTYPE_STRING,
TYPE_STRING: CPPTYPE_STRING,
TYPE_BOOL: CPPTYPE_BOOL,
TYPE_MESSAGE: CPPTYPE_MESSAGE,
TYPE_GROUP: CPPTYPE_MESSAGE
}

Definition at line 485 of file bloaty/third_party/protobuf/python/google/protobuf/descriptor.py.

◆ containing_oneof

google.protobuf.descriptor.FieldDescriptor.containing_oneof

◆ containing_type

google.protobuf.descriptor.FieldDescriptor.containing_type

◆ cpp_type

google.protobuf.descriptor.FieldDescriptor.cpp_type

◆ CPPTYPE_BOOL

int FieldDescriptor.CPPTYPE_BOOL = 7
static

◆ CPPTYPE_DOUBLE

int FieldDescriptor.CPPTYPE_DOUBLE = 5
static

◆ CPPTYPE_ENUM

int FieldDescriptor.CPPTYPE_ENUM = 8
static

◆ CPPTYPE_FLOAT

int FieldDescriptor.CPPTYPE_FLOAT = 6
static

◆ CPPTYPE_INT32

int FieldDescriptor.CPPTYPE_INT32 = 1
static

◆ CPPTYPE_INT64

int FieldDescriptor.CPPTYPE_INT64 = 2
static

◆ CPPTYPE_MESSAGE

int FieldDescriptor.CPPTYPE_MESSAGE = 10
static

◆ CPPTYPE_STRING

int FieldDescriptor.CPPTYPE_STRING = 9
static

◆ CPPTYPE_UINT32

int FieldDescriptor.CPPTYPE_UINT32 = 3
static

◆ CPPTYPE_UINT64

int FieldDescriptor.CPPTYPE_UINT64 = 4
static

◆ default_value

google.protobuf.descriptor.FieldDescriptor.default_value

◆ enum_type

google.protobuf.descriptor.FieldDescriptor.enum_type

◆ extension_scope

google.protobuf.descriptor.FieldDescriptor.extension_scope

◆ file

google.protobuf.descriptor.FieldDescriptor.file

◆ FIRST_RESERVED_FIELD_NUMBER

int FieldDescriptor.FIRST_RESERVED_FIELD_NUMBER = 19000
static

◆ full_name

google.protobuf.descriptor.FieldDescriptor.full_name

◆ has_default_value

google.protobuf.descriptor.FieldDescriptor.has_default_value

◆ index

google.protobuf.descriptor.FieldDescriptor.index

◆ is_extension

google.protobuf.descriptor.FieldDescriptor.is_extension

◆ json_name

google.protobuf.descriptor.FieldDescriptor.json_name

◆ label

google.protobuf.descriptor.FieldDescriptor.label

◆ LABEL_OPTIONAL

int FieldDescriptor.LABEL_OPTIONAL = 1
static

◆ LABEL_REPEATED

int FieldDescriptor.LABEL_REPEATED = 3
static

◆ LABEL_REQUIRED

int FieldDescriptor.LABEL_REQUIRED = 2
static

◆ LAST_RESERVED_FIELD_NUMBER

int FieldDescriptor.LAST_RESERVED_FIELD_NUMBER = 19999
static

◆ MAX_CPPTYPE

int FieldDescriptor.MAX_CPPTYPE = 10
static

◆ MAX_FIELD_NUMBER

tuple FieldDescriptor.MAX_FIELD_NUMBER = (1 << 29) - 1
static

◆ MAX_LABEL

int FieldDescriptor.MAX_LABEL = 3
static

◆ MAX_TYPE

int FieldDescriptor.MAX_TYPE = 18
static

◆ message_type

google.protobuf.descriptor.FieldDescriptor.message_type

◆ name

google.protobuf.descriptor.FieldDescriptor.name

◆ number

google.protobuf.descriptor.FieldDescriptor.number

◆ type

google.protobuf.descriptor.FieldDescriptor.type

◆ TYPE_BOOL

int FieldDescriptor.TYPE_BOOL = 8
static

◆ TYPE_BYTES

int FieldDescriptor.TYPE_BYTES = 12
static

◆ TYPE_DOUBLE

int FieldDescriptor.TYPE_DOUBLE = 1
static

◆ TYPE_ENUM

int FieldDescriptor.TYPE_ENUM = 14
static

◆ TYPE_FIXED32

int FieldDescriptor.TYPE_FIXED32 = 7
static

◆ TYPE_FIXED64

int FieldDescriptor.TYPE_FIXED64 = 6
static

◆ TYPE_FLOAT

int FieldDescriptor.TYPE_FLOAT = 2
static

◆ TYPE_GROUP

int FieldDescriptor.TYPE_GROUP = 10
static

◆ TYPE_INT32

int FieldDescriptor.TYPE_INT32 = 5
static

◆ TYPE_INT64

int FieldDescriptor.TYPE_INT64 = 3
static

◆ TYPE_MESSAGE

int FieldDescriptor.TYPE_MESSAGE = 11
static

◆ TYPE_SFIXED32

int FieldDescriptor.TYPE_SFIXED32 = 15
static

◆ TYPE_SFIXED64

int FieldDescriptor.TYPE_SFIXED64 = 16
static

◆ TYPE_SINT32

int FieldDescriptor.TYPE_SINT32 = 17
static

◆ TYPE_SINT64

int FieldDescriptor.TYPE_SINT64 = 18
static

◆ TYPE_STRING

int FieldDescriptor.TYPE_STRING = 9
static

◆ TYPE_UINT32

int FieldDescriptor.TYPE_UINT32 = 13
static

◆ TYPE_UINT64

int FieldDescriptor.TYPE_UINT64 = 4
static

The documentation for this class was generated from the following file:


grpc
Author(s):
autogenerated on Fri May 16 2025 03:03:23