KiCad PCB EDA Suite
export_footprint_associations.cpp File Reference
#include <fctsys.h>
#include <confirm.h>
#include <kicad_string.h>
#include <pcb_edit_frame.h>
#include <class_board.h>
#include <class_module.h>
#include <project.h>
#include <wildcards_and_files_ext.h>

Go to the source code of this file.

Functions

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

Function Documentation

bool RecreateCmpFile ( BOARD aBrd,
const wxString &  aFullCmpFileName 
)

Definition at line 34 of file export_footprint_associations.cpp.

References DateAndTime(), BOARD::m_Modules, MODULE::Next(), and TO_UTF8.

Referenced by PCB_EDIT_FRAME::RecreateCmpFileFromBoard().

35 {
36  FILE* cmpFile = wxFopen( aFullCmpFileName, wxT( "wt" ) );
37 
38  if( cmpFile == NULL )
39  return false;
40 
41  fprintf( cmpFile, "Cmp-Mod V01 Created by PcbNew date = %s\n", TO_UTF8( DateAndTime() ) );
42 
43  for( MODULE* module = aBrd->m_Modules; module != NULL; module = module->Next() )
44  {
45  fprintf( cmpFile, "\nBeginCmp\n" );
46  fprintf( cmpFile, "TimeStamp = %8.8lX\n", (unsigned long)module->GetTimeStamp() );
47  fprintf( cmpFile, "Path = %s\n", TO_UTF8( module->GetPath() ) );
48  fprintf( cmpFile, "Reference = %s;\n",
49  !module->GetReference().IsEmpty() ? TO_UTF8( module->GetReference() ) : "[NoRef]" );
50  fprintf( cmpFile, "ValeurCmp = %s;\n",
51  !module->GetValue().IsEmpty() ? TO_UTF8( module->GetValue() ) : "[NoVal]" );
52  fprintf( cmpFile, "IdModule = %s;\n", module->GetFPID().Format().c_str() );
53  fprintf( cmpFile, "EndCmp\n" );
54  }
55 
56  fprintf( cmpFile, "\nEndListe\n" );
57  fclose( cmpFile );
58 
59  return true;
60 }
MODULE * Next() const
Definition: class_module.h:123
#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
DLIST< MODULE > m_Modules
Definition: class_board.h:248
wxString DateAndTime()
Function DateAndTime.
Definition: string.cpp:306