32 #include <pcb_calculator_datafile_lexer.h> 37 using namespace PCBCALC_DATA_T;
42 return PCB_CALCULATOR_DATAFILE_LEXER::TokenName( aTok );
48 FILE* file = wxFopen( GetDataFilename(), wxT(
"rt" ) );
64 datafile_parser.
Parse( datafile );
70 wxString msg = ioe.
What();
73 msg +=
_(
"Data file error.");
89 auto datafile = std::make_unique<PCB_CALCULATOR_DATAFILE>( &m_RegulatorList );
95 int nestlevel = datafile->WriteHeader( &formatter );
97 datafile->Format( &formatter, nestlevel );
100 formatter.
Print( nestlevel,
")\n" );
107 m_RegulatorListChanged =
false;
119 "normal",
"3terminal" 125 aFormatter->
Print( nestlevel++,
"(datafile\n");
126 aFormatter->
Print( nestlevel++,
"(version 1)\n" );
127 aFormatter->
Print( nestlevel++,
"(date %s)\n",
129 aFormatter->
Print( nestlevel++,
"(tool %s)\n",
130 aFormatter->
Quotew(
Pgm().App().GetAppName() +
137 int aNestLevel )
const 141 for(
unsigned ii = 0; ii < m_list->m_List.size(); ii++ )
155 aFormatter->
Print( aNestLevel,
")\n" );
157 aFormatter->
Print( --aNestLevel,
")\n" );
163 aParser->
Parse(
this );
171 PCB_CALCULATOR_DATAFILE_LEXER( aReader )
177 PCB_CALCULATOR_DATAFILE_LEXER( aLine, aSource )
185 while( ( token = NextTok() ) != T_EOF)
187 if( token == T_LEFT )
191 if( token == T_regulators )
207 while( ( token = NextTok() ) != T_RIGHT )
212 if( token == T_LEFT )
215 if( token == T_regulator )
224 while( ( token = NextTok() ) != T_RIGHT )
229 if( token == T_LEFT )
236 if( token != T_NUMBER )
237 Expecting( T_NUMBER );
238 sscanf( CurText(),
"%lf" , &vref);
244 if( token != T_NUMBER )
245 Expecting( T_NUMBER );
246 sscanf( CurText(),
"%lf" , &iadj);
254 else if( strcasecmp( CurText(),
regtype_str[1] ) == 0 )
257 Unexpected( CurText() );
262 Unexpected( CurText() );
267 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.
PCB_CALCULATOR_DATAFILE_PARSER is the parser class 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