KiCad PCB EDA Suite
Loading...
Searching...
No Matches
easypc_document.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
29
30#ifndef EASYPC_DOCUMENT_H
31#define EASYPC_DOCUMENT_H
32
33#include <map>
34#include <memory>
35#include <optional>
36#include <vector>
37
38#include <wx/string.h>
39
43
44
45namespace EASYPC
46{
47
49{
52 std::unique_ptr<OBJECT> Design;
53 std::vector<std::unique_ptr<OBJECT>> Objects;
54 std::vector<uint8_t> SummaryInformation;
55};
56
57
59{
60 OBJECT* Item = nullptr;
61 wxString StreamName;
62};
63
64
67{
69 wxString Name;
70 std::vector<LIBRARY_STREAM> Streams;
71 std::vector<std::unique_ptr<OBJECT>> Objects;
72};
73
74
76{
77 std::unique_ptr<SOURCE_PROJECT> Project;
78 std::vector<std::unique_ptr<OBJECT>> Objects;
79};
80
81
83{
84 bool IsProject = false;
85 std::optional<FILE_KIND> FileKind;
86};
87
88
91{
92public:
94 explicit LIBRARY_FILE( const wxString& aPath );
95
97 static long long Timestamp( const wxString& aPath );
98
99 FILE_KIND Kind() const { return m_kind; }
100
102 const std::vector<wxString>& ItemNames() const { return m_names; }
103 bool HasItem( const wxString& aItemName ) const { return m_byName.count( aItemName ) > 0; }
104
106 const std::vector<wxString>& Warnings() const { return m_warnings; }
107
109 std::unique_ptr<LIBRARY_ITEM> LoadItem( const wxString& aItemName ) const;
110
111private:
112 wxString m_path;
116 std::vector<const SOURCE_FB_ENTRY*> m_entries;
117 std::vector<wxString> m_names;
118 std::map<wxString, size_t> m_byName;
119 std::vector<wxString> m_warnings;
120};
121
122
123std::unique_ptr<DESIGN_DOCUMENT> LoadDesign( const wxString& aPath );
124
125std::unique_ptr<PROJECT_DOCUMENT> LoadProject( const wxString& aPath );
126
131wxString ResolveProjectItem( const wxString& aProjectPath, const wxString& aItemName );
132
134FILE_INFO Probe( const wxString& aPath );
135
136} // namespace EASYPC
137
138#endif // EASYPC_DOCUMENT_H
A compound file held in memory; any malformed structure throws IO_ERROR.
Definition easypc_file.h:80
std::vector< const SOURCE_FB_ENTRY * > m_entries
std::unique_ptr< LIBRARY_ITEM > LoadItem(const wxString &aItemName) const
Throws IO_ERROR if no item has that name.
const std::vector< wxString > & Warnings() const
Warnings for item names that collide after unescaping.
bool HasItem(const wxString &aItemName) const
LIBRARY_FILE(const wxString &aPath)
Throws IO_ERROR when the file is not a library or is malformed.
std::map< wxString, size_t > m_byName
std::vector< wxString > m_warnings
FILE_KIND Kind() const
static long long Timestamp(const wxString &aPath)
A library file's modification time, 0 when it does not exist.
std::vector< wxString > m_names
const std::vector< wxString > & ItemNames() const
Item names in directory order, unescaped.
Reader for the serialized streams of Easy-PC and DesignSpark PCB.
The project file (.prj), a bare archive stream.
The OLE compound file container, over thirdparty/compoundfilereader.
FILE_INFO Probe(const wxString &aPath)
Identify a file; projects are parsed fully, while designs and libraries are only inspected....
std::unique_ptr< DESIGN_DOCUMENT > LoadDesign(const wxString &aPath)
DOC_KIND
Document kind, from the FileType stream or the file extension for projects.
FILE_KIND
The FileType strings the importer reads.
Definition easypc_file.h:44
wxString ResolveProjectItem(const wxString &aProjectPath, const wxString &aItemName)
The file a project item names, as Easy-PC opens it: the Windows path relative to the project's direct...
std::unique_ptr< PROJECT_DOCUMENT > LoadProject(const wxString &aPath)
std::unique_ptr< OBJECT > Design
design root, not in the load array
std::vector< uint8_t > SummaryInformation
the SummaryInformation stream, if any
std::vector< std::unique_ptr< OBJECT > > Objects
std::optional< FILE_KIND > FileKind
One stream, or for a component library every stream of the component's storage.
std::vector< LIBRARY_STREAM > Streams
for .cml "[ScmComponent]" first
std::vector< std::unique_ptr< OBJECT > > Objects
OBJECT * Item
what the stream's single ReadObject returned
Root of every deserialized object.
std::vector< std::unique_ptr< OBJECT > > Objects
std::unique_ptr< SOURCE_PROJECT > Project