KiCad PCB EDA Suite
pcm_data.h File Reference
#include "core/wx_stl_compat.h"
#include <boost/optional.hpp>
#include <map>
#include <nlohmann/json.hpp>
#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

 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)
 
 NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE (PCM_INSTALLATION_ENTRY, package, current_version, repository_id, repository_name, install_timestamp)
 

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 {
42  PT_INVALID,
43  PT_PLUGIN,
44  PT_LIBRARY,
46 };

◆ PCM_PACKAGE_VERSION_STATUS

Enumerator
PVS_INVALID 
PVS_STABLE 
PVS_TESTING 
PVS_DEVELOPMENT 
PVS_DEPRECATED 

Definition at line 50 of file pcm_data.h.

Function Documentation

◆ from_json() [1/4]

void from_json ( const json j,
PACKAGE_VERSION v 
)

Definition at line 65 of file pcm_data.cpp.

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

References PACKAGE_VERSION::download_sha256, PACKAGE_VERSION::download_size, PACKAGE_VERSION::download_url, PACKAGE_VERSION::install_size, 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/4]

void from_json ( const json j,
PCM_PACKAGE p 
)

Definition at line 103 of file pcm_data.cpp.

104 {
105  j.at( "name" ).get_to( p.name );
106  j.at( "description" ).get_to( p.description );
107  j.at( "description_full" ).get_to( p.description_full );
108  j.at( "identifier" ).get_to( p.identifier );
109  j.at( "type" ).get_to( p.type );
110  j.at( "author" ).get_to( p.author );
111  j.at( "license" ).get_to( p.license );
112  j.at( "resources" ).get_to( p.resources );
113  j.at( "versions" ).get_to( p.versions );
114 
115  to_optional( j, "maintainer", p.maintainer );
116 
117  if( j.contains( "tags" ) )
118  j.at( "tags" ).get_to( p.tags );
119 }
boost::optional< PCM_CONTACT > maintainer
Definition: pcm_data.h:101
PCM_PACKAGE_TYPE type
Definition: pcm_data.h:99
wxString description
Definition: pcm_data.h:96
wxString description_full
Definition: pcm_data.h:97
std::vector< std::string > tags
Definition: pcm_data.h:104
wxString name
Definition: pcm_data.h:95
STRING_MAP resources
Definition: pcm_data.h:103
std::vector< PACKAGE_VERSION > versions
Definition: pcm_data.h:105
void to_optional(const json &j, const char *key, boost::optional< T > &dest)
Definition: pcm_data.cpp:25
wxString identifier
Definition: pcm_data.h:98
PCM_CONTACT author
Definition: pcm_data.h:100
wxString license
Definition: pcm_data.h:102

References PCM_PACKAGE::author, PCM_PACKAGE::description, PCM_PACKAGE::description_full, PCM_PACKAGE::identifier, 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() [3/4]

void from_json ( const json j,
PCM_RESOURCE_REFERENCE r 
)

Definition at line 131 of file pcm_data.cpp.

132 {
133  j.at( "url" ).get_to( r.url );
134  j.at( "update_timestamp" ).get_to( r.update_timestamp );
135 
136  to_optional(j, "sha256", r.sha256 );
137 }
E_SERIE r
Definition: eserie.cpp:41
void to_optional(const json &j, const char *key, boost::optional< T > &dest)
Definition: pcm_data.cpp:25

References r, and to_optional().

◆ from_json() [4/4]

void from_json ( const json j,
PCM_REPOSITORY r 
)

Definition at line 155 of file pcm_data.cpp.

156 {
157  j.at( "name" ).get_to( r.name );
158  j.at( "packages" ).get_to( r.packages );
159 
160  to_optional(j, "resources", r.resources );
161  to_optional(j, "manifests", r.manifests );
162  to_optional(j, "maintainer", r.maintainer );
163 }
E_SERIE r
Definition: eserie.cpp:41
void to_optional(const json &j, const char *key, boost::optional< T > &dest)
Definition: pcm_data.cpp:25

References r, and to_optional().

◆ NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE()

NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE ( PCM_INSTALLATION_ENTRY  ,
package  ,
current_version  ,
repository_id  ,
repository_name  ,
install_timestamp   
)

◆ 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/3]

void to_json ( json j,
const PCM_PACKAGE p 
)

Definition at line 83 of file pcm_data.cpp.

84 {
85  j = json{ { "name", p.name },
86  { "description", p.description },
87  { "description_full", p.description_full },
88  { "identifier", p.identifier },
89  { "type", p.type },
90  { "author", p.author },
91  { "license", p.license },
92  { "resources", p.resources },
93  { "versions", p.versions } };
94 
95  if( p.maintainer )
96  j["maintainer"] = p.maintainer.get();
97 
98  if( p.tags.size() > 0 )
99  j["tags"] = p.tags;
100 }
boost::optional< PCM_CONTACT > maintainer
Definition: pcm_data.h:101
PCM_PACKAGE_TYPE type
Definition: pcm_data.h:99
wxString description
Definition: pcm_data.h:96
nlohmann::json json
Definition: gerbview.cpp:41
wxString description_full
Definition: pcm_data.h:97
std::vector< std::string > tags
Definition: pcm_data.h:104
wxString name
Definition: pcm_data.h:95
STRING_MAP resources
Definition: pcm_data.h:103
std::vector< PACKAGE_VERSION > versions
Definition: pcm_data.h:105
wxString identifier
Definition: pcm_data.h:98
PCM_CONTACT author
Definition: pcm_data.h:100
wxString license
Definition: pcm_data.h:102

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

◆ to_json() [2/3]

void to_json ( json j,
const PCM_RESOURCE_REFERENCE r 
)

Definition at line 122 of file pcm_data.cpp.

123 {
124  j = json{ { "url", r.url }, { "update_timestamp", r.update_timestamp } };
125 
126  if( r.sha256 )
127  j["sha256"] = r.sha256.get();
128 }
nlohmann::json json
Definition: gerbview.cpp:41
E_SERIE r
Definition: eserie.cpp:41

References r.

◆ to_json() [3/3]

void to_json ( json j,
const PCM_REPOSITORY r 
)

Definition at line 140 of file pcm_data.cpp.

141 {
142  j = json{ { "name", r.name }, { "packages", r.packages } };
143 
144  if( r.resources )
145  j["resources"] = r.resources.get();
146 
147  if( r.manifests )
148  j["manifests"] = r.manifests.get();
149 
150  if( r.maintainer )
151  j["maintainer"] = r.maintainer.get();
152 }
nlohmann::json json
Definition: gerbview.cpp:41
E_SERIE r
Definition: eserie.cpp:41

References r.