2011-07-06 16:40:54 +00:00
|
|
|
/* Helper class to read/write footprints libraries
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _FOOTPRINT_LIBRARY_H_
|
|
|
|
#define _FOOTPRINT_LIBRARY_H_
|
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <filter_reader.h>
|
2011-07-06 16:40:54 +00:00
|
|
|
|
|
|
|
class FOOTPRINT_LIBRARY
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
wxArrayString m_List; // list of footprints, used to read/write INDEX section
|
|
|
|
wxString m_LibraryName; // the full library name
|
|
|
|
|
|
|
|
private:
|
2011-08-26 17:01:17 +00:00
|
|
|
FILTER_READER * m_reader; // FILTER_READER to read file. If NULL, use m_file
|
2011-07-06 16:40:54 +00:00
|
|
|
FILE * m_file; // footprint file to read/write.
|
2012-04-16 03:18:41 +00:00
|
|
|
int m_LineNum; // the line count
|
2011-07-06 16:40:54 +00:00
|
|
|
|
|
|
|
public:
|
2012-04-16 03:18:41 +00:00
|
|
|
|
2011-07-06 16:40:54 +00:00
|
|
|
/**
|
2012-04-16 03:18:41 +00:00
|
|
|
* Constructor FOOTPRINT_LIBRARY
|
2011-07-06 16:40:54 +00:00
|
|
|
* @param aFile = a FILE * pointer used for write operations,
|
|
|
|
* and read operations when aReader = NULL
|
|
|
|
* @param aReader = a FILTER_READER pointer used for read operations
|
2011-08-26 17:01:17 +00:00
|
|
|
* If NULL, a direct aFile read is used
|
2011-07-06 16:40:54 +00:00
|
|
|
*/
|
|
|
|
FOOTPRINT_LIBRARY( FILE * aFile, FILTER_READER * aReader = NULL );
|
|
|
|
|
2012-04-16 03:18:41 +00:00
|
|
|
FOOTPRINT_LIBRARY() :
|
|
|
|
m_reader( 0 ),
|
|
|
|
m_file( 0 ),
|
|
|
|
m_LineNum( 0 )
|
|
|
|
{}
|
2011-07-06 16:40:54 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* function IsLibrary
|
|
|
|
* Read the library file Header
|
|
|
|
* return > 0 if this file is a footprint lib
|
|
|
|
* (currentlu return 1 but could be a value > 1 for future file formats
|
|
|
|
*/
|
|
|
|
int IsLibrary( );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* function RebuildIndex
|
2011-08-26 17:01:17 +00:00
|
|
|
* Read the full library file and build the list of footprints found
|
2011-07-06 16:40:54 +00:00
|
|
|
* Do not use the $INDEX ... $EndINDEX section
|
|
|
|
*/
|
|
|
|
bool RebuildIndex();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* function ReadSectionIndex
|
|
|
|
* Read the $INDEX ... $EndINDEX section
|
|
|
|
* list of footprints is stored in m_List
|
|
|
|
*/
|
|
|
|
bool ReadSectionIndex();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function WriteHeader
|
|
|
|
* Write the library header
|
|
|
|
*/
|
|
|
|
bool WriteHeader();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function WriteSectionIndex
|
|
|
|
* Write the $INDEX ... $EndINDEX section.
|
|
|
|
* This section is filled by names in m_List
|
|
|
|
*/
|
|
|
|
bool WriteSectionIndex();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function WriteEndOfFile
|
|
|
|
* Write the last line section.
|
|
|
|
*/
|
|
|
|
bool WriteEndOfFile();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function FindInList
|
|
|
|
* Search for aName int m_List
|
|
|
|
* @return true if found
|
|
|
|
*/
|
|
|
|
bool FindInList( const wxString & aName );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function RemoveFromList
|
|
|
|
* Search for aName int m_List and remove it
|
|
|
|
* @return true if found and removed
|
|
|
|
*/
|
|
|
|
bool RemoveFromList( const wxString & aName );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function SortList
|
|
|
|
* Sort m_List in alphabetic order
|
|
|
|
*/
|
|
|
|
void SortList();
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|