本文整理汇总了C++中Args类的典型用法代码示例。如果您正苦于以下问题:C++ Args类的具体用法?C++ Args怎么用?C++ Args使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Args类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DoExecute
virtual bool
DoExecute (Args& command, CommandReturnObject &result)
{
Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
if (!CheckTargetForWatchpointOperations(target, result))
return false;
Mutex::Locker locker;
target->GetWatchpointList().GetListMutex(locker);
const WatchpointList &watchpoints = target->GetWatchpointList();
size_t num_watchpoints = watchpoints.GetSize();
if (num_watchpoints == 0)
{
result.AppendError("No watchpoints exist to be disabled.");
result.SetStatus(eReturnStatusFailed);
return false;
}
if (command.GetArgumentCount() == 0)
{
// No watchpoint selected; disable all currently set watchpoints.
if (target->DisableAllWatchpoints())
{
result.AppendMessageWithFormat("All watchpoints disabled. (%" PRIu64 " watchpoints)\n", (uint64_t)num_watchpoints);
result.SetStatus(eReturnStatusSuccessFinishNoResult);
}
else
{
result.AppendError("Disable all watchpoints failed\n");
result.SetStatus(eReturnStatusFailed);
}
}
else
{
// Particular watchpoints selected; disable them.
std::vector<uint32_t> wp_ids;
if (!CommandObjectMultiwordWatchpoint::VerifyWatchpointIDs(target, command, wp_ids))
{
result.AppendError("Invalid watchpoints specification.");
result.SetStatus(eReturnStatusFailed);
return false;
}
int count = 0;
const size_t size = wp_ids.size();
for (size_t i = 0; i < size; ++i)
if (target->DisableWatchpointByID(wp_ids[i]))
++count;
result.AppendMessageWithFormat("%d watchpoints disabled.\n", count);
result.SetStatus(eReturnStatusSuccessFinishNoResult);
}
return result.Succeeded();
}
示例2: DoExecute
virtual bool
DoExecute (Args& command, CommandReturnObject &result)
{
Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
if (!CheckTargetForWatchpointOperations(target, result))
return false;
Mutex::Locker locker;
target->GetWatchpointList().GetListMutex(locker);
const WatchpointList &watchpoints = target->GetWatchpointList();
size_t num_watchpoints = watchpoints.GetSize();
if (num_watchpoints == 0)
{
result.AppendError("No watchpoints exist to be deleted.");
result.SetStatus(eReturnStatusFailed);
return false;
}
if (command.GetArgumentCount() == 0)
{
if (!m_interpreter.Confirm("About to delete all watchpoints, do you want to do that?", true))
{
result.AppendMessage("Operation cancelled...");
}
else
{
target->RemoveAllWatchpoints();
result.AppendMessageWithFormat("All watchpoints removed. (%lu watchpoints)\n", num_watchpoints);
}
result.SetStatus (eReturnStatusSuccessFinishNoResult);
}
else
{
// Particular watchpoints selected; delete them.
std::vector<uint32_t> wp_ids;
if (!CommandObjectMultiwordWatchpoint::VerifyWatchpointIDs(command, wp_ids))
{
result.AppendError("Invalid watchpoints specification.");
result.SetStatus(eReturnStatusFailed);
return false;
}
int count = 0;
const size_t size = wp_ids.size();
for (size_t i = 0; i < size; ++i)
if (target->RemoveWatchpointByID(wp_ids[i]))
++count;
result.AppendMessageWithFormat("%d watchpoints deleted.\n",count);
result.SetStatus (eReturnStatusSuccessFinishNoResult);
}
return result.Succeeded();
}
示例3: Execute
virtual bool
Execute (CommandInterpreter &interpreter,
Args& args,
CommandReturnObject &result)
{
const size_t argc = args.GetArgumentCount();
if (argc == 0)
{
Log::ListAllLogChannels (&result.GetOutputStream());
result.SetStatus(eReturnStatusSuccessFinishResult);
}
else
{
for (size_t i=0; i<argc; ++i)
{
Log::Callbacks log_callbacks;
std::string channel(args.GetArgumentAtIndex(i));
if (Log::GetLogChannelCallbacks (channel.c_str(), log_callbacks))
{
log_callbacks.list_categories (&result.GetOutputStream());
result.SetStatus(eReturnStatusSuccessFinishResult);
}
else if (channel == "all")
{
Log::ListAllLogChannels (&result.GetOutputStream());
result.SetStatus(eReturnStatusSuccessFinishResult);
}
else
{
LogChannelSP log_channel_sp (GetLogChannelPluginForChannel(channel.c_str()));
if (log_channel_sp)
{
log_channel_sp->ListCategories(&result.GetOutputStream());
result.SetStatus(eReturnStatusSuccessFinishNoResult);
}
else
result.AppendErrorWithFormat("Invalid log channel '%s'.\n", args.GetArgumentAtIndex(0));
}
}
}
return result.Succeeded();
}
示例4: installTestMCF
void InternalLink::installTestMCF(DesuraId id, Args args)
{
std::string branch = args.getArgValue("branch");
std::string build = args.getArgValue("build");
MCFBranch iBranch;
MCFBuild iBuild ;
if (branch.size() > 0)
iBranch = MCFBranch::BranchFromInt(Safe::atoi(branch.c_str()));
if (build.size() > 0)
iBuild = MCFBuild::BuildFromInt(Safe::atoi(build.c_str()));
UI::Forms::ItemForm* form = showItemForm(id, UI::Forms::INSTALL_ACTION::IA_INSTALL_TESTMCF, iBranch, iBuild);
if (!form)
Warning(gcString("Cant find item (or item not ready) for install test mcf [{0}].\n", id.toInt64()));
}
示例5: Unwind
UnwindLLDB::UnwindLLDB (Thread &thread) :
Unwind (thread),
m_frames(),
m_unwind_complete(false),
m_user_supplied_trap_handler_functions()
{
ProcessSP process_sp(thread.GetProcess());
if (process_sp)
{
Args args;
process_sp->GetTarget().GetUserSpecifiedTrapHandlerNames (args);
size_t count = args.GetArgumentCount();
for (size_t i = 0; i < count; i++)
{
const char *func_name = args.GetArgumentAtIndex(i);
m_user_supplied_trap_handler_functions.push_back (ConstString (func_name));
}
}
}
示例6: ConnectRemote
Status PlatformAndroidRemoteGDBServer::ConnectRemote(Args &args) {
m_device_id.clear();
if (args.GetArgumentCount() != 1)
return Status(
"\"platform connect\" takes a single argument: <connect-url>");
int remote_port;
llvm::StringRef scheme, host, path;
const char *url = args.GetArgumentAtIndex(0);
if (!url)
return Status("URL is null.");
if (!UriParser::Parse(url, scheme, host, remote_port, path))
return Status("Invalid URL: %s", url);
if (host != "localhost")
m_device_id = host;
m_socket_namespace.reset();
if (scheme == ConnectionFileDescriptor::UNIX_CONNECT_SCHEME)
m_socket_namespace = AdbClient::UnixSocketNamespaceFileSystem;
else if (scheme == ConnectionFileDescriptor::UNIX_ABSTRACT_CONNECT_SCHEME)
m_socket_namespace = AdbClient::UnixSocketNamespaceAbstract;
std::string connect_url;
auto error =
MakeConnectURL(g_remote_platform_pid, (remote_port < 0) ? 0 : remote_port,
path, connect_url);
if (error.Fail())
return error;
args.ReplaceArgumentAtIndex(0, connect_url);
Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PLATFORM));
if (log)
log->Printf("Rewritten platform connect URL: %s", connect_url.c_str());
error = PlatformRemoteGDBServer::ConnectRemote(args);
if (error.Fail())
DeleteForwardPort(g_remote_platform_pid);
return error;
}
示例7: main
int main(int argc, char** argv) {
try {
Args args;
if (argc < 2)
args.printHelp();
args = Args::read(argc, argv);
if (args.help_showed)
return -1;
App app(args);
app.run();
} catch (const Exception& e) {
return cout << "error: " << e.what() << endl, 1;
} catch (const exception& e) {
return cout << "error: " << e.what() << endl, 1;
} catch (...) {
return cout << "unknown exception" << endl, 1;
}
return 0;
}
示例8: DoExecute
virtual bool
DoExecute (Args& command, CommandReturnObject &result)
{
SBCommandReturnObject sb_return(&result);
SBCommandInterpreter sb_interpreter(&m_interpreter);
SBDebugger debugger_sb(m_interpreter.GetDebugger().shared_from_this());
bool ret = m_backend->DoExecute (debugger_sb,(char**)command.GetArgumentVector(), sb_return);
sb_return.Release();
return ret;
}
示例9: logArgs2String
std::string logArgs2String(const Args &args)
{
std::string message;
for (int i = 0; i < args.Length(); i++) {
::v8::HandleScope scope;
::v8::String::Utf8Value str(args[i]);
message += *str;
}
return message;
}
示例10: CalculateLocationPriorProbs
/*******************************************************************
* Function Name: CalculateLocationPriorProbs
* Return Type : ProbImg
* Created On : Jul 15, 2013
* Created By : hrushi
* Comments : Calculates the prior probability of an
* Arguments : const vector<ProbImg>& vPrbImgs, const Args& args
*******************************************************************/
int PriorProb::CalculateLocationPriorProbs( const vector<ProbImg>& vPrbImgs, const Args& args )
{
ProbImg CombinedProbImg = vPrbImgs.at(0) + vPrbImgs.at(1);
CombinedProbImg = CombinedProbImg + vPrbImgs.at(2);
m_LocationPriorProb = CombinedProbImg;
m_LocationPriorProb.Display(DISP_DELAY);
string FolderPath = args.GetTrainFolderPath();
if( FolderPath.length() == 0 )
{
FolderPath = args.GetSearchFolderPath();
}
const string ImgPath = FolderPath + LOC_PRIOR_PROB_IMGNAME;
m_LocationPriorProb.SetImagePath(ImgPath);
m_LocationPriorProb.Write( ImgPath );
return EXIT_SUCCESS;
}
示例11: GetOptions
bool
CommandObject::ParseOptions
(
CommandInterpreter &interpreter,
Args& args,
CommandReturnObject &result
)
{
// See if the subclass has options?
Options *options = GetOptions();
if (options != NULL)
{
Error error;
options->ResetOptionValues();
// ParseOptions calls getopt_long, which always skips the zero'th item in the array and starts at position 1,
// so we need to push a dummy value into position zero.
args.Unshift("dummy_string");
error = args.ParseOptions (*options);
// The "dummy_string" will have already been removed by ParseOptions,
// so no need to remove it.
if (error.Fail() || !options->VerifyOptions (result))
{
const char *error_cstr = error.AsCString();
if (error_cstr)
{
// We got an error string, lets use that
result.GetErrorStream().PutCString(error_cstr);
}
else
{
// No error string, output the usage information into result
options->GenerateOptionUsage (result.GetErrorStream(), this);
}
// Set the return status to failed (this was an error).
result.SetStatus (eReturnStatusFailed);
return false;
}
}
return true;
}
示例12: ProgInstance
integer ServiceApp::start(const Args & args)
{
StdError serr;
if (args.length() < 3) return onCommandLineError(args);
try {
appname = args[0];
String instanceName = args[1];
if (instanceName == defaultInstanceName) instanceName = getDefaultInstanceName(appname);
StringA command = String::getUtf8(args[2]);;
instance = ProgInstance(instanceName);
Args rmargs(const_cast<ConstStrW *>(args.data()+3),args.length()-3);
stopCommand = false;
return startCommand(command,rmargs,serr);
} catch (...) {
return onStartError(serr);
}
}
示例13: DoExecute
virtual bool
DoExecute (Args& command, CommandReturnObject &result)
{
Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
if (!CheckTargetForWatchpointOperations(target, result))
return false;
Mutex::Locker locker;
target->GetWatchpointList().GetListMutex(locker);
const WatchpointList &watchpoints = target->GetWatchpointList();
size_t num_watchpoints = watchpoints.GetSize();
if (num_watchpoints == 0)
{
result.AppendError("No watchpoints exist to be modified.");
result.SetStatus(eReturnStatusFailed);
return false;
}
if (command.GetArgumentCount() == 0)
{
WatchpointSP wp_sp = target->GetLastCreatedWatchpoint();
wp_sp->SetCondition(m_options.m_condition.c_str());
result.SetStatus (eReturnStatusSuccessFinishNoResult);
}
else
{
// Particular watchpoints selected; set condition on them.
std::vector<uint32_t> wp_ids;
if (!CommandObjectMultiwordWatchpoint::VerifyWatchpointIDs(target, command, wp_ids))
{
result.AppendError("Invalid watchpoints specification.");
result.SetStatus(eReturnStatusFailed);
return false;
}
int count = 0;
const size_t size = wp_ids.size();
for (size_t i = 0; i < size; ++i)
{
WatchpointSP wp_sp = watchpoints.FindByID(wp_ids[i]);
if (wp_sp)
{
wp_sp->SetCondition(m_options.m_condition.c_str());
++count;
}
}
result.AppendMessageWithFormat("%d watchpoints modified.\n",count);
result.SetStatus (eReturnStatusSuccessFinishNoResult);
}
return result.Succeeded();
}
示例14: if
bool
LogChannelDWARF::Enable
(
StreamSP &log_stream_sp,
uint32_t log_options,
Stream *feedback_strm, // Feedback stream for argument errors etc
const Args &categories // The categories to enable within this logging stream, if empty, enable default set
)
{
Delete ();
m_log_sp.reset(new Log (log_stream_sp));
g_log_channel = this;
uint32_t flag_bits = 0;
bool got_unknown_category = false;
const size_t argc = categories.GetArgumentCount();
for (size_t i=0; i<argc; ++i)
{
const char *arg = categories.GetArgumentAtIndex(i);
if (::strcasecmp (arg, "all") == 0 ) flag_bits |= DWARF_LOG_ALL;
else if (::strcasecmp (arg, "info") == 0 ) flag_bits |= DWARF_LOG_DEBUG_INFO;
else if (::strcasecmp (arg, "line") == 0 ) flag_bits |= DWARF_LOG_DEBUG_LINE;
else if (::strcasecmp (arg, "pubnames") == 0 ) flag_bits |= DWARF_LOG_DEBUG_PUBNAMES;
else if (::strcasecmp (arg, "pubtypes") == 0 ) flag_bits |= DWARF_LOG_DEBUG_PUBTYPES;
else if (::strcasecmp (arg, "default") == 0 ) flag_bits |= DWARF_LOG_DEFAULT;
else
{
feedback_strm->Printf("error: unrecognized log category '%s'\n", arg);
if (got_unknown_category == false)
{
got_unknown_category = true;
ListCategories (feedback_strm);
}
}
}
if (flag_bits == 0)
flag_bits = DWARF_LOG_DEFAULT;
m_log_sp->GetMask().Reset(flag_bits);
m_log_sp->GetOptions().Reset(log_options);
return m_log_sp.get() != NULL;
}
示例15: verifyItem
void InternalLink::verifyItem(DesuraId id, Args args)
{
bool showForm = args.getArgValue("show") != "false";
UI::Forms::ItemForm* form = showItemForm(id, UI::Forms::INSTALL_ACTION::IA_VERIFY, showForm);
if (!form)
Warning(gcString("Cant find item (or item not ready) for verify [{0}].\n", id.toInt64()));
else if (showForm == false)
form->Show(false);
}