From cbb70f0da1d2ed8445b9e5b6ddbac008d88411ec Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Mon, 19 Dec 2022 13:51:49 +0000 Subject: [PATCH] Formatting and CLang-Tidy warning reduction. --- eeschema/sim/sim_property.cpp | 22 +++++++++------------- eeschema/sim/sim_value.cpp | 11 +++++++---- eeschema/sim/sim_value.h | 9 ++++----- 3 files changed, 20 insertions(+), 22 deletions(-) diff --git a/eeschema/sim/sim_property.cpp b/eeschema/sim/sim_property.cpp index 23e965da23..1d19729b01 100644 --- a/eeschema/sim/sim_property.cpp +++ b/eeschema/sim/sim_property.cpp @@ -47,13 +47,12 @@ void SIM_PROPERTY::Disable() } -SIM_BOOL_PROPERTY::SIM_BOOL_PROPERTY( const wxString& aLabel, const wxString& aName, - SIM_MODEL& aModel, int aParamIndex ) : +SIM_BOOL_PROPERTY::SIM_BOOL_PROPERTY( const wxString& aLabel, const wxString& aName, SIM_MODEL& aModel, + int aParamIndex ) : wxBoolProperty( aLabel, aName ), SIM_PROPERTY( aModel, aParamIndex ) { - auto simValue = dynamic_cast*>( - m_model.GetParam( m_paramIndex ).value.get() ); + auto simValue = dynamic_cast*>( m_model.GetParam( m_paramIndex ).value.get() ); wxCHECK( simValue, /*void*/ ); @@ -74,8 +73,7 @@ void SIM_BOOL_PROPERTY::OnSetValue() if( m_disabled ) return; - auto simValue = dynamic_cast*>( - m_model.GetParam( m_paramIndex ).value.get() ); + auto simValue = dynamic_cast*>( m_model.GetParam( m_paramIndex ).value.get() ); wxCHECK( simValue, /*void*/ ); @@ -86,9 +84,8 @@ void SIM_BOOL_PROPERTY::OnSetValue() } -SIM_STRING_PROPERTY::SIM_STRING_PROPERTY( const wxString& aLabel, const wxString& aName, - SIM_MODEL& aModel, int aParamIndex, - SIM_VALUE::TYPE aValueType, +SIM_STRING_PROPERTY::SIM_STRING_PROPERTY( const wxString& aLabel, const wxString& aName, SIM_MODEL& aModel, + int aParamIndex, SIM_VALUE::TYPE aValueType, SIM_VALUE_GRAMMAR::NOTATION aNotation ) : wxStringProperty( aLabel, aName ), SIM_PROPERTY( aModel, aParamIndex ), @@ -157,8 +154,7 @@ wxValidator* SIM_STRING_PROPERTY::DoGetValidator() const } -bool SIM_STRING_PROPERTY::StringToValue( wxVariant& aVariant, const wxString& aText, - int aArgFlags ) const +bool SIM_STRING_PROPERTY::StringToValue( wxVariant& aVariant, const wxString& aText, int aArgFlags ) const { if( m_disabled ) return false; @@ -188,8 +184,8 @@ static wxArrayString convertStringsToWx( const std::vector& aString } -SIM_ENUM_PROPERTY::SIM_ENUM_PROPERTY( const wxString& aLabel, const wxString& aName, - SIM_MODEL& aModel, int aParamIndex ) : +SIM_ENUM_PROPERTY::SIM_ENUM_PROPERTY( const wxString& aLabel, const wxString& aName, SIM_MODEL& aModel, + int aParamIndex ) : wxEnumProperty( aLabel, aName, convertStringsToWx( aModel.GetParam( aParamIndex ).info.enumValues ) ), SIM_PROPERTY( aModel, aParamIndex ) { diff --git a/eeschema/sim/sim_value.cpp b/eeschema/sim/sim_value.cpp index bf14eecaac..ca5f6871fa 100644 --- a/eeschema/sim/sim_value.cpp +++ b/eeschema/sim/sim_value.cpp @@ -359,7 +359,8 @@ std::string SIM_VALUE_PARSER::ExponentToMetricSuffix( double aExponent, int& aRe } -std::unique_ptr SIM_VALUE::Create( TYPE aType, std::string aString, NOTATION aNotation ) +std::unique_ptr SIM_VALUE::Create( TYPE aType, const std::string& aString, + NOTATION aNotation ) { std::unique_ptr value = SIM_VALUE::Create( aType ); value->FromString( aString, aNotation ); @@ -387,9 +388,10 @@ std::unique_ptr SIM_VALUE::Create( TYPE aType ) } -void SIM_VALUE::operator=( const std::string& aString ) +SIM_VALUE& SIM_VALUE::operator=( const std::string& aString ) { FromString( aString ); + return *this; } @@ -548,7 +550,7 @@ std::string SIM_VALUE_INST::ToString( NOTATION aNotation ) const { static_assert( std::is_same>::value ); - std::string string = ""; + std::string string; for( auto it = m_value.cbegin(); it != m_value.cend(); it++ ) { @@ -657,10 +659,11 @@ std::string SIM_VALUE_COMPLEX::ToSimpleString() const template -void SIM_VALUE_INST::operator=( const SIM_VALUE& aOther ) +SIM_VALUE_INST& SIM_VALUE_INST::operator=( const SIM_VALUE& aOther ) { auto other = dynamic_cast*>( &aOther ); m_value = other->m_value; + return *this; } diff --git a/eeschema/sim/sim_value.h b/eeschema/sim/sim_value.h index 6d450725f4..1b7c4cc84f 100644 --- a/eeschema/sim/sim_value.h +++ b/eeschema/sim/sim_value.h @@ -76,7 +76,7 @@ public: TYPE_COMPLEX_VECTOR }; - static std::unique_ptr Create( TYPE aType, std::string aString, + static std::unique_ptr Create( TYPE aType, const std::string& aString, NOTATION aNotation = NOTATION::SI ); static std::unique_ptr Create( TYPE aType ); @@ -87,8 +87,8 @@ public: virtual bool HasValue() const = 0; - void operator=( const std::string& aString ); - virtual void operator=( const SIM_VALUE& aValue ) = 0; + SIM_VALUE& operator=( const std::string& aString ); + virtual SIM_VALUE& operator=( const SIM_VALUE& aValue ) = 0; virtual bool operator==( const SIM_VALUE& aOther ) const = 0; bool operator!=( const SIM_VALUE& aOther ) const; @@ -117,8 +117,7 @@ public: std::string ToString( NOTATION aNotation = NOTATION::SI ) const override; std::string ToSimpleString() const override; - void operator=( const SIM_VALUE& aOther ) override; - void operator=( const T& aValue ); + SIM_VALUE_INST& operator=( const SIM_VALUE& aOther ) override; bool operator==( const T& aOther ) const; bool operator==( const SIM_VALUE& aOther ) const override;