In case anyone was having the same issue I was, I figured out how to do it. I'm not 100% sure if this is the BEST way to do it, and I really hate being forced to use individual meta_get's instead of a single title format, but unless I'm missing something meta_get is the only option on a file_info*.
class metadb_io_edit_callback_impl : public metadb_io_edit_callback {
public:
typedef const pfc::list_base_const_t<const file_info*> & t_infosref;
void on_edited(metadb_handle_list_cref items, t_infosref before, t_infosref after) {
static static_api_ptr_t<metadb_index_manager> api; // initialized once here
for (size_t t = 0; t < items.get_count(); t++) {
metadb_index_hash hashOld, hashNew;
g_client->hashHandle(items[t], hashOld);
// my hash is pinned to "%artist% %album% $if2(%discnumber%,1) %tracknumber% %title%
pfc::string8 artist = meta_get_if_exists(after[t], "ARTIST", "");
pfc::string8 album = meta_get_if_exists(after[t], "ALBUM", "");
pfc::string8 discnum = meta_get_if_exists(after[t], "DISCNUMBER", "1");
pfc::string8 tracknum = meta_get_if_exists(after[t], "TRACKNUMBER", "");
pfc::string8 title = meta_get_if_exists(after[t], "TITLE", "");
pfc::string_formatter strAfter;
strAfter << artist << " " << album << " " << discnum << " " << tracknum << " " << title;
hashNew = static_api_ptr_t<hasher_md5>()->process_single_string(strAfter).xorHalve();
if (hashOld != hashNew) {
record_t record = getRecord(hashOld, api); // this is my function for retrieving the data structure from metadb
record_t newRecord = getRecord(hashNew, api);
// use whatever logic you want to determine if a record at the old hash exists and whether to overwrite a record at the new hash
}
}
}
};
static service_factory_single_t<metadb_io_edit_callback_impl> g_my_metadb_io;
// helper function to get meta value or return default if not found. equivalent to $if2
pfc::string8 meta_get_if_exists(const file_info * info, const char* key, const char* default) {
if (info->meta_exists(key)) {
return info->meta_get(key, 0);
}
return default;
}