KiCad PCB EDA Suite
Loading...
Searching...
No Matches
wildcards_and_files_ext.h File Reference

Definition of file extensions used in Kicad. More...

#include <kicommon.h>
#include <string>
#include <vector>
#include <wx/string.h>

Go to the source code of this file.

Classes

class  FILEEXT
 

Macros

#define PcbFileExtension   KiCadPcbFileExtension
 

Functions

KICOMMON_API bool compareFileExtensions (const std::string &aExtension, const std::vector< std::string > &aReference, bool aCaseSensitive=false)
 Compare the given extension against the reference extensions to see if it matches any of the reference extensions. More...
 
KICOMMON_API wxString AddFileExtListToFilter (const std::vector< std::string > &aExts)
 Build the wildcard extension file dialog wildcard filter to add to the base message dialog. More...
 
KICOMMON_API wxString formatWildcardExt (const wxString &aWildcard)
 Format wildcard extension to support case sensitive file dialogs. More...
 

Detailed Description

Definition of file extensions used in Kicad.

Definition in file wildcards_and_files_ext.h.

Function Documentation

◆ AddFileExtListToFilter()

KICOMMON_API wxString AddFileExtListToFilter ( const std::vector< std::string > &  aExts)

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: 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"

This function produces a case-insensitive filter (so .txt, .TXT and .tXT are all match if you pass "txt" into the function).

Parameters
aExtsis the list of exts to add to the filter. Do not include the leading dot. Empty means "allow all files".
Returns
the appropriate file dialog wildcard filter list.

Definition at line 85 of file wildcards_and_files_ext.cpp.

References filter, and formatWildcardExt().

Referenced by FILEEXT::AllegroNetlistFileWildcard(), FILEEXT::AllFilesWildcard(), FILEEXT::AllProjectFilesWildcard(), FILEEXT::AllSchematicFilesWildcard(), AskLoadBoardFileName(), BOOST_AUTO_TEST_CASE(), FILEEXT::CadstarArchiveFilesWildcard(), FILEEXT::CadstarNetlistFileWildcard(), FILEEXT::CsvFileWildcard(), FILEEXT::DrawingSheetFileWildcard(), FILEEXT::DrillFileWildcard(), FILEEXT::DxfFileWildcard(), FILEEXT::EagleFilesWildcard(), FILEEXT::EasyEdaArchiveWildcard(), FILEEXT::EasyEdaProFileWildcard(), FILEEXT::EquFileWildcard(), FILEEXT::ErcFileWildcard(), BOARD_EDITOR_CONTROL::ExportNetlist(), IO_BASE::IO_FILE_DESC::FileFilter(), FILEEXT::FootprintAssignmentFileWildcard(), FILEEXT::FootprintPlaceFileWildcard(), FILEEXT::GencadFileWildcard(), FILEEXT::GerberJobFileWildcard(), FILEEXT::HotkeyFileWildcard(), FILEEXT::HtmlFileWildcard(), FILEEXT::IDF3DFileWildcard(), FIELDS_GRID_TABLE< T >::initGrid(), FILEEXT::IpcD356FileWildcard(), FILEEXT::JpegFileWildcard(), FILEEXT::JsonFileWildcard(), FILEEXT::KiCadFootprintLibFileWildcard(), FILEEXT::KiCadFootprintLibPathWildcard(), FILEEXT::KiCadSchematicFileWildcard(), FILEEXT::KiCadSymbolLibFileWildcard(), FILEEXT::LegacyProjectFileWildcard(), FILEEXT::LegacySchematicFileWildcard(), GERBVIEW_FRAME::LoadGerberFiles(), FILEEXT::ModLegacyExportFileWildcard(), FILEEXT::NetlistFileWildcard(), DIALOG_EXPORT_STEP::onBrowseClicked(), DIALOG_IMPORT_GFX_SCH::onBrowseFiles(), DIALOG_IMPORT_GRAPHICS::onBrowseFiles(), PNS_LOG_VIEWER_FRAME::onOpen(), DIALOG_NET_INSPECTOR::onReport(), PNS_LOG_VIEWER_FRAME::onSaveAs(), FILEEXT::OrCadPcb2NetlistFileWildcard(), FILEEXT::PADSNetlistFileWildcard(), FILEEXT::PcbFileWildcard(), FILEEXT::PdfFileWildcard(), FILEEXT::PngFileWildcard(), FILEEXT::ProjectFileWildcard(), FILEEXT::PSFileWildcard(), FILEEXT::ReportFileWildcard(), ROUTER_TOOL::saveRouterDebugLog(), FILEEXT::Shapes3DFileWildcard(), FILEEXT::SpecctraDsnFileWildcard(), FILEEXT::SpecctraSessionFileWildcard(), FILEEXT::SpiceLibraryFileWildcard(), FILEEXT::SpiceNetlistFileWildcard(), FILEEXT::SVGFileWildcard(), FILEEXT::TextFileWildcard(), FILEEXT::WorkbookFileWildcard(), and FILEEXT::ZipFileWildcard().

◆ compareFileExtensions()

KICOMMON_API bool compareFileExtensions ( const std::string &  aExtension,
const std::vector< std::string > &  aReference,
bool  aCaseSensitive = false 
)

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.*) ).

Parameters
aExtensionis the extension to test
aReferenceis a vector containing the extensions to test against
aCaseSensitivesays if the comparison should be case sensitive or not
Returns
if the extension matches any reference extensions

Definition at line 37 of file wildcards_and_files_ext.cpp.

Referenced by BOOST_AUTO_TEST_CASE(), and GRAPHICS_IMPORT_MGR::GetPluginByExt().

◆ formatWildcardExt()

KICOMMON_API wxString formatWildcardExt ( const wxString &  aWildcard)

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.
Parameters
aWildcardis the extension part of the wild card.
Returns
the build appropriate file dialog wildcard filter.

Definition at line 63 of file wildcards_and_files_ext.cpp.

Referenced by AddFileExtListToFilter(), AskLoadBoardFileName(), PANEL_SYM_LIB_TABLE::browseLibrariesHandler(), GRAPHICS_IMPORT_PLUGIN::GetWildcards(), FOOTPRINT_EDIT_FRAME::ImportFootprint(), SYMBOL_EDIT_FRAME::ImportSymbol(), and SCH_EDIT_FRAME::OnImportProject().