File indexing completed on 2025-01-18 10:13:17
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #ifndef UPB_MESSAGE_MAP_GENCODE_UTIL_H_
0011 #define UPB_MESSAGE_MAP_GENCODE_UTIL_H_
0012
0013 #include "upb/message/internal/map.h"
0014
0015
0016 #include "upb/port/def.inc"
0017
0018 #ifdef __cplusplus
0019 extern "C" {
0020 #endif
0021
0022
0023
0024 UPB_INLINE void _upb_msg_map_key(const void* msg, void* key, size_t size) {
0025 const upb_tabent* ent = (const upb_tabent*)msg;
0026 uint32_t u32len;
0027 upb_StringView k;
0028 k.data = upb_tabstr(ent->key, &u32len);
0029 k.size = u32len;
0030 _upb_map_fromkey(k, key, size);
0031 }
0032
0033 UPB_INLINE void _upb_msg_map_value(const void* msg, void* val, size_t size) {
0034 const upb_tabent* ent = (const upb_tabent*)msg;
0035 upb_value v = {ent->val.val};
0036 _upb_map_fromvalue(v, val, size);
0037 }
0038
0039 UPB_INLINE void _upb_msg_map_set_value(void* msg, const void* val,
0040 size_t size) {
0041 upb_tabent* ent = (upb_tabent*)msg;
0042
0043
0044 if (size == UPB_MAPTYPE_STRING) {
0045 upb_StringView* strp = (upb_StringView*)(uintptr_t)ent->val.val;
0046 memcpy(strp, val, sizeof(*strp));
0047 } else {
0048 memcpy(&ent->val.val, val, size);
0049 }
0050 }
0051
0052 #ifdef __cplusplus
0053 }
0054 #endif
0055
0056 #include "upb/port/undef.inc"
0057
0058 #endif