KiCad PCB EDA Suite
File Extension Definitions

Macros

#define PcbFileExtension   KiCadPcbFileExtension
 

Functions

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...
 
wxString AddFileExtListToFilter (const std::vector< std::string > &aExts)
 Build the wildcard extension file dialog wildcard filter to add to the base message dialog. More...
 
wxString formatWildcardExt (const wxString &aWildcard)
 Format wildcard extension to support case sensitive file dialogs. More...
 
bool IsGerberFileExtension (const wxString &ext)
 

Variables

const std::string BackupFileSuffix
 
const std::string SchematicSymbolFileExtension
 
const std::string LegacySymbolLibFileExtension
 
const std::string LegacySymbolDocumentFileExtension
 
const std::string SchematicBackupFileExtension
 
const std::string VrmlFileExtension
 
const std::string ProjectFileExtension
 
const std::string LegacyProjectFileExtension
 
const std::string ProjectLocalSettingsFileExtension
 
const std::string LegacySchematicFileExtension
 
const std::string EagleSchematicFileExtension
 
const std::string CadstarSchematicFileExtension
 
const std::string KiCadSchematicFileExtension
 
const std::string SpiceFileExtension
 
const std::string CadstarNetlistFileExtension
 
const std::string OrCadPcb2NetlistFileExtension
 
const std::string NetlistFileExtension
 
const std::string GerberFileExtension
 
const std::string GerberJobFileExtension
 
const std::string HtmlFileExtension
 
const std::string EquFileExtension
 
const std::string HotkeyFileExtension
 
const std::string DatabaseLibraryFileExtension
 
const std::string ArchiveFileExtension
 
const std::string LegacyPcbFileExtension
 
const std::string EaglePcbFileExtension
 
const std::string CadstarPcbFileExtension
 
const std::string KiCadPcbFileExtension
 
const std::string KiCadSymbolLibFileExtension
 
const std::string DrawingSheetFileExtension
 
const std::string DesignRulesFileExtension
 
const std::string LegacyFootprintLibPathExtension
 
const std::string PdfFileExtension
 
const std::string MacrosFileExtension
 
const std::string FootprintAssignmentFileExtension
 
const std::string DrillFileExtension
 
const std::string SVGFileExtension
 
const std::string ReportFileExtension
 
const std::string FootprintPlaceFileExtension
 
const std::string KiCadFootprintFileExtension
 
const std::string KiCadFootprintLibPathExtension
 
const std::string AltiumFootprintLibPathExtension
 
const std::string GedaPcbFootprintLibFileExtension
 
const std::string EagleFootprintLibPathExtension
 
const std::string SpecctraDsnFileExtension
 
const std::string SpecctraSessionFileExtension
 
const std::string IpcD356FileExtension
 
const std::string WorkbookFileExtension
 
const std::string PngFileExtension
 
const std::string JpegFileExtension
 
const std::string TextFileExtension
 
const std::string MarkdownFileExtension
 
const std::string CsvFileExtension
 
const wxString GerberFileExtensionsRegex
 

Detailed Description

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.

Macro Definition Documentation

◆ PcbFileExtension

#define PcbFileExtension   KiCadPcbFileExtension

Definition at line 143 of file wildcards_and_files_ext.h.

Function Documentation

◆ AddFileExtListToFilter()

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.

86{
87 if( aExts.size() == 0 )
88 {
89 // The "all files" wildcard is different on different systems
90 wxString filter;
91 filter << " (" << wxFileSelectorDefaultWildcardStr << ")|"
92 << wxFileSelectorDefaultWildcardStr;
93 return filter;
94 }
95
96 wxString files_filter = " (";
97
98 // Add extensions to the info message:
99 for( const std::string& ext : aExts )
100 {
101 if( files_filter.length() > 2 )
102 files_filter << "; ";
103
104 files_filter << "*." << ext;
105 }
106
107 files_filter << ")|*.";
108
109 // Add extensions to the filter list, using a formatted string (GTK specific):
110 bool first = true;
111
112 for( const std::string& ext : aExts )
113 {
114 if( !first )
115 files_filter << ";*.";
116
117 first = false;
118
119 files_filter << formatWildcardExt( ext );
120 }
121
122 return files_filter;
123}
wxString formatWildcardExt(const wxString &aWildcard)
Format wildcard extension to support case sensitive file dialogs.

