///////////////////////////////////////////////////////////////////////////////
// ============================================================================
///////////////////////////////////////////////////////////////////////////////
// ============================================================================
GetLongOptionName(lng).Len() == lng.Len(),
wxT("Long option contains invalid characters")
);
GetLongOptionName(lng).Len() == lng.Len(),
wxT("Long option contains invalid characters")
);
{ Check(wxCMD_LINE_VAL_NUMBER); return m_longVal; }
const wxString& GetStrVal() const
{ Check(wxCMD_LINE_VAL_STRING); return m_strVal; }
{ Check(wxCMD_LINE_VAL_NUMBER); return m_longVal; }
const wxString& GetStrVal() const
{ Check(wxCMD_LINE_VAL_STRING); return m_strVal; }
void SetLongVal(long val)
{ Check(wxCMD_LINE_VAL_NUMBER); m_longVal = val; m_hasVal = TRUE; }
void SetStrVal(const wxString& val)
{ Check(wxCMD_LINE_VAL_STRING); m_strVal = val; m_hasVal = TRUE; }
void SetLongVal(long val)
{ Check(wxCMD_LINE_VAL_NUMBER); m_longVal = val; m_hasVal = TRUE; }
void SetStrVal(const wxString& val)
{ Check(wxCMD_LINE_VAL_STRING); m_strVal = val; m_hasVal = TRUE; }
void SetDateVal(const wxDateTime val)
{ Check(wxCMD_LINE_VAL_DATE); m_dateVal = val; m_hasVal = TRUE; }
void SetDateVal(const wxDateTime val)
{ Check(wxCMD_LINE_VAL_DATE); m_dateVal = val; m_hasVal = TRUE; }
void SetHasValue(bool hasValue = TRUE) { m_hasVal = hasValue; }
bool HasValue() const { return m_hasVal; }
void SetHasValue(bool hasValue = TRUE) { m_hasVal = hasValue; }
bool HasValue() const { return m_hasVal; }
bool wxCmdLineParser::Found(const wxString& name, wxDateTime *value) const
{
int i = m_data->FindOption(name);
bool wxCmdLineParser::Found(const wxString& name, wxDateTime *value) const
{
int i = m_data->FindOption(name);
- errorMsg << wxString::Format(_("Option '%s' requires a value, '=' expected."), name.c_str()) << "\n";
+ errorMsg << wxString::Format(_("Option '%s' requires a value, '=' expected."), name.c_str()) << wxT("\n");
if ( opt.flags & wxCMD_LINE_NEEDS_SEPARATOR )
{
errorMsg << wxString::Format(_("Separator expected after the option '%s'."),
if ( opt.flags & wxCMD_LINE_NEEDS_SEPARATOR )
{
errorMsg << wxString::Format(_("Separator expected after the option '%s'."),
if ( !(param.flags & wxCMD_LINE_PARAM_OPTIONAL) )
{
errorMsg << wxString::Format(_("The required parameter '%s' was not specified."),
if ( !(param.flags & wxCMD_LINE_PARAM_OPTIONAL) )
{
errorMsg << wxString::Format(_("The required parameter '%s' was not specified."),
- if ( !ok && (errorMsg.length() != 0 || helpRequested) )
+ // if there was an error during parsing the command line, show this error
+ // and also the usage message if it had been requested
+ if ( !ok && (!errorMsg.empty() || (helpRequested && showUsage)) )
- case wxCMD_LINE_VAL_STRING: s = _("str"); break;
- case wxCMD_LINE_VAL_NUMBER: s = _("num"); break;
- case wxCMD_LINE_VAL_DATE: s = _("date"); break;
+ case wxCMD_LINE_VAL_STRING:
+ s = _("str");
+ break;
+
+ case wxCMD_LINE_VAL_NUMBER:
+ s = _("num");
+ break;
+
+ case wxCMD_LINE_VAL_DATE:
+ s = _("date");
+ break;
myprog.exe foo bar -> argc = 3, argv[1] = "foo", argv[2] = "bar"
myprog.exe "foo bar" -> argc = 2, argv[1] = "foo bar"
myprog.exe foo bar -> argc = 3, argv[1] = "foo", argv[2] = "bar"
myprog.exe "foo bar" -> argc = 2, argv[1] = "foo bar"