Reference documentation and code samples for the proto library Client class FieldOptions.
Generated from protobuf message google.protobuf.FieldOptions
Namespace
Google \ Protobuf \ InternalMethods
__construct
Constructor.
| Parameters | |
|---|---|
| Name | Description |
data |
array
Optional. Data for populating the Message object. |
↳ ctype |
int
NOTE: ctype is deprecated. Use |
↳ packed |
bool
The packed option can be enabled for repeated primitive fields to enable a more efficient representation on the wire. Rather than repeatedly writing the tag and type for each element, the entire array is encoded as a single length-delimited blob. In proto3, only explicit setting it to false will avoid using packed encoding. This option is prohibited in Editions, but the |
↳ jstype |
int
The jstype option determines the JavaScript type used for values of the field. The option is permitted only for 64 bit integral and fixed types (int64, uint64, sint64, fixed64, sfixed64). A field with jstype JS_STRING is represented as JavaScript string, which avoids loss of precision that can happen when a large value is converted to a floating point JavaScript. Specifying JS_NUMBER for the jstype causes the generated JavaScript code to use the JavaScript "number" type. The behavior of the default option JS_NORMAL is implementation dependent. This option is an enum to permit additional types to be added, e.g. goog.math.Integer. |
↳ lazy |
bool
Should this field be parsed lazily? Lazy applies only to message-type fields. It means that when the outer message is initially parsed, the inner message's contents will not be parsed but instead stored in encoded form. The inner message will actually be parsed when it is first accessed. This is only a hint. Implementations are free to choose whether to use eager or lazy parsing regardless of the value of this option. However, setting this option true suggests that the protocol author believes that using lazy parsing on this field is worth the additional bookkeeping overhead typically needed to implement it. This option does not affect the public interface of any generated code; all method signatures remain the same. Furthermore, thread-safety of the interface is not affected by this option; const methods remain safe to call from multiple threads concurrently, while non-const methods continue to require exclusive access. Note that lazy message fields are still eagerly verified to check ill-formed wireformat or missing required fields. Calling IsInitialized() on the outer message would fail if the inner message has missing required fields. Failed verification would result in parsing failure (except when uninitialized messages are acceptable). |
↳ unverified_lazy |
bool
unverified_lazy does no correctness checks on the byte stream. This should only be used where lazy with verification is prohibitive for performance reasons. |
↳ deprecated |
bool
Is this field deprecated? Depending on the target platform, this can emit Deprecated annotations for accessors, or it will be completely ignored; in the very least, this is a formalization for deprecating fields. |
↳ weak |
bool
DEPRECATED. DO NOT USE! For Google-internal migration only. Do not use. |
↳ debug_redact |
bool
Indicate that the field value should not be printed out when using debug formats, e.g. when the field contains sensitive credentials. |
↳ retention |
int
|
↳ targets |
int[]
|
↳ edition_defaults |
array<FieldOptions\EditionDefault>
|
↳ features |
FeatureSet
Any features defined in the specific edition. WARNING: This field should only be used by protobuf plugins or special cases like the proto compiler. Other uses are discouraged and developers should rely on the protoreflect APIs for their client language. |
↳ feature_support |
FieldOptions\FeatureSupport
|
↳ uninterpreted_option |
array<UninterpretedOption>
The parser stores options it doesn't recognize here. See above. |
getCtype
NOTE: ctype is deprecated. Use features.(pb.cpp).string_type instead.
The ctype option instructs the C++ code generator to use a different representation of the field than it normally would. See the specific options below. This option is only implemented to support use of [ctype=CORD] and [ctype=STRING] (the default) on non-repeated fields of type "bytes" in the open source release. TODO: make ctype actually deprecated.
| Returns | |
|---|---|
| Type | Description |
int |
one of the values in {@see \Google\Protobuf\Internal\FieldOptions\CType} |
hasCtype
clearCtype
setCtype
NOTE: ctype is deprecated. Use features.(pb.cpp).string_type instead.
The ctype option instructs the C++ code generator to use a different representation of the field than it normally would. See the specific options below. This option is only implemented to support use of [ctype=CORD] and [ctype=STRING] (the default) on non-repeated fields of type "bytes" in the open source release. TODO: make ctype actually deprecated.
| Parameter | |
|---|---|
| Name | Description |
var |
int
one of the values in FieldOptions\CType |
| Returns | |
|---|---|
| Type | Description |
$this |
|
getPacked
The packed option can be enabled for repeated primitive fields to enable
a more efficient representation on the wire. Rather than repeatedly
writing the tag and type for each element, the entire array is encoded as
a single length-delimited blob. In proto3, only explicit setting it to
false will avoid using packed encoding. This option is prohibited in
Editions, but the repeated_field_encoding feature can be used to control
the behavior.
| Returns | |
|---|---|
| Type | Description |
bool |
|
hasPacked
clearPacked
setPacked
The packed option can be enabled for repeated primitive fields to enable
a more efficient representation on the wire. Rather than repeatedly
writing the tag and type for each element, the entire array is encoded as
a single length-delimited blob. In proto3, only explicit setting it to
false will avoid using packed encoding. This option is prohibited in
Editions, but the repeated_field_encoding feature can be used to control
the behavior.
| Parameter | |
|---|---|
| Name | Description |
var |
bool
|
| Returns | |
|---|---|
| Type | Description |
$this |
|
getJstype
The jstype option determines the JavaScript type used for values of the field. The option is permitted only for 64 bit integral and fixed types (int64, uint64, sint64, fixed64, sfixed64). A field with jstype JS_STRING is represented as JavaScript string, which avoids loss of precision that can happen when a large value is converted to a floating point JavaScript.
Specifying JS_NUMBER for the jstype causes the generated JavaScript code to use the JavaScript "number" type. The behavior of the default option JS_NORMAL is implementation dependent. This option is an enum to permit additional types to be added, e.g. goog.math.Integer.
| Returns | |
|---|---|
| Type | Description |
int |
one of the values in {@see \Google\Protobuf\Internal\FieldOptions\JSType} |
hasJstype
clearJstype
setJstype
The jstype option determines the JavaScript type used for values of the field. The option is permitted only for 64 bit integral and fixed types (int64, uint64, sint64, fixed64, sfixed64). A field with jstype JS_STRING is represented as JavaScript string, which avoids loss of precision that can happen when a large value is converted to a floating point JavaScript.
Specifying JS_NUMBER for the jstype causes the generated JavaScript code to use the JavaScript "number" type. The behavior of the default option JS_NORMAL is implementation dependent. This option is an enum to permit additional types to be added, e.g. goog.math.Integer.
| Parameter | |
|---|---|
| Name | Description |
var |
int
one of the values in FieldOptions\JSType |
| Returns | |
|---|---|
| Type | Description |
$this |
|
getLazy
Should this field be parsed lazily? Lazy applies only to message-type fields. It means that when the outer message is initially parsed, the inner message's contents will not be parsed but instead stored in encoded form. The inner message will actually be parsed when it is first accessed.
This is only a hint. Implementations are free to choose whether to use eager or lazy parsing regardless of the value of this option. However, setting this option true suggests that the protocol author believes that using lazy parsing on this field is worth the additional bookkeeping overhead typically needed to implement it. This option does not affect the public interface of any generated code; all method signatures remain the same. Furthermore, thread-safety of the interface is not affected by this option; const methods remain safe to call from multiple threads concurrently, while non-const methods continue to require exclusive access. Note that lazy message fields are still eagerly verified to check ill-formed wireformat or missing required fields. Calling IsInitialized() on the outer message would fail if the inner message has missing required fields. Failed verification would result in parsing failure (except when uninitialized messages are acceptable).
| Returns | |
|---|---|
| Type | Description |
bool |
|
hasLazy
clearLazy
setLazy
Should this field be parsed lazily? Lazy applies only to message-type fields. It means that when the outer message is initially parsed, the inner message's contents will not be parsed but instead stored in encoded form. The inner message will actually be parsed when it is first accessed.
This is only a hint. Implementations are free to choose whether to use eager or lazy parsing regardless of the value of this option. However, setting this option true suggests that the protocol author believes that using lazy parsing on this field is worth the additional bookkeeping overhead typically needed to implement it. This option does not affect the public interface of any generated code; all method signatures remain the same. Furthermore, thread-safety of the interface is not affected by this option; const methods remain safe to call from multiple threads concurrently, while non-const methods continue to require exclusive access. Note that lazy message fields are still eagerly verified to check ill-formed wireformat or missing required fields. Calling IsInitialized() on the outer message would fail if the inner message has missing required fields. Failed verification would result in parsing failure (except when uninitialized messages are acceptable).
| Parameter | |
|---|---|
| Name | Description |
var |
bool
|
| Returns | |
|---|---|
| Type | Description |
$this |
|
getUnverifiedLazy
unverified_lazy does no correctness checks on the byte stream. This should only be used where lazy with verification is prohibitive for performance reasons.
| Returns | |
|---|---|
| Type | Description |
bool |
|
hasUnverifiedLazy
clearUnverifiedLazy
setUnverifiedLazy
unverified_lazy does no correctness checks on the byte stream. This should only be used where lazy with verification is prohibitive for performance reasons.
| Parameter | |
|---|---|
| Name | Description |
var |
bool
|
| Returns | |
|---|---|
| Type | Description |
$this |
|
getDeprecated
Is this field deprecated? Depending on the target platform, this can emit Deprecated annotations for accessors, or it will be completely ignored; in the very least, this is a formalization for deprecating fields.
| Returns | |
|---|---|
| Type | Description |
bool |
|
hasDeprecated
clearDeprecated
setDeprecated
Is this field deprecated? Depending on the target platform, this can emit Deprecated annotations for accessors, or it will be completely ignored; in the very least, this is a formalization for deprecating fields.
| Parameter | |
|---|---|
| Name | Description |
var |
bool
|
| Returns | |
|---|---|
| Type | Description |
$this |
|
getWeak
DEPRECATED. DO NOT USE! For Google-internal migration only. Do not use.
| Returns | |
|---|---|
| Type | Description |
bool |
|
hasWeak
clearWeak
setWeak
DEPRECATED. DO NOT USE! For Google-internal migration only. Do not use.
| Parameter | |
|---|---|
| Name | Description |
var |
bool
|
| Returns | |
|---|---|
| Type | Description |
$this |
|
getDebugRedact
Indicate that the field value should not be printed out when using debug formats, e.g. when the field contains sensitive credentials.
| Returns | |
|---|---|
| Type | Description |
bool |
|
hasDebugRedact
clearDebugRedact
setDebugRedact
Indicate that the field value should not be printed out when using debug formats, e.g. when the field contains sensitive credentials.
| Parameter | |
|---|---|
| Name | Description |
var |
bool
|
| Returns | |
|---|---|
| Type | Description |
$this |
|
getRetention
Generated from protobuf field optional .google.protobuf.FieldOptions.OptionRetention retention = 17;
| Returns | |
|---|---|
| Type | Description |
int |
one of the values in {@see \Google\Protobuf\Internal\FieldOptions\OptionRetention} |
hasRetention
clearRetention
setRetention
Generated from protobuf field optional .google.protobuf.FieldOptions.OptionRetention retention = 17;
| Parameter | |
|---|---|
| Name | Description |
var |
int
one of the values in FieldOptions\OptionRetention |
| Returns | |
|---|---|
| Type | Description |
$this |
|
getTargets
Generated from protobuf field repeated .google.protobuf.FieldOptions.OptionTargetType targets = 19;
| Returns | |
|---|---|
| Type | Description |
Google\Protobuf\RepeatedField<int> |
one of the values in {@see \Google\Protobuf\Internal\FieldOptions\OptionTargetType} |
setTargets
Generated from protobuf field repeated .google.protobuf.FieldOptions.OptionTargetType targets = 19;
| Parameter | |
|---|---|
| Name | Description |
var |
int[]
one of the values in FieldOptions\OptionTargetType |
| Returns | |
|---|---|
| Type | Description |
$this |
|
getEditionDefaults
Generated from protobuf field repeated .google.protobuf.FieldOptions.EditionDefault edition_defaults = 20;
| Returns | |
|---|---|
| Type | Description |
Google\Protobuf\RepeatedField<FieldOptions\EditionDefault> |
|
setEditionDefaults
Generated from protobuf field repeated .google.protobuf.FieldOptions.EditionDefault edition_defaults = 20;
| Parameter | |
|---|---|
| Name | Description |
var |
array<FieldOptions\EditionDefault>
|
| Returns | |
|---|---|
| Type | Description |
$this |
|
getFeatures
Any features defined in the specific edition.
WARNING: This field should only be used by protobuf plugins or special cases like the proto compiler. Other uses are discouraged and developers should rely on the protoreflect APIs for their client language.
| Returns | |
|---|---|
| Type | Description |
FeatureSet|null |
|
hasFeatures
clearFeatures
setFeatures
Any features defined in the specific edition.
WARNING: This field should only be used by protobuf plugins or special cases like the proto compiler. Other uses are discouraged and developers should rely on the protoreflect APIs for their client language.
| Parameter | |
|---|---|
| Name | Description |
var |
FeatureSet
|
| Returns | |
|---|---|
| Type | Description |
$this |
|
getFeatureSupport
Generated from protobuf field optional .google.protobuf.FieldOptions.FeatureSupport feature_support = 22;
| Returns | |
|---|---|
| Type | Description |
FieldOptions\FeatureSupport|null |
|
hasFeatureSupport
clearFeatureSupport
setFeatureSupport
Generated from protobuf field optional .google.protobuf.FieldOptions.FeatureSupport feature_support = 22;
| Parameter | |
|---|---|
| Name | Description |
var |
FieldOptions\FeatureSupport
|
| Returns | |
|---|---|
| Type | Description |
$this |
|
getUninterpretedOption
The parser stores options it doesn't recognize here. See above.
| Returns | |
|---|---|
| Type | Description |
Google\Protobuf\RepeatedField<UninterpretedOption> |
|
setUninterpretedOption
The parser stores options it doesn't recognize here. See above.
| Parameter | |
|---|---|
| Name | Description |
var |
array<UninterpretedOption>
|
| Returns | |
|---|---|
| Type | Description |
$this |
|