KiCad PCB EDA Suite
Loading...
Searching...
No Matches
EASYPC::ARCHIVE Class Reference

One archive load stream; it owns every object it creates. More...

#include <easypc_archive.h>

Classes

class  EMBEDDED_AWAITER
 An embedded member for a loader to co_await: no tag and no load-array slot. More...
 
struct  FRAME
 
class  OBJECT_AWAITER
 The next object tag for a loader to co_await: null, a back reference, or a new object fully loaded. More...
 
struct  SLOT
 
class  TYPED_AWAITER
 Object that must be a T or null. More...
 

Public Member Functions

 ARCHIVE (const uint8_t *aData, size_t aSize, DOC_KIND aKind, int32_t aProduct)
 aData must outlive the archive; aProduct is the product key in force
 
uint8_t U8 ()
 
bool Bool ()
 
bool InBool ()
 one or four bytes, depending on the active format
 
uint16_t U16 ()
 
uint32_t U32 ()
 
int32_t I32 ()
 
uint64_t U64 ()
 
double F64 ()
 
uint32_t Count ()
 a 16-bit count, 0xFFFF escaping to 32 bits
 
wxString ReadString ()
 ANSI (windows-1252) or the 0xFF 0xFFFE UTF-16 form.
 
void SkipString ()
 
void Skip (size_t aLen)
 
void Require (size_t aLen) const
 Throw unless aLen more bytes remain.
 
OBJECT_AWAITER Object ()
 
template<typename T>
TYPED_AWAITER< T > ObjectAs ()
 
EMBEDDED_AWAITER Embedded (OBJECT &aObject, const char *aClass)
 
OBJECT * ReadObject ()
 ReadObject and LoadEmbedded outside any loader, running the nested loads to completion.
 
void LoadEmbedded (OBJECT &aObject, const char *aClass)
 
void MapObject (OBJECT *aObject)
 A load-array slot for an object not read through a tag.
 
void SetBooleanIsByte (bool aByte)
 
int ShapeFormat () const
 
void SetShapeFormat (int aFormat)
 
int CurrentReadFormat () const
 
void SetReadFormat (int aFormat)
 
int OrphanFormat () const
 A null parent tag is the document: the header version in a design, else the current read format.
 
int DocumentVersion () const
 
void SetDocumentVersion (int aVersion)
 
DOC_KIND Kind () const
 
bool IsDesign () const
 
int32_t Product () const
 
void SetProduct (int32_t aProduct)
 
size_t & ParentWalkDepth () const
 Bounds ItemFormat parent walks, which recurse through file-supplied parent tags.
 
size_t LoadArraySize () const
 
size_t Pos () const
 
size_t Size () const
 
bool AtEnd () const
 
uint16_t ObjectSchema () const
 
std::vector< std::unique_ptr< OBJECT > > TakeObjects ()
 

Static Public Member Functions

static std::unique_ptr< OBJECT > Create (const char *aClass)
 An object of a registered class, not yet loaded.
 

Static Public Attributes

static constexpr int MAX_DEPTH = 100000
 

Private Member Functions

void throwBadClass (const OBJECT &aObject) const
 
OBJECT * readTag (bool &aIsNew)
 Read a tag; a new object is created and mapped but not loaded (aIsNew)
 
void pushObjectLoad (OBJECT &aObject, uint16_t aSchema)
 
void pushTask (LOAD_TASK::HANDLE aHandle)
 
void drive (LOAD_TASK aRoot)
 Run aRoot and everything it awaits until it finishes, rethrowing its failure.
 
uint32_t stringLength (bool &aUnicode)
 The string length prefix; aUnicode for the UTF-16 form.
 

Private Attributes

const uint8_t * m_data
 
size_t m_size
 
size_t m_pos = 0
 
DOC_KIND m_kind
 
int32_t m_product
 
std::vector< SLOT > m_load
 slot 0 is the null slot
 
std::vector< std::unique_ptr< OBJECT > > m_objects
 
std::vector< FRAME > m_frames
 
uint16_t m_objectSchema = 0
 
int m_depth = 0
 
bool m_errorHasContext = false
 
bool m_boolIsByte = true
 
int m_shapeFormat = 3
 
