KiCad PCB EDA Suite
X2_ATTRIBUTE Class Reference

class X2_ATTRIBUTE The attribute value consists of a number of substrings separated by a comma More...

#include <class_X2_gerber_attributes.h>

Inheritance diagram for X2_ATTRIBUTE:
X2_ATTRIBUTE_FILEFUNCTION

Public Member Functions

 X2_ATTRIBUTE ()
 
 ~X2_ATTRIBUTE ()
 
wxArrayString & GetPrms ()
 
const wxString & GetPrm (int aIdx)
 
const wxString & GetAttribute ()
 
int GetPrmCount ()
 
bool ParseAttribCmd (FILE *aFile, char *aBuffer, int aBuffSize, char *&aText, int &aLineNum)
 parse a TF command terminated with a % and fill m_Prms by the parameters found. More...
 
void DbgListPrms ()
 Debug function: pring using wxLogMessage le list of parameters. More...
 
bool IsFileFunction ()
 return true if the attribute is .FileFunction More...
 
bool IsFileMD5 ()
 return true if the attribute is .MD5 More...
 
bool IsFilePart ()
 return true if the attribute is .Part More...
 

Protected Attributes

wxArrayString m_Prms
 the list of parameters (after TF) in gbr file the first one is the attribute name, if starting by '. More...
 

Detailed Description

class X2_ATTRIBUTE The attribute value consists of a number of substrings separated by a comma

Definition at line 54 of file class_X2_gerber_attributes.h.

Constructor & Destructor Documentation

X2_ATTRIBUTE::X2_ATTRIBUTE ( )

Definition at line 52 of file class_X2_gerber_attributes.cpp.

53 {
54 }
X2_ATTRIBUTE::~X2_ATTRIBUTE ( )

Definition at line 56 of file class_X2_gerber_attributes.cpp.

57 {
58 }

Member Function Documentation

void X2_ATTRIBUTE::DbgListPrms ( )

Debug function: pring using wxLogMessage le list of parameters.

Definition at line 84 of file class_X2_gerber_attributes.cpp.

References GetPrmCount(), and m_Prms.

85 {
86  wxLogMessage( wxT("prms count %d"), GetPrmCount() );
87 
88  for( int ii = 0; ii < GetPrmCount(); ii++ )
89  wxLogMessage( m_Prms.Item( ii ) );
90 }
wxArrayString m_Prms
the list of parameters (after TF) in gbr file the first one is the attribute name, if starting by '.
const wxString & X2_ATTRIBUTE::GetAttribute ( )
Returns
the attribute name (for instance .FileFunction) which is given by TF command (i.e. the first parameter read).

Definition at line 63 of file class_X2_gerber_attributes.cpp.

References m_Prms.

Referenced by GERBER_FILE_IMAGE::ExecuteRS274XCommand(), IsFileFunction(), IsFileMD5(), and IsFilePart().

64 {
65  return m_Prms.Item( 0 );
66 }
wxArrayString m_Prms
the list of parameters (after TF) in gbr file the first one is the attribute name, if starting by '.
const wxString & X2_ATTRIBUTE::GetPrm ( int  aIdx)
Returns
a parameter read in TF command.
Parameters
aIdx= the index of the parameter aIdx = 0 is the parameter read after the TF function (the same as GetAttribute())

Definition at line 73 of file class_X2_gerber_attributes.cpp.

References dummy(), GetPrmCount(), and m_Prms.

Referenced by GERBER_FILE_IMAGE::ExecuteRS274XCommand(), and GERBER_FILE_IMAGE::RemoveAttribute().

74 {
75  static const wxString dummy;
76 
77  if( GetPrmCount() > aIdx && aIdx >= 0 )
78  return m_Prms.Item( aIdx );
79 
80  return dummy;
81 }
static LIB_PART * dummy()
Used when a LIB_PART is not found in library to draw a dummy shape This component is a 400 mils squar...
wxArrayString m_Prms
the list of parameters (after TF) in gbr file the first one is the attribute name, if starting by '.
int X2_ATTRIBUTE::GetPrmCount ( )
inline
Returns
the number of parameters read in TF (or similar like TA TO ...) command.

Definition at line 88 of file class_X2_gerber_attributes.h.

Referenced by DbgListPrms(), GERBER_FILE_IMAGE::ExecuteRS274XCommand(), GetPrm(), and X2_ATTRIBUTE_FILEFUNCTION::X2_ATTRIBUTE_FILEFUNCTION().

