KiCad PCB EDA Suite
Loading...
Searching...
No Matches
design_block_io.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 (C) 2024 Mike Williams <[email protected]>
5 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 */
20#ifndef DESIGN_BLOCK_IO_H
21#define DESIGN_BLOCK_IO_H
22
23#include <kicommon.h>
24#include <io/io_base.h>
25#include <io/io_mgr.h>
26
27class DESIGN_BLOCK;
28class DESIGN_BLOCK_IO;
29class wxArrayString;
30
32{
33public:
42
43 static const wxString ShowType( DESIGN_BLOCK_FILE_T aFileType );
44 static DESIGN_BLOCK_IO* FindPlugin( DESIGN_BLOCK_FILE_T aFileType );
45 static DESIGN_BLOCK_FILE_T EnumFromStr( const wxString& aFileType );
46 static DESIGN_BLOCK_FILE_T GuessPluginTypeFromLibPath( const wxString& aLibPath, int aCtl = 0 );
47
51 static bool ConvertLibrary( std::map<std::string, UTF8>* aOldFileProps,
52 const wxString& aOldFilePath, const wxString& aNewFilePath );
53};
54
55
57{
58public:
59 DESIGN_BLOCK_IO() : IO_BASE( wxS( "KiCad" ) ) {}
60
61 const IO_BASE::IO_FILE_DESC GetLibraryDesc() const override;
62 long long GetLibraryTimestamp( const wxString& aLibraryPath ) const;
63
64 void DesignBlockEnumerate( wxArrayString& aDesignBlockNames, const wxString& aLibraryPath,
65 bool aBestEfforts,
66 const std::map<std::string, UTF8>* aProperties = nullptr );
67
68 const DESIGN_BLOCK*
69 GetEnumeratedDesignBlock( const wxString& aLibraryPath, const wxString& aDesignBlockName,
70 const std::map<std::string, UTF8>* aProperties = nullptr )
71 {
72 return DesignBlockLoad( aLibraryPath, aDesignBlockName, false, aProperties );
73 }
74
75 bool DesignBlockExists( const wxString& aLibraryPath, const wxString& aDesignBlockName,
76 const std::map<std::string, UTF8>* aProperties = nullptr );
77
78 DESIGN_BLOCK* ImportDesignBlock( const wxString& aDesignBlockPath,
79 wxString& aDesignBlockNameOut,
80 const std::map<std::string, UTF8>* aProperties = nullptr )
81 {
82 return nullptr;
83 }
84
85 void CreateLibrary( const wxString& aLibraryPath,
86 const std::map<std::string, UTF8>* aProperties = nullptr ) override;
87
88 virtual bool DeleteLibrary( const wxString& aLibraryPath,
89 const std::map<std::string, UTF8>* aProperties = nullptr ) override;
90
91
92 bool IsLibraryWritable( const wxString& aLibraryPath ) override;
93
94 DESIGN_BLOCK* DesignBlockLoad( const wxString& aLibraryPath, const wxString& aDesignBlockName,
95 bool aKeepUUID = false,
96 const std::map<std::string, UTF8>* aProperties = nullptr );
97
98 void DesignBlockSave( const wxString& aLibraryPath, const DESIGN_BLOCK* aDesignBlock,
99 const std::map<std::string, UTF8>* aProperties = nullptr );
100
101 void DesignBlockDelete( const wxString& aLibraryPath, const wxString& aDesignBlockName,
102 const std::map<std::string, UTF8>* aProperties = nullptr );
103};
104
105#endif
@ KICAD_SEXP
S-expression KiCad file format.
@ DESIGN_BLOCK_FILE_UNKNOWN
0 is not a legal menu id on Mac
DESIGN_BLOCK * DesignBlockLoad(const wxString &aLibraryPath, const wxString &aDesignBlockName, bool aKeepUUID=false, const std::map< std::string, UTF8 > *aProperties=nullptr)
const DESIGN_BLOCK * GetEnumeratedDesignBlock(const wxString &aLibraryPath, const wxString &aDesignBlockName, const std::map< std::string, UTF8 > *aProperties=nullptr)
DESIGN_BLOCK * ImportDesignBlock(const wxString &aDesignBlockPath, wxString &aDesignBlockNameOut, const std::map< std::string, UTF8 > *aProperties=nullptr)
IO_BASE()=delete
#define KICOMMON_API
Definition kicommon.h:27
Container that describes file type info.
Definition io_base.h:43