int m_currentReadFormat = -1
 
int m_documentVersion = 0
 
size_t m_parentWalkDepth = 0
 

Friends

class LOAD_TASK
 

Detailed Description

One archive load stream; it owns every object it creates.

Definition at line 183 of file easypc_archive.h.

Constructor & Destructor Documentation

◆ ARCHIVE()

EASYPC::ARCHIVE::ARCHIVE ( const uint8_t * aData,
size_t aSize,
DOC_KIND aKind,
int32_t aProduct )

aData must outlive the archive; aProduct is the product key in force

Definition at line 91 of file easypc_archive.cpp.

References m_data, m_kind, m_load, m_product, and m_size.

Referenced by EASYPC::ARCHIVE::EMBEDDED_AWAITER::EMBEDDED_AWAITER(), and EASYPC::ARCHIVE::OBJECT_AWAITER::OBJECT_AWAITER().

Member Function Documentation

◆ AtEnd()

bool EASYPC::ARCHIVE::AtEnd ( ) const
inline

Definition at line 309 of file easypc_archive.h.

References m_pos, and m_size.

◆ Bool()

◆ Count()

◆ Create()

std::unique_ptr< OBJECT > EASYPC::ARCHIVE::Create ( const char * aClass)
static

An object of a registered class, not yet loaded.

Definition at line 447 of file easypc_archive.cpp.

References _, end, and THROW_IO_ERROR.

Referenced by EASYPC::SOURCE_SYMBOL::Load(), EASYPC::LoadDesign(), and EASYPC::SkipMember().

◆ CurrentReadFormat()

◆ DocumentVersion()

int EASYPC::ARCHIVE::DocumentVersion ( ) const
inline

Definition at line 295 of file easypc_archive.h.

References m_documentVersion.

Referenced by EASYPC::DESIGN_MEMBER::ItemFormat().

◆ drive()

void EASYPC::ARCHIVE::drive ( LOAD_TASK aRoot)
private

◆ Embedded()

EMBEDDED_AWAITER EASYPC::ARCHIVE::Embedded ( OBJECT & aObject,
const char * aClass )
inline

◆ F64()

double EASYPC::ARCHIVE::F64 ( )

Definition at line 156 of file easypc_archive.cpp.

References U64().

◆ I32()

◆ InBool()

◆ IsDesign()

bool EASYPC::ARCHIVE::IsDesign ( ) const
inline

Definition at line 299 of file easypc_archive.h.

References m_kind, EASYPC::PCB, and EASYPC::SCHEMATIC.

Referenced by EASYPC::SOURCE_LAYER::Load(), and OrphanFormat().

◆ Kind()

DOC_KIND EASYPC::ARCHIVE::Kind ( ) const
inline

◆ LoadArraySize()

size_t EASYPC::ARCHIVE::LoadArraySize ( ) const
inline

Definition at line 305 of file easypc_archive.h.

References m_load.

◆ LoadEmbedded()

void EASYPC::ARCHIVE::LoadEmbedded ( OBJECT & aObject,
const char * aClass )

Definition at line 435 of file easypc_archive.cpp.

References drive().

Referenced by EASYPC::LoadDesign(), and EASYPC::LoadProject().

◆ MapObject()

void EASYPC::ARCHIVE::MapObject ( OBJECT * aObject)

A load-array slot for an object not read through a tag.

Definition at line 441 of file easypc_archive.cpp.

References EASYPC::OBJECT::ClassName, and m_load.

Referenced by EASYPC::SOURCE_SYMBOL::Load().

◆ Object()

OBJECT_AWAITER EASYPC::ARCHIVE::Object ( )
inline

Definition at line 224 of file easypc_archive.h.

