#ifndef UPB_MESSAGE_MAP_GENCODE_UTIL_H_
#define UPB_MESSAGE_MAP_GENCODE_UTIL_H_
#include "upb/message/internal/map.h"
#include "upb/port/def.inc"
#ifdef __cplusplus
extern "C" {
#endif
UPB_INLINE void _upb_msg_map_key(const void* msg, void* key, size_t size) {
const upb_tabent* ent = (const upb_tabent*)msg;
uint32_t u32len;
upb_StringView k;
k.data = upb_tabstr(ent->key, &u32len);
k.size = u32len;
_upb_map_fromkey(k, key, size);
}
UPB_INLINE void _upb_msg_map_value(const void* msg, void* val, size_t size) {
const upb_tabent* ent = (const upb_tabent*)msg;
upb_value v = {ent->val.val};
_upb_map_fromvalue(v, val, size);
}
UPB_INLINE void _upb_msg_map_set_value(void* msg, const void* val,
size_t size) {
upb_tabent* ent = (upb_tabent*)msg;
if (size == UPB_MAPTYPE_STRING) {
upb_StringView* strp = (upb_StringView*)(uintptr_t)ent->val.val;
memcpy(strp, val, sizeof(*strp));
} else {
memcpy(&ent->val.val, val, size);
}
}
#ifdef __cplusplus
}
#endif
#include "upb/port/undef.inc"
#endif