KiCad PCB EDA Suite
Loading...
Searching...
No Matches
pcm_data.h
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2021 Andrew Lutsenko, anlutsenko at gmail dot com
5 * Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software: you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation, either version 3 of the License, or (at your
10 * option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21#ifndef PCM_DATA_H_
22#define PCM_DATA_H_
23
24#include "core/wx_stl_compat.h"
25
26#include <map>
27#include <json_common.h>
29#include <optional>
30#include <string>
31#include <tuple>
32#include <vector>
33#include <wx/string.h>
34
35
36using STRING_MAP = std::map<std::string, wxString>;
37using nlohmann::json;
38
39
42{
47};
48
49
52{
58};
59
60
63{
64 wxString name;
66};
67
68
69// MSVC, wxWidgets and nlohmann_json don't play nice together and
70// create linker errors about redefinition of some vector members
71// if an attempt to use vector<wxString> in json is made.
72
75{
76 wxString version;
77 std::optional<int> version_epoch;
78 std::optional<wxString> download_url;
79 std::optional<wxString> download_sha256;
80 std::optional<uint64_t> download_size;
81 std::optional<uint64_t> install_size;
83 std::vector<std::string> platforms;
84 wxString kicad_version;
85 std::optional<wxString> kicad_version_max;
86 std::vector<std::string> keep_on_update;
87
88 // Not serialized fields
89 std::tuple<int, int, int, int> parsed_version; // Full version tuple for sorting
90 bool compatible = true;
91};
92
93
96{
97 wxString name;
98 wxString description;
100 wxString identifier;
103 std::optional<PCM_CONTACT> maintainer;
104 wxString license;
106 std::vector<std::string> tags;
107 std::vector<std::string> keep_on_update;
108 std::vector<PACKAGE_VERSION> versions;
109};
110
111
114{
115 wxString url;
116 std::optional<wxString> sha256;
118};
119
120
123{
124 wxString name;
126 std::optional<PCM_RESOURCE_REFERENCE> resources;
127 std::optional<PCM_RESOURCE_REFERENCE> manifests;
128 std::optional<PCM_CONTACT> maintainer;
129
130 // Not serialized fields
131 std::vector<PCM_PACKAGE> package_list;
132 // pkg id to index of package from package_list for quick lookup
133 std::unordered_map<wxString, size_t> package_map;
134};
135
136
139{
145 bool pinned;
146
147 // Not serialized fields
149};
150
151
153 { PT_INVALID, "invalid" },
154 { PT_PLUGIN, "plugin" },
155 { PT_LIBRARY, "library" },
156 { PT_COLORTHEME, "colortheme" },
157 } )
158
159
161 {
162 { PVS_INVALID, "invalid" },
163 { PVS_STABLE, "stable" },
164 { PVS_TESTING, "testing" },
165 { PVS_DEVELOPMENT, "development" },
166 { PVS_DEPRECATED, "deprecated" },
167 } )
168
169
170// Following are templates and definitions for en/decoding above structs
171// to/from json
172
174
175
176void to_json( json& j, const PACKAGE_VERSION& v );
177void from_json( const json& j, PACKAGE_VERSION& v );
178
179
180void to_json( json& j, const PCM_PACKAGE& p );
181void from_json( const json& j, PCM_PACKAGE& p );
182
183
184void to_json( json& j, const PCM_RESOURCE_REFERENCE& r );
185void from_json( const json& j, PCM_RESOURCE_REFERENCE& r );
186
187
188void to_json( json& j, const PCM_REPOSITORY& r );
189void from_json( const json& j, PCM_REPOSITORY& r );
190
191
192void to_json( json& j, const PCM_INSTALLATION_ENTRY& e );
193void from_json( const json& j, PCM_INSTALLATION_ENTRY& e );
194
195
196#endif // PCM_DATA_H_
const char * name
Definition: DXF_plotter.cpp:57
std::map< wxString, wxString > STRING_MAP
Definition: env_vars.cpp:30
nlohmann::json json
Definition: gerbview.cpp:47
PCM_PACKAGE_TYPE
< Supported package types
Definition: pcm_data.h:42
@ PT_COLORTHEME
Definition: pcm_data.h:46
@ PT_INVALID
Definition: pcm_data.h:43
@ PT_PLUGIN
Definition: pcm_data.h:44
@ PT_LIBRARY
Definition: pcm_data.h:45
std::map< std::string, wxString > STRING_MAP
Definition: pcm_data.h:36
PCM_PACKAGE_VERSION_STATUS
Definition: pcm_data.h:52
@ PVS_INVALID
Definition: pcm_data.h:53
@ PVS_DEVELOPMENT
Definition: pcm_data.h:56
@ PVS_STABLE
Definition: pcm_data.h:54
@ PVS_TESTING
Definition: pcm_data.h:55
@ PVS_DEPRECATED
Definition: pcm_data.h:57
void to_json(json &j, const PCM_PACKAGE &p)
Definition: pcm_data.cpp:89
NLOHMANN_JSON_SERIALIZE_ENUM(PCM_PACKAGE_TYPE, { { PT_INVALID, "invalid" }, { PT_PLUGIN, "plugin" }, { PT_LIBRARY, "library" }, { PT_COLORTHEME, "colortheme" }, }) NLOHMANN_JSON_SERIALIZE_ENUM(PCM_PACKAGE_VERSION_STATUS
void from_json(const json &j, PACKAGE_VERSION &v)
Definition: pcm_data.cpp:68
< Package version metadata Package metadata
Definition: pcm_data.h:75
std::optional< uint64_t > download_size
Definition: pcm_data.h:80
bool compatible
Definition: pcm_data.h:90
std::optional< uint64_t > install_size
Definition: pcm_data.h:81
wxString version
Definition: pcm_data.h:76
PCM_PACKAGE_VERSION_STATUS status
Definition: pcm_data.h:82
std::optional< wxString > kicad_version_max
Definition: pcm_data.h:85
std::optional< wxString > download_url
Definition: pcm_data.h:78
std::optional< wxString > download_sha256
Definition: pcm_data.h:79
std::optional< int > version_epoch
Definition: pcm_data.h:77
std::vector< std::string > platforms
Definition: pcm_data.h:83
wxString kicad_version
Definition: pcm_data.h:84
std::tuple< int, int, int, int > parsed_version
Definition: pcm_data.h:89
std::vector< std::string > keep_on_update
Definition: pcm_data.h:86
wxString name
Definition: pcm_data.h:64
STRING_MAP contact
Definition: pcm_data.h:65
Definition: pcm_data.h:139
wxString repository_name
Definition: pcm_data.h:143
PCM_PACKAGE package
Definition: pcm_data.h:140
uint64_t install_timestamp
Definition: pcm_data.h:144
wxString repository_id
Definition: pcm_data.h:142
wxString current_version
Definition: pcm_data.h:141
bool update_available
Definition: pcm_data.h:148
bool pinned
Definition: pcm_data.h:145
Repository reference to a resource.
Definition: pcm_data.h:96
wxString description
Definition: pcm_data.h:98
wxString description_full
Definition: pcm_data.h:99
wxString identifier
Definition: pcm_data.h:100
wxString license
Definition: pcm_data.h:104
std::vector< std::string > tags
Definition: pcm_data.h:106
STRING_MAP resources
Definition: pcm_data.h:105
std::optional< PCM_CONTACT > maintainer
Definition: pcm_data.h:103
wxString name
Definition: pcm_data.h:97
std::vector< PACKAGE_VERSION > versions
Definition: pcm_data.h:108
PCM_PACKAGE_TYPE type
Definition: pcm_data.h:101
std::vector< std::string > keep_on_update
Definition: pcm_data.h:107
PCM_CONTACT author
Definition: pcm_data.h:102
Package installation entry.
Definition: pcm_data.h:123
PCM_RESOURCE_REFERENCE packages
Definition: pcm_data.h:125
std::optional< PCM_CONTACT > maintainer
Definition: pcm_data.h:128
std::vector< PCM_PACKAGE > package_list
Definition: pcm_data.h:131
wxString name
Definition: pcm_data.h:124
std::optional< PCM_RESOURCE_REFERENCE > manifests
Definition: pcm_data.h:127
std::optional< PCM_RESOURCE_REFERENCE > resources
Definition: pcm_data.h:126
std::unordered_map< wxString, size_t > package_map
Definition: pcm_data.h:133
Repository metadata.
Definition: pcm_data.h:114
std::optional< wxString > sha256
Definition: pcm_data.h:116
uint64_t update_timestamp
Definition: pcm_data.h:117
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(UPDATE_REQUEST, platform, arch, current_version, lang, last_check) struct UPDATE_RESPONSE