Referenced by EASYPC::SOURCE_AREA::Load(), EASYPC::SOURCE_BUS::Load(), EASYPC::SOURCE_COMMON_SHAPE::Load(), EASYPC::SOURCE_COMPONENT_INSTANCE::Load(), EASYPC::SOURCE_CONNECT_POINT::Load(), EASYPC::SOURCE_CONNECTION::Load(), EASYPC::SOURCE_COPPER_INSTANCE::Load(), EASYPC::SOURCE_DEFAULTS::Load(), EASYPC::SOURCE_DESIGN::Load(), EASYPC::SOURCE_DESIGN_ARRAY::Load(), EASYPC::SOURCE_DESIGN_DATA::Load(), EASYPC::SOURCE_DESIGN_ITEM::Load(), EASYPC::SOURCE_DESIGN_LIST::Load(), EASYPC::SOURCE_DESIGN_SPACINGS::Load(), EASYPC::SOURCE_FREE_COPPER::Load(), EASYPC::SOURCE_FREE_PAD::Load(), EASYPC::SOURCE_FREE_TEXT::Load(), EASYPC::SOURCE_GATE_MAP::Load(), EASYPC::SOURCE_LAYER::Load(), EASYPC::SOURCE_LAYERED_SHAPE_ITEM::Load(), EASYPC::SOURCE_NET::Load(), EASYPC::SOURCE_NODE::Load(), EASYPC::SOURCE_ORIGIN::Load(), EASYPC::SOURCE_PAD_INSTANCE::Load(), EASYPC::SOURCE_PAD_STYLE::Load(), EASYPC::SOURCE_PAD_STYLE_EXCEPTION::Load(), EASYPC::SOURCE_PCB_COMPONENT::Load(), EASYPC::SOURCE_PIN_NAME_INSTANCE::Load(), EASYPC::SOURCE_SCM_COMPONENT::Load(), EASYPC::SOURCE_SHAPE_ITEM::Load(), EASYPC::SOURCE_SYMBOL::Load(), EASYPC::SOURCE_SYMBOL_INSTANCE::Load(), EASYPC::SOURCE_TEXT_INSTANCE::Load(), EASYPC::SOURCE_TEXT_STYLE::Load(), EASYPC::SOURCE_TRACK::Load(), EASYPC::SOURCE_VIA::Load(), EASYPC::SOURCE_TEXT_POSITION::LoadRemainder(), EASYPC::SOURCE_SHAPE::LoadShape(), EASYPC::SOURCE_COMMON_SEGMENT::LoadTail(), EASYPC::SOURCE_TRACK_SEGMENT::LoadTail(), and EASYPC::SkipFields().

◆ ObjectAs()

◆ ObjectSchema()

uint16_t EASYPC::ARCHIVE::ObjectSchema ( ) const
inline

Definition at line 310 of file easypc_archive.h.

References m_objectSchema.

Referenced by EASYPC::SOURCE_DESIGN_ITEM::LoadFormatted().

◆ OrphanFormat()

int EASYPC::ARCHIVE::OrphanFormat ( ) const

A null parent tag is the document: the header version in a design, else the current read format.

Definition at line 502 of file easypc_archive.cpp.

References IsDesign(), m_currentReadFormat, and m_documentVersion.

Referenced by EASYPC::SOURCE_DESIGN_DATA::ItemFormat(), EASYPC::SOURCE_DESIGN_ITEM::ItemFormat(), and EASYPC::SOURCE_DESIGN_LIST::ItemFormat().

◆ ParentWalkDepth()

size_t & EASYPC::ARCHIVE::ParentWalkDepth ( ) const
inline

Bounds ItemFormat parent walks, which recurse through file-supplied parent tags.

Definition at line 304 of file easypc_archive.h.

References m_parentWalkDepth.

Referenced by EASYPC::SOURCE_DESIGN_ITEM::ItemFormat().

◆ Pos()

size_t EASYPC::ARCHIVE::Pos ( ) const
inline

Definition at line 307 of file easypc_archive.h.

References m_pos.

Referenced by EASYPC::SOURCE_DESIGN::Load().

◆ Product()

int32_t EASYPC::ARCHIVE::Product ( ) const
inline

Definition at line 300 of file easypc_archive.h.

References m_product.

Referenced by EASYPC::SOURCE_SCM_COMPONENT::Load(), and EASYPC::SOURCE_SYMBOL::Load().

◆ pushObjectLoad()

void EASYPC::ARCHIVE::pushObjectLoad ( OBJECT & aObject,
uint16_t aSchema )
private

◆ pushTask()

void EASYPC::ARCHIVE::pushTask ( LOAD_TASK::HANDLE aHandle)
private

