KiCad PCB EDA Suite
Loading...
Searching...
No Matches
rc_json_schema.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 The KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software: you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation, either version 3 of the License, or (at your
9 * option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#ifndef RC_JSON_SCHEMA_H
21#define RC_JSON_SCHEMA_H
22
23#include <json_common.h>
24#include <wx/string.h>
25#include <vector>
26#include <json_conversions.h>
27
34namespace RC_JSON
35{
37{
38 double x;
39 double y;
40};
41
43
44
46{
47 wxString uuid;
48 wxString description;
50};
51
53
54
56{
57 wxString type;
58 wxString description;
59 wxString severity;
60 std::vector<AFFECTED_ITEM> items;
62 wxString comment; // exclusion comment; if any
63};
64
65inline void to_json( nlohmann::json& aJson, const VIOLATION& aViolation )
66{
67 aJson["type"] = aViolation.type;
68 aJson["description"] = aViolation.description;
69 aJson["severity"] = aViolation.severity;
70 aJson["items"] = aViolation.items;
71
72 if( aViolation.excluded )
73 {
74 aJson["excluded"] = aViolation.excluded;
75 aJson["comment"] = aViolation.comment;
76 }
77}
78
79inline void from_json( const nlohmann::json& aJson, VIOLATION& aViolation )
80{
81 aJson.at( "type" ).get_to( aViolation.type );
82 aJson.at( "description" ).get_to( aViolation.description );
83 aJson.at( "severity" ).get_to( aViolation.severity );
84 aJson.at( "items" ).get_to( aViolation.items );
85 aJson.at( "excluded" ).get_to( aViolation.excluded );
86 aJson.at( "comment" ).get_to( aViolation.comment );
87}
88
89
91{
92 wxString key;
93 wxString description;
94};
95
97
98
100{
101 wxString $schema;
102 wxString source;
103 wxString date;
105 wxString type;
107};
108
109
111{
112 DRC_REPORT() { type = wxS( "drc" ); }
113
114 std::vector<VIOLATION> violations;
115 std::vector<VIOLATION> unconnected_items;
116 std::vector<VIOLATION> schematic_parity;
117 std::vector<wxString> included_severities;
118 std::vector<IGNORED_CHECK> ignored_checks;
119};
120
121NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE( DRC_REPORT, $schema, source, date, kicad_version, violations,
122 unconnected_items, schematic_parity, coordinate_units,
123 included_severities, ignored_checks )
124
125
126struct ERC_SHEET
127{
128 wxString uuid_path;
129 wxString path;
130 std::vector<VIOLATION> violations;
131};
132
133NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE( ERC_SHEET, uuid_path, path, violations )
134
135
137{
138 ERC_REPORT() { type = wxS( "erc" ); }
139
140 std::vector<ERC_SHEET> sheets;
141 std::vector<wxString> included_severities;
142 std::vector<IGNORED_CHECK> ignored_checks;
143};
144
145NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE( ERC_REPORT, $schema, source, date, kicad_version, sheets,
146 coordinate_units, included_severities, ignored_checks )
147
148} // namespace RC_JSON
149
150#endif
Contains the json serialization structs for DRC and ERC reports If you are trying to change the outpu...
Definition rc_item.h:40
void from_json(const nlohmann::json &aJson, VIOLATION &aViolation)
void to_json(nlohmann::json &aJson, const VIOLATION &aViolation)
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(DRC_REPORT, $schema, source, date, kicad_version, violations, unconnected_items, schematic_parity, coordinate_units, included_severities, ignored_checks) struct ERC_SHEET
std::vector< wxString > included_severities
std::vector< VIOLATION > unconnected_items
std::vector< IGNORED_CHECK > ignored_checks
std::vector< VIOLATION > violations
std::vector< VIOLATION > schematic_parity
std::vector< wxString > included_severities
std::vector< ERC_SHEET > sheets
std::vector< IGNORED_CHECK > ignored_checks
std::vector< AFFECTED_ITEM > items
std::string path