#pragma hdrstop
#endif
+#if wxUSE_CMDLINE_PARSER
+
#ifndef WX_PRECOMP
#include "wx/string.h"
#include "wx/log.h"
wxCmdLineParamType typ,
int fl)
{
+ wxASSERT_MSG( !shrt.empty() || !lng.empty(),
+ _T("option should have at least one name") );
+
kind = k;
shortName = shrt;
// methods
wxCmdLineParserData();
- void SetArguments(int argc, char **argv);
+ void SetArguments(int argc, wxChar **argv);
void SetArguments(const wxString& cmdline);
int FindOption(const wxString& name);
#endif
}
-void wxCmdLineParserData::SetArguments(int argc, char **argv)
+void wxCmdLineParserData::SetArguments(int argc, wxChar **argv)
{
m_arguments.Empty();
int wxCmdLineParserData::FindOption(const wxString& name)
{
- size_t count = m_options.GetCount();
- for ( size_t n = 0; n < count; n++ )
+ if ( !name.empty() )
{
- if ( m_options[n].shortName == name )
+ size_t count = m_options.GetCount();
+ for ( size_t n = 0; n < count; n++ )
{
- // found
- return n;
+ if ( m_options[n].shortName == name )
+ {
+ // found
+ return n;
+ }
}
}
m_data = new wxCmdLineParserData;
}
-void wxCmdLineParser::SetCmdLine(int argc, char **argv)
+void wxCmdLineParser::SetCmdLine(int argc, wxChar **argv)
{
m_data->SetArguments(argc, argv);
}
bool wxCmdLineParser::Found(const wxString& name) const
{
int i = m_data->FindOption(name);
+ if ( i == wxNOT_FOUND )
+ i = m_data->FindOptionByLongName(name);
+
wxCHECK_MSG( i != wxNOT_FOUND, FALSE, _T("unknown switch") );
wxCmdLineOption& opt = m_data->m_options[(size_t)i];
bool wxCmdLineParser::Found(const wxString& name, wxString *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];
bool wxCmdLineParser::Found(const wxString& name, long *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];
bool wxCmdLineParser::Found(const wxString& name, wxDateTime *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];
// Resets switches and options
void wxCmdLineParser::Reset()
{
- unsigned int i;
- for (i = 0; i < m_data->m_options.Count(); i++)
- {
- wxCmdLineOption& opt = m_data->m_options[(size_t)i];
- opt.SetHasValue(FALSE);
- }
+ for ( size_t i = 0; i < m_data->m_options.Count(); i++ )
+ {
+ wxCmdLineOption& opt = m_data->m_options[i];
+ opt.SetHasValue(FALSE);
+ }
}
size_t countParam = m_data->m_paramDesc.GetCount();
- Reset();
+ Reset();
// parse everything
wxString arg;
return s;
}
+
+#endif // wxUSE_CMDLINE_PARSER