Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:13:18

0001 // Protocol Buffers - Google's data interchange format
0002 // Copyright 2023 Google LLC.  All rights reserved.
0003 //
0004 // Use of this source code is governed by a BSD-style
0005 // license that can be found in the LICENSE file or at
0006 // https://developers.google.com/open-source/licenses/bsd
0007 
0008 // IWYU pragma: private, include "upb/reflection/def.h"
0009 
0010 #ifndef UPB_REFLECTION_MESSAGE_DEF_H_
0011 #define UPB_REFLECTION_MESSAGE_DEF_H_
0012 
0013 #include "upb/base/string_view.h"
0014 #include "upb/reflection/common.h"
0015 
0016 // Must be last.
0017 #include "upb/port/def.inc"
0018 
0019 // Well-known field tag numbers for map-entry messages.
0020 #define kUpb_MapEntry_KeyFieldNumber 1
0021 #define kUpb_MapEntry_ValueFieldNumber 2
0022 
0023 // Well-known field tag numbers for Any messages.
0024 #define kUpb_Any_TypeFieldNumber 1
0025 #define kUpb_Any_ValueFieldNumber 2
0026 
0027 // Well-known field tag numbers for duration messages.
0028 #define kUpb_Duration_SecondsFieldNumber 1
0029 #define kUpb_Duration_NanosFieldNumber 2
0030 
0031 // Well-known field tag numbers for timestamp messages.
0032 #define kUpb_Timestamp_SecondsFieldNumber 1
0033 #define kUpb_Timestamp_NanosFieldNumber 2
0034 
0035 // All the different kind of well known type messages. For simplicity of check,
0036 // number wrappers and string wrappers are grouped together. Make sure the
0037 // order and number of these groups are not changed.
0038 typedef enum {
0039   kUpb_WellKnown_Unspecified,
0040   kUpb_WellKnown_Any,
0041   kUpb_WellKnown_FieldMask,
0042   kUpb_WellKnown_Duration,
0043   kUpb_WellKnown_Timestamp,
0044 
0045   // number wrappers
0046   kUpb_WellKnown_DoubleValue,
0047   kUpb_WellKnown_FloatValue,
0048   kUpb_WellKnown_Int64Value,
0049   kUpb_WellKnown_UInt64Value,
0050   kUpb_WellKnown_Int32Value,
0051   kUpb_WellKnown_UInt32Value,
0052 
0053   // string wrappers
0054   kUpb_WellKnown_StringValue,
0055   kUpb_WellKnown_BytesValue,
0056   kUpb_WellKnown_BoolValue,
0057   kUpb_WellKnown_Value,
0058   kUpb_WellKnown_ListValue,
0059   kUpb_WellKnown_Struct,
0060 } upb_WellKnown;
0061 
0062 #ifdef __cplusplus
0063 extern "C" {
0064 #endif
0065 
0066 const upb_MessageDef* upb_MessageDef_ContainingType(const upb_MessageDef* m);
0067 
0068 const upb_ExtensionRange* upb_MessageDef_ExtensionRange(const upb_MessageDef* m,
0069                                                         int i);
0070 int upb_MessageDef_ExtensionRangeCount(const upb_MessageDef* m);
0071 
0072 UPB_API const upb_FieldDef* upb_MessageDef_Field(const upb_MessageDef* m,
0073                                                  int i);
0074 UPB_API int upb_MessageDef_FieldCount(const upb_MessageDef* m);
0075 
0076 UPB_API const upb_FileDef* upb_MessageDef_File(const upb_MessageDef* m);
0077 
0078 // Returns a field by either JSON name or regular proto name.
0079 const upb_FieldDef* upb_MessageDef_FindByJsonNameWithSize(
0080     const upb_MessageDef* m, const char* name, size_t size);
0081 UPB_INLINE const upb_FieldDef* upb_MessageDef_FindByJsonName(
0082     const upb_MessageDef* m, const char* name) {
0083   return upb_MessageDef_FindByJsonNameWithSize(m, name, strlen(name));
0084 }
0085 
0086 // Lookup of either field or oneof by name. Returns whether either was found.
0087 // If the return is true, then the found def will be set, and the non-found
0088 // one set to NULL.
0089 UPB_API bool upb_MessageDef_FindByNameWithSize(const upb_MessageDef* m,
0090                                                const char* name, size_t size,
0091                                                const upb_FieldDef** f,
0092                                                const upb_OneofDef** o);
0093 UPB_INLINE bool upb_MessageDef_FindByName(const upb_MessageDef* m,
0094                                           const char* name,
0095                                           const upb_FieldDef** f,
0096                                           const upb_OneofDef** o) {
0097   return upb_MessageDef_FindByNameWithSize(m, name, strlen(name), f, o);
0098 }
0099 
0100 const upb_FieldDef* upb_MessageDef_FindFieldByName(const upb_MessageDef* m,
0101                                                    const char* name);
0102 UPB_API const upb_FieldDef* upb_MessageDef_FindFieldByNameWithSize(
0103     const upb_MessageDef* m, const char* name, size_t size);
0104 UPB_API const upb_FieldDef* upb_MessageDef_FindFieldByNumber(
0105     const upb_MessageDef* m, uint32_t i);
0106 const upb_OneofDef* upb_MessageDef_FindOneofByName(const upb_MessageDef* m,
0107                                                    const char* name);
0108 UPB_API const upb_OneofDef* upb_MessageDef_FindOneofByNameWithSize(
0109     const upb_MessageDef* m, const char* name, size_t size);
0110 UPB_API const char* upb_MessageDef_FullName(const upb_MessageDef* m);
0111 bool upb_MessageDef_HasOptions(const upb_MessageDef* m);
0112 bool upb_MessageDef_IsMapEntry(const upb_MessageDef* m);
0113 bool upb_MessageDef_IsMessageSet(const upb_MessageDef* m);
0114 
0115 // Creates a mini descriptor string for a message, returns true on success.
0116 bool upb_MessageDef_MiniDescriptorEncode(const upb_MessageDef* m, upb_Arena* a,
0117                                          upb_StringView* out);
0118 
0119 UPB_API const upb_MiniTable* upb_MessageDef_MiniTable(const upb_MessageDef* m);
0120 const char* upb_MessageDef_Name(const upb_MessageDef* m);
0121 
0122 const upb_EnumDef* upb_MessageDef_NestedEnum(const upb_MessageDef* m, int i);
0123 const upb_FieldDef* upb_MessageDef_NestedExtension(const upb_MessageDef* m,
0124                                                    int i);
0125 const upb_MessageDef* upb_MessageDef_NestedMessage(const upb_MessageDef* m,
0126                                                    int i);
0127 
0128 int upb_MessageDef_NestedEnumCount(const upb_MessageDef* m);
0129 int upb_MessageDef_NestedExtensionCount(const upb_MessageDef* m);
0130 int upb_MessageDef_NestedMessageCount(const upb_MessageDef* m);
0131 
0132 UPB_API const upb_OneofDef* upb_MessageDef_Oneof(const upb_MessageDef* m,
0133                                                  int i);
0134 UPB_API int upb_MessageDef_OneofCount(const upb_MessageDef* m);
0135 int upb_MessageDef_RealOneofCount(const upb_MessageDef* m);
0136 
0137 const UPB_DESC(MessageOptions) *
0138     upb_MessageDef_Options(const upb_MessageDef* m);
0139 const UPB_DESC(FeatureSet) *
0140     upb_MessageDef_ResolvedFeatures(const upb_MessageDef* m);
0141 
0142 upb_StringView upb_MessageDef_ReservedName(const upb_MessageDef* m, int i);
0143 int upb_MessageDef_ReservedNameCount(const upb_MessageDef* m);
0144 
0145 const upb_MessageReservedRange* upb_MessageDef_ReservedRange(
0146     const upb_MessageDef* m, int i);
0147 int upb_MessageDef_ReservedRangeCount(const upb_MessageDef* m);
0148 
0149 UPB_API upb_Syntax upb_MessageDef_Syntax(const upb_MessageDef* m);
0150 UPB_API upb_WellKnown upb_MessageDef_WellKnownType(const upb_MessageDef* m);
0151 
0152 #ifdef __cplusplus
0153 } /* extern "C" */
0154 #endif
0155 
0156 #include "upb/port/undef.inc"
0157 
0158 #endif /* UPB_REFLECTION_MESSAGE_DEF_H_ */