References filter, and formatWildcardExt().

Referenced by AllFilesWildcard(), AllProjectFilesWildcard(), AllSchematicFilesWildcard(), AllSymbolLibFilesWildcard(), AltiumCircuitMakerPcbFileWildcard(), AltiumCircuitStudioPcbFileWildcard(), AltiumDesignerPcbFileWildcard(), AltiumFootprintLibPathWildcard(), AltiumSchematicFileWildcard(), AskLoadBoardFileName(), BOOST_AUTO_TEST_CASE(), CadstarArchiveFilesWildcard(), CadstarNetlistFileWildcard(), CadstarPcbArchiveFileWildcard(), CadstarSchematicArchiveFileWildcard(), CsvFileWildcard(), DatabaseLibFileWildcard(), DIALOG_EXPORT_STEP::DIALOG_EXPORT_STEP(), DrawingSheetFileWildcard(), DrillFileWildcard(), DxfFileWildcard(), EagleFilesWildcard(), EagleFootprintLibPathWildcard(), EaglePcbFileWildcard(), EagleSchematicFileWildcard(), EquFileWildcard(), ErcFileWildcard(), BOARD_EDITOR_CONTROL::ExportNetlist(), FabmasterPcbFileWildcard(), FootprintAssignmentFileWildcard(), FootprintPlaceFileWildcard(), GedaPcbFootprintLibFileWildcard(), GencadFileWildcard(), GerberJobFileWildcard(), HotkeyFileWildcard(), HtmlFileWildcard(), IDF3DFileWildcard(), FIELDS_GRID_TABLE< T >::initGrid(), IpcD356FileWildcard(), JpegFileWildcard(), KiCadFootprintLibFileWildcard(), KiCadFootprintLibPathWildcard(), KiCadSchematicFileWildcard(), KiCadSymbolLibFileWildcard(), LegacyFootprintLibPathWildcard(), LegacyPcbFileWildcard(), LegacyProjectFileWildcard(), LegacySchematicFileWildcard(), LegacySymbolLibFileWildcard(), GERBVIEW_FRAME::LoadGerberFiles(), ModLegacyExportFileWildcard(), NetlistFileWildcard(), DIALOG_IMPORT_GFX::onBrowseFiles(), DIALOG_NET_INSPECTOR::onReport(), OrCadPcb2NetlistFileWildcard(), PCadPcbFileWildcard(), PcbFileWildcard(), PdfFileWildcard(), PngFileWildcard(), ProjectFileWildcard(), PSFileWildcard(), ReportFileWildcard(), SchematicSymbolFileWildcard(), Shapes3DFileWildcard(), SpecctraDsnFileWildcard(), SpecctraSessionFileWildcard(), SpiceLibraryFileWildcard(), SpiceNetlistFileWildcard(), SVGFileWildcard(), TextFileWildcard(), WorkbookFileWildcard(), and ZipFileWildcard().

◆ compareFileExtensions()

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.

39{
40 // Form the regular expression string by placing all possible extensions into it as alternatives
41 std::string regexString = "(";
42 bool first = true;
43
44 for( const std::string& ext : aReference )
45 {
46 // The | separate goes between the extensions
47 if( !first )
48 regexString += "|";
49 else
50 first = false;
51
52 regexString += ext;
53 }
54
55 regexString += ")";
56
57 // Create the regex and see if it matches
58 std::regex extRegex( regexString, aCaseSensitive ? std::regex::ECMAScript : std::regex::icase );
59 return std::regex_match( aExtension, extRegex );
60}

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

◆ formatWildcardExt()

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.

64{
65 wxString wc;
66#if defined( __WXGTK__ )
67
68 for( const auto& ch : aWildcard )
69 {
70 if( wxIsalpha( ch ) )
71 wc += wxString::Format( "[%c%c]", wxTolower( ch ), wxToupper( ch ) );
72 else
73 wc += ch;
74 }
75
76 return wc;
77#else
78 wc = aWildcard;
79
80 return wc;
81#endif
82}
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200

References Format().

Referenced by AddFileExtListToFilter(), AskLoadBoardFileName(), GRAPHICS_IMPORT_PLUGIN::GetWildcards(), and SCH_EDIT_FRAME::OnImportProject().

◆ IsGerberFileExtension()

