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, you may find one here:
19 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20 * or you may search the http://www.gnu.org website for the version 2 license,
21 * or you may write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23 */
24#ifndef DESIGN_BLOCK_IO_H
25#define DESIGN_BLOCK_IO_H
26
27#include <kicommon.h>
28#include <io/io_base.h>
29#include <io/io_mgr.h>
30
31class DESIGN_BLOCK;
32class DESIGN_BLOCK_IO;
33class wxArrayString;
34
36{
37public:
46
47 static const wxString ShowType( DESIGN_BLOCK_FILE_T aFileType );
48 static DESIGN_BLOCK_IO* FindPlugin( DESIGN_BLOCK_FILE_T aFileType );
49 static DESIGN_BLOCK_FILE_T EnumFromStr( const wxString& aFileType );
50 static DESIGN_BLOCK_FILE_T GuessPluginTypeFromLibPath( const wxString& aLibPath, int aCtl = 0 );
51
55 static bool ConvertLibrary( std::map<std::string, UTF8>* aOldFileProps,
56 const wxString& aOldFilePath, const wxString& aNewFilePath );
57};
58
59
61{
62public:
63 DESIGN_BLOCK_IO() : IO_BASE( wxS( "KiCad" ) ) {}
64
65 const IO_BASE::IO_FILE_DESC GetLibraryDesc() const override;
66 long long GetLibraryTimestamp( const wxString& aLibraryPath ) const;
67
68 void DesignBlockEnumerate( wxArrayString& aDesignBlockNames, const wxString& aLibraryPath,
69 bool aBestEfforts,
70 const std::map<std::string, UTF8>* aProperties = nullptr );
71
72 const DESIGN_BLOCK*
73 GetEnumeratedDesignBlock( const wxString& aLibraryPath, const wxString& aDesignBlockName,
74 const std::map<std::string, UTF8>* aProperties = nullptr )
75 {
76 return DesignBlockLoad( aLibraryPath, aDesignBlockName, false, aProperties );
77 }
78
79 bool DesignBlockExists( const wxString& aLibraryPath, const wxString& aDesignBlockName,
80 const std::map<std::string, UTF8>* aProperties = nullptr );
81
82 DESIGN_BLOCK* ImportDesignBlock( const wxString& aDesignBlockPath,
83 wxString& aDesignBlockNameOut,
84 const std::map<std::string, UTF8>* aProperties = nullptr )
85 {
86 return nullptr;
87 }
88
89 void CreateLibrary( const wxString& aLibraryPath,
90 const std::map<std::string, UTF8>* aProperties = nullptr ) override;
91
92 virtual bool DeleteLibrary( const wxString& aLibraryPath,
93 const std::map<std::string, UTF8>* aProperties = nullptr ) override;
94
95
96 bool IsLibraryWritable( const wxString& aLibraryPath ) override;
97
98 DESIGN_BLOCK* DesignBlockLoad( const wxString& aLibraryPath, const wxString& aDesignBlockName,
99 bool aKeepUUID = false,
100 const std::map<std::string, UTF8>* aProperties = nullptr );
101
102 void DesignBlockSave( const wxString& aLibraryPath, const DESIGN_BLOCK* aDesignBlock,
103 const std::map<std::string, UTF8>* aProperties = nullptr );
104
105 void DesignBlockDelete( const wxString& aLibraryPath, const wxString& aDesignBlockName,
106 const std::map<std::string, UTF8>* aProperties = nullptr );
107};
108
109#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:28
Container that describes file type info.
Definition io_base.h:45