@ -859,6 +859,10 @@ class PROTOBUF_EXPORT FieldDescriptor : private internal::SymbolBase,
const char * cpp_type_name ( ) const ; // Name of the C++ type.
const char * cpp_type_name ( ) const ; // Name of the C++ type.
Label label ( ) const ; // optional/required/repeated
Label label ( ) const ; // optional/required/repeated
# ifndef SWIG
CppStringType cpp_string_type ( ) const ; // The C++ string type of this field.
# endif
bool is_required ( ) const ; // shorthand for label() == LABEL_REQUIRED
bool is_required ( ) const ; // shorthand for label() == LABEL_REQUIRED
bool is_optional ( ) const ; // shorthand for label() == LABEL_OPTIONAL
bool is_optional ( ) const ; // shorthand for label() == LABEL_OPTIONAL
bool is_repeated ( ) const ; // shorthand for label() == LABEL_REPEATED
bool is_repeated ( ) const ; // shorthand for label() == LABEL_REPEATED
@ -2892,22 +2896,21 @@ PROTOBUF_EXPORT bool HasPreservingUnknownEnumSemantics(
PROTOBUF_EXPORT bool HasHasbit ( const FieldDescriptor * field ) ;
PROTOBUF_EXPORT bool HasHasbit ( const FieldDescriptor * field ) ;
# ifndef SWIG
// For a string field, returns the effective ctype. If the actual ctype is
// For a string field, returns the effective ctype. If the actual ctype is
// not supported, returns the default of STRING.
// not supported, returns the default of STRING.
template < typename FieldDesc = FieldDescriptor ,
template < typename FieldDesc = FieldDescriptor ,
typename FieldOpts = FieldOptions >
typename FieldOpts = FieldOptions >
typename FieldOpts : : CType EffectiveStringCType ( const FieldDesc * field ) {
typename FieldOpts : : CType EffectiveStringCType ( const FieldDesc * field ) {
ABSL_DCHECK ( field - > cpp_type ( ) = = FieldDescriptor : : CPPTYPE_STRING ) ;
// TODO Replace this function with FieldDescriptor::string_type;
// Open-source protobuf release only supports STRING ctype and CORD for
switch ( field - > cpp_string_type ( ) ) {
// sinuglar bytes.
case FieldDescriptor : : CppStringType : : kCord :
if ( field - > type ( ) = = FieldDescriptor : : TYPE_BYTES & & ! field - > is_repeated ( ) & &
field - > options ( ) . ctype ( ) = = FieldOpts : : CORD & & ! field - > is_extension ( ) ) {
return FieldOpts : : CORD ;
return FieldOpts : : CORD ;
}
default :
return FieldOpts : : STRING ;
return FieldOpts : : STRING ;
}
}
}
# ifndef SWIG
enum class Utf8CheckMode : uint8_t {
enum class Utf8CheckMode : uint8_t {
kStrict = 0 , // Parsing will fail if non UTF-8 data is in string fields.
kStrict = 0 , // Parsing will fail if non UTF-8 data is in string fields.
kVerify = 1 , // Only log an error but parsing will succeed.
kVerify = 1 , // Only log an error but parsing will succeed.