KiCad PCB EDA Suite
pcm_data.h File Reference
#include "core/wx_stl_compat.h"
#include <map>
#include <nlohmann/json.hpp>
#include <optional>
#include <string>
#include <tuple>
#include <vector>
#include <wx/string.h>

Go to the source code of this file.

Classes

struct  PCM_CONTACT
 
struct  PACKAGE_VERSION
 < Package version metadata Package metadata More...
 
struct  PCM_PACKAGE
 Repository reference to a resource. More...
 
struct  PCM_RESOURCE_REFERENCE
 Repository metadata. More...
 
struct  PCM_REPOSITORY
 Package installation entry. More...
 
struct  PCM_INSTALLATION_ENTRY
 
struct  nlohmann::adl_serializer< wxString >
 

Namespaces

namespace  nlohmann
 

Typedefs

using STRING_MAP = std::map< std::string, wxString >
 

Enumerations

enum  PCM_PACKAGE_TYPE { PT_INVALID , PT_PLUGIN , PT_LIBRARY , PT_COLORTHEME }
 < Supported package types More...
 
enum  PCM_PACKAGE_VERSION_STATUS {
  PVS_INVALID , PVS_STABLE , PVS_TESTING , PVS_DEVELOPMENT ,
  PVS_DEPRECATED
}
 

Functions

 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)
 
void to_json (json &j, const PCM_PACKAGE &p)
 
void from_json (const json &j, PCM_PACKAGE &p)
 
void to_json (json &j, const PCM_RESOURCE_REFERENCE &r)
 
void from_json (const json &j, PCM_RESOURCE_REFERENCE &r)
 
void to_json (json &j, const PCM_REPOSITORY &r)
 
void from_json (const json &j, PCM_REPOSITORY &r)
 
void to_json (json &j, const PCM_INSTALLATION_ENTRY &e)
 
void from_json (const json &j, PCM_INSTALLATION_ENTRY &e)
 

Typedef Documentation

◆ STRING_MAP

using STRING_MAP = std::map<std::string, wxString>

Definition at line 35 of file pcm_data.h.

Enumeration Type Documentation

◆ PCM_PACKAGE_TYPE

< Supported package types

Enumerator
PT_INVALID 
PT_PLUGIN 
PT_LIBRARY 
PT_COLORTHEME 

Definition at line 40 of file pcm_data.h.

41{
46};
@ PT_COLORTHEME
Definition: pcm_data.h:45
@ PT_INVALID
Definition: pcm_data.h:42
@ PT_PLUGIN
Definition: pcm_data.h:43
@ PT_LIBRARY
Definition: pcm_data.h:44

◆ PCM_PACKAGE_VERSION_STATUS

Enumerator
PVS_INVALID 
PVS_STABLE 
PVS_TESTING 
PVS_DEVELOPMENT 
PVS_DEPRECATED 

Definition at line 50 of file pcm_data.h.

51{
57};
@ PVS_INVALID
Definition: pcm_data.h:52
@ PVS_DEVELOPMENT
Definition: pcm_data.h:55
@ PVS_STABLE
Definition: pcm_data.h:53
@ PVS_TESTING
Definition: pcm_data.h:54
@ PVS_DEPRECATED
Definition: pcm_data.h:56

Function Documentation

◆ from_json() [1/5]

void from_json ( const json j,
PACKAGE_VERSION v 
)

Definition at line 68 of file pcm_data.cpp.

69{
70 j.at( "version" ).get_to( v.version );
71 j.at( "status" ).get_to( v.status );
72 j.at( "kicad_version" ).get_to( v.kicad_version );
73
74 to_optional( j, "version_epoch", v.version_epoch );
75 to_optional( j, "download_url", v.download_url );
76 to_optional( j, "download_sha256", v.download_sha256 );
77 to_optional( j, "download_size", v.download_size );
78 to_optional( j, "install_size", v.install_size );
79 to_optional( j, "kicad_version_max", v.kicad_version_max );
80
81 if( j.contains( "platforms" ) )
82 j.at( "platforms" ).get_to( v.platforms );
83
84 if( j.contains( "keep_on_update" ) )
85 j.at( "keep_on_update" ).get_to( v.keep_on_update );
86}
void to_optional(const json &j, const char *key, std::optional< T > &dest)
Definition: pcm_data.cpp:25
std::optional< uint64_t > download_size
Definition: pcm_data.h:79
std::optional< uint64_t > install_size
Definition: pcm_data.h:80
wxString version
Definition: pcm_data.h:75
PCM_PACKAGE_VERSION_STATUS status
Definition: pcm_data.h:81
std::optional< wxString > kicad_version_max
Definition: pcm_data.h:84
std::optional< wxString > download_url
Definition: pcm_data.h:77
std::optional< wxString > download_sha256
Definition: pcm_data.h:78
std::optional< int > version_epoch
Definition: pcm_data.h:76
std::vector< std::string > platforms
Definition: pcm_data.h:82
wxString kicad_version
Definition: pcm_data.h:83
std::vector< std::string > keep_on_update
Definition: pcm_data.h:85

