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() );
83 wxString lib =
m_library.m_pathResolver( node->children.at( 0 )->string(), aFilePath );
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 );
124 m_library.m_models.reserve( modelQueue.size() );
125 m_library.m_modelNames.reserve( modelQueue.size() );
127 for(
const auto& [
name, source] : modelQueue )
129 m_library.m_models.emplace_back(
nullptr );
134 [&](
int ii,
bool firstPass )
137 firstPass, aReporter );
143 auto results =
tp.submit_loop( 0, modelQueue.size(),
146 createModel( ii, true );
151 for(
int ii = 0; ii < (int) modelQueue.size(); ++ii )
154 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)
Report a string with a given severity.
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.
thread_pool & GetKiCadThreadPool()
Get a reference to the current thread pool.
BS::thread_pool< 0 > thread_pool