32#if defined(__MINGW32__) && defined(Yield)
36#include "catalog_parser.h"
37#include "ocpn_utils.h"
38#include "catalog_handler.h"
42bool ParseCatalog(
const std::string xml,
CatalogCtx* ctx) {
46 pugi::xml_document doc;
47 doc.load_string(xml.c_str());
49 pugi::xml_node elements = doc.child(
"plugins");
50 for (pugi::xml_node element = elements.first_child(); element;
51 element = element.next_sibling()) {
52 if (!strcmp(element.name(),
"version") && ctx->version ==
"") {
53 ctx->version = ocpn::trim(element.first_child().value());
54 }
else if (strcmp(element.name(),
"date") == 0 && ctx->date ==
"") {
55 ctx->date = ocpn::trim(element.first_child().value());
56 }
else if (strcmp(element.name(),
"meta-url") == 0) {
57 ctx->meta_url = ocpn::trim(element.first_child().value());
58 }
else if (!strcmp(element.name(),
"plugin")) {
59 if (ctx->meta_url !=
"") {
60 ctx->meta_urls.push_back(ctx->meta_url);
63 if (plugin) ctx->plugins.push_back(*plugin);
67 for (pugi::xml_node plugin_element = element.first_child();
68 plugin_element; plugin_element = plugin_element.next_sibling()) {
69 if (strcmp(plugin_element.name(),
"meta-url") == 0) {
70 auto url = ocpn::trim(plugin_element.first_child().value());
72 }
else if (strcmp(plugin_element.name(),
"name") == 0) {
73 plugin->name = ocpn::trim(plugin_element.first_child().value());
74 }
else if (strcmp(plugin_element.name(),
"version") == 0) {
75 plugin->version = ocpn::trim(plugin_element.first_child().value());
76 }
else if (strcmp(plugin_element.name(),
"release") == 0) {
77 plugin->release = ocpn::trim(plugin_element.first_child().value());
78 }
else if (strcmp(plugin_element.name(),
"summary") == 0) {
79 plugin->summary = ocpn::trim(plugin_element.first_child().value());
80 }
else if (strcmp(plugin_element.name(),
"api_version") == 0) {
82 ocpn::trim(plugin_element.first_child().value());
83 }
else if (strcmp(plugin_element.name(),
"author") == 0) {
84 plugin->author = ocpn::trim(plugin_element.first_child().value());
85 }
else if (strcmp(plugin_element.name(),
"description") == 0) {
87 ocpn::trim(plugin_element.first_child().value());
88 }
else if (strcmp(plugin_element.name(),
"git-commit") == 0) {
89 plugin->git_commit = ocpn::trim(plugin_element.first_child().value());
90 }
else if (strcmp(plugin_element.name(),
"git-date") == 0) {
91 plugin->git_date = ocpn::trim(plugin_element.first_child().value());
92 }
else if (strcmp(plugin_element.name(),
"source") == 0) {
93 plugin->source = ocpn::trim(plugin_element.first_child().value());
94 }
else if (strcmp(plugin_element.name(),
"tarball-url") == 0) {
96 ocpn::trim(plugin_element.first_child().value());
97 }
else if (strcmp(plugin_element.name(),
"info-url") == 0) {
98 plugin->info_url = ocpn::trim(plugin_element.first_child().value());
99 }
else if (strcmp(plugin_element.name(),
"target") == 0) {
100 plugin->target = ocpn::trim(plugin_element.first_child().value());
101 }
else if (strcmp(plugin_element.name(),
"build-gtk") == 0) {
102 plugin->build_gtk = ocpn::trim(plugin_element.first_child().value());
103 }
else if (strcmp(plugin_element.name(),
"target-version") == 0) {
104 plugin->target_version =
105 ocpn::trim(plugin_element.first_child().value());
106 }
else if (strcmp(plugin_element.name(),
"target-arch") == 0) {
107 plugin->target_arch =
108 ocpn::trim(plugin_element.first_child().value());
109 }
else if (strcmp(plugin_element.name(),
"tarball-checksum") == 0) {
110 plugin->checksum = ocpn::trim(plugin_element.first_child().value());
111 }
else if (strcmp(plugin_element.name(),
"open-source") == 0) {
113 ocpn::trim(plugin_element.first_child().value()) ==
"yes";
121 ctx->plugins.push_back(*plugin);
123 if (ctx->meta_url !=
"") {
124 ctx->meta_urls.push_back(ctx->meta_url);
The result from parsing the xml catalog i.