30#include <pegtl/contrib/parse_tree.hpp>
61 std::vector<std::string> currentNames;
64 currentNames.push_back( fmt::format(
"I({}:{})",
ItemName( aItem ),
pin.modelPinName ) );
71 const std::string& aSpiceCode )
73 tao::pegtl::string_input<> in( aSpiceCode,
"from_content" );
74 std::unique_ptr<tao::pegtl::parse_tree::node> root;
83 catch(
const tao::pegtl::parse_error& e )
90 for(
const auto& node : root->children )
94 for(
const auto& subnode : node->children )
101 model.
AddPin( { subnode->string(), fmt::format(
"{}", model.
GetPinCount() + 1 ) } );
105 for(
const auto& subsubnode : subnode->children )
109 model.
m_paramInfos.push_back( std::make_unique<SIM_MODEL::PARAM::INFO>() );
119 model.
m_paramInfos.back()->defaultValue = subsubnode->string();
123 wxFAIL_MSG(
"Unhandled parse tree subsubnode" );
131 wxFAIL_MSG(
"Unhandled parse tree node" );
166 return baseModel->GetSpiceCode();
std::string GetSpiceCode() const
void SetBaseModel(const SIM_MODEL &aBaseModel) override
std::vector< std::unique_ptr< PARAM::INFO > > m_paramInfos
const SIM_MODEL * GetBaseModel() const
void AddParam(const PARAM::INFO &aInfo)
void AddPin(const SIM_MODEL_PIN &aPin)
virtual const PARAM & GetParam(unsigned aParamIndex) const
virtual void SetBaseModel(const SIM_MODEL &aBaseModel)
int GetParamCount() const
std::vector< std::reference_wrapper< const SIM_MODEL_PIN > > GetPins() const
const SIM_MODEL * m_baseModel
std::vector< std::string > CurrentNames(const SPICE_ITEM &aItem) const override
std::string ModelLine(const SPICE_ITEM &aItem) const override
virtual std::string ItemName(const SPICE_ITEM &aItem) const
virtual std::vector< std::reference_wrapper< const SIM_MODEL_PIN > > GetPins() const
void ReadModel(const SIM_LIBRARY_SPICE &aLibrary, const std::string &aSpiceCode) override
SIM_MODEL_SPICE & m_model
#define THROW_IO_ERROR(msg)
must_if< error >::control< Rule > control