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 (C) 2023 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 <nlohmann/json.hpp>
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};
42
44{
45 wxString uuid;
46 wxString description;
48};
49
51
53{
54 wxString type;
55 wxString description;
56 wxString severity;
57 std::vector<AFFECTED_ITEM> items;
59};
60
61inline void to_json( nlohmann::json& aJson, const VIOLATION& aViolation )
62{
63 aJson["type"] = aViolation.type;
64 aJson["description"] = aViolation.description;
65 aJson["severity"] = aViolation.severity;
66 aJson["items"] = aViolation.items;
67
68 if( aViolation.excluded )
69 aJson["excluded"] = aViolation.excluded;
70}
71inline void from_json( const nlohmann::json& aJson, VIOLATION& aViolation )
72{
73 aJson.at( "type" ).get_to( aViolation.type );
74 aJson.at( "description" ).get_to( aViolation.description );
75 aJson.at( "severity" ).get_to( aViolation.severity );
76 aJson.at( "items" ).get_to( aViolation.items );
77 aJson.at( "excluded" ).get_to( aViolation.excluded );
78}
79
81{
82 wxString $schema;
83 wxString source;
84 wxString date;
85 wxString kicad_version;
86 wxString type;
88};
89
91{
92 DRC_REPORT() { type = wxS( "drc" ); }
93
94 std::vector<VIOLATION> violations;
95 std::vector<VIOLATION> unconnected_items;
96 std::vector<VIOLATION> schematic_parity;
97};
98
99NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE( DRC_REPORT, $schema, source, date, kicad_version, violations,
100 unconnected_items, schematic_parity, coordinate_units )
101
102struct ERC_SHEET
103{
104 wxString uuid_path;
105 wxString path;
106 std::vector<VIOLATION> violations;
107};
108
109NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE( ERC_SHEET, uuid_path, path, violations )
110
112{
113 ERC_REPORT() { type = wxS( "erc" ); }
114
115 std::vector<ERC_SHEET> sheets;
116};
117
118NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE( ERC_REPORT, $schema, source, date, kicad_version, sheets,
119 coordinate_units )
120
121} // namespace RC_JSON
122
123#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) struct ERC_SHEET
std::vector< VIOLATION > unconnected_items
std::vector< VIOLATION > violations
std::vector< VIOLATION > schematic_parity
std::vector< ERC_SHEET > sheets
std::vector< AFFECTED_ITEM > items