示例#1
0
static style_t *style_load_fname(appdata_t *appdata, const char *filename) {
  xmlChar *fname = NULL;
  style_t *style = style_parse(appdata, filename, &fname, FALSE);

  printf("  elemstyle filename: %s\n", fname);
  style->elemstyles = josm_elemstyles_load((char*)fname);
  xmlFree(fname);

  return style;
}
示例#2
0
int main(int argc, char **argv)
{
  OSM2GO_TEST_INIT(argc, argv);

  if (argc < 4 || argc > 5) {
    usage(argv[0]);
    return 1;
  }

  char *endp;
  unsigned long rules = strtoul(argv[2], &endp, 10);
  if (endp == nullptr || *endp != 0) {
    usage(argv[0]);
    return 1;
  }
  unsigned long conditions = strtoul(argv[3], &endp, 10);
  if (endp == nullptr || *endp != 0) {
    usage(argv[0]);
    return 1;
  }

  if(argc == 5)
    path_prefix = argv[4];

  xmlInitParser();

  std::vector<elemstyle_t *> styles = josm_elemstyles_load(argv[1]);

  if(styles.empty()) {
    std::cerr << "failed to load styles" << std::endl;
    return 1;
  }

  std::cout << styles.size() << " top level items found";
  if (styles.size() != rules) {
    std::cout << ", but " << rules << " expected";
    error = true;
  }
  std::cout << std::endl;

  std::for_each(styles.begin(), styles.end(), checkItem);

  if (counter.ruletypes.size() > 4) {
    std::cerr << "too many rule types found" << std::endl;
    error = true;
  }

  std::for_each(styles.begin(), styles.end(), icon_check);

  std::for_each(counter.ruletypes.begin(), counter.ruletypes.end(), show_rule_count);

  std::cout << counter.conditions << " conditions found";
  if (counter.conditions != conditions) {
    std::cout << ", but " << conditions << " expected";
    error = true;
  }
  std::cout << std::endl;

  josm_elemstyles_free(styles);
  xmlCleanupParser();

  return error ? 1 : 0;
}