References PACKAGE_VERSION::download_sha256, PACKAGE_VERSION::download_size, PACKAGE_VERSION::download_url, PACKAGE_VERSION::install_size, PACKAGE_VERSION::keep_on_update, PACKAGE_VERSION::kicad_version, PACKAGE_VERSION::kicad_version_max, PACKAGE_VERSION::platforms, PACKAGE_VERSION::status, to_optional(), PACKAGE_VERSION::version, and PACKAGE_VERSION::version_epoch.

◆ from_json() [2/5]

void from_json ( const json j,
PCM_INSTALLATION_ENTRY e 
)

Definition at line 189 of file pcm_data.cpp.

190{
191 j.at( "package" ).get_to( e.package );
192 j.at( "current_version" ).get_to( e.current_version );
193 j.at( "repository_id" ).get_to( e.repository_id );
194 j.at( "repository_name" ).get_to( e.repository_name );
195 j.at( "install_timestamp" ).get_to( e.install_timestamp );
196
197 e.pinned = false;
198 if( j.contains( "pinned" ) )
199 j.at( "pinned" ).get_to( e.pinned );
200}
wxString repository_name
Definition: pcm_data.h:142
PCM_PACKAGE package
Definition: pcm_data.h:139
uint64_t install_timestamp
Definition: pcm_data.h:143
wxString repository_id
Definition: pcm_data.h:141
wxString current_version
Definition: pcm_data.h:140
bool pinned
Definition: pcm_data.h:144

References PCM_INSTALLATION_ENTRY::current_version, PCM_INSTALLATION_ENTRY::install_timestamp, PCM_INSTALLATION_ENTRY::package, PCM_INSTALLATION_ENTRY::pinned, PCM_INSTALLATION_ENTRY::repository_id, and PCM_INSTALLATION_ENTRY::repository_name.

◆ from_json() [3/5]

void from_json ( const json j,
PCM_PACKAGE p 
)

Definition at line 112 of file pcm_data.cpp.

113{
114 j.at( "name" ).get_to( p.name );
115 j.at( "description" ).get_to( p.description );
116 j.at( "description_full" ).get_to( p.description_full );
117 j.at( "identifier" ).get_to( p.identifier );
118 j.at( "type" ).get_to( p.type );
119 j.at( "author" ).get_to( p.author );
120 j.at( "license" ).get_to( p.license );
121 j.at( "resources" ).get_to( p.resources );
122 j.at( "versions" ).get_to( p.versions );
123
124 to_optional( j, "maintainer", p.maintainer );
125
126 if( j.contains( "tags" ) )
127 j.at( "tags" ).get_to( p.tags );
128
129 if( j.contains( "keep_on_update" ) )
130 j.at( "keep_on_update" ).get_to( p.keep_on_update );
131}
wxString description
Definition: pcm_data.h:97
wxString description_full
Definition: pcm_data.h:98
wxString identifier
Definition: pcm_data.h:99
wxString license
Definition: pcm_data.h:103
std::vector< std::string > tags
Definition: pcm_data.h:105
STRING_MAP resources
Definition: pcm_data.h:104
std::optional< PCM_CONTACT > maintainer
Definition: pcm_data.h:102
wxString name
Definition: pcm_data.h:96
std::vector< PACKAGE_VERSION > versions
Definition: pcm_data.h:107
PCM_PACKAGE_TYPE type
Definition: pcm_data.h:100
std::vector< std::string > keep_on_update
Definition: pcm_data.h:106
PCM_CONTACT author
Definition: pcm_data.h:101

References PCM_PACKAGE::author, PCM_PACKAGE::description, PCM_PACKAGE::description_full, PCM_PACKAGE::identifier, PCM_PACKAGE::keep_on_update, PCM_PACKAGE::license, PCM_PACKAGE::maintainer, PCM_PACKAGE::name, PCM_PACKAGE::resources, PCM_PACKAGE::tags, to_optional(), PCM_PACKAGE::type, and PCM_PACKAGE::versions.

◆ from_json() [4/5]

void from_json ( const json j,
PCM_REPOSITORY r 
)

Definition at line 167 of file pcm_data.cpp.

168{
169 j.at( "name" ).get_to( r.name );
170 j.at( "packages" ).get_to( r.packages );
171
172 to_optional( j, "resources", r.resources );
173 to_optional( j, "manifests", r.manifests );
174 to_optional( j, "maintainer", r.maintainer );
175}
PCM_RESOURCE_REFERENCE packages
Definition: pcm_data.h:124
std::optional< PCM_CONTACT > maintainer
Definition: pcm_data.h:127
wxString name
Definition: pcm_data.h:123
std::optional< PCM_RESOURCE_REFERENCE > manifests
Definition: pcm_data.h:126
std::optional< PCM_RESOURCE_REFERENCE > resources
Definition: pcm_data.h:125

