37#include <pegtl/contrib/parse_tree.hpp>
64 std::vector<std::pair<std::string, std::string>>* aQueue )
68 tao::pegtl::string_input<> in(
SafeReadFile( aFilePath, wxS(
"r" ) ).ToStdString(),
69 aFilePath.ToStdString() );
75 for(
const auto& node : root->children )
79 aQueue->emplace_back( node->children.at( 0 )->string(), node->string() );
100 wxFAIL_MSG(
"Unhandled parse tree node" );
108 catch(
const tao::pegtl::parse_error& e )
120 std::vector<std::pair<std::string, std::string>> modelQueue;
122 parseFile( aFilePath, aReporter, &modelQueue );
127 for(
const auto& [
name, source] : modelQueue )
134 [&](
int ii,
bool firstPass )
137 firstPass, aReporter );
143 tp.push_loop( modelQueue.size(),
144 [&](
const int a,
const int b )
146 for( int ii = a; ii < b; ++ii )
147 createModel( ii, true );
152 for(
int ii = 0; ii < (int) modelQueue.size(); ++ii )
155 createModel( ii,
false );
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()
A pure virtual class used to derive REPORTER objects from.
virtual REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)=0
Report a string with a given severity.
std::vector< std::string > m_modelNames
std::vector< std::unique_ptr< SIM_MODEL > > m_models
std::function< wxString(const wxString &, const wxString &)> m_pathResolver
static std::unique_ptr< SIM_MODEL_SPICE > Create(const SIM_LIBRARY_SPICE &aLibrary, const std::string &aSpiceCode, bool aFirstPass, REPORTER &aReporter)
SIM_LIBRARY_SPICE & m_library
virtual void ReadFile(const wxString &aFilePath, REPORTER &firstPass)
void parseFile(const wxString &aFilePath, REPORTER &aReporter, std::vector< std::pair< std::string, std::string > > *aModelQueue)
must_if< error >::control< Rule > control
wxString SafeReadFile(const wxString &aFilePath, const wxString &aReadType)
Nominally opens a file and reads it into a string.
BS::thread_pool thread_pool
thread_pool & GetKiCadThreadPool()
Get a reference to the current thread pool.