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#include <wx/arrstr.h> // for MSVC to see std::vector<wxString> is exported from wx
40
44
45
46namespace EASYPC
47{
48
50{
53 std::unique_ptr<OBJECT> Design;
54 std::vector<std::unique_ptr<OBJECT>> Objects;
55 std::vector<uint8_t> SummaryInformation;
56};
57
58
60{
61 OBJECT* Item = nullptr;
62 wxString StreamName;
63};
64
65
68{
70 wxString Name;
71 std::vector<LIBRARY_STREAM> Streams;
72 std::vector<std::unique_ptr<OBJECT>> Objects;
73};
74
75
77{
78 std::unique_ptr<SOURCE_PROJECT> Project;
79 std::vector<std::unique_ptr<OBJECT>> Objects;
80};
81
82
84{
85 bool IsProject = false;
86 std::optional<FILE_KIND> FileKind;
87};
88
89
92{
93public:
95 explicit LIBRARY_FILE( const wxString& aPath );
96
98 static long long Timestamp( const wxString& aPath );
99
100 FILE_KIND Kind() const { return m_kind; }
101
103 const std::vector<wxString>& ItemNames() const { return m_names; }
104 bool HasItem( const wxString& aItemName ) const { return m_byName.count( aItemName ) > 0; }
105
107 const std::vector<wxString>& Warnings() const { return m_warnings; }
108
110 std::unique_ptr<LIBRARY_ITEM> LoadItem( const wxString& aItemName ) const;
111
112private:
113 wxString m_path;
117 std::vector<const SOURCE_FB_ENTRY*> m_entries;
118 std::vector<wxString> m_names;
119 std::map<wxString, size_t> m_byName;
120 std::vector<wxString> m_warnings;
121};
122
123
124std::unique_ptr<DESIGN_DOCUMENT> LoadDesign( const wxString& aPath );
125
126std::unique_ptr<PROJECT_DOCUMENT> LoadProject( const wxString& aPath );
127
132wxString ResolveProjectItem( const wxString& aProjectPath, const wxString& aItemName );
133
135FILE_INFO Probe( const wxString& aPath );
136
137} // namespace EASYPC
138
139#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