References PCM_REPOSITORY::maintainer, PCM_REPOSITORY::manifests, PCM_REPOSITORY::name, PCM_REPOSITORY::packages, PCM_REPOSITORY::resources, and to_optional().

◆ from_json() [5/5]

void from_json ( const json j,
PCM_RESOURCE_REFERENCE r 
)

Definition at line 143 of file pcm_data.cpp.

144{
145 j.at( "url" ).get_to( r.url );
146 j.at( "update_timestamp" ).get_to( r.update_timestamp );
147
148 to_optional( j, "sha256", r.sha256 );
149}
std::optional< wxString > sha256
Definition: pcm_data.h:115
uint64_t update_timestamp
Definition: pcm_data.h:116

References PCM_RESOURCE_REFERENCE::sha256, to_optional(), PCM_RESOURCE_REFERENCE::update_timestamp, and PCM_RESOURCE_REFERENCE::url.

◆ NLOHMANN_JSON_SERIALIZE_ENUM()

NLOHMANN_JSON_SERIALIZE_ENUM ( PCM_PACKAGE_TYPE  ,
{ { PT_INVALID, "invalid" }, { PT_PLUGIN, "plugin" }, { PT_LIBRARY, "library" }, { PT_COLORTHEME, "colortheme" }, }   
)

◆ to_json() [1/4]

void to_json ( json j,
const PCM_INSTALLATION_ENTRY e 
)

Definition at line 178 of file pcm_data.cpp.

179{
180 j = json{ { "package", e.package },
181 { "current_version", e.current_version },
182 { "repository_id", e.repository_id },
183 { "repository_name", e.repository_name },
184 { "install_timestamp", e.install_timestamp },
185 { "pinned", e.pinned } };
186}
nlohmann::json json
Definition: gerbview.cpp:44

References PCM_INSTALLATION_ENTRY::current_version, PCM_INSTALLATION_ENTRY::install_timestamp, PCM_INSTALLATION_ENTRY::package, PCM_INSTALLATION_ENTRY::pinned, PCM_INSTALLATION_ENTRY::repository_id, and PCM_INSTALLATION_ENTRY::repository_name.

◆ to_json() [2/4]

void to_json ( json j,
const PCM_PACKAGE p 
)

Definition at line 89 of file pcm_data.cpp.

90{
91 j = json{ { "name", p.name },
92 { "description", p.description },
93 { "description_full", p.description_full },
94 { "identifier", p.identifier },
95 { "type", p.type },
96 { "author", p.author },
97 { "license", p.license },
98 { "resources", p.resources },
99 { "versions", p.versions } };
100
101 if( p.maintainer )
102 j["maintainer"] = *p.maintainer;
103
104 if( p.tags.size() > 0 )
105 j["tags"] = p.tags;
106
107 if( p.keep_on_update.size() > 0 )
108 j["keep_on_update"] = p.keep_on_update;
109}

References PCM_PACKAGE::author, PCM_PACKAGE::description, PCM_PACKAGE::description_full, PCM_PACKAGE::identifier, PCM_PACKAGE::keep_on_update, PCM_PACKAGE::license, PCM_PACKAGE::maintainer, PCM_PACKAGE::name, PCM_PACKAGE::resources, PCM_PACKAGE::tags, PCM_PACKAGE::type, and PCM_PACKAGE::versions.

◆ to_json() [3/4]

void to_json ( json j,
const PCM_REPOSITORY r 
)

Definition at line 152 of file pcm_data.cpp.

153{
154 j = json{ { "name", r.name }, { "packages", r.packages } };
155
156 if( r.resources )
157 j["resources"] = *r.resources;
158
159 if( r.manifests )
160 j["manifests"] = *r.manifests;
161
162 if( r.maintainer )
163 j["maintainer"] = *r.maintainer;
164}

References PCM_REPOSITORY::maintainer, PCM_REPOSITORY::manifests, PCM_REPOSITORY::name, PCM_REPOSITORY::packages, and PCM_REPOSITORY::resources.

◆ to_json() [4/4]

void to_json ( json j,
const PCM_RESOURCE_REFERENCE r 
)

Definition at line 134 of file pcm_data.cpp.

135{
136 j = json{ { "url", r.url }, { "update_timestamp", r.update_timestamp } };
137
138 if( r.sha256 )
139 j["sha256"] = *r.sha256;
140}

References PCM_RESOURCE_REFERENCE::sha256, PCM_RESOURCE_REFERENCE::update_timestamp, and PCM_RESOURCE_REFERENCE::url.