- Added wxMessageQueue class for inter-thread communications
- Use UTF-8 for Unicode data in wxIPC classes (Anders Larsen)
- Added support for user-defined types to wxConfig (Marcin Wojdyr).
+- Added numeric options support to wxCmdLineParser (crjjrc)
- Added wxJoin() and wxSplit() functions (Francesco Montorsi).
- Added wxDateTime::FormatISOCombined() and ParseISODate/Time/Combined()
- Added wxMutex::LockTimeout() (Aleksandr Napylov).
wxCMD_LINE_VAL_STRING, // should be 0 (default)
wxCMD_LINE_VAL_NUMBER,
wxCMD_LINE_VAL_DATE,
+ wxCMD_LINE_VAL_DOUBLE,
wxCMD_LINE_VAL_NONE
};
// the value in the provided pointer
bool Found(const wxString& name, long *value) const;
+ // returns true if an option taking a double value was found and stores
+ // the value in the provided pointer
+ bool Found(const wxString& name, double *value) const;
+
#if wxUSE_DATETIME
// returns true if an option taking a date value was found and stores the
// value in the provided pointer
value in the provided pointer (which should not be @NULL).
*/
bool Found(const wxString& name) const;
- const bool Found(const wxString& name, wxString* value) const;
- const bool Found(const wxString& name, long* value) const;
- const bool Found(const wxString& name, wxDateTime* value) const;
+ bool Found(const wxString& name, wxString* value) const;
+ bool Found(const wxString& name, long* value) const;
+ bool Found(const wxString& name, double* value) const;
+ bool Found(const wxString& name, wxDateTime* value) const;
//@}
/**
wxString strVal;
long lVal;
+ double dVal;
wxDateTime dt;
if ( parser.Found(_T("o"), &strVal) )
s << _T("Output file:\t") << strVal << '\n';
s << _T("Input dir:\t") << strVal << '\n';
if ( parser.Found(_T("s"), &lVal) )
s << _T("Size:\t") << lVal << '\n';
+ if ( parser.Found(_T("f"), &dVal) )
+ s << _T("Double:\t") << dVal << '\n';
if ( parser.Found(_T("d"), &dt) )
s << _T("Date:\t") << dt.FormatISODate() << '\n';
if ( parser.Found(_T("project_name"), &strVal) )
wxCMD_LINE_VAL_NUMBER },
{ wxCMD_LINE_OPTION, "d", "date", "output file date",
wxCMD_LINE_VAL_DATE },
+ { wxCMD_LINE_OPTION, "f", "double", "output double",
+ wxCMD_LINE_VAL_DOUBLE },
{ wxCMD_LINE_PARAM, NULL, NULL, "input file",
wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_MULTIPLE },
wxASSERT_MSG( type == typ, _T("type mismatch in wxCmdLineOption") );
}
+ double GetDoubleVal() const
+ { Check(wxCMD_LINE_VAL_DOUBLE); return m_doubleVal; }
long GetLongVal() const
{ Check(wxCMD_LINE_VAL_NUMBER); return m_longVal; }
const wxString& GetStrVal() const
{ Check(wxCMD_LINE_VAL_DATE); return m_dateVal; }
#endif // wxUSE_DATETIME
+ void SetDoubleVal(double val)
+ { Check(wxCMD_LINE_VAL_DOUBLE); m_doubleVal = val; m_hasVal = true; }
void SetLongVal(long val)
{ Check(wxCMD_LINE_VAL_NUMBER); m_longVal = val; m_hasVal = true; }
void SetStrVal(const wxString& val)
private:
bool m_hasVal;
+ double m_doubleVal;
long m_longVal;
wxString m_strVal;
#if wxUSE_DATETIME
return true;
}
+bool wxCmdLineParser::Found(const wxString& name, double *value) const
+{
+ int i = m_data->FindOption(name);
+ if ( i == wxNOT_FOUND )
+ i = m_data->FindOptionByLongName(name);
+
+ wxCHECK_MSG( i != wxNOT_FOUND, false, _T("unknown option") );
+
+ wxCmdLineOption& opt = m_data->m_options[(size_t)i];
+ if ( !opt.HasValue() )
+ return false;
+
+ wxCHECK_MSG( value, false, _T("NULL pointer in wxCmdLineOption::Found") );
+
+ *value = opt.GetDoubleVal();
+
+ return true;
+}
+
#if wxUSE_DATETIME
bool wxCmdLineParser::Found(const wxString& name, wxDateTime *value) const
{
}
break;
+ case wxCMD_LINE_VAL_DOUBLE:
+ {
+ double val;
+ if ( value.ToDouble(&val) )
+ {
+ opt.SetDoubleVal(val);
+ }
+ else
+ {
+ errorMsg << wxString::Format(_("'%s' is not a correct numeric value for option '%s'."),
+ value.c_str(), name.c_str())
+ << _T('\n');
+
+ ok = false;
+ }
+ }
+ break;
+
#if wxUSE_DATETIME
case wxCMD_LINE_VAL_DATE:
{
s = _("num");
break;
+ case wxCMD_LINE_VAL_DOUBLE:
+ s = _("double");
+ break;
+
case wxCMD_LINE_VAL_DATE:
s = _("date");
break;