7
mirror of https://gitlab.com/kicad/code/kicad.git synced 2025-04-20 00:21:31 +00:00

Replace boost::optional with std::optional

This commit is contained in:
Seth Hillbrand 2022-08-25 15:50:47 -07:00
parent c491cd01c5
commit f1261e71d4
117 changed files with 432 additions and 449 deletions
common
eeschema
gerbview/tools
include
kicad/pcm
libs/kimath
pagelayout_editor/tools
pcbnew
qa
tools/drc_proto
unittests
common
utils/kicad2step/pcb
utils/kicad2step/pcb

View File

@ -62,10 +62,10 @@ const wxString& ARRAY_AXIS::GetAlphabet() const
}
OPT<int> ARRAY_AXIS::getNumberingOffset( const wxString& str ) const
std::optional<int> ARRAY_AXIS::getNumberingOffset( const wxString& str ) const
{
if( str.length() == 0 )
return OPT<int>{};
return std::optional<int>{};
const wxString& alphabet = GetAlphabet();
@ -77,7 +77,7 @@ OPT<int> ARRAY_AXIS::getNumberingOffset( const wxString& str ) const
int chIndex = alphabet.Find( str[i], false );
if( chIndex == wxNOT_FOUND )
return OPT<int>{};
return std::optional<int>{};
const bool start0 = schemeNonUnitColsStartAt0( m_type );
@ -89,7 +89,7 @@ OPT<int> ARRAY_AXIS::getNumberingOffset( const wxString& str ) const
offset += chIndex;
}
return OPT<int>{ offset };
return std::optional<int>{ offset };
}
@ -101,7 +101,7 @@ void ARRAY_AXIS::SetAxisType( NUMBERING_TYPE aType )
bool ARRAY_AXIS::SetOffset( const wxString& aOffsetName )
{
OPT<int> offset = getNumberingOffset( aOffsetName );
std::optional<int> offset = getNumberingOffset( aOffsetName );
// The string does not decode to a valid offset
if( !offset )

View File

@ -117,7 +117,7 @@ wxString ENV_VAR::LookUpEnvVarHelp( const wxString& aEnvVar )
template<>
OPT<double> ENV_VAR::GetEnvVar( const wxString& aEnvVarName )
std::optional<double> ENV_VAR::GetEnvVar( const wxString& aEnvVarName )
{
wxString env;
@ -129,14 +129,14 @@ OPT<double> ENV_VAR::GetEnvVar( const wxString& aEnvVarName )
return value;
}
return NULLOPT;
return std::nullopt;
}
template<>
OPT<wxString> ENV_VAR::GetEnvVar( const wxString& aEnvVarName )
std::optional<wxString> ENV_VAR::GetEnvVar( const wxString& aEnvVarName )
{
OPT<wxString> optValue;
std::optional<wxString> optValue;
wxString env;

View File

@ -23,7 +23,7 @@
#include <gal/dpi_scaling.h>
#include <core/optional.h>
#include <optional>
#include <env_vars.h>
#include <settings/common_settings.h>
@ -47,9 +47,9 @@ const wxChar* const traceHiDpi = wxT( "KICAD_TRACE_HIGH_DPI" );
*
* @return the scale factor, if set
*/
static OPT<double> getKiCadConfiguredScale( const COMMON_SETTINGS& aConfig )
static std::optional<double> getKiCadConfiguredScale( const COMMON_SETTINGS& aConfig )
{
OPT<double> scale;
std::optional<double> scale;
double canvas_scale = aConfig.m_Appearance.canvas_scale;
if( canvas_scale > 0.0 )
@ -72,10 +72,10 @@ static OPT<double> getKiCadConfiguredScale( const COMMON_SETTINGS& aConfig )
*
* @return the scale factor, if set
*/
static OPT<double> getEnvironmentScale()
static std::optional<double> getEnvironmentScale()
{
const wxPortId port_id = wxPlatformInfo::Get().GetPortId();
OPT<double> scale;
std::optional<double> scale;
if( port_id == wxPORT_GTK )
{
@ -100,7 +100,7 @@ DPI_SCALING::DPI_SCALING( COMMON_SETTINGS* aConfig, const wxWindow* aWindow )
double DPI_SCALING::GetScaleFactor() const
{
OPT<double> val;
std::optional<double> val;
if( m_config )
{
@ -140,7 +140,7 @@ bool DPI_SCALING::GetCanvasIsAutoScaled() const
return true;
}
const bool automatic = getKiCadConfiguredScale( *m_config ) == boost::none;
const bool automatic = getKiCadConfiguredScale( *m_config ) == std::nullopt;
wxLogTrace( traceHiDpi, "Scale is automatic: %d", automatic );
return automatic;
}

View File

@ -181,7 +181,7 @@ wxString Convert<wxString>( const wxString& aValue );
/**
* Model an optional XML attribute.
*
* This was implemented as an alternative to OPT. This class should be replaced with a
* This was implemented as an alternative to std::optional. This class should be replaced with a
* simple typedef per type using std::optional when C++17 is published.
*/
template <typename T>

View File

@ -152,7 +152,7 @@ void POLYGON_GEOM_MANAGER::updateLeaderPoints( const VECTOR2I& aEndPoint, LEADER
const VECTOR2I line_vec( aEndPoint - last_pt );
// get a restricted 45/H/V line from the last fixed point to the cursor
auto new_end = last_pt + GetVectorSnapped45( line_vec );
OPT_VECTOR2I pt = boost::make_optional( false, VECTOR2I() );
OPT_VECTOR2I pt;
if( m_lockedPoints.SegmentCount() > 1 )
{

View File

@ -35,8 +35,8 @@
const int netSettingsSchemaVersion = 3; // netclass assignment patterns
static OPT<int> getInPcbUnits( const nlohmann::json& aObj, const std::string& aKey,
OPT<int> aDefault = OPT<int>() )
static std::optional<int> getInPcbUnits( const nlohmann::json& aObj, const std::string& aKey,
std::optional<int> aDefault = std::optional<int>() )
{
if( aObj.contains( aKey ) && aObj[aKey].is_number() )
return PcbMm2iu( aObj[aKey].get<double>() );

View File

@ -252,7 +252,7 @@ COLOR_SETTINGS::COLOR_SETTINGS( const wxString& aFilename, bool aAbsolutePath )
"3d_viewer.silkscreen_bottom",
"3d_viewer.solderpaste" } )
{
if( OPT<COLOR4D> optval = Get<COLOR4D>( path ) )
if( std::optional<COLOR4D> optval = Get<COLOR4D>( path ) )
Set( path, optval->WithAlpha( 1.0 ) );
}
@ -262,11 +262,11 @@ COLOR_SETTINGS::COLOR_SETTINGS( const wxString& aFilename, bool aAbsolutePath )
registerMigration( 3, 4,
[&]()
{
if( OPT<COLOR4D> optval = Get<COLOR4D>( "board.grid" ) )
Set( "board.page_limits", optval.get() );
if( std::optional<COLOR4D> optval = Get<COLOR4D>( "board.grid" ) )
Set( "board.page_limits", optval.value() );
if( OPT<COLOR4D> optval = Get<COLOR4D>( "schematic.grid" ) )
Set( "schematic.page_limits", optval.get() );
if( std::optional<COLOR4D> optval = Get<COLOR4D>( "schematic.grid" ) )
Set( "schematic.page_limits", optval.value() );
return true;
} );

View File

@ -471,7 +471,7 @@ bool COMMON_SETTINGS::MigrateFromLegacy( wxConfigBase* aCfg )
ret &= fromLegacy<bool>( aCfg, "ZoomNoCenter", "input.center_on_zoom" );
// This was stored inverted in legacy config
if( OPT<bool> value = Get<bool>( "input.center_on_zoom" ) )
if( std::optional<bool> value = Get<bool>( "input.center_on_zoom" ) )
Set( "input.center_on_zoom", !( *value ) );
ret &= fromLegacy<int>( aCfg, "OpenGLAntialiasingMode", "graphics.opengl_antialiasing_mode" );

View File

@ -471,7 +471,7 @@ bool JSON_SETTINGS::SaveToFile( const wxString& aDirectory, bool aForce )
}
OPT<nlohmann::json> JSON_SETTINGS::GetJson( const std::string& aPath ) const
std::optional<nlohmann::json> JSON_SETTINGS::GetJson( const std::string& aPath ) const
{
nlohmann::json::json_pointer ptr = m_internals->PointerFromString( aPath );
@ -479,21 +479,21 @@ OPT<nlohmann::json> JSON_SETTINGS::GetJson( const std::string& aPath ) const
{
try
{
return OPT<nlohmann::json>{ m_internals->at( ptr ) };
return std::optional<nlohmann::json>{ m_internals->at( ptr ) };
}
catch( ... )
{
}
}
return OPT<nlohmann::json>{};
return std::optional<nlohmann::json>{};
}
template<typename ValueType>
OPT<ValueType> JSON_SETTINGS::Get( const std::string& aPath ) const
std::optional<ValueType> JSON_SETTINGS::Get( const std::string& aPath ) const
{
if( OPT<nlohmann::json> ret = GetJson( aPath ) )
if( std::optional<nlohmann::json> ret = GetJson( aPath ) )
{
try
{
@ -504,20 +504,20 @@ OPT<ValueType> JSON_SETTINGS::Get( const std::string& aPath ) const
}
}
return NULLOPT;
return std::nullopt;
}
// Instantiate all required templates here to allow reducing scope of json.hpp
template OPT<bool> JSON_SETTINGS::Get<bool>( const std::string& aPath ) const;
template OPT<double> JSON_SETTINGS::Get<double>( const std::string& aPath ) const;
template OPT<float> JSON_SETTINGS::Get<float>( const std::string& aPath ) const;
template OPT<int> JSON_SETTINGS::Get<int>( const std::string& aPath ) const;
template OPT<unsigned int> JSON_SETTINGS::Get<unsigned int>( const std::string& aPath ) const;
template OPT<unsigned long long> JSON_SETTINGS::Get<unsigned long long>( const std::string& aPath ) const;
template OPT<std::string> JSON_SETTINGS::Get<std::string>( const std::string& aPath ) const;
template OPT<nlohmann::json> JSON_SETTINGS::Get<nlohmann::json>( const std::string& aPath ) const;
template OPT<KIGFX::COLOR4D> JSON_SETTINGS::Get<KIGFX::COLOR4D>( const std::string& aPath ) const;
template std::optional<bool> JSON_SETTINGS::Get<bool>( const std::string& aPath ) const;
template std::optional<double> JSON_SETTINGS::Get<double>( const std::string& aPath ) const;
template std::optional<float> JSON_SETTINGS::Get<float>( const std::string& aPath ) const;
template std::optional<int> JSON_SETTINGS::Get<int>( const std::string& aPath ) const;
template std::optional<unsigned int> JSON_SETTINGS::Get<unsigned int>( const std::string& aPath ) const;
template std::optional<unsigned long long> JSON_SETTINGS::Get<unsigned long long>( const std::string& aPath ) const;
template std::optional<std::string> JSON_SETTINGS::Get<std::string>( const std::string& aPath ) const;
template std::optional<nlohmann::json> JSON_SETTINGS::Get<nlohmann::json>( const std::string& aPath ) const;
template std::optional<KIGFX::COLOR4D> JSON_SETTINGS::Get<KIGFX::COLOR4D>( const std::string& aPath ) const;
template<typename ValueType>
@ -770,12 +770,12 @@ void JSON_SETTINGS::ReleaseNestedSettings( NESTED_SETTINGS* aSettings )
// Specializations to allow conversion between wxString and std::string via JSON_SETTINGS API
template<> OPT<wxString> JSON_SETTINGS::Get( const std::string& aPath ) const
template<> std::optional<wxString> JSON_SETTINGS::Get( const std::string& aPath ) const
{
if( OPT<nlohmann::json> opt_json = GetJson( aPath ) )
if( std::optional<nlohmann::json> opt_json = GetJson( aPath ) )
return wxString( opt_json->get<std::string>().c_str(), wxConvUTF8 );
return NULLOPT;
return std::nullopt;
}

View File

@ -35,14 +35,14 @@ void PARAM_LAMBDA<ValueType>::Load( JSON_SETTINGS* aSettings, bool aResetIfMissi
if( std::is_same<ValueType, nlohmann::json>::value )
{
if( OPT<nlohmann::json> optval = aSettings->GetJson( m_path ) )
if( std::optional<nlohmann::json> optval = aSettings->GetJson( m_path ) )
m_setter( *optval );
else
m_setter( m_default );
}
else
{
if( OPT<ValueType> optval = aSettings->Get<ValueType>( m_path ) )
if( std::optional<ValueType> optval = aSettings->Get<ValueType>( m_path ) )
m_setter( *optval );
else
m_setter( m_default );
@ -55,12 +55,12 @@ bool PARAM_LAMBDA<ValueType>::MatchesFile( JSON_SETTINGS* aSettings ) const
{
if( std::is_same<ValueType, nlohmann::json>::value )
{
if( OPT<nlohmann::json> optval = aSettings->GetJson( m_path ) )
if( std::optional<nlohmann::json> optval = aSettings->GetJson( m_path ) )
return *optval == m_getter();
}
else
{
if( OPT<ValueType> optval = aSettings->Get<ValueType>( m_path ) )
if( std::optional<ValueType> optval = aSettings->Get<ValueType>( m_path ) )
return *optval == m_getter();
}
@ -82,7 +82,7 @@ void PARAM_LIST<ValueType>::Load( JSON_SETTINGS* aSettings, bool aResetIfMissing
if( m_readOnly )
return;
if( OPT<nlohmann::json> js = aSettings->GetJson( m_path ) )
if( std::optional<nlohmann::json> js = aSettings->GetJson( m_path ) )
{
std::vector<ValueType> val;
@ -114,7 +114,7 @@ void PARAM_LIST<ValueType>::Store( JSON_SETTINGS* aSettings ) const
template <typename ValueType>
bool PARAM_LIST<ValueType>::MatchesFile( JSON_SETTINGS* aSettings ) const
{
if( OPT<nlohmann::json> js = aSettings->GetJson( m_path ) )
if( std::optional<nlohmann::json> js = aSettings->GetJson( m_path ) )
{
if( js->is_array() )
{
@ -151,7 +151,7 @@ void PARAM_PATH_LIST::Store( JSON_SETTINGS* aSettings ) const
bool PARAM_PATH_LIST::MatchesFile( JSON_SETTINGS* aSettings ) const
{
if( OPT<nlohmann::json> js = aSettings->GetJson( m_path ) )
if( std::optional<nlohmann::json> js = aSettings->GetJson( m_path ) )
{
if( js->is_array() )
{
@ -174,7 +174,7 @@ void PARAM_MAP<Value>::Load( JSON_SETTINGS* aSettings, bool aResetIfMissing ) co
if( m_readOnly )
return;
if( OPT<nlohmann::json> js = aSettings->GetJson( m_path ) )
if( std::optional<nlohmann::json> js = aSettings->GetJson( m_path ) )
{
if( js->is_object() )
{
@ -204,7 +204,7 @@ void PARAM_MAP<Value>::Store( JSON_SETTINGS* aSettings ) const
template <typename Value>
bool PARAM_MAP<Value>::MatchesFile( JSON_SETTINGS* aSettings ) const
{
if( OPT<nlohmann::json> js = aSettings->GetJson( m_path ) )
if( std::optional<nlohmann::json> js = aSettings->GetJson( m_path ) )
{
if( js->is_object() )
{
@ -234,7 +234,7 @@ void PARAM_WXSTRING_MAP::Load( JSON_SETTINGS* aSettings, bool aResetIfMissing )
if( m_readOnly )
return;
if( OPT<nlohmann::json> js = aSettings->GetJson( m_path ) )
if( std::optional<nlohmann::json> js = aSettings->GetJson( m_path ) )
{
if( js->is_object() )
{
@ -267,7 +267,7 @@ void PARAM_WXSTRING_MAP::Store( JSON_SETTINGS* aSettings ) const
bool PARAM_WXSTRING_MAP::MatchesFile( JSON_SETTINGS* aSettings ) const
{
if( OPT<nlohmann::json> js = aSettings->GetJson( m_path ) )
if( std::optional<nlohmann::json> js = aSettings->GetJson( m_path ) )
{
if( js->is_object() )
{

View File

@ -361,7 +361,7 @@ void SETTINGS_MANAGER::SaveColorSettings( COLOR_SETTINGS* aSettings, const std::
aSettings->GetFilename(),
aNamespace );
OPT<nlohmann::json> backup = aSettings->GetJson( aNamespace );
std::optional<nlohmann::json> backup = aSettings->GetJson( aNamespace );
wxString path = GetColorSettingsPath();
aSettings->LoadFromFile( path );

View File

@ -74,7 +74,7 @@ void GRID_HELPER::SetAuxAxes( bool aEnable, const VECTOR2I& aOrigin )
}
else
{
m_auxAxis = OPT<VECTOR2I>();
m_auxAxis = std::optional<VECTOR2I>();
m_toolMgr->GetView()->SetVisible( &m_viewAxis, false );
}
}

View File

@ -33,11 +33,11 @@ void PICKER_TOOL_BASE::reset()
m_cursor = KICURSOR::ARROW;
m_snap = true;
m_picked = NULLOPT;
m_clickHandler = NULLOPT;
m_motionHandler = NULLOPT;
m_cancelHandler = NULLOPT;
m_finalizeHandler = NULLOPT;
m_picked = std::nullopt;
m_clickHandler = std::nullopt;
m_motionHandler = std::nullopt;
m_cancelHandler = std::nullopt;
m_finalizeHandler = std::nullopt;
}

View File

@ -351,7 +351,7 @@ bool SELECTION_TOOL::doSelectionMenu( COLLECTOR* aCollector )
unhighlight( current, BRIGHTENED, &highlightGroup );
}
OPT<int> id = evt->GetCommandId();
std::optional<int> id = evt->GetCommandId();
// User has selected the "Select All" option
if( id == limit + 1 )

View File

@ -40,7 +40,7 @@
#include <eda_draw_frame.h>
#include <core/arraydim.h>
#include <core/optional.h>
#include <optional>
#include <wx/log.h>
#include <wx/stc/stc.h>
#include <wx/settings.h>
@ -177,7 +177,7 @@ bool TOOL_DISPATCHER::handleMouseButton( wxEvent& aEvent, int aIndex, bool aMoti
{
BUTTON_STATE* st = m_buttons[aIndex];
wxEventType type = aEvent.GetEventType();
OPT<TOOL_EVENT> evt;
std::optional<TOOL_EVENT> evt;
bool isClick = false;
// bool up = type == st->upEvent;
@ -358,9 +358,9 @@ int translateSpecialCode( int aKeyCode )
}
OPT<TOOL_EVENT> TOOL_DISPATCHER::GetToolEvent( wxKeyEvent* aKeyEvent, bool* keyIsSpecial )
std::optional<TOOL_EVENT> TOOL_DISPATCHER::GetToolEvent( wxKeyEvent* aKeyEvent, bool* keyIsSpecial )
{
OPT<TOOL_EVENT> evt;
std::optional<TOOL_EVENT> evt;
int key = aKeyEvent->GetKeyCode();
int unicode_key = aKeyEvent->GetUnicodeKey();
@ -443,7 +443,7 @@ void TOOL_DISPATCHER::DispatchWxEvent( wxEvent& aEvent )
bool motion = false;
bool buttonEvents = false;
VECTOR2D pos;
OPT<TOOL_EVENT> evt;
std::optional<TOOL_EVENT> evt;
bool keyIsEscape = false; // True if the keypress was the escape key
bool keyIsSpecial = false; // True if the key is a special key code
wxWindow* focus = wxWindow::FindFocus();

View File

@ -212,11 +212,9 @@ bool TOOL_EVENT::IsDblClick( int aButtonMask ) const
bool TOOL_EVENT::IsCancelInteractive() const
{
return( ( m_commandStr.is_initialized()
&& m_commandStr.get() == ACTIONS::cancelInteractive.GetName() )
|| ( m_commandId.is_initialized()
&& m_commandId.get() == ACTIONS::cancelInteractive.GetId() )
|| ( m_actions == TA_CANCEL_TOOL ) );
return ( ( m_commandStr && m_commandStr.value() == ACTIONS::cancelInteractive.GetName() )
|| ( m_commandId && m_commandId.value() == ACTIONS::cancelInteractive.GetId() )
|| ( m_actions == TA_CANCEL_TOOL ) );
}
@ -231,22 +229,19 @@ bool TOOL_EVENT::IsSelectionEvent() const
bool TOOL_EVENT::IsPointEditor() const
{
return( ( m_commandStr.is_initialized()
&& m_commandStr.get().find( "PointEditor" ) != GetCommandStr()->npos )
|| ( m_commandId.is_initialized()
&& m_commandId.get() == ACTIONS::activatePointEditor.GetId() ) );
return ( ( m_commandStr && m_commandStr.value().find( "PointEditor" ) != GetCommandStr()->npos )
|| ( m_commandId && m_commandId.value() == ACTIONS::activatePointEditor.GetId() ) );
}
bool TOOL_EVENT::IsMoveTool() const
{
return( m_commandStr.is_initialized()
&& m_commandStr.get().find( "InteractiveMove" ) != GetCommandStr()->npos );
return ( m_commandStr
&& m_commandStr.value().find( "InteractiveMove" ) != GetCommandStr()->npos );
}
bool TOOL_EVENT::IsSimulator() const
{
return( m_commandStr.is_initialized()
&& m_commandStr.get().find( "Simulation" ) != GetCommandStr()->npos );
return ( m_commandStr && m_commandStr.value().find( "Simulation" ) != GetCommandStr()->npos );
}

View File

@ -25,7 +25,7 @@
*/
#include <core/kicad_algo.h>
#include <core/optional.h>
#include <optional>
#include <map>
#include <stack>
#include <trace_helpers.h>
@ -879,7 +879,7 @@ void TOOL_MANAGER::DispatchContextMenu( const TOOL_EVENT& aEvent )
if( vc.m_forceCursorPosition )
m_cursorSettings[idState.first] = vc.m_forcedPosition;
else
m_cursorSettings[idState.first] = NULLOPT;
m_cursorSettings[idState.first] = std::nullopt;
}
if( m_viewControls )
@ -916,7 +916,7 @@ void TOOL_MANAGER::DispatchContextMenu( const TOOL_EVENT& aEvent )
m_menuOwner = -1;
// Restore cursor settings
for( const std::pair<const TOOL_ID, OPT<VECTOR2D>>& cursorSetting : m_cursorSettings )
for( const std::pair<const TOOL_ID, std::optional<VECTOR2D>>& cursorSetting : m_cursorSettings )
{
auto it = m_toolIdIndex.find( cursorSetting.first );
wxASSERT( it != m_toolIdIndex.end() );
@ -1103,13 +1103,13 @@ void TOOL_MANAGER::saveViewControls( TOOL_STATE* aState )
if( !curr.m_forceCursorPosition || curr.m_forcedPosition != m_menuCursor )
{
if( !curr.m_forceCursorPosition )
it->second = NULLOPT;
it->second = std::nullopt;
else
it->second = curr.m_forcedPosition;
}
else
{
OPT<VECTOR2D> cursor = it->second;
std::optional<VECTOR2D> cursor = it->second;
if( cursor )
{
@ -1147,8 +1147,8 @@ bool TOOL_MANAGER::processEvent( const TOOL_EVENT& aEvent )
if( GetToolHolder() && !GetToolHolder()->GetDoImmediateActions() )
{
// An tool-selection-event has no position
if( mod_event.GetCommandStr().is_initialized()
&& mod_event.GetCommandStr().get() != GetToolHolder()->CurrentToolName()
if( mod_event.GetCommandStr()
&& mod_event.GetCommandStr().value() != GetToolHolder()->CurrentToolName()
&& !mod_event.ForceImmediate() )
{
mod_event.SetHasPosition( false );

View File

@ -60,7 +60,7 @@ void ZOOM_TOOL::Reset( RESET_REASON aReason )
int ZOOM_TOOL::Main( const TOOL_EVENT& aEvent )
{
std::string tool = aEvent.GetCommandStr().get();
std::string tool = aEvent.GetCommandStr().value();
m_frame->PushTool( tool );
auto setCursor =

View File

@ -467,7 +467,7 @@ EESCHEMA_SETTINGS::EESCHEMA_SETTINGS() :
{
// We used to have a bug on GTK which would set the lib tree column width way
// too narrow.
if( OPT<int> optval = Get<int>( "lib_tree.column_width" ) )
if( std::optional<int> optval = Get<int>( "lib_tree.column_width" ) )
{
if( optval < 150 )
Set( "lib_tree.column_width", 300 );
@ -487,7 +487,7 @@ bool EESCHEMA_SETTINGS::MigrateFromLegacy( wxConfigBase* aCfg )
// this index and the possible eeschema grids list that we have to subtract.
std::string gridSizePtr = "window.grid.last_size";
if( OPT<int> currentSize = Get<int>( gridSizePtr ) )
if( std::optional<int> currentSize = Get<int>( gridSizePtr ) )
{
Set( gridSizePtr, *currentSize - 4 );
}

View File

@ -25,7 +25,6 @@
#include <memory>
#include <unordered_set>
#include <boost/optional.hpp>
#include <wx/regex.h>
#include <bus_alias.h>
#include <sch_sheet_path.h>

View File

@ -222,10 +222,10 @@ SCHEMATIC_SETTINGS::SCHEMATIC_SETTINGS( JSON_SETTINGS* aParent, const std::strin
registerMigration( 0, 1,
[&]() -> bool
{
OPT<double> tor = Get<double>( "drawing.text_offset_ratio" );
std::optional<double> tor = Get<double>( "drawing.text_offset_ratio" );
if( tor.is_initialized() )
Set( "drawing.label_size_ratio", tor.get() );
if( tor )
Set( "drawing.label_size_ratio", tor.value() );
return true;
} );

View File

@ -101,10 +101,10 @@ namespace SIM_VALUE_PARSER
bool isOk = true;
bool isEmpty = true;
std::string significand;
OPT<long> intPart;
OPT<long> fracPart;
OPT<long> exponent;
OPT<long> metricSuffixExponent;
std::optional<long> intPart;
std::optional<long> fracPart;
std::optional<long> exponent;
std::optional<long> metricSuffixExponent;
};
PARSE_RESULT Parse( const wxString& aString,
@ -415,7 +415,7 @@ template <>
bool SIM_VALUE_INST<bool>::FromString( const wxString& aString, NOTATION aNotation )
{
SIM_VALUE_PARSER::PARSE_RESULT parseResult = SIM_VALUE_PARSER::Parse( aString, aNotation );
m_value = NULLOPT;
m_value = std::nullopt;
if( !parseResult.isOk )
return false;
@ -441,7 +441,7 @@ template <>
bool SIM_VALUE_INST<long>::FromString( const wxString& aString, NOTATION aNotation )
{
SIM_VALUE_PARSER::PARSE_RESULT parseResult = SIM_VALUE_PARSER::Parse( aString, aNotation );
m_value = NULLOPT;
m_value = std::nullopt;
if( !parseResult.isOk )
return false;
@ -464,7 +464,7 @@ template <>
bool SIM_VALUE_INST<double>::FromString( const wxString& aString, NOTATION aNotation )
{
SIM_VALUE_PARSER::PARSE_RESULT parseResult = SIM_VALUE_PARSER::Parse( aString, aNotation );
m_value = NULLOPT;
m_value = std::nullopt;
if( !parseResult.isOk )
return false;

View File

@ -26,7 +26,7 @@
#define SIM_VALUE_H
#include <wx/string.h>
#include <core/optional.h>
#include <optional>
#include <memory>
#include <pegtl.hpp>
@ -118,7 +118,7 @@ public:
private:
wxString getMetricSuffix();
OPT<T> m_value = NULLOPT;
std::optional<T> m_value = std::nullopt;
};
typedef SIM_VALUE_INST<bool> SIM_VALUE_BOOL;

View File

@ -32,7 +32,7 @@
#include <sch_screen.h>
#include <lib_item.h>
#include <ee_collectors.h>
#include <core/optional.h>
#include <optional>
class SCH_EDIT_FRAME;
class SYMBOL_LIB_TABLE;

View File

@ -93,7 +93,7 @@ bool SYMBOL_EDITOR_SETTINGS::MigrateFromLegacy( wxConfigBase* aCfg )
// this index and the possible eeschema grids list that we have to subtract.
std::string gridSizePtr = "window.grid.last_size";
if( OPT<int> currentSize = Get<int>( gridSizePtr ) )
if( std::optional<int> currentSize = Get<int>( gridSizePtr ) )
{
Set( gridSizePtr, *currentSize - 4 );
}

Some files were not shown because too many files have changed in this diff Show More