本文整理汇总了C++中wxCmdLineParser::Parse方法的典型用法代码示例。如果您正苦于以下问题:C++ wxCmdLineParser::Parse方法的具体用法?C++ wxCmdLineParser::Parse怎么用?C++ wxCmdLineParser::Parse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wxCmdLineParser
的用法示例。
在下文中一共展示了wxCmdLineParser::Parse方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnCmdLineParsed
bool DolphinApp::OnCmdLineParsed(wxCmdLineParser& parser)
{
if (argc == 2 && File::Exists(argv[1].ToUTF8().data()))
{
m_load_file = true;
m_file_to_load = argv[1];
}
else if (parser.Parse() != 0)
{
return false;
}
if (!m_load_file)
m_load_file = parser.Found("exec", &m_file_to_load);
m_use_debugger = parser.Found("debugger");
m_use_logger = parser.Found("logger");
m_batch_mode = parser.Found("batch");
m_confirm_stop = parser.Found("confirm", &m_confirm_setting);
m_select_video_backend = parser.Found("video_backend", &m_video_backend_name);
m_select_audio_emulation = parser.Found("audio_emulation", &m_audio_emulation_name);
m_play_movie = parser.Found("movie", &m_movie_file);
parser.Found("user", &m_user_path);
return true;
}
示例2: OnCmdLineParsed
//! @brief parses the command line and sets global app options like log verbosity or log target
bool SpringLobbyApp::OnCmdLineParsed(wxCmdLineParser& parser)
{
if (!parser.Parse(true)) {
m_log_console = parser.Found(_T("console-logging"));
m_log_window_show = parser.Found(_T("gui-logging"));
m_crash_handle_disable = parser.Found(_T("no-crash-handler"));
parser.Found(_T("log-verbosity"), &m_log_verbosity);
// TODO make sure this is called before settings are accessed
wxString config;
const bool userconfig = parser.Found(_T("config-file"), &config);
if (userconfig) {
wxFileName fn(config);
if (!fn.IsAbsolute()) {
wxLogError(_T("path for parameter \"config-file\" must be absolute"));
return false;
}
if (!fn.IsFileWritable()) {
wxLogError(_T("path for parameter \"config-file\" must be writeable"));
return false;
}
SlPaths::SetUserConfigPath(STD_STRING(config));
}
if (parser.Found(_T("help")))
return false; // not a syntax error, but program should stop if user asked for command line usage
if (parser.Found(_T("version"))) {
wxLogMessage(TowxString(GetSpringlobbyVersion()).c_str());
return false;
}
return true;
} else {
return false;
}
}
示例3: OnInitCmdLine
void RaceAnalyzerApp::OnInitCmdLine(wxCmdLineParser& parser){
parser.AddParam("",wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL);
parser.Parse(false);
if (parser.GetParamCount() > 0){
wxString mjljConfigFile = parser.GetParam(0);
_mainFrame->OpenRaceEvent(mjljConfigFile);
}
}
示例4: OnCmdLineParsed
bool MyApp::OnCmdLineParsed(wxCmdLineParser& parser)
{
parser.Parse();
long value;
if(parser.Found(wxT("WID"), &value)){
wxMessageBox(wxString::Format("%d\n",value));
}
return true;
}
示例5: testIsCmdLineSwitch
void testIsCmdLineSwitch()
{
parser->SetDesc(getCmdlineEntryDesc());
wxString cmdLine("test -v");
parser->SetCmdLine(cmdLine);
parser->Parse();
TS_ASSERT_EQUALS(parser->FoundSwitch("v"),wxCMD_SWITCH_ON);
#if defined WIN32
cmdLine = "test /v";
parser->SetCmdLine(cmdLine);
parser->Parse();
TS_ASSERT_EQUALS(parser->FoundSwitch("v"),wxCMD_SWITCH_ON);
#endif
cmdLine = "test v";
parser->SetCmdLine(cmdLine);
parser->Parse();
TS_ASSERT_EQUALS(parser->FoundSwitch("v"),wxCMD_SWITCH_NOT_FOUND);
TS_ASSERT_EQUALS(parser->GetParam(1),"v");
//TS_ASSERT_EQUALS(isCmdLineSwitch("-v"),true);
//TS_ASSERT_EQUALS(isCmdLineSwitch("-i"),true);
//TS_ASSERT_EQUALS(isCmdLineSwitch("-l"),true);
//TS_ASSERT_EQUALS(isCmdLineSwitch("-a"),true);
//TS_ASSERT_EQUALS(isCmdLineSwitch("-del"),true);
//TS_ASSERT_EQUALS(isCmdLineSwitch("--verbose"),true);
//TS_ASSERT_EQUALS(isCmdLineSwitch("--interactive"),true);
//TS_ASSERT_EQUALS(isCmdLineSwitch("--list"),true);
//TS_ASSERT_EQUALS(isCmdLineSwitch("--add"),true);
//TS_ASSERT_EQUALS(isCmdLineSwitch("--del"),true);
//TS_ASSERT_EQUALS(isCmdLineSwitch(""),false);
//TS_ASSERT_EQUALS(isCmdLineSwitch("/a"),false);
//TS_ASSERT_EQUALS(isCmdLineSwitch("-z"),false);
//TS_ASSERT_EQUALS(isCmdLineSwitch("--z"),false);
}
示例6: Process
bool Process(wxCmdLineParser& parser)
{
parser.Parse();
// long process_id (wxNOT_FOUND);
wxString exe_name(wxEmptyString);
//We got a command to close eTrigger
// parser.Found(wxT("pid"), &process_id);
parser.Found(wxT("name"), &exe_name);
if ( /*process_id == wxNOT_FOUND || */exe_name.IsEmpty() ) {
PrintUsage();
return false;
}
// Kill the process
// if (wxProcess::Exists(process_id)) {
//
// //Okay, then let's close parent.exe
// int killError = wxProcess::Kill(process_id, wxSIGTERM);
// if (killError) {
// if (killError == wxKILL_BAD_SIGNAL) {
// wxPrintf(wxT("wxProcess::Kill Error: no such signal\n"));
// return true;
// }
// if (killError == wxKILL_ACCESS_DENIED) {
// wxPrintf(wxT("wxProcess::Kill Error: permission denied\n"));
// return true;
// }
// if (killError == wxKILL_NO_PROCESS) {
// wxPrintf(wxT("wxProcess::Kill Error: no such process\n"));
// return true;
// }
// if (killError == wxKILL_ERROR) {
// wxPrintf(wxT("An Error occurred attempting to close parent.exe, the helper will now attempt to forcefully close %s\n"), exe_name.c_str());
// int killError2 = wxProcess::Kill(process_id, wxSIGKILL);
// if (killError2) {
// wxPrintf(wxT("The Helper could not close %s\n"), exe_name.c_str());
// return true;
// }
// }
// }
// } else {
// wxPrintf(wxT("Error: process %d does not exist\n"), process_id);
// }
// Now let's open the parent
wxProcess proc;
wxSleep( 3 );
proc.Open(wxString::Format(wxT("%s"), exe_name.c_str()), wxEXEC_ASYNC | wxEXEC_NOHIDE);
proc.Detach();
}
示例7: OnCmdLineParsed
//! @brief parses the command line and sets global app options like log verbosity or log target
bool SpringLobbyApp::OnCmdLineParsed(wxCmdLineParser& parser)
{
#if wxUSE_CMDLINE_PARSER
if ( !parser.Parse(true) )
{
m_log_console = parser.Found(_T("console-logging"));
m_log_window_show = parser.Found(_T("gui-logging"));
m_log_file = parser.Found(_T("file-logging"), &m_log_file_path);
m_crash_handle_disable = parser.Found(_T("no-crash-handler"));
m_start_simple_interface = parser.Found(_T("simple"));
Settings::m_user_defined_config = parser.Found( _T("config-file"), &Settings::m_user_defined_config_path );
if ( Settings::m_user_defined_config ) {
wxFileName fn ( Settings::m_user_defined_config_path );
if ( ! fn.IsAbsolute() ) {
wxLogError ( _T("path for parameter \"config-file\" must be absolute") );
return false;
}
if ( ! fn.IsFileWritable() ) {
wxLogError ( _T("path for parameter \"config-file\" must be writeable") );
return false;
}
}
if ( !parser.Found(_T("log-verbosity"), &m_log_verbosity ) )
m_log_verbosity = m_log_window_show ? 3 : 5;
if ( !parser.Found(_T("customize"), &m_customizer_modname ) )
m_customizer_modname = _T("");
if ( !parser.Found(_T("name"), &m_appname ) )
m_appname = _T("SpringLobby");
if ( parser.Found(_T("help")) )
return false; // not a syntax error, but program should stop if user asked for command line usage
return true;
}
else
{
return false;
}
#else // wxUSE_CMDLINE_PARSER
return true;
#endif
}
示例8: OnCmdLineParsed
//! @brief parses the command line and sets global app options like log verbosity or log target
bool Springsettings::OnCmdLineParsed(wxCmdLineParser& parser)
{
// #if wxUSE_CMDLINE_PARSER
if ( !parser.Parse(true) )
{
#if wxUSE_STD_IOSTREAM
m_log_console = parser.Found(_T("console-logging"));
#endif
m_log_file = parser.Found(_T("file-logging"), &m_log_file_path);
m_log_window_show = parser.Found(_T("gui-logging"));
m_crash_handle_disable = parser.Found(_T("no-crash-handler"));
wxString config;;
const bool userconfig = parser.Found( _T("config-file"), &config);
if ( userconfig ) {
wxFileName fn ( config );
if ( ! fn.IsAbsolute() ) {
wxLogError ( _T("path for parameter \"config-file\" must be absolute") );
return false;
}
if ( ! fn.IsFileWritable() ) {
wxLogError ( _T("path for parameter \"config-file\" must be writeable") );
return false;
}
SlPaths::SetUserConfigPath(STD_STRING(config));
}
if ( !parser.Found(_T("log-verbosity"), &m_log_verbosity ) )
m_log_verbosity = m_log_window_show ? 3 : 5;
return true;
}
else
{
return false;
}
// #else // wxUSE_CMDLINE_PARSER
return true;
// #endif
}
示例9: OnCmdLineParsed
//! @brief parses the command line and sets global app options like log verbosity or log target
bool Springsettings::OnCmdLineParsed(wxCmdLineParser& parser)
{
#if wxUSE_CMDLINE_PARSER
if ( !parser.Parse(true) )
{
#if wxUSE_STD_IOSTREAM
m_log_console = parser.Found(_T("console-logging"));
#endif
m_log_file = parser.Found(_T("file-logging"), &m_log_file_path);
m_log_window_show = parser.Found(_T("gui-logging"));
m_crash_handle_disable = parser.Found(_T("no-crash-handler"));
slConfig::m_user_defined_config = parser.Found( _T("config-file"), &slConfig::m_user_defined_config_path );
if ( slConfig::m_user_defined_config ) {
wxFileName fn ( slConfig::m_user_defined_config_path );
if ( ! fn.IsAbsolute() ) {
wxLogError ( _T("path for parameter \"config-file\" must be absolute") );
return false;
}
if ( ! fn.IsFileWritable() ) {
wxLogError ( _T("path for parameter \"config-file\" must be writeable") );
return false;
}
}
if ( !parser.Found(_T("log-verbosity"), &m_log_verbosity ) )
m_log_verbosity = m_log_window_show ? 3 : 5;
return true;
}
else
{
return false;
}
#else // wxUSE_CMDLINE_PARSER
return true;
#endif
}
示例10: tokenizer
CommandLineInterface::CommandLineInterface (wxCmdLineParser &parser, UserInterfaceType::Enum interfaceType) :
ArgCommand (CommandId::None),
ArgFilesystem (VolumeCreationOptions::FilesystemType::Unknown),
ArgNoHiddenVolumeProtection (false),
ArgSize (0),
ArgVolumeType (VolumeType::Unknown),
StartBackgroundTask (false)
{
parser.SetSwitchChars (L"-");
parser.AddOption (L"", L"auto-mount", _("Auto mount device-hosted/favorite volumes"));
parser.AddSwitch (L"", L"backup-headers", _("Backup volume headers"));
parser.AddSwitch (L"", L"background-task", _("Start Background Task"));
#ifdef TC_WINDOWS
parser.AddSwitch (L"", L"cache", _("Cache passwords and keyfiles"));
#endif
parser.AddSwitch (L"C", L"change", _("Change password or keyfiles"));
parser.AddSwitch (L"c", L"create", _("Create new volume"));
parser.AddSwitch (L"", L"create-keyfile", _("Create new keyfile"));
parser.AddSwitch (L"", L"delete-token-keyfiles", _("Delete security token keyfiles"));
parser.AddSwitch (L"d", L"dismount", _("Dismount volume"));
parser.AddSwitch (L"", L"display-password", _("Display password while typing"));
parser.AddOption (L"", L"encryption", _("Encryption algorithm"));
parser.AddSwitch (L"", L"explore", _("Open explorer window for mounted volume"));
parser.AddSwitch (L"", L"export-token-keyfile",_("Export keyfile from security token"));
parser.AddOption (L"", L"filesystem", _("Filesystem type"));
parser.AddSwitch (L"f", L"force", _("Force mount/dismount/overwrite"));
#if !defined(TC_WINDOWS) && !defined(TC_MACOSX)
parser.AddOption (L"", L"fs-options", _("Filesystem mount options"));
#endif
parser.AddOption (L"", L"hash", _("Hash algorithm"));
parser.AddSwitch (L"h", L"help", _("Display detailed command line help"), wxCMD_LINE_OPTION_HELP);
parser.AddSwitch (L"", L"import-token-keyfiles", _("Import keyfiles to security token"));
parser.AddOption (L"k", L"keyfiles", _("Keyfiles"));
parser.AddSwitch (L"l", L"list", _("List mounted volumes"));
parser.AddSwitch (L"", L"list-token-keyfiles", _("List security token keyfiles"));
parser.AddSwitch (L"", L"load-preferences", _("Load user preferences"));
parser.AddSwitch (L"", L"mount", _("Mount volume interactively"));
parser.AddOption (L"m", L"mount-options", _("TrueCrypt volume mount options"));
parser.AddOption (L"", L"new-keyfiles", _("New keyfiles"));
parser.AddOption (L"", L"new-password", _("New password"));
parser.AddSwitch (L"", L"non-interactive", _("Do not interact with user"));
parser.AddOption (L"p", L"password", _("Password"));
parser.AddOption (L"", L"protect-hidden", _("Protect hidden volume"));
parser.AddOption (L"", L"protection-keyfiles", _("Keyfiles for protected hidden volume"));
parser.AddOption (L"", L"protection-password", _("Password for protected hidden volume"));
parser.AddOption (L"", L"random-source", _("Use file as source of random data"));
parser.AddSwitch (L"", L"restore-headers", _("Restore volume headers"));
parser.AddSwitch (L"", L"save-preferences", _("Save user preferences"));
parser.AddSwitch (L"", L"quick", _("Enable quick format"));
parser.AddOption (L"", L"size", _("Size in bytes"));
parser.AddOption (L"", L"slot", _("Volume slot number"));
parser.AddSwitch (L"", L"test", _("Test internal algorithms"));
parser.AddSwitch (L"t", L"text", _("Use text user interface"));
parser.AddOption (L"", L"token-lib", _("Security token library"));
parser.AddSwitch (L"v", L"verbose", _("Enable verbose output"));
parser.AddSwitch (L"", L"version", _("Display version information"));
parser.AddSwitch (L"", L"volume-properties", _("Display volume properties"));
parser.AddOption (L"", L"volume-type", _("Volume type"));
parser.AddParam ( _("Volume path"), wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL);
parser.AddParam ( _("Mount point"), wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL);
wxString str;
bool param1IsVolume = false;
bool param1IsMountedVolumeSpec = false;
bool param1IsMountPoint = false;
bool param1IsFile = false;
if (parser.Parse () > 0)
throw_err (_("Incorrect command line specified."));
if (parser.Found (L"help"))
{
ArgCommand = CommandId::Help;
return;
}
if (parser.Found (L"text") && interfaceType != UserInterfaceType::Text)
{
wstring msg = wstring (_("Option -t or --text must be specified as the first argument."));
wcerr << msg << endl;
throw_err (msg);
}
if (parser.Found (L"version"))
{
ArgCommand = CommandId::DisplayVersion;
return;
}
// Preferences
if (parser.Found (L"load-preferences"))
{
// Load preferences first to allow command line options to override them
Preferences.Load();
ArgMountOptions = Preferences.DefaultMountOptions;
}
// Commands
if (parser.Found (L"auto-mount", &str))
//.........这里部分代码省略.........