KiCad PCB EDA Suite
PCB_CALCULATOR_DATAFILE_PARSER Class Reference

PCB_CALCULATOR_DATAFILE_PARSER is the parser class for PCB_CALCULATOR_DATAFILE. More...

#include <datafile_read_write.h>

Inheritance diagram for PCB_CALCULATOR_DATAFILE_PARSER:

Public Member Functions

 PCB_CALCULATOR_DATAFILE_PARSER (LINE_READER *aReader)
 
 PCB_CALCULATOR_DATAFILE_PARSER (char *aLine, const wxString &aSource)
 
LINE_READERGetReader ()
 
void Parse (PCB_CALCULATOR_DATAFILE *aDataList)
 
void ParseRegulatorDescr (PCB_CALCULATOR_DATAFILE *aDataList)
 

Detailed Description

PCB_CALCULATOR_DATAFILE_PARSER is the parser class for PCB_CALCULATOR_DATAFILE.

Definition at line 51 of file datafile_read_write.h.

Constructor & Destructor Documentation

◆ PCB_CALCULATOR_DATAFILE_PARSER() [1/2]

PCB_CALCULATOR_DATAFILE_PARSER::PCB_CALCULATOR_DATAFILE_PARSER ( LINE_READER aReader)

Definition at line 170 of file datafile_read_write.cpp.

170  :
171  PCB_CALCULATOR_DATAFILE_LEXER( aReader )
172 {
173 }

◆ PCB_CALCULATOR_DATAFILE_PARSER() [2/2]

PCB_CALCULATOR_DATAFILE_PARSER::PCB_CALCULATOR_DATAFILE_PARSER ( char *  aLine,
const wxString &  aSource 
)

Definition at line 176 of file datafile_read_write.cpp.

176  :
177  PCB_CALCULATOR_DATAFILE_LEXER( aLine, aSource )
178 {
179 }

Member Function Documentation

◆ GetReader()

LINE_READER* PCB_CALCULATOR_DATAFILE_PARSER::GetReader ( )
inline

Definition at line 56 of file datafile_read_write.h.

56 { return reader; };

◆ Parse()

void PCB_CALCULATOR_DATAFILE_PARSER::Parse ( PCB_CALCULATOR_DATAFILE aDataList)

Definition at line 182 of file datafile_read_write.cpp.

183 {
184  T token;
185  while( ( token = NextTok() ) != T_EOF)
186  {
187  if( token == T_LEFT )
188  {
189  token = NextTok();
190 
191  if( token == T_regulators )
192  {
193  ParseRegulatorDescr( aDataList );
194  continue;
195  }
196  }
197  }
198 }
void ParseRegulatorDescr(PCB_CALCULATOR_DATAFILE *aDataList)

References ParseRegulatorDescr().

Referenced by PCB_CALCULATOR_DATAFILE::Parse(), and PCB_CALCULATOR_FRAME::ReadDataFile().

◆ ParseRegulatorDescr()

void PCB_CALCULATOR_DATAFILE_PARSER::ParseRegulatorDescr ( PCB_CALCULATOR_DATAFILE aDataList)

Definition at line 200 of file datafile_read_write.cpp.

201 {
202  T token;
203  wxString name;
204  double vref, iadj;
205  int type;
206 
207  while( ( token = NextTok() ) != T_RIGHT )
208  {
209  if( token == T_EOF)
210  Unexpected( T_EOF );
211 
212  if( token == T_LEFT )
213  token = NextTok();
214 
215  if( token == T_regulator )
216  {
217  type = 0;
218  vref = 0.0;
219 
220  // Read name
221  token = NextTok();
222  name = FROM_UTF8( CurText() );
223 
224  while( ( token = NextTok() ) != T_RIGHT )
225  {
226  if( token == T_EOF)
227  Unexpected( T_EOF );
228 
229  if( token == T_LEFT )
230  token = NextTok();
231 
232  switch( token )
233  {
234  case T_reg_vref: // the voltage reference value
235  token = NextTok();
236  if( token != T_NUMBER )
237  Expecting( T_NUMBER );
238  sscanf( CurText(), "%lf" , &vref);
239  NeedRIGHT();
240  break;
241 
242  case T_reg_iadj: // the Iadj reference value
243  token = NextTok();
244  if( token != T_NUMBER )
245  Expecting( T_NUMBER );
246  sscanf( CurText(), "%lf" , &iadj);
247  NeedRIGHT();
248  break;
249 
250  case T_reg_type: // type: normal or 3 terminal reg
251  token = NextTok();
252  if( strcasecmp( CurText(), regtype_str[0] ) == 0 )
253  type = 0;
254  else if( strcasecmp( CurText(), regtype_str[1] ) == 0 )
255  type = 1;
256  else
257  Unexpected( CurText() );
258  NeedRIGHT();
259  break;
260 
261  default:
262  Unexpected( CurText() );
263  break;
264  }
265  }
266 
267  if( ! name.IsEmpty() )
268  {
269  if( type != 1 )
270  iadj = 0.0;
271  REGULATOR_DATA * new_item = new REGULATOR_DATA(name, vref, type, iadj );
272  aDataList->m_list->Add( new_item );
273  }
274  }
275  }
276 }
static wxString FROM_UTF8(const char *cstring)
Convert a UTF8 encoded C string to a wxString for all wxWidgets build modes.
Definition: macros.h:110
void Add(REGULATOR_DATA *aItem)
static const char * regtype_str[]
const char * name
Definition: DXF_plotter.cpp:59

References REGULATOR_LIST::Add(), FROM_UTF8(), PCB_CALCULATOR_DATAFILE::m_list, name, and regtype_str.

Referenced by Parse().


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