KiCad PCB EDA Suite
Loading...
Searching...
No Matches
api_utils.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) 2024 Jon Evans <[email protected]>
5 * Copyright (C) 2024 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 KICAD_API_UTILS_H
22#define KICAD_API_UTILS_H
23
24#include <optional>
25#include <google/protobuf/any.pb.h>
26
27#include <core/typeinfo.h>
28#include <lib_id.h>
29#include <api/common/types/base_types.pb.h>
30#include <layer_ids.h>
32#include <math/vector2d.h>
33
35
36namespace kiapi::common
37{
38
39std::optional<KICAD_T> TypeNameFromAny( const google::protobuf::Any& aMessage );
40
41LIB_ID LibIdFromProto( const types::LibraryIdentifier& aId );
42
43types::LibraryIdentifier LibIdToProto( const LIB_ID& aId );
44
45void PackVector2( types::Vector2& aOutput, const VECTOR2I& aInput );
46
47VECTOR2I UnpackVector2( const types::Vector2& aInput );
48
49void PackBox2( types::Box2& aOutput, const BOX2I& aInput );
50
51BOX2I UnpackBox2( const types::Box2& aInput );
52
53void PackPolyLine( kiapi::common::types::PolyLine& aOutput, const SHAPE_LINE_CHAIN& aSlc );
54
55SHAPE_LINE_CHAIN UnpackPolyLine( const kiapi::common::types::PolyLine& aInput );
56
57} // namespace kiapi::common
58
59#endif //KICAD_API_UTILS_H
A logical library item identifier and consists of various portions much like a URI.
Definition: lib_id.h:49
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
std::optional< KICAD_T > TypeNameFromAny(const google::protobuf::Any &aMessage)
Definition: api_utils.cpp:27
types::LibraryIdentifier LibIdToProto(const LIB_ID &aId)
Definition: api_utils.cpp:60
VECTOR2I UnpackVector2(const types::Vector2 &aInput)
Definition: api_utils.cpp:76
void PackVector2(types::Vector2 &aOutput, const VECTOR2I &aInput)
Definition: api_utils.cpp:69
void PackPolyLine(kiapi::common::types::PolyLine &aOutput, const SHAPE_LINE_CHAIN &aSlc)
Definition: api_utils.cpp:95
BOX2I UnpackBox2(const types::Box2 &aInput)
Definition: api_utils.cpp:89
SHAPE_LINE_CHAIN UnpackPolyLine(const kiapi::common::types::PolyLine &aInput)
Definition: api_utils.cpp:125
LIB_ID LibIdFromProto(const types::LibraryIdentifier &aId)
Definition: api_utils.cpp:54
void PackBox2(types::Box2 &aOutput, const BOX2I &aInput)
Definition: api_utils.cpp:82