KiCad PCB EDA Suite
Loading...
Searching...
No Matches
allegro_pcb_structs.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 Quilter
5 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 3
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, you may find one here:
19 * http://www.gnu.org/licenses/gpl-3.0.html
20 * or you may search the http://www.gnu.org website for the version 3 license,
21 * or you may write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23 */
24
25#pragma once
26
27#include "string_any_map.h"
28
29
30#include <array>
31#include <cstdint>
32#include <optional>
33#include <memory>
34#include <string>
35#include <unordered_map>
36#include <variant>
37#include <vector>
38
39
40namespace ALLEGRO
41{
42
53{
54public:
55 BLOCK_BASE( uint8_t aBlockType, size_t aOffset ) :
56 m_blockType( aBlockType ),
57 m_offset( aOffset )
58 {}
59
60 virtual ~BLOCK_BASE() = default;
61
62 uint8_t GetBlockType() const { return m_blockType; }
63 size_t GetOffset() const { return m_offset; }
64
65 // If this block data has a key, return it, else 0
66 uint32_t GetKey() const;
67
68private:
69 uint8_t m_blockType;
70 size_t m_offset;
71};
72
73
74template <typename T>
75class BLOCK : public BLOCK_BASE
76{
77public:
78 BLOCK( uint8_t aBlockType, size_t aOffset ) :
79 BLOCK_BASE( aBlockType, aOffset )
80 {}
81
82 const T& GetData() const { return m_data; }
83 T& GetData() { return m_data; }
84
85private:
87};
88
89
91{
92 x1B_NET = 0x1B,
93};
94
95
106enum class FMT_VER
107{
109 V_PRE_V16, // Allegro versions before 16.0 (unsupported binary format)
110 V_160, // Allegro 16.0, 0x00130000
111 V_162, // Allegro 16.2 0x00130400
112 V_164, // Allegro 16.4, 0x00130C00
113 V_165, // Allegro 16.5, 0x00131000
114 V_166, // Allegro 16.6, 0x00131500
115 V_172, // Allegro 17.2, 0x00140400
116 V_174, // Allegro 17.4, 0x00140900
117 V_175, // Allegro 17.5, 0x00141500
118 V_180, // Allegro 18.0, 0x00150000
119};
120
121constexpr bool operator>=( FMT_VER lhs, FMT_VER rhs )
122{
123 return static_cast<uint32_t>( lhs ) >= static_cast<uint32_t>( rhs );
124}
125
126
127template <typename T>
129{
130 using value_type = T;
131
136 virtual bool exists( FMT_VER ver ) const = 0;
137
138 // Access to the value (use std::optional-like semantics)
139 T& value() { return *m_Value; }
140 const T& value() const { return *m_Value; }
141 bool has_value() const { return m_Value.has_value(); }
142
143 const T& value_or( const T& aDefault ) const { return has_value() ? value() : aDefault; }
144
145 T& operator*() { return *m_Value; }
146 const T& operator*() const { return *m_Value; }
147
148 T* operator->() { return m_Value.operator->(); }
149 const T* operator->() const { return m_Value.operator->(); }
150
151 // Assigmnent operator
153 {
154 m_Value = value;
155 return *this;
156 }
158 {
159 m_Value = std::move( value );
160 return *this;
161 }
162
163private:
164 std::optional<T> m_Value;
165};
166
167
172template <FMT_VER MinVersion, typename T>
173struct COND_GE : public COND_FIELD_BASE<T>
174{
175 constexpr bool exists( FMT_VER ver ) const override { return ver >= MinVersion; }
176
177 using COND_FIELD_BASE<T>::operator=;
178};
179
180
185template <FMT_VER MaxVersion, typename T>
186struct COND_LT : public COND_FIELD_BASE<T>
187{
188 constexpr bool exists( FMT_VER ver ) const override { return ver < MaxVersion; }
189
190 using COND_FIELD_BASE<T>::operator=;
191};
192
193
198template <FMT_VER GEVersion, FMT_VER LTVersion, typename T>
199struct COND_GE_LT : public COND_FIELD_BASE<T>
200{
201 constexpr bool exists( FMT_VER ver ) const override { return ver >= GEVersion && ver < LTVersion; }
202
203 using COND_FIELD_BASE<T>::operator=;
204};
205
206
208{
209 MILS = 0x01,
210 INCHES = 0x02,
214};
215
216
225{
227 {
228 uint32_t m_A;
230 };
231
238 {
239 uint32_t m_Tail;
240 uint32_t m_Head;
241 };
242
243 uint32_t m_Magic;
244
245 uint32_t m_Unknown1a; // 0x03
246 uint32_t m_FileRole; // 0x01 (.brd) or 0x02 (.dra) (?)
247 uint32_t m_Unknown1b; // 0x03
248 uint32_t m_WriterProgram; // 0x09 (Allegro) or 0x130000 (DB Doctor) (?)
249
251
252 uint32_t m_UnknownMagic; // This is always 0x000a0d0a?
253 uint32_t m_UnknownFlags; // This looks like flags: 0x01000000, 0x0400000, 0x06000000
254
255 // In this block of 7 uint32s, it seems they have very different meanings pre and post v18
256
257 // Pre v18, these are all unknown
258 // - 3 and 4 are the same.
259 // - 5 and 6 arer of a similar size
261
262 // V18
263 COND_GE<FMT_VER::V_180, uint32_t> m_Unknown2a_V18; // Looks like an 'end pointer' like 0x27_end
270
271 // V180 has 6 additional linked lists in the header
272 // 5 of them are at the start
278
279 // Linked lists grouping top-level elements by type
280 LINKED_LIST m_LL_0x04; // Net assignments
281 LINKED_LIST m_LL_0x06; // Component definitions
282 LINKED_LIST m_LL_0x0C; // Pin definitions
283 LINKED_LIST m_LL_Shapes; // Shape segments (0x0E) and shapes (0x28)
286 LINKED_LIST m_LL_0x1C; // Padstacks
287 LINKED_LIST m_LL_0x24_0x28; // Rects and shapes
289 LINKED_LIST m_LL_0x2B; // Footprint definitions
290 LINKED_LIST m_LL_0x03_0x30; // Fields (0x03) and string wrappers (0x30)
291 LINKED_LIST m_LL_0x0A; // DRC elements
292 LINKED_LIST m_LL_0x1D_0x1E_0x1F; // Constraint sets, SI models, padstack dims
296 LINKED_LIST m_LL_0x0C_2; // Secondary pin definitions
298
299 // For some reason the 0x35 extents are recorded in the header
302
306
309
311
313
316
317 // Fixed length string field
318 std::array<char, 60> m_AllegroVersion;
319
320 uint32_t m_Unknown4;
321
322 uint32_t m_MaxKey;
323
326
328 // 3 empty bytes here?
329
330 uint32_t m_Unknown6;
332
333 // The end of the 0x27 object(?)
334 // In V18, this is relocated to m_0x27_End_V18
336
337 uint32_t m_Unknown8;
338
340
341 std::array<uint32_t, 50> m_Unknown9;
342
343 uint32_t m_Unknown10a; // Often 0x000500FF
344 uint32_t m_Unknown10b; // Similar to 0xFFA60000
345 uint32_t m_Unknown10c; // Usually 0x01
346
347 // E.g. 1000 for mils
349
356 std::array<LAYER_MAP_ENTRY, 25> m_LayerMap;
357
358 uint32_t GetStringsCount() const
359 {
360 if( m_StringCount_V18.has_value() )
361 return m_StringCount_V18.value();
362
363 return m_StringCount_preV18.value();
364 }
365
366 uint32_t Get_0x27_End() const
367 {
368 if( m_0x27_End_V18.has_value() )
369 return m_0x27_End_V18.value();
370
371 return m_0x27_End_preV18.value();
372 }
373
375 {
376 if( m_LL_Unknown5_V18.has_value() )
377 return m_LL_Unknown5_V18.value();
378
379 return m_LL_Unknown5_preV18.value();
380 }
381};
382
383
385{
411
418 {
419 // BOARD_GEOMETRY
440
441 // COMPONENT_VALUE / DEVICE_TYPE / USER_PART_NUMBER
442 // REF_DES / TOLERANCE
449
450 // ANALYSIS
457
458 // DRAWING_FORMAT
464
465 // PACKAGE_GEOMETRY
481
482 // MANUFACTURING
497
498 // CONSTRAINTS_REGION
499 CREG_ALL = 0xFD,
500
501 // PACKAGE_KEEPIN / ROUTE_KEEPIN
503
504 // PACKAGE_KEEPOUT / ROUTE_KEEPOUT / VIA_KEEPOUT
508 };
509
510 uint8_t m_Class;
511 uint8_t m_Subclass;
512
513 bool operator==( const LAYER_INFO& ) const = default;
514};
515
516
523{
525 uint8_t m_SubType;
526 uint32_t m_Key;
527 uint32_t m_Next;
528 uint32_t m_Parent;
529 uint32_t m_Unknown1;
530
532
533 uint32_t m_Width;
534
535 int32_t m_StartX;
536 int32_t m_StartY;
537 int32_t m_EndX;
538 int32_t m_EndY;
539
540 double m_CenterX; // Center
541 double m_CenterY;
542 double m_Radius;
543
544 std::array<int32_t, 4> m_BoundingBoxCoords;
545};
546
547
553{
554 struct SUB_0x6C
555 {
556 uint32_t m_NumEntries;
557 std::vector<uint32_t> m_Entries;
558 };
559
561 {
562 uint16_t m_X0;
563 uint16_t m_X1;
564 std::vector<uint32_t> m_Entries;
565 };
566
567 struct SUB_0xF6
568 {
569 std::array<uint32_t, 20> m_Entries;
570 };
571
572 uint16_t m_Hdr1;
573
574 uint32_t m_Key;
575 uint32_t m_Next;
576
577
579
580 uint8_t m_SubType;
581 uint8_t m_Hdr2;
582 uint16_t m_Size;
583
585
586 std::variant<uint32_t, std::array<uint32_t, 2>, std::string, SUB_0x6C, SUB_0x70_0x74, SUB_0xF6> m_Substruct;
587};
588
602
603
610{
611 uint8_t m_Type;
612 uint16_t m_R;
613 uint32_t m_Key;
614 uint32_t m_Next;
615 uint32_t m_Net;
616 uint32_t m_ConnItem;
617
619};
620
621
650
651
657{
658 uint32_t m_Key;
659
660 // Pointer to the next BLK_0x06_COMPONENT
661 uint32_t m_Next;
662 // Pointer to COMP_DEVICE_TYPE string
664 // Pointer to SYM_NAME string
665 uint32_t m_SymbolName;
666 // Points to 0x07, first instance
668 // Points to 0x0F, function slot
670 // Points to 0x08, pin number
672
673 // Points to 0x03, first 'field'
674 uint32_t m_Fields;
675
677};
678
679
705
706
737
738
759
760
765{
766 uint8_t m_T;
768 uint32_t m_Key;
769 uint32_t m_Next;
770 uint32_t m_Unknown1;
771
773
774 std::array<int32_t, 4> m_Coords;
775 std::array<uint32_t, 4> m_Unknown4;
776 std::array<uint32_t, 5> m_Unknown5;
777
779};
780
781
787{
789 {
790 // These are in the same order as the pad shapes, at least for the 'simple' shapes
791 CIRCLE = 0x02,
792 OCTAGON = 0x03,
793 CROSS = 0x04,
794 SQUARE = 0x05,
795 RECTANGLE = 0x06,
796 DIAMOND = 0x07,
797 PENTAGON = 0x0a,
798 OBLONG_X = 0x0b,
799 OBLONG_Y = 0x0c,
800 HEXAGON_X = 0x0f,
801 HEXAGON_Y = 0x10,
802 TRIANGLE = 0x12,
803 };
804
805 uint8_t m_T;
807 uint32_t m_Key;
808 uint32_t m_Next;
809
810 uint32_t m_Unknown1;
811 uint32_t m_Unknown2;
812
816
820
821 uint32_t m_Unknown4;
822
823 std::array<int32_t, 2> m_Coords;
824 std::array<int32_t, 2> m_Size;
825
826 std::array<uint32_t, 3> m_UnknownArray;
827
829
830 uint32_t GetShape() const
831 {
832 return m_Shape16x.value_or( m_Shape.value_or( 0 ) );
833 }
834};
835
836
861
862
867{
868 uint8_t m_T;
870 uint32_t m_Key;
871 uint32_t m_Next;
872 uint32_t m_FpPtr;
873
874 uint32_t m_Unknown1;
875 uint32_t m_Unknown2;
876 uint32_t m_Unknown3;
877
880
881 std::array<int32_t, 4> m_Coords;
882
883 std::array<uint32_t, 3> m_UnknownArr;
885 uint32_t m_Rotation;
886};
887
888
911
912
919{
920 uint32_t m_Key;
921
923
925
927
928 uint32_t m_PtrX12;
929 uint32_t m_Unknown3;
931 uint32_t m_Slots; // 0x0F?
932 uint32_t m_Fields; // Presumably a pointer to a string
933};
934
935
955
956
974
975
996
997
1006{
1007 uint32_t m_Key;
1008 uint32_t m_Next;
1009 uint32_t m_Parent;
1010 uint32_t m_Flags;
1011
1013
1014 uint32_t m_Width;
1015
1016 int32_t m_StartX;
1017 int32_t m_StartY;
1018 int32_t m_EndX;
1019 int32_t m_EndY;
1020};
1021
1028{
1029 uint32_t m_Key;
1030 uint32_t m_Next;
1031 uint32_t m_NetName;
1032
1033 uint32_t m_Unknown1;
1034
1036
1037 uint32_t m_Type;
1038
1040 uint32_t m_Ratline;
1042 uint32_t m_FieldsPtr;
1044 uint32_t m_ModelPtr;
1048};
1049
1050
1064
1065
1071{
1095
1096 uint8_t m_Type;
1100
1102
1103 int32_t m_W;
1104 int32_t m_H;
1105
1107
1108 int32_t m_X3;
1109 int32_t m_X4;
1110
1112
1119 uint32_t m_StrPtr;
1120
1121 // In versions < 17.2, seems to be not present in the last entry.
1122 std::optional<uint32_t> m_Z2;
1123};
1124
1125
1134{
1136
1140 uint8_t m_N;
1142 uint32_t m_Key;
1143 uint32_t m_Next;
1144 uint32_t m_PadStr;
1145
1150 uint32_t m_Drill;
1151 uint32_t m_Unknown2;
1152 uint32_t m_PadPath;
1153
1158
1160
1161 // Not sure if this is really a substruct
1162 // Only lower 4 bits (top 4 are type)
1163 uint8_t m_A;
1164 uint8_t m_B;
1165 uint8_t m_C;
1166 uint8_t m_D;
1167
1171
1173
1175
1176 // Presumably the counterpart to m_Unknown10
1177 // Or just padding (?)
1179
1186 std::array<uint32_t, 8> m_DrillArr;
1187
1195
1197
1203
1223 {
1224 // V<172 verified slots
1228
1229 // V>=172 verified slots
1231 };
1232
1238 {
1239 // First slot: Antipad
1241 // Thermal relief shape
1243 // Pad shape
1244 PAD = 2,
1245 // Unsure what this layer component slot is
1246 // But I suspect it's keepout, as that was added in V172.
1248 };
1249
1262 std::vector<PADSTACK_COMPONENT> m_Components;
1263
1269
1276 std::vector<uint32_t> m_UnknownArrN;
1277};
1278
1279
1284{
1285 uint32_t m_Key;
1286 uint32_t m_Next;
1287 uint32_t m_NameStrKey;
1288 uint32_t m_FieldPtr;
1289 uint16_t m_SizeA;
1290 uint16_t m_SizeB;
1291
1297 std::vector<std::array<uint8_t, 56>> m_DataB;
1302 std::vector<std::array<uint8_t, 256>> m_DataA;
1303
1305};
1306
1307
1313{
1314 uint8_t m_Type;
1315 uint16_t m_T2;
1316 uint32_t m_Key;
1317 uint32_t m_Next;
1318
1319 // Versioning seems unsure here
1320 // At least it is in Kinoma (V_164)
1323
1324 uint32_t m_StrPtr;
1325 uint32_t m_Size;
1326
1327 std::string m_String;
1328
1330};
1331
1332
1337{
1338 uint32_t m_Key;
1339 uint32_t m_Next;
1340 uint32_t m_Unknown2;
1341 uint32_t m_Unknown3;
1342 uint32_t m_Unknown4;
1343 uint16_t m_Unknown5;
1344 uint16_t m_Size;
1345
1349 std::vector<uint8_t> m_Substruct;
1350};
1351
1352
1373
1380{
1381 uint8_t m_Type;
1382 uint16_t m_R;
1383 uint32_t m_Size;
1384 uint32_t m_Key;
1385
1391 std::vector<uint8_t> m_Data;
1392};
1393
1394
1399{
1400 uint8_t m_Type;
1401 uint16_t m_T2;
1402 uint32_t m_Key;
1403
1405
1406 std::array<uint32_t, 8> m_UnknownArray;
1407};
1408
1409
1414{
1415 uint8_t m_Type;
1417 uint32_t m_Key;
1418 uint32_t m_Next;
1419
1420 std::array<uint32_t, 2> m_Flags;
1421
1422 uint32_t m_Ptr1;
1423 uint32_t m_Ptr2;
1424 uint32_t m_Ptr3;
1425
1426 std::array<int32_t, 5> m_Coords;
1427
1428 std::array<uint32_t, 4> m_Unknown1;
1429
1431
1433};
1434
1435
1443{
1444 uint8_t m_Type;
1446 uint32_t m_Key;
1447 uint32_t m_Next;
1448 uint32_t m_Parent;
1449 uint32_t m_Unknown1;
1450
1452
1453 std::array<int32_t, 4> m_Coords;
1454
1455 uint32_t m_Ptr2;
1456
1457 uint32_t m_Unknown3;
1458 uint32_t m_Unknown4;
1460 uint32_t m_Rotation;
1461};
1462
1463
1482
1483
1493{
1494 std::vector<uint32_t> m_Refs;
1495};
1496
1497
1534
1535
1542{
1543 uint8_t m_Type;
1544 uint16_t m_T;
1545 uint32_t m_Key;
1546
1547 // Points to something in the header
1548 uint32_t m_Ptr1;
1549 uint32_t m_Ptr2;
1550
1551 uint32_t m_Null; // Null value
1552
1553 uint32_t m_Ptr3;
1554
1555 int32_t m_Coord1;
1556 int32_t m_Coord2;
1557
1559
1560 uint32_t m_Unknown1;
1561
1562 // Pointer to a string, e.g., "2" in R0603
1563 uint32_t m_PtrX30;
1564
1565 uint32_t m_Unknown2;
1566 uint32_t m_Unknown3;
1567 uint32_t m_Unknown4;
1568};
1569
1570
1597
1598
1605{
1606 uint32_t m_Key;
1607
1608 uint32_t m_FpStrRef;
1609 uint32_t m_Unknown1;
1610
1611 // Could these be signed?
1612 std::array<uint32_t, 4> m_Coords;
1613
1614 uint32_t m_Next;
1623
1626};
1627
1628
1684
1685
1694{
1696 uint8_t m_Layer; // 0 = top (F_Cu), 1 = bottom (B_Cu)
1698
1699 uint32_t m_Key;
1700
1701 uint32_t m_Next;
1702
1704
1705 // Unsure what 16x means
1707
1708 uint16_t m_Unknown2;
1709 uint16_t m_Unknown3;
1710
1712
1713 uint32_t m_Flags;
1714
1715 uint32_t m_Rotation;
1716 int32_t m_CoordX;
1717 int32_t m_CoordY;
1718
1719 // Presumably equivalent to m_InstRef16x
1721
1724 uint32_t m_TextPtr; // Points to 0x30
1725
1727 uint32_t m_AreasPtr;
1730
1731 uint32_t GetInstRef() const
1732 {
1733 return m_InstRef.value_or( m_InstRef16x.value_or( 0 ) );
1734 }
1735};
1736
1737
1757
1758
1763{
1764 uint8_t m_Type;
1765 uint16_t m_T2;
1766 uint32_t m_Key;
1767
1768 std::array<uint32_t, 6> m_UnknownArray;
1769};
1770
1771
1836
1837
1871
1872
1879{
1880 uint8_t m_Type;
1882 uint32_t m_Key;
1883 uint32_t m_Next;
1884 uint32_t m_NetPtr;
1885 uint32_t m_Flags;
1886
1888
1889 uint32_t m_NextInFp;
1890 uint32_t m_ParentFp;
1891 uint32_t m_Track;
1892 uint32_t m_PadPtr;
1893 uint32_t m_Ptr6;
1894 uint32_t m_Ratline;
1897
1899
1900 uint32_t m_NameText;
1901 uint32_t m_Ptr11;
1902
1903 std::array<int32_t, 4> m_Coords;
1904};
1905
1906
1939
1940
1959
1960
1966{
1967 uint8_t m_T2;
1968 uint16_t m_T3;
1969
1970 std::array<uint8_t, 120> m_Content;
1971};
1972
1973
1980{
1981 uint16_t m_Code;
1982 uint32_t m_Key;
1983 uint32_t m_Next;
1984
1986
1987 uint32_t m_NumItems;
1988 uint32_t m_Count;
1989 uint32_t m_LastIdx;
1990 uint32_t m_Unknown2;
1991
1993
2002
2009
2010 struct X05
2011 {
2012 std::array<uint8_t, 28> m_Unknown;
2013 };
2014
2015 struct X06
2016 {
2017 uint16_t m_N;
2018 uint8_t m_R;
2019 uint8_t m_S;
2020 uint32_t m_Unknown1;
2021
2023 };
2024
2038
2039 struct X0B
2040 {
2041 std::array<uint8_t, 1016> m_Unknown;
2042 };
2043
2044 struct X0C
2045 {
2046 std::array<uint8_t, 232> m_Unknown;
2047 };
2048
2049 struct X0D
2050 {
2051 std::array<uint8_t, 200> m_Unknown;
2052 };
2053
2054 struct X0F
2055 {
2056 uint32_t m_Key;
2057 std::array<uint32_t, 3> m_Ptrs;
2058 uint32_t m_Ptr2;
2059 };
2060
2061 struct X10
2062 {
2063 std::array<uint8_t, 108> m_Unknown;
2064
2065 // V18 has an extra uint32 "somewhere" in this block
2067 };
2068
2069 using SubstructVariant = std::variant<X02, X03, X05, X06, FontDef_X08, X0B, X0C, X0D, X0F, X10>;
2070
2071 std::vector<SubstructVariant> m_Items;
2072};
2073
2074
2081{
2082 uint8_t m_T;
2083 uint16_t m_T2;
2084 uint32_t m_Key;
2085 uint32_t m_GroupPtr;
2086 uint32_t m_Next;
2087 uint32_t m_Capacity;
2088 uint32_t m_Count;
2089 uint32_t m_Unknown2;
2090
2092
2093 std::array<uint32_t, 100> m_Ptrs;
2094};
2095
2096
2115
2116
2121{
2122 uint32_t m_Key;
2123 uint32_t m_Parent;
2124 uint32_t m_Head;
2125
2126 // Array of 22 uint16_t values
2127 std::array<uint16_t, 22> m_X;
2128};
2129
2130
2143
2144
2150{
2151 uint8_t m_T;
2152 uint16_t m_SubType;
2153 uint32_t m_Len;
2154
2155 std::string m_Name;
2156 std::string m_Type;
2157
2158 uint32_t m_Unknown1;
2159 uint32_t m_Unknown2;
2160
2162
2163 std::string m_Value;
2164};
2165
2166
2172{
2173 uint8_t m_T;
2174 uint16_t m_T2;
2175 uint32_t m_Key;
2176
2178
2180 std::vector<uint32_t> m_Entries;
2181};
2182
2183
2188{
2189public:
2190 RAW_BOARD();
2191
2192 std::unique_ptr<FILE_HEADER> m_Header;
2193
2198
2203 std::unordered_map<uint32_t, std::string> m_StringTable;
2204
2205 // All the objects in the file
2206 std::vector<std::unique_ptr<BLOCK_BASE>> m_Objects;
2207
2208 // Map of keys to objects (for the objects we can get keys for)
2209 std::unordered_map<uint32_t, BLOCK_BASE*> m_ObjectKeyMap;
2210
2211 // Lists of the objects by type
2212 std::unordered_map<uint8_t, std::vector<BLOCK_BASE*>> m_ObjectLists;
2213
2214 static const size_t STRING_TABLE_OFFSET = 0x1200;
2215
2216 const BLOCK_BASE* GetObjectByKey( uint32_t aKey ) const
2217 {
2218 auto it = m_ObjectKeyMap.find( aKey );
2219 if( it != m_ObjectKeyMap.end() )
2220 return it->second;
2221 return nullptr;
2222 }
2223
2224 const std::string& GetString( uint32_t aId ) const
2225 {
2226 if( m_StringTable.count( aId ) )
2227 return m_StringTable.at( aId );
2228
2229 static const std::string empty;
2230 return empty;
2231 }
2232};
2233
2234} // namespace ALLEGRO
The base class for all blocks in the main body of an Allegro file.
uint32_t GetKey() const
virtual ~BLOCK_BASE()=default
uint8_t GetBlockType() const
BLOCK_BASE(uint8_t aBlockType, size_t aOffset)
BLOCK(uint8_t aBlockType, size_t aOffset)
const T & GetData() const
static bool empty(const wxTextEntryBase *aCtrl)
FIELD_KEYS
Hdr1 keys for field roles.
@ PHYS_CONSTRAINT_SET
Physical Constraint Set assignment.
@ NET_SCHEDULE
Net class/schedule assignment.
PAD_TYPE
The type of the padstack.
constexpr bool operator>=(FMT_VER lhs, FMT_VER rhs)
FMT_VER
The format of an Allego file.
Arc segment used in tracks, zone outlines, and shape boundaries.
std::array< int32_t, 4 > m_BoundingBoxCoords
uint8_t m_SubType
Bit 6 (0x40) = clockwise direction.
COND_GE< FMT_VER::V_172, uint32_t > m_Unknown6
std::array< uint32_t, 20 > m_Entries
Field/property references with variable-typed substructs.
COND_GE< FMT_VER::V_172, uint32_t > m_Unknown1
std::variant< uint32_t, std::array< uint32_t, 2 >, std::string, SUB_0x6C, SUB_0x70_0x74, SUB_0xF6 > m_Substruct
COND_GE< FMT_VER::V_172, uint32_t > m_Unknown2
Net assignment linking a net (0x1B) to its member objects.
COND_GE< FMT_VER::V_174, uint32_t > m_Unknown
Track segment container.
COND_GE< FMT_VER::V_172, uint32_t > m_Unknown5b
COND_GE< FMT_VER::V_172, uint32_t > m_Unknown5a
Component/symbol definitions.
COND_GE< FMT_VER::V_172, uint32_t > m_Unknown1
Component instance reference data.
COND_GE< FMT_VER::V_172, uint32_t > m_Unknown2
COND_LT< FMT_VER::V_172, uint32_t > m_Unknown4
COND_GE< FMT_VER::V_172, uint32_t > m_Unknown3
COND_GE< FMT_VER::V_172, uint32_t > m_UnknownPtr1
Pin number within a component.
COND_GE< FMT_VER::V_172, uint32_t > m_Previous
COND_LT< FMT_VER::V_172, uint32_t > m_StrPtr16x
COND_GE< FMT_VER::V_172, uint32_t > m_StrPtr
Pointer to 0x11 PIN_NAME object.
COND_GE< FMT_VER::V_172, uint32_t > m_Unknown1
0x0A objects represent DRC (Design Rule Check) elements.
std::array< uint32_t, 4 > m_Unknown4
std::array< int32_t, 4 > m_Coords
COND_GE< FMT_VER::V_172, uint32_t > m_Unknown2
COND_GE< FMT_VER::V_174, uint32_t > m_Unknown6
std::array< uint32_t, 5 > m_Unknown5
Pin definition with shape type, drill character, coordinates, and size.
COND_GE< FMT_VER::V_174, uint32_t > m_Unknown6
COND_GE< FMT_VER::V_172, uint32_t > m_Unknown_16x
COND_LT< FMT_VER::V_172, uint8_t > m_DrillChar
COND_LT< FMT_VER::V_172, uint8_t > m_Shape
std::array< uint32_t, 3 > m_UnknownArray
std::array< int32_t, 2 > m_Size
COND_GE< FMT_VER::V_172, uint32_t > m_DrillChars
COND_GE< FMT_VER::V_172, uint32_t > m_Shape16x
std::array< int32_t, 2 > m_Coords
COND_LT< FMT_VER::V_172, uint16_t > m_UnknownPadding
Pad geometry and placement in board-absolute coordinates.
uint32_t m_Rotation
Board-absolute millidegrees. Subtract footprint rotation for FP-local orientation.
COND_GE< FMT_VER::V_172, uint32_t > m_Unknown3
int32_t m_CoordsX
Board coordinates. Use SetFPRelativePosition() for KiCad FP-local space.
COND_GE< FMT_VER::V_174, uint32_t > m_Unknown1
int32_t m_CoordsY
Board coordinates. Use SetFPRelativePosition() for KiCad FP-local space.
COND_GE< FMT_VER::V_172, uint32_t > m_Unknown5
std::array< uint32_t, 3 > m_UnknownArr
uint32_t m_Rotation
Rotation in millidegrees.
COND_GE< FMT_VER::V_172, uint32_t > m_Unknown4
std::array< int32_t, 4 > m_Coords
Function slot in a multi-slot component (e.g.
std::array< char, 32 > m_CompDeviceType
COND_GE< FMT_VER::V_174, uint32_t > m_Unknown3
COND_GE< FMT_VER::V_172, uint32_t > m_Unknown2
Function instance linking a component instance (0x07) to its schematic function, pin cross-references...
COND_GE< FMT_VER::V_174, uint32_t > m_Unknown2
COND_GE< FMT_VER::V_172, uint32_t > m_Unknown1
Pin name within a component, linked from function slots (0x0F).
uint32_t m_Key
Pointer to pin name string.
uint32_t m_PinNameStrPtr
Pointer to next 0x11 PIN_NAME object or 0x0F SLOT.
COND_GE< FMT_VER::V_174, uint32_t > m_Unknown2
uint32_t m_Next
Pointer to 0x08 PIN_NUMBER object.
Cross-reference between objects.
COND_GE< FMT_VER::V_165, uint32_t > m_Unknown2
COND_GE< FMT_VER::V_174, uint32_t > m_Unknown3
Graphics container holding a chain of line segments and arcs.
COND_GE< FMT_VER::V_172, uint32_t > m_Unknown2
0x15 , 0x16, 0x17 are segments:
COND_GE< FMT_VER::V_172, uint32_t > m_Unknown2
0x1B objects are nets.
uint32_t m_Ratline
Pointer to first 0x03 FIELD object or null.
COND_GE< FMT_VER::V_172, uint32_t > m_Unknown2
uint32_t m_MatchGroupPtr
Diff pair / match group pointer (0x26 or 0x2C)
Padstack definition containing drill dimensions and a table of per-layer pad/antipad/thermal componen...
std::array< uint32_t, 8 > m_DrillArr
In >= V172, elements [4] and [7] hold drill dimensions: [4] = drill diameter (or width for oblong dri...
COND_GE< FMT_VER::V_172, uint16_t > m_Unknown11
COND_GE< FMT_VER::V_172, uint32_t > m_Unknown7
COND_GE< FMT_VER::V_172, uint32_t > m_Unknown9
COND_LT< FMT_VER::V_172, uint32_t > m_Unknown6
COND_LT< FMT_VER::V_172, uint32_t > m_Unknown3
LAYER_COMP_SLOT
Component table layer offsets In the component table's layer section, each layer has 3 or 4 slots,...
COND_GE< FMT_VER::V_180, std::array< uint32_t, 8 > > m_V180Trailer
V180 inserts 8 extra uint32s between the fixed arrays and the component table.
COND_LT< FMT_VER::V_172, uint16_t > m_Unknown10
COND_LT< FMT_VER::V_172, uint32_t > m_Unknown5
uint32_t m_Drill
In < V172, this is the drill diameter in internal coordinates.
std::vector< uint32_t > m_UnknownArrN
Some structure of m_N * 8 or 10:
COND_LT< FMT_VER::V_172, uint32_t > m_Unknown4
COND_GE< FMT_VER::V_172, std::array< uint32_t, 28 > > m_SlotAndUnknownArr
In V172+, elements [0] and [3] hold the true slot outline dimensions (X, Y) in internal coordinate un...
size_t m_NumFixedCompEntries
How many of the entries are fixed roles (after this is n*layers)
uint8_t m_N
The number of something.
COND_GE< FMT_VER::V_172, uint32_t > m_Unknown8
std::vector< PADSTACK_COMPONENT > m_Components
Collection of components that make up the padstack.
SLOTS
Fixed slot indices in the component table.
COND_GE_LT< FMT_VER::V_165, FMT_VER::V_172, std::array< uint32_t, 8 > > m_UnknownArr8_2
Physical constraint sets containing trace width, clearance, and routing rules.
uint32_t m_FieldPtr
Pointer to 0x03 FIELD with CS name (fallback when m_NameStrKey fails)
COND_GE< FMT_VER::V_172, uint32_t > m_Unknown4
uint32_t m_NameStrKey
String table key for constraint set name.
std::vector< std::array< uint8_t, 256 > > m_DataA
Records contain ASCII padstack/via name strings (null-terminated at offset 4) and file path reference...
std::vector< std::array< uint8_t, 56 > > m_DataB
Per-copper-layer dimension values, 14 x int32 per record.
uint32_t m_Next
Linked list next pointer (used by LL_WALKER)
Signal integrity and simulation model data (IBIS netlists).
COND_GE< FMT_VER::V_164, uint16_t > m_Unknown3
COND_GE< FMT_VER::V_172, uint32_t > m_Unknown4
uint32_t m_Next
Linked list next pointer (used by LL_WALKER)
COND_GE< FMT_VER::V_164, uint16_t > m_Unknown2
Per-padstack dimension records with name and value.
std::vector< uint8_t > m_Substruct
Version-dependent substruct holding padstack dimension name and value.
uint32_t m_Next
Linked list next pointer (used by LL_WALKER)
COND_GE< FMT_VER::V_174, std::array< uint32_t, 10 > > m_UnknownArray2
std::array< uint32_t, 7 > m_UnknownArray1
Headered data blob containing structured board data such as layer stackup definitions,...
std::vector< uint8_t > m_Data
An array of bytes that seems to be a variable length.
Purpose not determined.
COND_GE< FMT_VER::V_174, uint32_t > m_Unknown1
std::array< uint32_t, 8 > m_UnknownArray
0x23 objects represent ratlines.
COND_GE< FMT_VER::V_164, std::array< uint32_t, 4 > > m_Unknown2
std::array< uint32_t, 4 > m_Unknown1
COND_GE< FMT_VER::V_174, uint32_t > m_Unknown3
std::array< uint32_t, 2 > m_Flags
std::array< int32_t, 5 > m_Coords
Rectangle defined by four coordinates.
uint32_t m_Rotation
Rotation in millidegrees.
std::array< int32_t, 4 > m_Coords
COND_GE< FMT_VER::V_172, uint32_t > m_Unknown2
Match group indirection for differential pairs and match groups.
COND_GE< FMT_VER::V_172, uint32_t > m_Unknown1
uint32_t m_ConstPtr
Points to timing/delay constraints (field type 0x63), not physical constraints.
COND_GE< FMT_VER::V_174, uint32_t > m_Unknown2
Serialized Constraint Manager database containing secondary name table (V172+), material stackup,...
Polygon shape defined by a linked list of segments starting at m_FirstSegmentPtr (0x15/0x16/0x17 line...
COND_LT< FMT_VER::V_172, uint32_t > m_Ptr7_16x
COND_GE< FMT_VER::V_172, uint32_t > m_Ptr7
COND_GE< FMT_VER::V_172, uint32_t > m_Unknown3
COND_GE< FMT_VER::V_172, uint32_t > m_Unknown2
std::array< int32_t, 4 > m_Coords
0x29 objects may represent pins in .dra files.
std::string m_Name
uint32_t m_Properties
uint32_t m_Unknown
uint32_t mLayerNameId
Represents a list of layers.
COND_GE< FMT_VER::V_165, std::vector< REF_ENTRY > > m_RefEntries
COND_GE< FMT_VER::V_174, uint32_t > m_Unknown
COND_LT< FMT_VER::V_165, std::vector< NONREF_ENTRY > > m_NonRefEntries
Footprint definition (template) shared by multiple placed instances.
COND_GE< FMT_VER::V_164, uint32_t > m_Unknown2
COND_GE< FMT_VER::V_172, uint32_t > m_Unknown3
std::array< uint32_t, 4 > m_Coords
Lookup table used for named associations.
COND_LT< FMT_VER::V_172, uint32_t > m_Unknown4
COND_GE< FMT_VER::V_172, uint32_t > m_Unknown3
SUBTYPE
The subtype of a table.
@ SUBTYPE_0x102
Some kind of net match group.
@ SUBTYPE_GRAPHICAL_GROUP
Used for drill charts and x-section charts.
COND_GE< FMT_VER::V_172, uint32_t > m_Unknown2
COND_GE< FMT_VER::V_172, uint32_t > m_Unknown1
Placed footprint instance on the board.
uint32_t m_Rotation
Millidegrees (divide by 1000 for degrees)
COND_LT< FMT_VER::V_172, uint32_t > m_InstRef16x
COND_GE< FMT_VER::V_172, uint32_t > m_InstRef
COND_GE< FMT_VER::V_172, uint32_t > m_Unknown1
COND_GE< FMT_VER::V_172, uint32_t > m_Unknown4
Connection point at a track junction or pad-to-track transition.
COND_GE< FMT_VER::V_172, uint32_t > m_Unknown3
Purpose not determined.
std::array< uint32_t, 6 > m_UnknownArray
Text object with position, rotation, layer, font properties, and alignment.
COND_GE< FMT_VER::V_172, uint32_t > m_Unknown2
COND_GE< FMT_VER::V_172, TEXT_PROPERTIES > m_Font
COND_LT< FMT_VER::V_172, uint32_t > m_PtrGroup_16x
COND_GE< FMT_VER::V_172, uint32_t > m_PtrGroup_17x
COND_GE< FMT_VER::V_172, uint32_t > m_Unknown1
COND_GE< FMT_VER::V_172, uint32_t > m_Ptr2
COND_LT< FMT_VER::V_172, uint32_t > m_Unknown4
COND_GE< FMT_VER::V_172, uint32_t > m_Ptr1
COND_GE< FMT_VER::V_174, uint32_t > m_Unknown3
COND_LT< FMT_VER::V_172, TEXT_PROPERTIES > m_Font16x
String graphic content holding the actual text value and its display layer category.
COND_GE< FMT_VER::V_174, uint32_t > m_Un2
Placed pad instance linking a pad definition (0x0D via m_PadPtr) to its parent footprint (m_ParentFp)...
COND_GE< FMT_VER::V_172, uint32_t > m_Unknown2
std::array< int32_t, 4 > m_Coords
COND_GE< FMT_VER::V_172, uint32_t > m_Prev
Via instance with board position, padstack reference (m_Padstack for drill/annular ring definitions),...
COND_GE< FMT_VER::V_172, uint32_t > m_Unknown3
COND_GE< FMT_VER::V_172, uint32_t > m_UnknownPtr2
std::array< int32_t, 4 > m_BoundingBoxCoords
0x34 objects represent keepouts.
COND_GE< FMT_VER::V_172, uint32_t > m_Unknown1
File path references to Allegro log and report files (terminator.log, eclrpt.txt).
std::array< uint8_t, 120 > m_Content
COND_GE< FMT_VER::V_172, std::array< uint32_t, 8 > > m_Ys
COND_GE< FMT_VER::V_174, uint32_t > m_Unknown2
COND_GE< FMT_VER::V_172, std::array< uint32_t, 2 > > m_Zs
COND_GE< FMT_VER::V_164, std::array< uint32_t, 3 > > m_Ys
COND_GE< FMT_VER::V_172, std::string > m_Str
COND_GE< FMT_VER::V_174, uint32_t > m_Unknown1
COND_LT< FMT_VER::V_172, std::string > m_Str16x
std::array< uint8_t, 28 > m_Unknown
COND_LT< FMT_VER::V_172, std::array< uint32_t, 50 > > m_Unknown2
std::array< uint8_t, 1016 > m_Unknown
std::array< uint8_t, 232 > m_Unknown
std::array< uint8_t, 200 > m_Unknown
std::array< uint8_t, 108 > m_Unknown
COND_GE< FMT_VER::V_180, uint32_t > m_Unknown2
Heterogeneous definition table containing font metrics (FontDef_X08), layer name definitions (X03),...
std::variant< X02, X03, X05, X06, FontDef_X08, X0B, X0C, X0D, X0F, X10 > SubstructVariant
COND_GE< FMT_VER::V_174, uint32_t > m_Unknown3
COND_GE< FMT_VER::V_172, uint32_t > m_Unknown1
std::vector< SubstructVariant > m_Items
Fixed-capacity pointer array (100 entries).
COND_GE< FMT_VER::V_174, uint32_t > m_Unknown3
std::array< uint32_t, 100 > m_Ptrs
0x38 objects represent films.
COND_GE< FMT_VER::V_166, uint32_t > m_Unknown2
std::array< uint32_t, 7 > m_UnknownArray1
COND_GE< FMT_VER::V_174, uint32_t > m_Unknown3
COND_GE< FMT_VER::V_166, uint32_t > m_LayerNameStr
COND_LT< FMT_VER::V_166, std::string > m_FilmName
0x39 objects represent a film layer list.
0x3A objects represent a list of films
COND_GE< FMT_VER::V_174, uint32_t > m_Unknown1
Named property with type and value strings.
COND_GE< FMT_VER::V_172, uint32_t > m_Unknown3
Ordered list of block keys.
COND_GE< FMT_VER::V_174, uint32_t > m_Unknown
std::vector< uint32_t > m_Entries
COND_FIELD_BASE & operator=(const T &value)
COND_FIELD_BASE & operator=(T &&value)
virtual bool exists(FMT_VER ver) const =0
Define this function in the derived class to determine if the field exists in the given version of th...
const T & value_or(const T &aDefault) const
This is a conditional field that only exists in versions of a file less than a certain version and gr...
constexpr bool exists(FMT_VER ver) const override
Define this function in the derived class to determine if the field exists in the given version of th...
This is a conditional field that only exists in versions of a file of or above a certain version.
constexpr bool exists(FMT_VER ver) const override
Define this function in the derived class to determine if the field exists in the given version of th...
This is a conditional field that only exists in versions of a file less than a certain version.
constexpr bool exists(FMT_VER ver) const override
Define this function in the derived class to determine if the field exists in the given version of th...
uint32_t m_LayerList0x2A
uint32_t m_A
This is apparently some kind of linked list that chains though subsets objects in the file.
Allegro files start with this header.
COND_GE< FMT_VER::V_180, LINKED_LIST > m_LL_V18_4
COND_GE< FMT_VER::V_180, uint32_t > m_Unknown2g_V18
COND_LT< FMT_VER::V_180, std::array< uint32_t, 7 > > m_Unknown2_preV18
COND_LT< FMT_VER::V_180, uint32_t > m_0x35_Start_preV18
COND_GE< FMT_VER::V_180, std::array< uint32_t, 9 > > m_Unknown5_V18
std::array< char, 60 > m_AllegroVersion
COND_GE< FMT_VER::V_180, LINKED_LIST > m_LL_V18_5
COND_GE< FMT_VER::V_180, uint32_t > m_0x35_Start_V18
COND_LT< FMT_VER::V_180, LINKED_LIST > m_LL_Unknown5_preV18
COND_GE< FMT_VER::V_180, LINKED_LIST > m_LL_V18_3
COND_LT< FMT_VER::V_180, uint32_t > m_Unknown7
std::array< LAYER_MAP_ENTRY, 25 > m_LayerMap
The layer maps is a list of groups of two numbers.
COND_GE< FMT_VER::V_180, uint32_t > m_Unknown2e_V18
std::array< uint32_t, 50 > m_Unknown9
COND_LT< FMT_VER::V_180, uint32_t > m_0x27_End_preV18
COND_GE< FMT_VER::V_180, LINKED_LIST > m_LL_Unknown5_V18
COND_GE< FMT_VER::V_180, uint32_t > m_0x27_End_V18
COND_GE< FMT_VER::V_180, uint32_t > m_0x35_End_V18
COND_GE< FMT_VER::V_180, LINKED_LIST > m_LL_V18_6
uint32_t Get_0x27_End() const
const LINKED_LIST & GetUnknown5() const
COND_LT< FMT_VER::V_180, std::array< uint32_t, 17 > > m_Unknown5_preV18
COND_LT< FMT_VER::V_180, uint32_t > m_Unknown3
COND_LT< FMT_VER::V_180, uint32_t > m_0x35_End_preV18
COND_GE< FMT_VER::V_180, LINKED_LIST > m_LL_V18_1
COND_LT< FMT_VER::V_180, uint32_t > m_StringCount_preV18
COND_GE< FMT_VER::V_180, uint32_t > m_StringCount_V18
uint32_t GetStringsCount() const
COND_GE< FMT_VER::V_180, uint32_t > m_Unknown2b_V18
COND_GE< FMT_VER::V_180, uint32_t > m_Unknown2d_V18
COND_GE< FMT_VER::V_180, LINKED_LIST > m_LL_V18_2
COND_GE< FMT_VER::V_180, uint32_t > m_Unknown2a_V18
SUBCLASS
The second byte in a CLASS:SUBCLASS pair.
bool operator==(const LAYER_INFO &) const =default
Substruct in a padstack object.
uint32_t m_StrPtr
Seems to point to various things:
COND_GE< FMT_VER::V_172, int16_t > m_Z1
COND_GE< FMT_VER::V_172, uint32_t > m_Unknown1
COND_GE< FMT_VER::V_172, int16_t > m_Z
std::optional< uint32_t > m_Z2
const BLOCK_BASE * GetObjectByKey(uint32_t aKey) const
static const size_t STRING_TABLE_OFFSET
std::unordered_map< uint32_t, std::string > m_StringTable
The string map is a map of U32 ID to strings.
const std::string & GetString(uint32_t aId) const
std::unordered_map< uint32_t, BLOCK_BASE * > m_ObjectKeyMap
FMT_VER m_FmtVer
What version is this file?
std::vector< std::unique_ptr< BLOCK_BASE > > m_Objects
std::unique_ptr< FILE_HEADER > m_Header
std::unordered_map< uint8_t, std::vector< BLOCK_BASE * > > m_ObjectLists
0x33 VIA objects.
Definition allegro_db.h:877