Definition at line 360 of file easypc_archive.cpp.

References m_frames, and m_objectSchema.

Referenced by drive().

◆ ReadObject()

OBJECT * EASYPC::ARCHIVE::ReadObject ( )

ReadObject and LoadEmbedded outside any loader, running the nested loads to completion.

Definition at line 427 of file easypc_archive.cpp.

References drive(), and result.

Referenced by EASYPC::LIBRARY_FILE::LoadItem().

◆ ReadString()

◆ readTag()

OBJECT * EASYPC::ARCHIVE::readTag ( bool & aIsNew)
private

Read a tag; a new object is created and mapped but not loaded (aIsNew)

Definition at line 226 of file easypc_archive.cpp.

References _, EASYPC::OBJECT::ClassName, end, index, m_data, m_depth, m_load, m_objects, m_pos, MAX_DEPTH, name, EASYPC::OBJECT::Offset, Require(), EASYPC::OBJECT::Schema, THROW_IO_ERROR, U16(), and U32().

◆ Require()

void EASYPC::ARCHIVE::Require ( size_t aLen) const

Throw unless aLen more bytes remain.

Definition at line 101 of file easypc_archive.cpp.

References _, m_pos, m_size, and THROW_IO_ERROR.

Referenced by ReadString(), readTag(), Skip(), U16(), U32(), U64(), and U8().

◆ SetBooleanIsByte()

void EASYPC::ARCHIVE::SetBooleanIsByte ( bool aByte)
inline

Definition at line 286 of file easypc_archive.h.

References m_boolIsByte.

Referenced by EASYPC::SOURCE_DESIGN::Load().

◆ SetDocumentVersion()

void EASYPC::ARCHIVE::SetDocumentVersion ( int aVersion)
inline

Definition at line 296 of file easypc_archive.h.

References m_documentVersion.

Referenced by EASYPC::SOURCE_DESIGN::Load().

◆ SetProduct()

void EASYPC::ARCHIVE::SetProduct ( int32_t aProduct)
inline

Definition at line 301 of file easypc_archive.h.

References m_product.

Referenced by EASYPC::SOURCE_DESIGN::Load().

◆ SetReadFormat()

void EASYPC::ARCHIVE::SetReadFormat ( int aFormat)
inline

◆ SetShapeFormat()

void EASYPC::ARCHIVE::SetShapeFormat ( int aFormat)
inline

Definition at line 288 of file easypc_archive.h.

References m_shapeFormat.

Referenced by EASYPC::SOURCE_SHAPE::LoadShape().

◆ ShapeFormat()

int EASYPC::ARCHIVE::ShapeFormat ( ) const
inline

◆ Size()

size_t EASYPC::ARCHIVE::Size ( ) const
inline

Definition at line 308 of file easypc_archive.h.

References m_size.

◆ Skip()

◆ SkipString()

◆ stringLength()

uint32_t EASYPC::ARCHIVE::stringLength ( bool & aUnicode)
private

The string length prefix; aUnicode for the UTF-16 form.

Definition at line 172 of file easypc_archive.cpp.

References U16(), U32(), and U8().

Referenced by ReadString(), and SkipString().

◆ TakeObjects()

std::vector< std::unique_ptr< OBJECT > > EASYPC::ARCHIVE::TakeObjects ( )
inline

Definition at line 312 of file easypc_archive.h.

References m_objects.

Referenced by EASYPC::LoadDesign(), EASYPC::LIBRARY_FILE::LoadItem(), and EASYPC::LoadProject().

◆ throwBadClass()

void EASYPC::ARCHIVE::throwBadClass ( const OBJECT & aObject) const
private

◆ U16()

uint16_t EASYPC::ARCHIVE::U16 ( )

Definition at line 132 of file easypc_archive.cpp.

References m_data, m_pos, and Require().

Referenced by Count(), readTag(), and stringLength().

◆ U32()

◆ U64()

uint64_t EASYPC::ARCHIVE::U64 ( )

◆ U8()

uint8_t EASYPC::ARCHIVE::U8 ( )

Definition at line 119 of file easypc_archive.cpp.

References m_data, m_pos, and Require().

