KiCad PCB EDA Suite
dialog_exchange_modules.cpp File Reference
#include <fctsys.h>
#include <class_drawpanel.h>
#include <class_draw_panel_gal.h>
#include <confirm.h>
#include <kicad_string.h>
#include <wxPcbStruct.h>
#include <macros.h>
#include <board_commit.h>
#include <class_board.h>
#include <class_module.h>
#include <project.h>
#include <wx_html_report_panel.h>
#include <pcbnew.h>
#include <dialog_exchange_modules.h>
#include <wildcards_and_files_ext.h>
#include <kiway.h>

Go to the source code of this file.

Functions

static bool RecreateCmpFile (BOARD *aBrd, const wxString &aFullCmpFileName)
 

Function Documentation

bool RecreateCmpFile ( BOARD aBrd,
const wxString &  aFullCmpFileName 
)
static

Definition at line 452 of file dialog_exchange_modules.cpp.

References UTF8::c_str(), DateAndTime(), LIB_ID::Format(), MODULE::GetFPID(), MODULE::GetPath(), MODULE::GetReference(), EDA_ITEM::GetTimeStamp(), MODULE::GetValue(), BOARD::m_Modules, MODULE::Next(), and TO_UTF8.

Referenced by DIALOG_EXCHANGE_MODULE::RebuildCmpList(), and PCB_EDIT_FRAME::RecreateCmpFileFromBoard().

453 {
454  FILE* cmpFile;
455 
456  cmpFile = wxFopen( aFullCmpFileName, wxT( "wt" ) );
457 
458  if( cmpFile == NULL )
459  return false;
460 
461  fprintf( cmpFile, "Cmp-Mod V01 Created by PcbNew date = %s\n", TO_UTF8( DateAndTime() ) );
462 
463  MODULE* module = aBrd->m_Modules;
464  for( ; module != NULL; module = module->Next() )
465  {
466  fprintf( cmpFile, "\nBeginCmp\n" );
467  fprintf( cmpFile, "TimeStamp = %8.8lX\n", (unsigned long)module->GetTimeStamp() );
468  fprintf( cmpFile, "Path = %s\n", TO_UTF8( module->GetPath() ) );
469  fprintf( cmpFile, "Reference = %s;\n",
470  !module->GetReference().IsEmpty() ?
471  TO_UTF8( module->GetReference() ) : "[NoRef]" );
472  fprintf( cmpFile, "ValeurCmp = %s;\n",
473  !module->GetValue().IsEmpty() ?
474  TO_UTF8( module->GetValue() ) : "[NoVal]" );
475  fprintf( cmpFile, "IdModule = %s;\n", module->GetFPID().Format().c_str() );
476  fprintf( cmpFile, "EndCmp\n" );
477  }
478 
479  fprintf( cmpFile, "\nEndListe\n" );
480  fclose( cmpFile );
481 
482  return true;
483 }
MODULE * Next() const
Definition: class_module.h:100
const wxString & GetValue() const
Function GetValue.
Definition: class_module.h:447
const LIB_ID & GetFPID() const
Definition: class_module.h:164
#define TO_UTF8(wxstring)
Macro TO_UTF8 converts a wxString to a UTF8 encoded C string for all wxWidgets build modes...
Definition: macros.h:47
time_t GetTimeStamp() const
Definition: base_struct.h:218
const wxString & GetReference() const
Function GetReference.
Definition: class_module.h:419
DLIST< MODULE > m_Modules
Definition: class_board.h:245
const char * c_str() const
Definition: utf8.h:107
UTF8 Format() const
Function Format.
Definition: lib_id.cpp:263
const wxString & GetPath() const
Definition: class_module.h:173
wxString DateAndTime()
Function DateAndTime.
Definition: string.cpp:229