Skip to content

Add untyped/dynamic tag getter/adder

Matthew Waters requested to merge ystreet:dynamic-tags into master

Allows iterating over all the tags without knowing the specific tags and therefore types.

Allows iterating over all the tags in the TagList with something like:

for i in 0..tags.n_tags() {
  let tag_name = tags.nth_tag(i as u32);
  for j in 0..tags.get_size_dynamic(tag_name); {
    let v = tags.get_index_dynamic (tag_name, j).unwrap();
    match &v.type_() {
      glib::types::Type::String => println!("{} {}", tag_name, v.get::<String>().unwrap()),
      glib::types::Type::U32 => println!("{} {}", tag_name, v.get::<u32>().unwrap()),
      glib::types::Type::I32 => println!("{} {}", tag_name, v.get::<i32>().unwrap()),
      glib::types::Type::U64 => println!("{} {}", tag_name, v.get::<u64>().unwrap()),
      glib::types::Type::I64 => println!("{} {}", tag_name, v.get::<i64>().unwrap()),
      _ => println!("Unknown value type for tag {}", tag_name),
    }
  }
}

Merge request reports