35#include <pcb_calculator_datafile_lexer.h>
40using namespace PCBCALC_DATA_T;
45 return PCB_CALCULATOR_DATAFILE_LEXER::TokenName( aTok );
68 datafile_parser.
Parse( datafile );
74 wxString msg = ioe.
What();
77 msg +=
_(
"Data file error.");
98 auto datafile = std::make_unique<PCB_CALCULATOR_DATAFILE>( &
m_RegulatorList );
104 int nestlevel = datafile->WriteHeader( &formatter );
106 datafile->Format( &formatter, nestlevel );
109 formatter.
Print( nestlevel,
")\n" );
129 "normal",
"3terminal"
136 aFormatter->
Print( nestlevel++,
"(datafile\n");
137 aFormatter->
Print( nestlevel++,
"(version 2)\n" );
138 aFormatter->
Print( nestlevel++,
"(date %s)\n",
140 aFormatter->
Print( nestlevel++,
"(tool %s)\n",
141 aFormatter->
Quotew(
Pgm().App().GetAppName() +
148 int aNestLevel )
const
175 aFormatter->
Print( aNestLevel,
")\n" );
178 aFormatter->
Print( --aNestLevel,
")\n" );
184 aParser->
Parse(
this );
189 PCB_CALCULATOR_DATAFILE_LEXER( aReader )
195 const wxString& aSource ) :
196 PCB_CALCULATOR_DATAFILE_LEXER( aLine, aSource )
205 while( ( token = NextTok() ) != T_EOF)
207 if( token == T_LEFT )
211 if( token == T_regulators )
225 double vrefmin, vreftyp, vrefmax = 0.0;
226 double iadjtyp, iadjmax = 0.0;
228 auto parseToken = [&]()
233 if( token != T_NUMBER )
234 Expecting( T_NUMBER );
236 sscanf( CurText(),
"%lf", &val );
243 while( ( token = NextTok() ) != T_RIGHT )
248 if( token == T_LEFT )
251 if( token == T_regulator )
264 while( ( token = NextTok() ) != T_RIGHT )
269 if( token == T_LEFT )
276 vreftyp = parseToken();
281 case T_reg_vref_min: vrefmin = parseToken();
break;
282 case T_reg_vref_typ: vreftyp = parseToken();
break;
283 case T_reg_vref_max: vrefmax = parseToken();
break;
287 iadjtyp = parseToken();
291 case T_reg_iadj_typ: iadjtyp = parseToken();
break;
292 case T_reg_iadj_max: iadjmax = parseToken();
break;
299 else if( strcasecmp( CurText(),
regtype_str[1] ) == 0 )
302 Unexpected( CurText() );
308 Unexpected( CurText() );
313 if( !
name.IsEmpty() )
316 type, iadjtyp, iadjmax );
wxString GetBuildVersion()
Get the full KiCad version string.
A LINE_READER that reads from an open file.
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
virtual const wxString What() const
A composite of Problem() and Where()
An abstract class from which implementation specific LINE_READERs may be derived to read single lines...
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
wxChoice * m_choiceRegulatorSelector
bool m_RegulatorListChanged
REGULATOR_LIST m_RegulatorList
const wxString GetDataFilename()
void SelectLastSelectedRegulator()
If m_lastSelectedRegulatorName is empty, just calls RegulatorPageUpdate()
Parser for PCB_CALCULATOR_DATAFILE.
PCB_CALCULATOR_DATAFILE_PARSER(LINE_READER *aReader)
void Parse(PCB_CALCULATOR_DATAFILE *aDataList)
void ParseRegulatorDescr(PCB_CALCULATOR_DATAFILE *aDataList)
PCB_CALCULATOR_DATAFILE handles data to calculate regulators parameters.
void Parse(PCB_CALCULATOR_DATAFILE_PARSER *aParser)
void Format(OUTPUTFORMATTER *aFormatter, int aNestLevel) const
int WriteHeader(OUTPUTFORMATTER *aFormatter) const
PCB_CALCULATOR_DATAFILE(REGULATOR_LIST *aList)
wxArrayString GetRegList() const
void Add(REGULATOR_DATA *aItem)
std::vector< REGULATOR_DATA * > m_List
Contains structures for storage of regulator data.
static const char * regtype_str[]
static const char * getTokenName(T aTok)
static const char * getTokenName(T aTok)
This file contains miscellaneous commonly used macros and functions.
PGM_BASE & Pgm()
The global Program "get" accessor.
wxString From_UTF8(const char *cstring)
wxString GetISO8601CurrentDateTime()