KiCad PCB EDA Suite
Loading...
Searching...
No Matches
generated_table_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
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
20#ifndef GENERATED_TABLE_SCHEMA_H
21#define GENERATED_TABLE_SCHEMA_H
22
23#include <cstdint>
24#include <vector>
25
26#include <lset.h>
27#include <wx/string.h>
28
29
36
37
44
45
50constexpr int GENERATED_TABLE_MAX_COLUMN_WIDTH = 1000 * 1000000;
51
52
59constexpr int64_t GENERATED_TABLE_MAX_TOTAL_WIDTH = 10LL * 1000 * 1000000;
60
61
68{
69 int m_Id = 0;
70 wxString m_Heading;
72 int m_Width = 0; // minimum width, 0 = autosize
73
74 bool operator==( const GENERATED_TABLE_COLUMN& aOther ) const = default;
75};
76
77
83{
84 int m_Id;
85 const char* m_Token; // file and JSON token, never translated
86 const wxChar* m_Heading; // _HKI() string, translated when used
88 bool m_DefaultShown; // part of Defaults()
89 const wxChar* m_Label = nullptr; // _HKI() UI name, the heading when null
90};
91
92
102{
103public:
104 GENERATED_TABLE_SCHEMA( std::vector<GENERATED_TABLE_COLUMN_DEF> aDefs, GENERATED_TABLE_UNITS aDefaultUnits,
105 int aDefaultPrecision );
106
107 const std::vector<GENERATED_TABLE_COLUMN_DEF>& Defs() const { return m_defs; }
108
109 const GENERATED_TABLE_COLUMN_DEF* Find( int aId ) const;
110 const GENERATED_TABLE_COLUMN_DEF* FindToken( const wxString& aToken ) const;
111
116 const char* Token( int aId ) const;
117
118 GENERATED_TABLE_COLUMN DefaultColumn( int aId ) const;
119 std::vector<GENERATED_TABLE_COLUMN> Defaults() const;
120
127 bool Validate( std::vector<GENERATED_TABLE_COLUMN>& aColumns ) const;
128
130 int DefaultPrecision() const { return m_defaultPrecision; }
131
132private:
133 std::vector<GENERATED_TABLE_COLUMN_DEF> m_defs;
136};
137
138
144wxString FormatGeneratedTableLength( int aValue, GENERATED_TABLE_UNITS aUnits, int aPrecision );
145
146
152bool GeneratedTableUnitsFromToken( const wxString& aToken, GENERATED_TABLE_UNITS& aUnits );
154bool GeneratedTableAlignFromToken( const wxString& aToken, GENERATED_TABLE_ALIGN& aAlign );
155
156
164
165#endif // GENERATED_TABLE_SCHEMA_H
const char * Token(int aId) const
The file token for a known id, or a stable placeholder for one the schema does not recognize,...
GENERATED_TABLE_COLUMN DefaultColumn(int aId) const
std::vector< GENERATED_TABLE_COLUMN > Defaults() const
GENERATED_TABLE_UNITS m_defaultUnits
const std::vector< GENERATED_TABLE_COLUMN_DEF > & Defs() const
const GENERATED_TABLE_COLUMN_DEF * FindToken(const wxString &aToken) const
const GENERATED_TABLE_COLUMN_DEF * Find(int aId) const
GENERATED_TABLE_SCHEMA(std::vector< GENERATED_TABLE_COLUMN_DEF > aDefs, GENERATED_TABLE_UNITS aDefaultUnits, int aDefaultPrecision)
GENERATED_TABLE_UNITS DefaultUnits() const
bool Validate(std::vector< GENERATED_TABLE_COLUMN > &aColumns) const
Drop a column whose id the schema does not know and a column that repeats an id already kept,...
std::vector< GENERATED_TABLE_COLUMN_DEF > m_defs
LSET is a set of PCB_LAYER_IDs.
Definition lset.h:37
bool GeneratedTableUnitsFromToken(const wxString &aToken, GENERATED_TABLE_UNITS &aUnits)
const char * GeneratedTableUnitsToken(GENERATED_TABLE_UNITS aUnits)
Stable file tokens, independent of enum ordering so inserting a value later cannot change what an exi...
LSET DocumentationLayers()
Layers a drill chart or drill map may live on.
wxString FormatGeneratedTableLength(int aValue, GENERATED_TABLE_UNITS aUnits, int aPrecision)
Render a length the way a generated table's cell shows it.
bool GeneratedTableAlignFromToken(const wxString &aToken, GENERATED_TABLE_ALIGN &aAlign)
GENERATED_TABLE_UNITS
constexpr int GENERATED_TABLE_MAX_COLUMN_WIDTH
A column can be no wider than this.
constexpr int64_t GENERATED_TABLE_MAX_TOTAL_WIDTH
A column set can be no wider than this in total, summed after each column is clamped to GENERATED_TAB...
GENERATED_TABLE_ALIGN
const char * GeneratedTableAlignToken(GENERATED_TABLE_ALIGN aAlign)
@ INCH
Definition rs274x.cpp:61
The column a schema knows how to build, independent of whether any particular table shows it.
A column as a generated table actually carries it: what a row's cell in that column holds and how it ...
GENERATED_TABLE_ALIGN m_Align
bool operator==(const GENERATED_TABLE_COLUMN &aOther) const =default
static const long long MM