#include "element_info.h"

// !! ATTENTION ATTENTION ATTENTION !!
// This file is auto-generated by the "dev:update-element-info" rake target.
// !! ATTENTION ATTENTION ATTENTION !!

std::map<uint32_t, std::string> g_element_names;

void
init_element_names() {<% libmatroska_elements.each do |element| %>
  g_element_names[<%= element[:id] %>]<%= " " * (10 - element[:id].length) %> = "<%= element[:name] %>";<% end %>
}

uint32_t
element_name_to_id(const std::string &name) {
  std::map<uint32_t, std::string>::const_iterator i;
  for (i = g_element_names.begin(); g_element_names.end() != i; ++i)
    if (i->second == name)
      return i->first;

  return 0;
}

std::map<uint32_t, bool> g_master_information;

void
init_master_information() {
  const char *s_master_names[] = {<% libmatroska_elements.select { |element| element[:type] == :master }.each do |element| %>
    "<%= element[:name] %>",<% end %>
    nullptr
  };

  int i;
  for (i = 0; s_master_names[i]; ++i) {
    uint32_t id = element_name_to_id(s_master_names[i]);
    if (0 != id)
      g_master_information[id] = true;
  }
}
