File indexing completed on 2025-01-18 10:13:17
0001
0002
0003
0004
0005
0006
0007
0008 #ifndef UPB_MESSAGE_COMPARE_H_
0009 #define UPB_MESSAGE_COMPARE_H_
0010
0011 #include <stddef.h>
0012
0013 #include "upb/base/descriptor_constants.h"
0014 #include "upb/message/message.h"
0015 #include "upb/message/value.h"
0016 #include "upb/mini_table/extension.h"
0017 #include "upb/mini_table/field.h"
0018 #include "upb/mini_table/message.h"
0019
0020
0021 #include "upb/port/def.inc"
0022
0023 enum {
0024
0025
0026 kUpb_CompareOption_IncludeUnknownFields = (1 << 0)
0027 };
0028
0029 #ifdef __cplusplus
0030 extern "C" {
0031 #endif
0032
0033
0034 UPB_API bool upb_Message_IsEmpty(const upb_Message* msg,
0035 const upb_MiniTable* m);
0036
0037 UPB_API bool upb_Message_IsEqual(const upb_Message* msg1,
0038 const upb_Message* msg2,
0039 const upb_MiniTable* m, int options);
0040
0041
0042 UPB_API_INLINE bool upb_MessageValue_IsEqual(upb_MessageValue val1,
0043 upb_MessageValue val2,
0044 upb_CType ctype,
0045 const upb_MiniTable* m,
0046 int options) {
0047 switch (ctype) {
0048 case kUpb_CType_Bool:
0049 return val1.bool_val == val2.bool_val;
0050
0051 case kUpb_CType_Float:
0052 case kUpb_CType_Int32:
0053 case kUpb_CType_UInt32:
0054 case kUpb_CType_Enum:
0055 return val1.int32_val == val2.int32_val;
0056
0057 case kUpb_CType_Double:
0058 case kUpb_CType_Int64:
0059 case kUpb_CType_UInt64:
0060 return val1.int64_val == val2.int64_val;
0061
0062 case kUpb_CType_String:
0063 case kUpb_CType_Bytes:
0064 return upb_StringView_IsEqual(val1.str_val, val2.str_val);
0065
0066 case kUpb_CType_Message:
0067 return upb_Message_IsEqual(val1.msg_val, val2.msg_val, m, options);
0068
0069 default:
0070 UPB_UNREACHABLE();
0071 return false;
0072 }
0073 }
0074
0075 #ifdef __cplusplus
0076 }
0077 #endif
0078
0079 #include "upb/port/undef.inc"
0080
0081 #endif