1 // Protocol Buffers - Google's data interchange format 2 // Copyright 2023 Google LLC. All rights reserved. 3 // 4 // Use of this source code is governed by a BSD-style 5 // license that can be found in the LICENSE file or at 6 // https://developers.google.com/open-source/licenses/bsd 7 8 #ifndef UPB_UTIL_COMPARE_H_ 9 #define UPB_UTIL_COMPARE_H_ 10 11 #include <stddef.h> 12 13 #ifdef __cplusplus 14 extern "C" { 15 #endif 16 17 // Returns true if unknown fields from the two messages are equal when sorted 18 // and varints are made canonical. 19 // 20 // This function is discouraged, as the comparison is inherently lossy without 21 // schema data: 22 // 23 // 1. We don't know whether delimited fields are sub-messages. Unknown 24 // sub-messages will therefore not have their fields sorted and varints 25 // canonicalized. 26 // 2. We don't know about oneof/non-repeated fields, which should semantically 27 // discard every value except the last. 28 29 typedef enum { 30 kUpb_UnknownCompareResult_Equal = 0, 31 kUpb_UnknownCompareResult_NotEqual = 1, 32 kUpb_UnknownCompareResult_OutOfMemory = 2, 33 kUpb_UnknownCompareResult_MaxDepthExceeded = 3, 34 } upb_UnknownCompareResult; 35 36 upb_UnknownCompareResult upb_Message_UnknownFieldsAreEqual(const char* buf1, 37 size_t size1, 38 const char* buf2, 39 size_t size2, 40 int max_depth); 41 42 #ifdef __cplusplus 43 } /* extern "C" */ 44 #endif 45 46 #endif /* UPB_UTIL_COMPARE_H_ */ 47