26#include <fast_float/fast_float.h>
67 wxCHECK( settings,
false );
78 return it !=
m_options.end() ? it->second : wxString();
84 if( aValue.Strip( wxString::both ).IsEmpty() )
93 wxString value = aValue.Strip( wxString::both );
98 if( aName ==
"method" )
102 if( value == wxS(
"trap" ) || value == wxS(
"gear" ) )
108 if( aName ==
"itl1" || aName ==
"itl4" )
112 if( !value.IsNumber() || !value.ToLong( &limit ) || limit < 1 || limit > INT_MAX )
115 return wxString::Format( wxS(
"%ld" ), limit );
119 value.Replace( wxS(
"," ), wxS(
"." ) );
121 std::string str( value.ToUTF8() );
122 const char* begin = str.data();
123 const char*
end = begin + str.size();
124 const char* mantissa = ( *begin ==
'+' || *begin ==
'-' ) ? begin + 1 : begin;
127 if( mantissa ==
end || !( std::isdigit( (
unsigned char) *mantissa ) || *mantissa ==
'.' ) )
131 auto result = fast_float::from_chars( mantissa,
end, parsed );
133 if(
result.ec != std::errc() )
137 for(
const char* c =
result.ptr; c !=
end; ++c )
139 if( !std::isalpha( (
unsigned char) *c ) )
155 if( value && !value->IsEmpty() )
156 options += wxString::Format( wxS(
" %s=%s" ), wxString::FromUTF8(
name ), *value );
159 if( options.IsEmpty() )
160 return wxEmptyString;
162 return wxS(
".options" ) + options;
168 static const std::vector<std::string> options = {
"method",
"reltol",
"abstol",
"vntol",
"chgtol",
169 "trtol",
"gmin",
"gshunt",
"rshunt",
"itl1",
170 "itl4",
"temp",
"tnom" };
std::vector< PARAM_BASE * > m_params
The list of parameters (owned by this object)
JSON_SETTINGS(const wxString &aFilename, SETTINGS_LOC aLocation, int aSchemaVersion)
NESTED_SETTINGS(const std::string &aName, int aSchemaVersion, JSON_SETTINGS *aParent, const std::string &aPath, bool aLoadFromFile=true)
wxString GetOptionsDirective() const
Build a ".options ..." directive from the valid options that have a value set, or an empty string if ...
std::map< std::string, wxString > m_options
static std::optional< wxString > NormalizeOption(const std::string &aName, const wxString &aValue)
Return aValue in the form ngspice reads for option aName.
NGSPICE_SETTINGS(JSON_SETTINGS *aParent, const std::string &aPath)
bool operator==(const SPICE_SETTINGS &aRhs) const override
void SetOption(const std::string &aName, const wxString &aValue)
Set the value for a simulator option. A blank value clears it.
NGSPICE_COMPATIBILITY_MODE m_compatibilityMode
static const std::vector< std::string > & SupportedOptions()
The ngspice option names exposed through the settings UI.
wxString GetOption(const std::string &aName) const
Return the value set for a simulator option, or an empty string if it is unset.
Stores an enum as an integer.
Represents a map of <std::string, Value>.
wxString m_workbookFilename
SPICE_SETTINGS(JSON_SETTINGS *aParent, const std::string &aPath)
virtual bool operator==(const SPICE_SETTINGS &aRhs) const =0
const int spiceSettingsSchemaVersion
NGSPICE_COMPATIBILITY_MODE
Ngspice simulator compatibility modes.
wxString result
Test unit parsing edge cases and error handling.