bool IsGerberFileExtension ( const wxString &  ext)

Definition at line 190 of file wildcards_and_files_ext.cpp.

191{
192 static wxRegEx gerberRE( GerberFileExtensionsRegex, wxRE_ICASE );
193
194 return gerberRE.Matches( ext );
195}
const wxString GerberFileExtensionsRegex("(gbr|gko|pho|(g[tb][alops])|(gm?\\d\\d*)|(gp[tb]))")

References GerberFileExtensionsRegex().

Referenced by KICAD_MANAGER_FRAME::DoWithAcceptedFiles(), EDA_BASE_FRAME::OnDropFiles(), SAVE_AS_TRAVERSER::OnFile(), and GERBV::IFACE::SaveFileAs().

Variable Documentation

◆ AltiumFootprintLibPathExtension

const std::string AltiumFootprintLibPathExtension
extern

◆ ArchiveFileExtension

◆ BackupFileSuffix

◆ CadstarNetlistFileExtension

const std::string CadstarNetlistFileExtension
extern

◆ CadstarPcbFileExtension

const std::string CadstarPcbFileExtension
extern

◆ CadstarSchematicFileExtension

const std::string CadstarSchematicFileExtension
extern

◆ CsvFileExtension

◆ DatabaseLibraryFileExtension

◆ DesignRulesFileExtension

◆ DrawingSheetFileExtension

◆ DrillFileExtension

◆ EagleFootprintLibPathExtension

const std::string EagleFootprintLibPathExtension
extern

◆ EaglePcbFileExtension

const std::string EaglePcbFileExtension
extern

◆ EagleSchematicFileExtension

const std::string EagleSchematicFileExtension
extern

◆ EquFileExtension

const std::string EquFileExtension
extern

◆ FootprintAssignmentFileExtension

const std::string FootprintAssignmentFileExtension
extern

◆ FootprintPlaceFileExtension

const std::string FootprintPlaceFileExtension
extern

◆ GedaPcbFootprintLibFileExtension

const std::string GedaPcbFootprintLibFileExtension
extern

◆ GerberFileExtension

◆ GerberFileExtensionsRegex

const wxString GerberFileExtensionsRegex
extern

◆ GerberJobFileExtension

◆ HotkeyFileExtension

const std::string HotkeyFileExtension
extern

◆ HtmlFileExtension

const std::string HtmlFileExtension
extern

◆ IpcD356FileExtension

const std::string IpcD356FileExtension
extern

◆ JpegFileExtension

const std::string JpegFileExtension
extern

◆ KiCadFootprintFileExtension

◆ KiCadFootprintLibPathExtension

◆ KiCadPcbFileExtension

◆ KiCadSchematicFileExtension

◆ KiCadSymbolLibFileExtension

◆ LegacyFootprintLibPathExtension

const std::string LegacyFootprintLibPathExtension
extern

◆ LegacyPcbFileExtension

◆ LegacyProjectFileExtension

◆ LegacySchematicFileExtension

◆ LegacySymbolDocumentFileExtension

◆ LegacySymbolLibFileExtension

◆ MacrosFileExtension

const std::string MacrosFileExtension
extern

◆ MarkdownFileExtension

const std::string MarkdownFileExtension
extern

◆ NetlistFileExtension

◆ OrCadPcb2NetlistFileExtension

const std::string OrCadPcb2NetlistFileExtension
extern

◆ PdfFileExtension

const std::string PdfFileExtension
extern

◆ PngFileExtension

const std::string PngFileExtension
extern

◆ ProjectFileExtension

◆ ProjectLocalSettingsFileExtension

◆ ReportFileExtension

◆ SchematicBackupFileExtension

const std::string SchematicBackupFileExtension
extern

◆ SchematicSymbolFileExtension

const std::string SchematicSymbolFileExtension
extern

◆ SpecctraDsnFileExtension

const std::string SpecctraDsnFileExtension
extern

◆ SpecctraSessionFileExtension

const std::string SpecctraSessionFileExtension
extern

◆ SpiceFileExtension

◆ SVGFileExtension

◆ TextFileExtension

const std::string TextFileExtension
extern

◆ VrmlFileExtension

const std::string VrmlFileExtension
extern

◆ WorkbookFileExtension

const std::string WorkbookFileExtension
extern