Enum api examples for C++ sdk?

Hi, are there any examples of working with the new add enum C++ apis? I have been going through typeinf.hpp but not sure of some of the args.

looks like add_enum is now create_enum_type
and add_enum_member is now tinfo_t::add_edm

edit: ok so this works…

tinfo_t tt;
enum_type_data_t ei;
tid_t ti = create_enum_type("enumName", ei, 0, type_unsigned, false, 0); 
if (tt.get_named_type("enumName"))  return tt.add_edm("memberName", 0x11223344);

if tt.get_named_type(enumName) doesnt exist its a crash though.

edit 2: so this will do a safe lookup. cant seem to reuse the tid_t from create enum though
maybe there is a way to convert tid_t to til_t for get_named_type dunno head hurtz.

qstring q;
tinfo_t tt;
tid_t id = get_named_type_tid(args[1]);
if (id != BADADDR) {
	   msg("valid type name\n");
	   q = args[1];
}else{
	   id = (tid_t)atoi(args[1]);
	   msg("not a type name trying as tid %d\n", id);
	   if (get_tid_name(&q, id)){ 
					   msg("it was a tid for %s\n", q.c_str()); //should now have valid name for tid
	   }
	   else {
					   msg("was not a tid either quitting '%s'\n", q.c_str());
					   return -1;
	   }
}
 
//or can we convert tid to til? 
if (tt.get_named_type(q.c_str())) return tt.add_edm(args[3], ua2);

hopefully I am doing things at a lower level than necessary, the old api was very simple. (I have to do things based on user supplied args since this is wired to a scripting client.)

Hello @d11,
Have you had a chance to look at our Porting Guide? Currently, we lack some clear, ready-to-use examples regarding types for C++ APIs, similar to those available for IDAPython. However, this is an area we’re aiming to improve. I will try to collect more info if we can expect something sooner rather than later, to set the right expectations.

great thanks. I did check out the porting guide it gave some tips on which file to look at but mostly just gave removed api listings. The header file itself did have some hints enough to piece together what I got so far.

Actually the IDAPython source might have enough to get me going again:

edit: got it working by tid, was just my bug, didnt realize tid_t was 64 bit. was being truncated in translation between layers. my bad… get_tid_name was valid as well, just had same problem…

Oh I see, that’s great that you spotted it!
Anyway, you are in the right place if you have any further questions about the new APIs.