26 #include <wx/msgdlg.h> 35 #include <pcb_calculator_datafile_lexer.h> 40 using namespace PCBCALC_DATA_T;
45 return PCB_CALCULATOR_DATAFILE_LEXER::TokenName( aTok );
51 FILE* file = wxFopen( GetDataFilename(), wxT(
"rt" ) );
67 datafile_parser.
Parse( datafile );
73 wxString msg = ioe.
What();
76 msg +=
_(
"Data file error.");
82 m_choiceRegulatorSelector->Clear();
83 m_choiceRegulatorSelector->Append( m_RegulatorList.GetRegList() );
84 SelectLastSelectedRegulator();
97 auto datafile = std::make_unique<PCB_CALCULATOR_DATAFILE>( &m_RegulatorList );
103 int nestlevel = datafile->WriteHeader( &formatter );
105 datafile->Format( &formatter, nestlevel );
108 formatter.
Print( nestlevel,
")\n" );
115 m_RegulatorListChanged =
false;
128 "normal",
"3terminal" 135 aFormatter->
Print( nestlevel++,
"(datafile\n");
136 aFormatter->
Print( nestlevel++,
"(version 1)\n" );
137 aFormatter->
Print( nestlevel++,
"(date %s)\n",
139 aFormatter->
Print( nestlevel++,
"(tool %s)\n",
140 aFormatter->
Quotew(
Pgm().App().GetAppName() +
147 int aNestLevel )
const 167 aFormatter->
Print( aNestLevel,
")\n" );
170 aFormatter->
Print( --aNestLevel,
")\n" );
176 aParser->
Parse(
this );
181 PCB_CALCULATOR_DATAFILE_LEXER( aReader )
187 const wxString& aSource ) :
188 PCB_CALCULATOR_DATAFILE_LEXER( aLine, aSource )
197 while( ( token = NextTok() ) != T_EOF)
199 if( token == T_LEFT )
203 if( token == T_regulators )
220 while( ( token = NextTok() ) != T_RIGHT )
225 if( token == T_LEFT )
228 if( token == T_regulator )
237 while( ( token = NextTok() ) != T_RIGHT )
242 if( token == T_LEFT )
250 if( token != T_NUMBER )
251 Expecting( T_NUMBER );
253 sscanf( CurText(),
"%lf" , &vref);
260 if( token != T_NUMBER )
261 Expecting( T_NUMBER );
263 sscanf( CurText(),
"%lf" , &iadj);
272 else if( strcasecmp( CurText(),
regtype_str[1] ) == 0 )
275 Unexpected( CurText() );
281 Unexpected( CurText() );
286 if( !
name.IsEmpty() )
An abstract class from which implementation specific LINE_READERs may be derived to read single lines...
static wxString FROM_UTF8(const char *cstring)
Convert a UTF8 encoded C string to a wxString for all wxWidgets build modes.
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
PCB_CALCULATOR_DATAFILE(REGULATOR_LIST *aList)
void Parse(PCB_CALCULATOR_DATAFILE *aDataList)
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
int WriteHeader(OUTPUTFORMATTER *aFormatter) const
This file contains miscellaneous commonly used macros and functions.
A LINE_READER that reads from an open file.
virtual const wxString What() const
A composite of Problem() and Where()
wxString GetBuildVersion()
Get the full KiCad version string.
Parser for PCB_CALCULATOR_DATAFILE.
Contains structures for storage of regulator data.
void Add(REGULATOR_DATA *aItem)
static const char * getTokenName(T aTok)
static const char * regtype_str[]
PCB_CALCULATOR_DATAFILE_PARSER(LINE_READER *aReader)
void ParseRegulatorDescr(PCB_CALCULATOR_DATAFILE *aDataList)
PCB_CALCULATOR_DATAFILE handles data to calculate regulators parameters.
void Parse(PCB_CALCULATOR_DATAFILE_PARSER *aParser)
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
void Format(OUTPUTFORMATTER *aFormatter, int aNestLevel) const