2012-02-16 20:03:33 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2019-01-01 14:38:57 +00:00
|
|
|
* Copyright (C) 2018 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
2012-02-16 20:03:33 +00:00
|
|
|
* Copyright (C) 2007-2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
2017-11-12 00:31:38 +00:00
|
|
|
* Copyright (C) 2008 Wayne Stambaugh <stambaughw@gmail.com>
|
2023-04-22 20:17:08 +00:00
|
|
|
* Copyright (C) 1992-2023 KiCad Developers, see AUTHORS.txt for contributors.
|
2012-02-16 20:03:33 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @file wildcards_and_files_ext.h
|
2019-01-01 14:38:57 +00:00
|
|
|
* Definition of file extensions used in Kicad.
|
2012-02-16 20:03:33 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef INCLUDE_WILDCARDS_AND_FILES_EXT_H_
|
|
|
|
#define INCLUDE_WILDCARDS_AND_FILES_EXT_H_
|
|
|
|
|
2023-12-28 02:10:01 +00:00
|
|
|
#include <kicommon.h>
|
2019-01-05 23:55:14 +00:00
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
2021-05-01 07:50:29 +00:00
|
|
|
#include <wx/string.h>
|
2019-01-05 23:55:14 +00:00
|
|
|
|
2019-09-26 20:09:09 +00:00
|
|
|
/**
|
|
|
|
* Compare the given extension against the reference extensions to see if it matches any
|
|
|
|
* of the reference extensions.
|
|
|
|
*
|
|
|
|
* This function uses the C++ regular expression functionality to perform the comparison,
|
|
|
|
* so the reference extensions can be regular expressions of their own right. This means
|
|
|
|
* that partial searches can be made, for example ^g.* can be used to see if the first
|
|
|
|
* character of the extension is g. The reference extensions are concatenated together
|
|
|
|
* as alternatives when doing the evaluation (e.g. (dxf|svg|^g.*) ).
|
|
|
|
*
|
|
|
|
* @param aExtension is the extension to test
|
|
|
|
* @param aReference is a vector containing the extensions to test against
|
|
|
|
* @param aCaseSensitive says if the comparison should be case sensitive or not
|
|
|
|
*
|
|
|
|
* @return if the extension matches any reference extensions
|
|
|
|
*/
|
2023-12-28 02:10:01 +00:00
|
|
|
KICOMMON_API bool compareFileExtensions( const std::string& aExtension,
|
|
|
|
const std::vector<std::string>& aReference, bool aCaseSensitive = false );
|
2019-09-26 20:09:09 +00:00
|
|
|
|
2019-01-01 14:38:57 +00:00
|
|
|
/**
|
2019-01-05 23:55:14 +00:00
|
|
|
* Build the wildcard extension file dialog wildcard filter to add to the base message dialog.
|
|
|
|
*
|
|
|
|
* For instance, to open .txt files in a file dialog:
|
2019-01-01 14:38:57 +00:00
|
|
|
* the base message is for instance "Text files"
|
|
|
|
* the ext list is " (*.txt)|*.txt"
|
|
|
|
* and the returned string to add to the base message is " (*.txt)|*.txt"
|
|
|
|
* the message to display in the dialog is "Text files (*.txt)|*.txt"
|
|
|
|
*
|
2019-01-05 23:55:14 +00:00
|
|
|
* This function produces a case-insensitive filter (so .txt, .TXT and .tXT
|
|
|
|
* are all match if you pass "txt" into the function).
|
|
|
|
*
|
|
|
|
* @param aExts is the list of exts to add to the filter. Do not include the
|
2019-01-08 11:57:39 +00:00
|
|
|
* leading dot. Empty means "allow all files".
|
2019-01-01 14:38:57 +00:00
|
|
|
*
|
|
|
|
* @return the appropriate file dialog wildcard filter list.
|
|
|
|
*/
|
|
|
|
|
2023-12-28 02:10:01 +00:00
|
|
|
KICOMMON_API wxString AddFileExtListToFilter( const std::vector<std::string>& aExts );
|
2019-01-01 14:38:57 +00:00
|
|
|
|
2019-06-15 03:27:36 +00:00
|
|
|
/**
|
|
|
|
* Format wildcard extension to support case sensitive file dialogs.
|
|
|
|
*
|
|
|
|
* The file extension wildcards of the GTK+ file dialog are case sensitive so using all lower
|
|
|
|
* case characters means that only file extensions that are all lower case will show up in the
|
|
|
|
* file dialog. The GTK+ file dialog does support regular expressions so the file extension
|
|
|
|
* is converted to a regular expression ( sch -> [sS][cC][hH] ) when wxWidgets is built against
|
|
|
|
* GTK+. Please make sure you call this function when adding new file wildcards.
|
|
|
|
*
|
|
|
|
* @note When calling wxFileDialog with a default file defined, make sure you include the
|
|
|
|
* file extension along with the file name. Otherwise, on GTK+ builds, the file
|
|
|
|
* dialog will append the wildcard regular expression as the file extension which is
|
|
|
|
* surely not what you want.
|
|
|
|
*
|
|
|
|
* @param aWildcard is the extension part of the wild card.
|
|
|
|
*
|
|
|
|
* @return the build appropriate file dialog wildcard filter.
|
|
|
|
*/
|
2023-12-28 02:10:01 +00:00
|
|
|
KICOMMON_API wxString formatWildcardExt( const wxString& aWildcard );
|
2019-01-01 14:38:57 +00:00
|
|
|
|
2021-03-03 01:06:25 +00:00
|
|
|
|
2023-12-28 02:10:01 +00:00
|
|
|
class KICOMMON_API FILEEXT
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
FILEEXT() = delete;
|
2012-09-28 17:47:41 +00:00
|
|
|
|
2023-12-28 02:10:01 +00:00
|
|
|
/**
|
|
|
|
* \defgroup file_extensions File Extension Definitions
|
|
|
|
*
|
|
|
|
* @note Please do not changes these. If a different file extension is needed, create a new
|
|
|
|
* definition in here. If you create a extension definition in another file, make sure
|
|
|
|
* to add it to the Doxygen group "file_extensions" using the "addtogroup" tag. Also
|
|
|
|
* note, just because they are defined as const doesn't guarantee that they cannot be
|
|
|
|
* changed.
|
|
|
|
*
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
static const std::string BackupFileSuffix;
|
|
|
|
static const std::string LockFilePrefix;
|
|
|
|
static const std::string LockFileExtension;
|
2020-07-03 13:40:31 +00:00
|
|
|
|
2023-12-28 02:10:01 +00:00
|
|
|
static const std::string SchematicSymbolFileExtension;
|
|
|
|
static const std::string LegacySymbolLibFileExtension;
|
|
|
|
static const std::string LegacySymbolDocumentFileExtension;
|
|
|
|
static const std::string SchematicBackupFileExtension;
|
2012-12-14 16:54:54 +00:00
|
|
|
|
2023-12-28 02:10:01 +00:00
|
|
|
static const std::string VrmlFileExtension;
|
|
|
|
static const std::string ProjectFileExtension;
|
|
|
|
static const std::string LegacyProjectFileExtension;
|
|
|
|
static const std::string ProjectLocalSettingsFileExtension;
|
|
|
|
static const std::string LegacySchematicFileExtension;
|
|
|
|
static const std::string CadstarSchematicFileExtension;
|
|
|
|
static const std::string CadstarPartsLibraryFileExtension;
|
|
|
|
static const std::string KiCadSchematicFileExtension;
|
|
|
|
static const std::string SpiceFileExtension;
|
|
|
|
static const std::string CadstarNetlistFileExtension;
|
|
|
|
static const std::string OrCadPcb2NetlistFileExtension;
|
|
|
|
static const std::string NetlistFileExtension;
|
|
|
|
static const std::string AllegroNetlistFileExtension;
|
2024-03-09 14:57:24 +00:00
|
|
|
static const std::string PADSNetlistFileExtension;
|
2023-12-28 02:10:01 +00:00
|
|
|
static const std::string GerberFileExtension;
|
|
|
|
static const std::string GerberJobFileExtension;
|
|
|
|
static const std::string HtmlFileExtension;
|
|
|
|
static const std::string EquFileExtension;
|
|
|
|
static const std::string HotkeyFileExtension;
|
|
|
|
static const std::string DatabaseLibraryFileExtension;
|
|
|
|
static const std::string HTTPLibraryFileExtension;
|
2012-12-14 16:54:54 +00:00
|
|
|
|
2023-12-28 02:10:01 +00:00
|
|
|
static const std::string ArchiveFileExtension;
|
2012-02-16 20:03:33 +00:00
|
|
|
|
2023-12-28 02:10:01 +00:00
|
|
|
static const std::string LegacyPcbFileExtension;
|
|
|
|
static const std::string EaglePcbFileExtension;
|
|
|
|
static const std::string CadstarPcbFileExtension;
|
|
|
|
static const std::string KiCadPcbFileExtension;
|
|
|
|
#define PcbFileExtension KiCadPcbFileExtension // symlink choice
|
|
|
|
static const std::string KiCadSymbolLibFileExtension;
|
|
|
|
static const std::string DrawingSheetFileExtension;
|
|
|
|
static const std::string DesignRulesFileExtension;
|
2018-12-08 13:20:32 +00:00
|
|
|
|
2023-12-28 02:10:01 +00:00
|
|
|
static const std::string LegacyFootprintLibPathExtension;
|
|
|
|
static const std::string PdfFileExtension;
|
|
|
|
static const std::string MacrosFileExtension;
|
|
|
|
static const std::string FootprintAssignmentFileExtension;
|
|
|
|
static const std::string DrillFileExtension;
|
|
|
|
static const std::string SVGFileExtension;
|
|
|
|
static const std::string ReportFileExtension;
|
|
|
|
static const std::string FootprintPlaceFileExtension;
|
|
|
|
static const std::string KiCadFootprintFileExtension;
|
|
|
|
static const std::string KiCadFootprintLibPathExtension;
|
|
|
|
static const std::string AltiumFootprintLibPathExtension;
|
|
|
|
static const std::string CadstarFootprintLibPathExtension;
|
|
|
|
static const std::string GedaPcbFootprintLibFileExtension;
|
|
|
|
static const std::string EagleFootprintLibPathExtension;
|
|
|
|
static const std::string SpecctraDsnFileExtension;
|
|
|
|
static const std::string SpecctraSessionFileExtension;
|
|
|
|
static const std::string IpcD356FileExtension;
|
|
|
|
static const std::string Ipc2581FileExtension;
|
|
|
|
static const std::string WorkbookFileExtension;
|
2023-08-19 23:01:05 +00:00
|
|
|
|
2023-12-28 02:10:01 +00:00
|
|
|
static const std::string PngFileExtension;
|
|
|
|
static const std::string JpegFileExtension;
|
|
|
|
static const std::string TextFileExtension;
|
|
|
|
static const std::string MarkdownFileExtension;
|
|
|
|
static const std::string CsvFileExtension;
|
|
|
|
static const std::string XmlFileExtension;
|
|
|
|
static const std::string JsonFileExtension;
|
2022-09-14 22:28:09 +00:00
|
|
|
|
2023-12-28 02:10:01 +00:00
|
|
|
static const std::string StepFileExtension;
|
|
|
|
static const std::string StepFileAbrvExtension;
|
|
|
|
static const std::string GltfBinaryFileExtension;
|
2019-11-11 20:34:42 +00:00
|
|
|
|
2023-12-28 02:10:01 +00:00
|
|
|
static const wxString GerberFileExtensionsRegex;
|
2013-01-03 16:33:22 +00:00
|
|
|
|
2023-12-28 02:10:01 +00:00
|
|
|
/**
|
|
|
|
* @}
|
|
|
|
*/
|
2012-02-16 20:03:33 +00:00
|
|
|
|
2023-12-28 02:10:01 +00:00
|
|
|
/**
|
|
|
|
* \defgroup file_wildcards File Wildcard Definitions
|
|
|
|
*
|
|
|
|
* @note Please do not changes these. If a different file wildcard is needed, create a new
|
|
|
|
* definition in here. If you create a wildcard definition in another file, make sure
|
|
|
|
* to add it to the Doxygen group "file_extensions" using the "addtogroup" tag and
|
|
|
|
* correct handle the GTK+ file dialog case sensitivity issue.
|
|
|
|
* @{
|
|
|
|
*/
|
2017-11-12 00:31:38 +00:00
|
|
|
|
2018-08-02 22:15:01 +00:00
|
|
|
|
2023-12-28 02:10:01 +00:00
|
|
|
static bool IsGerberFileExtension( const wxString& ext );
|
|
|
|
static wxString AllFilesWildcard();
|
|
|
|
|
|
|
|
static wxString FootprintAssignmentFileWildcard();
|
|
|
|
static wxString DrawingSheetFileWildcard();
|
|
|
|
static wxString KiCadSymbolLibFileWildcard();
|
|
|
|
static wxString ProjectFileWildcard();
|
|
|
|
static wxString LegacyProjectFileWildcard();
|
|
|
|
static wxString AllProjectFilesWildcard();
|
|
|
|
static wxString AllSchematicFilesWildcard();
|
|
|
|
static wxString KiCadSchematicFileWildcard();
|
|
|
|
static wxString LegacySchematicFileWildcard();
|
|
|
|
static wxString BoardFileWildcard();
|
|
|
|
static wxString OrCadPcb2NetlistFileWildcard();
|
|
|
|
static wxString NetlistFileWildcard();
|
|
|
|
static wxString AllegroNetlistFileWildcard();
|
2024-03-09 14:57:24 +00:00
|
|
|
static wxString PADSNetlistFileWildcard();
|
2023-12-28 02:10:01 +00:00
|
|
|
static wxString HtmlFileWildcard();
|
|
|
|
static wxString CsvFileWildcard();
|
|
|
|
static wxString PcbFileWildcard();
|
|
|
|
static wxString CadstarArchiveFilesWildcard();
|
|
|
|
static wxString EagleFilesWildcard();
|
|
|
|
static wxString EasyEdaArchiveWildcard();
|
|
|
|
static wxString EasyEdaProFileWildcard();
|
|
|
|
static wxString PdfFileWildcard();
|
|
|
|
static wxString PSFileWildcard();
|
|
|
|
static wxString MacrosFileWildcard();
|
|
|
|
static wxString DrillFileWildcard();
|
|
|
|
static wxString SVGFileWildcard();
|
|
|
|
static wxString JsonFileWildcard();
|
|
|
|
static wxString ReportFileWildcard();
|
|
|
|
static wxString FootprintPlaceFileWildcard();
|
|
|
|
static wxString Shapes3DFileWildcard();
|
|
|
|
static wxString IDF3DFileWildcard();
|
|
|
|
static wxString DocModulesFileName();
|
|
|
|
static wxString KiCadFootprintLibFileWildcard();
|
|
|
|
static wxString KiCadFootprintLibPathWildcard();
|
|
|
|
static wxString TextFileWildcard();
|
|
|
|
static wxString ModLegacyExportFileWildcard();
|
|
|
|
static wxString ErcFileWildcard();
|
|
|
|
static wxString SpiceLibraryFileWildcard();
|
|
|
|
static wxString SpiceNetlistFileWildcard();
|
|
|
|
static wxString CadstarNetlistFileWildcard();
|
|
|
|
static wxString EquFileWildcard();
|
|
|
|
static wxString ZipFileWildcard();
|
|
|
|
static wxString GencadFileWildcard();
|
|
|
|
static wxString DxfFileWildcard();
|
|
|
|
static wxString GerberJobFileWildcard();
|
|
|
|
static wxString SpecctraDsnFileWildcard();
|
|
|
|
static wxString SpecctraSessionFileWildcard();
|
|
|
|
static wxString IpcD356FileWildcard();
|
|
|
|
static wxString WorkbookFileWildcard();
|
|
|
|
static wxString PngFileWildcard();
|
|
|
|
static wxString JpegFileWildcard();
|
|
|
|
static wxString HotkeyFileWildcard();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @}
|
|
|
|
*/
|
|
|
|
};
|
2017-11-12 00:31:38 +00:00
|
|
|
|
|
|
|
|
2012-02-16 20:03:33 +00:00
|
|
|
#endif // INCLUDE_WILDCARDS_AND_FILES_EXT_H_
|