KiCad PCB EDA Suite
PCB_CALCULATOR_DATAFILE_PARSER Class Reference

Parser 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

Parser for PCB_CALCULATOR_DATAFILE.

Definition at line 50 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 180 of file datafile_read_write.cpp.

180  :
181  PCB_CALCULATOR_DATAFILE_LEXER( aReader )
182 {
183 }

◆ PCB_CALCULATOR_DATAFILE_PARSER() [2/2]

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

Definition at line 186 of file datafile_read_write.cpp.

187  :
188  PCB_CALCULATOR_DATAFILE_LEXER( aLine, aSource )
189 {
190 }

Member Function Documentation

◆ GetReader()

LINE_READER* PCB_CALCULATOR_DATAFILE_PARSER::GetReader ( )
inline

Definition at line 55 of file datafile_read_write.h.

55 { return reader; };

◆ Parse()

void PCB_CALCULATOR_DATAFILE_PARSER::Parse ( PCB_CALCULATOR_DATAFILE aDataList)

Definition at line 193 of file datafile_read_write.cpp.

194 {
195  T token;
196 
197  while( ( token = NextTok() ) != T_EOF)
198  {
199  if( token == T_LEFT )
200  {
201  token = NextTok();
202 
203  if( token == T_regulators )
204  {
205  ParseRegulatorDescr( aDataList );
206  continue;
207  }
208  }
209  }
210 }
void ParseRegulatorDescr(PCB_CALCULATOR_DATAFILE *aDataList)

References ParseRegulatorDescr().

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

◆ ParseRegulatorDescr()

void PCB_CALCULATOR_DATAFILE_PARSER::ParseRegulatorDescr ( PCB_CALCULATOR_DATAFILE aDataList)

Definition at line 213 of file datafile_read_write.cpp.

214 {
215  T token;
216  wxString name;
217  double vref, iadj;
218  int type;
219 
220  while( ( token = NextTok() ) != T_RIGHT )
221  {
222  if( token == T_EOF)
223  Unexpected( T_EOF );
224 
225  if( token == T_LEFT )
226  token = NextTok();
227 
228  if( token == T_regulator )
229  {
230  type = 0;
231  vref = 0.0;
232 
233  // Read name
234  token = NextTok();
235  name = FROM_UTF8( CurText() );
236 
237  while( ( token = NextTok() ) != T_RIGHT )
238  {
239  if( token == T_EOF)
240  Unexpected( T_EOF );
241 
242  if( token == T_LEFT )
243  token = NextTok();
244 
245  switch( token )
246  {
247  case T_reg_vref: // the voltage reference value
248  token = NextTok();
249 
250  if( token != T_NUMBER )
251  Expecting( T_NUMBER );
252 
253  sscanf( CurText(), "%lf" , &vref);
254  NeedRIGHT();
255  break;
256 
257  case T_reg_iadj: // the Iadj reference value
258  token = NextTok();
259 
260  if( token != T_NUMBER )
261  Expecting( T_NUMBER );
262 
263  sscanf( CurText(), "%lf" , &iadj);
264  NeedRIGHT();
265  break;
266 
267  case T_reg_type: // type: normal or 3 terminal reg
268  token = NextTok();
269 
270  if( strcasecmp( CurText(), regtype_str[0] ) == 0 )
271  type = 0;
272  else if( strcasecmp( CurText(), regtype_str[1] ) == 0 )
273  type = 1;
274  else
275  Unexpected( CurText() );
276 
277  NeedRIGHT();
278  break;
279 
280  default:
281  Unexpected( CurText() );
282  break;
283  }
284  }
285 
286  if( ! name.IsEmpty() )
287  {
288  if( type != 1 )
289  iadj = 0.0;
290 
291  REGULATOR_DATA* new_item = new REGULATOR_DATA( name, vref, type, iadj );
292  aDataList->m_list->Add( new_item );
293  }
294  }
295  }
296 }
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:56

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: