KiCad PCB EDA Suite
Loading...
Searching...
No Matches
job_import_utils.cpp File Reference
#include <jobs/job_import_utils.h>
#include <reporter.h>
#include <string_utils.h>
#include <wx/file.h>
#include <wx/ffile.h>
#include <wx/filename.h>
#include <wx/intl.h>

Go to the source code of this file.

Functions

bool ParseImportReportFormat (const wxString &aText, IMPORT_REPORT_FORMAT &aFormat)
 Parse the user-facing report format name ("none", "json" or "text") into its enum.
 
wxString DefaultImportOutputPath (const wxString &aInputFile, const wxString &aKiCadExt)
 Build the default output path for an import by swapping the input file's extension for the given KiCad extension, keeping it in the input file's directory.
 
bool LoadLayerMapFile (const wxString &aFile, std::map< wxString, wxString > &aMap, wxString &aError)
 Load an explicit layer-mapping file into aMap.
 
void WriteImportReport (REPORTER *aReporter, IMPORT_REPORT_FORMAT aFormat, const wxString &aReportFile, const IMPORT_REPORT_DATA &aData)
 Emit an import report in the requested format to aReportFile, or to aReporter (at INFO severity) when no file is given.
 

Function Documentation

◆ DefaultImportOutputPath()

wxString DefaultImportOutputPath ( const wxString & aInputFile,
const wxString & aKiCadExt )

Build the default output path for an import by swapping the input file's extension for the given KiCad extension, keeping it in the input file's directory.

Definition at line 44 of file job_import_utils.cpp.

Referenced by EESCHEMA_JOBS_HANDLER::JobImport(), and PCBNEW_JOBS_HANDLER::JobImport().

◆ LoadLayerMapFile()

bool LoadLayerMapFile ( const wxString & aFile,
std::map< wxString, wxString > & aMap,
wxString & aError )

Load an explicit layer-mapping file into aMap.

The file is a flat JSON object whose keys are source (foreign) layer names and whose values are KiCad layer names, e.g.

{ "Top": "F.Cu", "Bottom": "B.Cu" }
Returns
false if the file cannot be read or does not parse as an object of string-to-string pairs, leaving aMap untouched and a human-readable reason in aError.

Definition at line 53 of file job_import_utils.cpp.

References _, and From_UTF8().

Referenced by CLI::IMPORT_COMMAND::doPerform(), and CLI::PCB_IMPORT_COMMAND::doPerform().

◆ ParseImportReportFormat()

bool ParseImportReportFormat ( const wxString & aText,
IMPORT_REPORT_FORMAT & aFormat )

Parse the user-facing report format name ("none", "json" or "text") into its enum.

Returns
false if the name is not recognized, leaving aFormat untouched.

Definition at line 29 of file job_import_utils.cpp.

References JSON, NONE, and TEXT.

Referenced by CLI::PCB_IMPORT_COMMAND::doPerform(), and CLI::SCH_IMPORT_COMMAND::doPerform().

◆ WriteImportReport()

void WriteImportReport ( REPORTER * aReporter,
IMPORT_REPORT_FORMAT aFormat,
const wxString & aReportFile,
const IMPORT_REPORT_DATA & aData )

Emit an import report in the requested format to aReportFile, or to aReporter (at INFO severity) when no file is given.

A NONE format is a no-op.

Definition at line 110 of file job_import_utils.cpp.

References _, JSON, NONE, output, REPORTER::Report(), RPT_SEVERITY_ERROR, and RPT_SEVERITY_INFO.

Referenced by EESCHEMA_JOBS_HANDLER::JobImport(), and PCBNEW_JOBS_HANDLER::JobImport().