Browse Source

Factoring out ConsumeParam

Source commit: a8d04d33391fed2ba6bf981426874a725bcdb3bf
Martin Prikryl 2 năm trước cách đây
mục cha
commit
afe45263b1

+ 7 - 0
source/core/Option.cpp

@@ -138,6 +138,13 @@ UnicodeString __fastcall TOptions::GetParam(int Index)
   return Result;
   return Result;
 }
 }
 //---------------------------------------------------------------------------
 //---------------------------------------------------------------------------
+UnicodeString TOptions::ConsumeParam()
+{
+  UnicodeString Result = Param[1];
+  ParamsProcessed(1, 1);
+  return Result;
+}
+//---------------------------------------------------------------------------
 bool __fastcall TOptions::GetEmpty()
 bool __fastcall TOptions::GetEmpty()
 {
 {
   return FOptions.empty();
   return FOptions.empty();

+ 2 - 1
source/core/Option.h

@@ -27,12 +27,12 @@ public:
   bool __fastcall FindSwitchCaseSensitive(const UnicodeString Switch);
   bool __fastcall FindSwitchCaseSensitive(const UnicodeString Switch);
   bool __fastcall FindSwitchCaseSensitive(const UnicodeString Switch, TStrings * Params,
   bool __fastcall FindSwitchCaseSensitive(const UnicodeString Switch, TStrings * Params,
     int ParamsMax = -1);
     int ParamsMax = -1);
-  void __fastcall ParamsProcessed(int Position, int Count);
   UnicodeString __fastcall SwitchValue(const UnicodeString Switch, const UnicodeString Default = L"");
   UnicodeString __fastcall SwitchValue(const UnicodeString Switch, const UnicodeString Default = L"");
   bool __fastcall SwitchValue(const UnicodeString Switch, bool Default);
   bool __fastcall SwitchValue(const UnicodeString Switch, bool Default);
   bool __fastcall SwitchValue(const UnicodeString Switch, bool Default, bool DefaultOnNonExistence);
   bool __fastcall SwitchValue(const UnicodeString Switch, bool Default, bool DefaultOnNonExistence);
   bool __fastcall UnusedSwitch(UnicodeString & Switch);
   bool __fastcall UnusedSwitch(UnicodeString & Switch);
   bool __fastcall WasSwitchAdded(UnicodeString & Switch, UnicodeString & Value, wchar_t & SwitchMark);
   bool __fastcall WasSwitchAdded(UnicodeString & Switch, UnicodeString & Value, wchar_t & SwitchMark);
+  UnicodeString ConsumeParam();
 
 
   void __fastcall LogOptions(TLogOptionEvent OnEnumOption);
   void __fastcall LogOptions(TLogOptionEvent OnEnumOption);
 
 
@@ -48,6 +48,7 @@ protected:
     UnicodeString & Value, int & ParamsStart, int & ParamsCount, bool CaseSensitive, bool & ValueSet);
     UnicodeString & Value, int & ParamsStart, int & ParamsCount, bool CaseSensitive, bool & ValueSet);
   bool __fastcall DoFindSwitch(const UnicodeString Switch, TStrings * Params,
   bool __fastcall DoFindSwitch(const UnicodeString Switch, TStrings * Params,
     int ParamsMax, bool CaseInsensitive);
     int ParamsMax, bool CaseInsensitive);
+  void __fastcall ParamsProcessed(int Position, int Count);
 
 
 private:
 private:
   struct TOption
   struct TOption

+ 1 - 2
source/windows/WinMain.cpp

@@ -1162,8 +1162,7 @@ int __fastcall Execute()
       bool NewInstance = Params->FindSwitch(NEWINSTANCE_SWICH);
       bool NewInstance = Params->FindSwitch(NEWINSTANCE_SWICH);
       if (Params->ParamCount > 0)
       if (Params->ParamCount > 0)
       {
       {
-        AutoStartSession = Params->Param[1];
-        Params->ParamsProcessed(1, 1);
+        AutoStartSession = Params->ConsumeParam();
 
 
         if ((ParamCommand == pcNone) &&
         if ((ParamCommand == pcNone) &&
             (WinConfiguration->ExternalSessionInExistingInstance != OpenInNewWindow()) &&
             (WinConfiguration->ExternalSessionInExistingInstance != OpenInNewWindow()) &&