Allow passing default value to Bench::GetXXXParameter()

Just an extra convenience for the benchmark functions.
This commit is contained in:
Vadim Zeitlin
2022-02-22 23:58:38 +00:00
parent 5847b302be
commit a8ec7eec0b
2 changed files with 8 additions and 6 deletions

View File

@@ -87,14 +87,16 @@ wxIMPLEMENT_APP_CONSOLE(BenchApp);
Bench::Function *Bench::Function::ms_head = NULL; Bench::Function *Bench::Function::ms_head = NULL;
long Bench::GetNumericParameter() long Bench::GetNumericParameter(long defVal)
{ {
return wxGetApp().GetNumericParameter(); const long val = wxGetApp().GetNumericParameter();
return val ? val : defVal;
} }
wxString Bench::GetStringParameter() wxString Bench::GetStringParameter(const wxString& defVal)
{ {
return wxGetApp().GetStringParameter(); const wxString& val = wxGetApp().GetStringParameter();
return !val.empty() ? val : defVal;
} }
// ============================================================================ // ============================================================================

View File

@@ -83,7 +83,7 @@ private:
Tests may use this parameter in whatever way they see fit, by default it is Tests may use this parameter in whatever way they see fit, by default it is
1 but can be set to a different value by user from the command line. 1 but can be set to a different value by user from the command line.
*/ */
long GetNumericParameter(); long GetNumericParameter(long defValue = 1);
/** /**
Get the string parameter. Get the string parameter.
@@ -91,7 +91,7 @@ long GetNumericParameter();
Tests may use this parameter in whatever way they see fit, by default it is Tests may use this parameter in whatever way they see fit, by default it is
empty but can be set to a different value by user from the command line. empty but can be set to a different value by user from the command line.
*/ */
wxString GetStringParameter(); wxString GetStringParameter(const wxString& defValue = wxString());
} // namespace Bench } // namespace Bench