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)
 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 111 of file class_X2_gerber_attributes.h.

References GetAttribute().

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

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

return true if the attribute is .MD5

Definition at line 119 of file class_X2_gerber_attributes.h.

References GetAttribute().

Referenced by GERBER_FILE_IMAGE::ExecuteRS274XCommand().

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

return true if the attribute is .Part

Definition at line 127 of file class_X2_gerber_attributes.h.

References GetAttribute().

Referenced by GERBER_FILE_IMAGE::ExecuteRS274XCommand().

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

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)
Returns
true if no error.

Definition at line 98 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().

99 {
100  bool ok = true;
101  wxString data;
102 
103  for( ; ; )
104  {
105  while( *aText )
106  {
107  switch( *aText )
108  {
109  case '%': // end of command
110  return ok; // success completion
111 
112  case ' ':
113  case '\r':
114  case '\n':
115  aText++;
116  break;
117 
118  case '*': // End of block
119  m_Prms.Add( data );
120  data.Empty();
121  aText++;
122  break;
123 
124  case ',': // End of parameter
125  aText++;
126  m_Prms.Add( data );
127  data.Empty();
128  break;
129 
130  default:
131  data.Append( *aText );
132  aText++;
133  break;
134  }
135  }
136 
137  // end of current line, read another one.
138  if( aBuffer )
139  {
140  if( fgets( aBuffer, aBuffSize, aFile ) == NULL )
141  {
142  // end of file
143  ok = false;
144  break;
145  }
146 
147  aText = aBuffer;
148  }
149  else
150  return ok;
151  }
152 
153  return ok;
154 }
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: