26#include <wx/translation.h>
38 constexpr int32_t LEGACY_SPACING_KEYS[] = { 0x40004, 0x40002, 0x100004, 0x200004, 0x40001, 0x20002, 0x100002,
39 0x200002, 0x20001, 0x100010, 0x200010, 0x100001, 0x200020, 0x200001,
40 0x80004, 0x80002, 0x80008, 0x100008, 0x200008, 0x80001 };
43 constexpr size_t MAX_PARENT_WALK = 1024;
46 constexpr FIELD_ROW ATTRIBUTE_ARRAY[] = { { 0, INT_MAX,
"o" } };
47 constexpr FIELD_ROW BARCODE_FONT[] = { { 0, INT_MAX,
"i s i" } };
48 constexpr FIELD_ROW HATCH_STYLE[] = { { 0, INT_MAX,
"s b i f" } };
49 constexpr FIELD_ROW NOTE_CATEGORY[] = { { 0, INT_MAX,
"s i2 13 i2" } };
52 constexpr FIELD_ROW OLD_LAYER_TAIL[] = { { 0x7d3, INT_MAX,
"i" }, { 5000, INT_MAX,
"b" },
53 { 7000, 0x2711,
"b" }, { 8000, 0x2711,
"i" },
54 { 0x2712, INT_MAX,
"b2 i" }, { 9000, INT_MAX,
"i" },
55 { 0x2716, INT_MAX,
"i" }, { 9000, INT_MAX,
"i" },
56 { 13000, INT_MAX,
"i2" }, { 14000, INT_MAX,
"b" } };
59 void checkItemFormat(
const ARCHIVE& aAr,
int aFormat )
64 wxString::Format(
_(
"Easy-PC item format %d at offset %zu is too new." ), aFormat, aAr.Pos() ) );
80 Items.push_back( item );
86 for( uint32_t i = aAr.
Count(); i > 0; --i )
122 co_await SkipFields( aAr, v > 28999 ?
"o2" : v > 0x835 ?
"o" :
"" );
140 if( depth > MAX_PARENT_WALK )
142 wxString::Format(
_(
"Easy-PC %s at offset %zu has a cyclic parent chain." ),
ClassName,
Offset ) );
147 ~UNWIND() { --Depth; }
150 return Parent->ItemFormat( aAr );
157 checkItemFormat( aAr, aFormat );
168 checkItemFormat( aAr, aFormat );
177 static constexpr FIELD_ROW ROWS[] = { { 8001, INT_MAX,
"s" }, { 0x2ee4, INT_MAX,
"i" } };
289 THROW_IO_ERROR( wxString::Format(
_(
"Unsupported Easy-PC turned slot in pad style '%s'." ),
Name ) );
326 static constexpr FIELD_ROW ROWS[] = { { 13000, INT_MAX,
"b" },
327 { 21000, INT_MAX,
"b i" },
328 { 0x6d63, INT_MAX,
"13" } };
372 aAr.
Skip( 8 *
size_t( aAr.
U32() ) + 4 );
381 co_await SkipRows( aAr, v, OLD_LAYER_TAIL );
396 if(
TypeName.CmpNoCase( wxS(
"Silk Screen" ) ) == 0 )
398 Type->SurfacePadInstancesEnabled =
false;
399 Type->AllLayerPadInstancesEnabled =
false;
400 Type->ViasEnabled =
false;
401 Type->AllLayerPadsEnabled =
false;
402 Type->SurfacePadsEnabled =
false;
423 auto it = std::find_if(
Items.begin(),
Items.end(),
426 const SOURCE_LAYER* layer = dynamic_cast<const SOURCE_LAYER*>( aItem );
427 return layer && layer->Side == LAYER_SIDE::BOTTOM
428 && ( layer->EffectiveUsage() & LAYER_USAGE_SET );
431 if( it !=
Items.end() )
432 std::rotate( it, it + 1,
Items.end() );
487 for( int32_t key : LEGACY_SPACING_KEYS )
499 for( uint32_t i = aAr.
Count(); i > 0; --i )
501 int32_t key = aAr.
I32();
510 for( int32_t key : LEGACY_SPACING_KEYS )
550 {
"CDesignList",
"CAttributeNameArray",
"CLineStyleArray",
"CTextStyleArray",
551 "CTrackStyleArray",
"CHatchStyleList",
"CPadStyleArray",
"CPadStyleExceptionList",
552 "CLayerTypeList",
"CLayerSpanArray",
"CNetClassArray",
"CNoteCategoryList" } );
One archive load stream; it owns every object it creates.
size_t & ParentWalkDepth() const
Bounds ItemFormat parent walks, which recurse through file-supplied parent tags.
int CurrentReadFormat() const
wxString ReadString()
ANSI (windows-1252) or the 0xFF 0xFFFE UTF-16 form.
TYPED_AWAITER< T > ObjectAs()
void SetReadFormat(int aFormat)
uint16_t ObjectSchema() const
bool InBool()
one or four bytes, depending on the active format
int OrphanFormat() const
A null parent tag is the document: the header version in a design, else the current read format.
uint32_t Count()
a 16-bit count, 0xFFFF escaping to 32 bits
A loader coroutine. Awaiting one queues it on its archive's frame stack instead of nesting the call.
Shapes, vertices and the free-standing drawn items.
Design items, attributes, styles, layers, net classes and spacings.
#define THROW_IO_ERROR(msg)
macro which captures the "call site" values of FILE_, __FUNCTION & LINE
std::map< std::string, std::function< std::unique_ptr< OBJECT >()>, std::less<> > REGISTRY
LOAD_TASK SkipRows(ARCHIVE &aAr, int aVersion, std::span< const FIELD_ROW > aRows)
SkipFields for every row aVersion falls in, in order.
constexpr int NEWEST_ITEM_FORMAT
The newest item format a file can carry (30001)
LOAD_TASK SkipFields(ARCHIVE &aAr, std::string_view aOps)
Read and drop a run of fields described by aOps, each letter optionally followed by a repeat count: b...
constexpr char THERMAL_RULE_SET[]
A thermal rule set as SkipFields ops: owner, four thermal rules (owner and an int array),...
@ LAYER_USAGE_NON_ELECTRICAL
LAYER_OVERSIZE_TYPE
How a layer type grows pads.
void RegisterSkipped(REGISTRY &aReg, const char *aName, std::span< const FIELD_ROW > aRows)
PAD_SHAPE
Pad style shape, also the drill and exception shape.
void Register(REGISTRY &aReg, std::initializer_list< const char * > aNames)
Register the class names whose objects load as a T.
void RegisterStyleClasses(REGISTRY &aReg)
A run of fields present from version since to until inclusive.
Root of every deserialized object.
size_t Offset
stream offset of the tag or of an embedded member's first field
const char * ClassName
registered class name
LOAD_TASK Load(ARCHIVE &aAr) override
Read this object's fields.
LOAD_TASK Load(ARCHIVE &aAr) override
Read this object's fields.
SOURCE_ATTRIBUTE_NAME * AttributeName
LOAD_TASK Load(ARCHIVE &aAr) override
Read this object's fields.
int ItemFormat(const ARCHIVE &aAr) const override
The version this object gates on; the base is the archive's current read format.
The base of nearly every class.
LOAD_TASK Load(ARCHIVE &aAr) override
Read this object's fields.
int ItemFormat(const ARCHIVE &aAr) const override
The version this object gates on; the base is the archive's current read format.
OBJECT * Attributes
attribute array
void LoadOldFormat(ARCHIVE &aAr, int &aFormat) const
An older item format, stored only while the format is still 0.
OBJECT * Parent
null is the document in a design, nothing in a library item
static void LoadFormatted(ARCHIVE &aAr, int &aFormat)
An item format, stored only from object schema 2, which governs what follows.
std::vector< OBJECT * > Items
int ItemFormat(const ARCHIVE &aAr) const override
The version this object gates on; the base is the archive's current read format.
LOAD_TASK Load(ARCHIVE &aAr) override
Read this object's fields.
LOAD_TASK Load(ARCHIVE &aAr) override
Read this object's fields.
LOAD_TASK Load(ARCHIVE &aAr) override
Read this object's fields.
LOAD_TASK Load(ARCHIVE &aAr) override
Read this object's fields.
SOURCE_LAYER * BottomLayer
Layer type names determine silk, mask and paste roles.
bool SurfacePadInstancesEnabled
bool AllLayerPadInstancesEnabled
LOAD_TASK Load(ARCHIVE &aAr) override
Read this object's fields.
LAYER_OVERSIZE_TYPE OversizeType
std::unique_ptr< SOURCE_LAYER_TYPE > ConvertedType
The type made from type_name.
OBJECT * Net
net of a power plane
SOURCE_LAYER_TYPE * Type
null for the layer sets
LOAD_TASK Load(ARCHIVE &aAr) override
Read this object's fields.
wxString TypeName
below v3000 the type is stored by name
OBJECT * Terminals
copper terminal array
LOAD_TASK Load(ARCHIVE &aAr) override
Read this object's fields.
SOURCE_PAD_STYLE * ViaStyle
LOAD_TASK Load(ARCHIVE &aAr) override
Read this object's fields.
SOURCE_TRACK_STYLE * TrackStyle1
the narrower of the two is the minimum width
SOURCE_TRACK_STYLE * TrackStyle2
int32_t Type
0 signal, 1 power
int32_t TentedVias
0 none, 1 all, 2 per via
LOAD_TASK Load(ARCHIVE &aAr) override
Read this object's fields.
LOAD_TASK Load(ARCHIVE &aAr) override
Read this object's fields.
OBJECT * Exceptions
pad style exception list
int32_t DrillCornerRadius
int32_t Length
Y extent for shapes that have one.
std::map< int32_t, int32_t > Values
LOAD_TASK Load(ARCHIVE &aAr) override
Read this object's fields.
LOAD_TASK Load(ARCHIVE &aAr) override
Read this object's fields.
OBJECT * Font
type or barcode font, or null for the stroke font
int32_t Height
the accessor is GetWidth but it is the text height
int32_t InterlineHeightPercent
LOAD_TASK Load(ARCHIVE &aAr) override
Read this object's fields.
LOAD_TASK Load(ARCHIVE &aAr) override
Read this object's fields.