KiCad PCB EDA Suite
Loading...
Searching...
No Matches
pads_sch_binary_reader.cpp
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 modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation, either version 3 of the License, or (at your option)
9 * any later version.
10 */
11
13
16
18#include <ki_exception.h>
19
20namespace PADS_SCH_BINARY
21{
22bool PADS_SCH_BINARY_READER::IsBinaryFamily( const std::vector<uint8_t>& aData )
23{
24 return PADS_SCH_SDB::HasFamilyMagic( aData );
25}
26
27
29{
30 return PADS_SCH_SDB::IsSupportedVersion( aVersion );
31}
32
33
34bool PADS_SCH_BINARY_READER::IsBinarySch( const std::vector<uint8_t>& aData )
35{
36 return IsBinaryFamily( aData );
37}
38
39
40bool PADS_SCH_BINARY_READER::ReadFile( const wxString& aFileName, std::vector<uint8_t>& aData )
41{
42 return PADS_IO::ReadFileToBuffer( aFileName, aData );
43}
44
45
46bool PADS_SCH_BINARY_READER::Parse( const std::vector<uint8_t>& aData, const wxString& aSourceName )
47{
48 m_model.reset();
49
50 if( !IsBinaryFamily( aData ) )
51 return false;
52
53 m_model = PADS_SCH_BINARY_PARSER().Parse( aData, aSourceName );
54 return true;
55}
56
57
59{
60 if( !m_model )
61 THROW_IO_ERROR( wxS( "PADS Logic binary schematic has not been parsed" ) );
62
63 return *m_model;
64}
65
66
68 const wxString& aSourcePath ) const
69{
70 return PADS_SCH_BINARY_BUILDER().Build( GetModel(), aSchematic, aAppendToMe, aSourcePath );
71}
72
73} // namespace PADS_SCH_BINARY
BUILD_RESULT Build(const PADS_SCH_MODEL &aModel, SCHEMATIC *aSchematic, SCH_SHEET *aAppendToMe, const wxString &aSourcePath)
PADS_SCH_MODEL Parse(const std::vector< uint8_t > &aBytes, const wxString &aSourceName={}) const
static bool ReadFile(const wxString &aFileName, std::vector< uint8_t > &aData)
static bool IsBinarySch(const std::vector< uint8_t > &aData)
bool Parse(const std::vector< uint8_t > &aData, const wxString &aSourceName={})
static bool IsSupportedVersion(uint16_t aVersion)
static bool IsBinaryFamily(const std::vector< uint8_t > &aData)
BUILD_RESULT BuildSchematic(SCHEMATIC *aSchematic, SCH_SHEET *aAppendToMe, const wxString &aSourcePath) const
std::optional< PADS_SCH_MODEL > m_model
static bool IsSupportedVersion(uint16_t aVersion)
static bool HasFamilyMagic(const std::vector< uint8_t > &aBytes)
Holds all the data relating to one schematic.
Definition schematic.h:148
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition sch_sheet.h:48
#define THROW_IO_ERROR(msg)
macro which captures the "call site" values of FILE_, __FUNCTION & LINE
bool ReadFileToBuffer(const wxString &aFileName, std::vector< uint8_t > &aOut)
Read an entire file into aOut.