Referenced by Bool(), InBool(), EASYPC::SOURCE_SHAPE::LoadShape(), and stringLength().

Friends And Related Symbol Documentation

◆ LOAD_TASK

friend class LOAD_TASK
friend

Definition at line 317 of file easypc_archive.h.

References LOAD_TASK.

Referenced by drive(), and LOAD_TASK.

Member Data Documentation

◆ m_boolIsByte

bool EASYPC::ARCHIVE::m_boolIsByte = true
private

Definition at line 361 of file easypc_archive.h.

Referenced by InBool(), and SetBooleanIsByte().

◆ m_currentReadFormat

int EASYPC::ARCHIVE::m_currentReadFormat = -1
private

Definition at line 363 of file easypc_archive.h.

Referenced by CurrentReadFormat(), OrphanFormat(), and SetReadFormat().

◆ m_data

const uint8_t* EASYPC::ARCHIVE::m_data
private

Definition at line 348 of file easypc_archive.h.

Referenced by ARCHIVE(), ReadString(), readTag(), U16(), U32(), U64(), and U8().

◆ m_depth

int EASYPC::ARCHIVE::m_depth = 0
private

Definition at line 358 of file easypc_archive.h.

Referenced by drive(), pushObjectLoad(), and readTag().

◆ m_documentVersion

int EASYPC::ARCHIVE::m_documentVersion = 0
private

Definition at line 364 of file easypc_archive.h.

Referenced by DocumentVersion(), OrphanFormat(), and SetDocumentVersion().

◆ m_errorHasContext

bool EASYPC::ARCHIVE::m_errorHasContext = false
private

Definition at line 359 of file easypc_archive.h.

Referenced by drive().

◆ m_frames

std::vector<FRAME> EASYPC::ARCHIVE::m_frames
private

Definition at line 356 of file easypc_archive.h.

Referenced by drive(), pushObjectLoad(), and pushTask().

◆ m_kind

DOC_KIND EASYPC::ARCHIVE::m_kind
private

Definition at line 351 of file easypc_archive.h.

Referenced by ARCHIVE(), IsDesign(), and Kind().

◆ m_load

std::vector<SLOT> EASYPC::ARCHIVE::m_load
private

slot 0 is the null slot

Definition at line 354 of file easypc_archive.h.

Referenced by ARCHIVE(), LoadArraySize(), MapObject(), and readTag().

◆ m_objects

std::vector<std::unique_ptr<OBJECT> > EASYPC::ARCHIVE::m_objects
private

Definition at line 355 of file easypc_archive.h.

Referenced by readTag(), and TakeObjects().

◆ m_objectSchema

uint16_t EASYPC::ARCHIVE::m_objectSchema = 0
private

Definition at line 357 of file easypc_archive.h.

Referenced by drive(), ObjectSchema(), pushObjectLoad(), and pushTask().

◆ m_parentWalkDepth

size_t EASYPC::ARCHIVE::m_parentWalkDepth = 0
mutableprivate

Definition at line 366 of file easypc_archive.h.

Referenced by ParentWalkDepth().

◆ m_pos

size_t EASYPC::ARCHIVE::m_pos = 0
private

Definition at line 350 of file easypc_archive.h.

Referenced by AtEnd(), Pos(), pushObjectLoad(), ReadString(), readTag(), Require(), Skip(), U16(), U32(), U64(), and U8().

◆ m_product

int32_t EASYPC::ARCHIVE::m_product
private

Definition at line 352 of file easypc_archive.h.

Referenced by ARCHIVE(), Product(), and SetProduct().

◆ m_shapeFormat

int EASYPC::ARCHIVE::m_shapeFormat = 3
private

Definition at line 362 of file easypc_archive.h.

Referenced by SetShapeFormat(), and ShapeFormat().

◆ m_size

size_t EASYPC::ARCHIVE::m_size
private

Definition at line 349 of file easypc_archive.h.

Referenced by ARCHIVE(), AtEnd(), Require(), and Size().

◆ MAX_DEPTH

int EASYPC::ARCHIVE::MAX_DEPTH = 100000
staticconstexpr

Definition at line 314 of file easypc_archive.h.

Referenced by pushObjectLoad(), and readTag().


The documentation for this class was generated from the following files: