OpenCPN Partial API docs
catalog_parser.h
1 /******************************************************************************
2  *
3  * Project: OpenCPN
4  *
5  ***************************************************************************
6  * Copyright (C) 2019 Alec Leamas *
7  * *
8  * This program is free software; you can redistribute it and/or modify *
9  * it under the terms of the GNU General Public License as published by *
10  * the Free Software Foundation; either version 2 of the License, or *
11  * (at your option) any later version. *
12  * *
13  * This program is distributed in the hope that it will be useful, *
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16  * GNU General Public License for more details. *
17  * *
18  * You should have received a copy of the GNU General Public License *
19  * along with this program; if not, write to the *
20  * Free Software Foundation, Inc., *
21  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
22  ***************************************************************************
23  */
24 #ifndef CATALOG_PARSER_H__
25 #define CATALOG_PARSER_H__
26 
27 #include <string>
28 #include <vector>
29 
36 struct CatalogData {
37  std::string version;
38  std::string date;
39  bool undef;
40  CatalogData() : undef(true) {}
41 };
42 
45  std::string name;
46  std::string version;
47  std::string release;
48  std::string summary;
49 
50  std::string api_version;
51  std::string author;
52  std::string description;
53  std::string git_commit;
54  std::string git_date;
55  std::string source;
56  std::string tarball_url;
57  std::string target;
58  std::string build_gtk;
59  std::string target_version;
60  std::string target_arch;
61  std::string info_url;
62  std::string meta_url;
63  std::string checksum;
64  bool is_imported;
65  bool is_orphan;
66 
67  bool openSource;
68 
69  bool readonly;
70  int ix;
71  void clear() { *this = PluginMetadata(); }
72  std::string key() const {
73  return name + version + release + target + target_version;
74  }
75 
76  std::string to_string();
77 
79  : is_imported(false), is_orphan(false), openSource(true),
80  readonly(true), ix(-1) {}
81 };
82 
86 struct CatalogCtx {
87  // list of plugins parsed
88  std::vector<PluginMetadata> plugins;
89 
90  // list meta-urls found when parsing last plugin.
91  std::vector<std::string> meta_urls;
92  std::vector<std::string> parsed_metas;
93 
94  std::string version;
95  std::string date;
96 
97  // Internal data used while parsing, undefined on exit.
98  std::string buff;
99  std::string meta_url;
100  int depth;
101  CatalogCtx() : depth(0) {}
102 };
103 
104 bool ParseCatalog(const std::string xml, CatalogCtx* ctx);
105 
106 bool ParsePlugin(const std::string& xml, PluginMetadata& metadata);
107 
108 #endif // CATALOG_PARSER_H__
The result from parsing the xml catalog i.
Datatypes and methods to parse ocpn-plugins.xml XML data, either complete catalog or a single plugin.
Plugin metadata, reflects the xml format directly.
std::string to_string()
Return printable XML representation.
int ix
Index in list of installed or available.
bool readonly
Can plugin be removed?