88 { return int( m_Prms.GetCount() ); }
wxArrayString m_Prms
the list of parameters (after TF) in gbr file the first one is the attribute name, if starting by '.
wxArrayString& X2_ATTRIBUTE::GetPrms ( )
inline
Returns
the parameters list read in TF command.

Definition at line 68 of file class_X2_gerber_attributes.h.

References m_Prms.

Referenced by X2_ATTRIBUTE_FILEFUNCTION::X2_ATTRIBUTE_FILEFUNCTION().

68 { return m_Prms; }
wxArrayString m_Prms
the list of parameters (after TF) in gbr file the first one is the attribute name, if starting by '.
bool X2_ATTRIBUTE::IsFileFunction ( )
inline

return true if the attribute is .FileFunction

Definition at line 112 of file class_X2_gerber_attributes.h.

References GetAttribute().

Referenced by GERBER_FILE_IMAGE::Execute_G_Command(), and GERBER_FILE_IMAGE::ExecuteRS274XCommand().

113  {
114  return GetAttribute().IsSameAs( wxT(".FileFunction"), false );
115  }
const wxString & GetAttribute()
bool X2_ATTRIBUTE::IsFileMD5 ( )
inline

return true if the attribute is .MD5

Definition at line 120 of file class_X2_gerber_attributes.h.

References GetAttribute().

Referenced by GERBER_FILE_IMAGE::ExecuteRS274XCommand().

121  {
122  return GetAttribute().IsSameAs( wxT(".MD5"), false );
123  }
const wxString & GetAttribute()
bool X2_ATTRIBUTE::IsFilePart ( )
inline

return true if the attribute is .Part

Definition at line 128 of file class_X2_gerber_attributes.h.

References GetAttribute().

Referenced by GERBER_FILE_IMAGE::ExecuteRS274XCommand().

129  {
130  return GetAttribute().IsSameAs( wxT(".Part"), false );
131  }
const wxString & GetAttribute()
bool X2_ATTRIBUTE::ParseAttribCmd ( FILE *  aFile,
char *  aBuffer,
int  aBuffSize,
char *&  aText,
int &  aLineNum 
)

parse a TF command terminated with a % and fill m_Prms by the parameters found.

Parameters
aFile= a FILE* ptr to the current Gerber file.
aBuffer= the buffer containing current Gerber data (can be null)
aBuffSize= the size of the buffer
aText= a pointer to the first char to read from Gerber data stored in aBuffer After parsing, text points the last char of the command line ('') (X2 mode) or the end of line if the line does not contain '' or aBuffer == NULL (X1 mode)
aLineNum= a point to the current line number of aFile
Returns
true if no error.

Definition at line 92 of file class_X2_gerber_attributes.cpp.

References m_Prms.

Referenced by GERBER_FILE_IMAGE::Execute_G_Command(), GERBER_FILE_IMAGE::ExecuteRS274XCommand(), and EXCELLON_IMAGE::LoadFile().

94 {
95  // parse a TF command and fill m_Prms by the parameters found.
96  // the "%TF" (start of command) is already read by the caller
97 
98  bool ok = true;
99  wxString data;
100 
101  for( ; ; )
102  {
103  while( *aText )
104  {
105  switch( *aText )
106  {
107  case '%': // end of command
108  return ok; // success completion
109 
110  case ' ':
111  case '\r':
112  case '\n':
113  aText++;
114  break;
115 
116  case '*': // End of block
117  m_Prms.Add( data );
118  data.Empty();
119  aText++;
120  break;
121 
122  case ',': // End of parameter (separator)
123  aText++;
124  m_Prms.Add( data );
125  data.Empty();
126  break;
127 
128  default:
129  data.Append( *aText );
130  aText++;
131  break;
132  }
133  }
134 
135  // end of current line, read another one.
136  if( aBuffer )
137  {
138  if( fgets( aBuffer, aBuffSize, aFile ) == NULL )
139  {
140  // end of file
141  ok = false;
142  break;
143  }
144 
145  aLineNum++;
146  aText = aBuffer;
147  }
148  else
149  return ok;
150  }
151 
152  return ok;
153 }
wxArrayString m_Prms
the list of parameters (after TF) in gbr file the first one is the attribute name, if starting by '.

Member Data Documentation


The documentation for this class was generated from the following files: