xref: /aosp_15_r20/external/grpc-grpc/third_party/upb/upb/message/value.h (revision cc02d7e222339f7a4f6ba5f422e6413f4bd931f2)
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 // Users should include array.h or map.h instead.
9 // IWYU pragma: private, include "upb/message/array.h"
10 
11 #ifndef UPB_MESSAGE_VALUE_H_
12 #define UPB_MESSAGE_VALUE_H_
13 
14 #include <stdint.h>
15 
16 #include "upb/base/string_view.h"
17 
18 typedef union {
19   bool bool_val;
20   float float_val;
21   double double_val;
22   int32_t int32_val;
23   int64_t int64_val;
24   uint32_t uint32_val;
25   uint64_t uint64_val;
26   const struct upb_Array* array_val;
27   const struct upb_Map* map_val;
28   const struct upb_Message* msg_val;
29   upb_StringView str_val;
30 
31   // EXPERIMENTAL: A tagged upb_Message*.  Users must use this instead of
32   // msg_val if unlinked sub-messages may possibly be in use.  See the
33   // documentation in kUpb_DecodeOption_ExperimentalAllowUnlinked for more
34   // information.
35   uintptr_t tagged_msg_val;  // upb_TaggedMessagePtr
36 } upb_MessageValue;
37 
38 typedef union {
39   struct upb_Array* array;
40   struct upb_Map* map;
41   struct upb_Message* msg;
42 } upb_MutableMessageValue;
43 
44 #endif /* UPB_MESSAGE_VALUE_H_ */
45