本文整理汇总了C++中Args::Clear方法的典型用法代码示例。如果您正苦于以下问题:C++ Args::Clear方法的具体用法?C++ Args::Clear怎么用?C++ Args::Clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Args
的用法示例。
在下文中一共展示了Args::Clear方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetArgs
size_t OptionValueDictionary::GetArgs(Args &args) const {
args.Clear();
collection::const_iterator pos, end = m_values.end();
for (pos = m_values.begin(); pos != end; ++pos) {
StreamString strm;
strm.Printf("%s=", pos->first.GetCString());
pos->second->DumpValue(nullptr, strm, eDumpOptionValue | eDumpOptionRaw);
args.AppendArgument(strm.GetString());
}
return args.GetArgumentCount();
}
示例2: GetArgs
size_t OptionValueArray::GetArgs(Args &args) const {
args.Clear();
const uint32_t size = m_values.size();
for (uint32_t i = 0; i < size; ++i) {
llvm::StringRef string_value = m_values[i]->GetStringValue();
if (!string_value.empty())
args.AppendArgument(string_value);
}
return args.GetArgumentCount();
}
示例3: GetArgs
size_t OptionValueArray::GetArgs(Args &args) const {
const uint32_t size = m_values.size();
std::vector<const char *> argv;
for (uint32_t i = 0; i < size; ++i) {
const char *string_value = m_values[i]->GetStringValue();
if (string_value)
argv.push_back(string_value);
}
if (argv.empty())
args.Clear();
else
args.SetArguments(argv.size(), &argv[0]);
return args.GetArgumentCount();
}
示例4: if
void
BreakpointIDList::FindAndReplaceIDRanges (Args &old_args, Target *target, CommandReturnObject &result,
Args &new_args)
{
std::string range_start;
const char *range_end;
const char *current_arg;
const size_t num_old_args = old_args.GetArgumentCount();
for (size_t i = 0; i < num_old_args; ++i)
{
bool is_range = false;
current_arg = old_args.GetArgumentAtIndex (i);
uint32_t range_start_len = 0;
uint32_t range_end_pos = 0;
if (BreakpointIDList::StringContainsIDRangeExpression (current_arg, &range_start_len, &range_end_pos))
{
is_range = true;
range_start = (char *) malloc (range_start_len + 1);
range_start.assign (current_arg, range_start_len);
range_end = current_arg + range_end_pos;
}
else if ((i + 2 < num_old_args)
&& BreakpointID::IsRangeIdentifier (old_args.GetArgumentAtIndex (i+1))
&& BreakpointID::IsValidIDExpression (current_arg)
&& BreakpointID::IsValidIDExpression (old_args.GetArgumentAtIndex (i+2)))
{
range_start.assign (current_arg);
range_end = old_args.GetArgumentAtIndex (i+2);
is_range = true;
i = i+2;
}
if (is_range)
{
break_id_t start_bp_id;
break_id_t end_bp_id;
break_id_t start_loc_id;
break_id_t end_loc_id;
BreakpointID::ParseCanonicalReference (range_start.c_str(), &start_bp_id, &start_loc_id);
BreakpointID::ParseCanonicalReference (range_end, &end_bp_id, &end_loc_id);
if ((start_bp_id == LLDB_INVALID_BREAK_ID)
|| (! target->GetBreakpointByID (start_bp_id)))
{
new_args.Clear();
result.AppendErrorWithFormat ("'%s' is not a valid breakpoint ID.\n", range_start.c_str());
result.SetStatus (eReturnStatusFailed);
return;
}
if ((end_bp_id == LLDB_INVALID_BREAK_ID)
|| (! target->GetBreakpointByID (end_bp_id)))
{
new_args.Clear();
result.AppendErrorWithFormat ("'%s' is not a valid breakpoint ID.\n", range_end);
result.SetStatus (eReturnStatusFailed);
return;
}
// We have valid range starting & ending breakpoint IDs. Go through all the breakpoints in the
// target and find all the breakpoints that fit into this range, and add them to new_args.
const BreakpointList& breakpoints = target->GetBreakpointList();
const size_t num_breakpoints = breakpoints.GetSize();
for (size_t j = 0; j < num_breakpoints; ++j)
{
Breakpoint *breakpoint = breakpoints.GetBreakpointByIndex (j).get();
break_id_t cur_bp_id = breakpoint->GetID();
if ((cur_bp_id < start_bp_id) || (cur_bp_id > end_bp_id))
continue;
const size_t num_locations = breakpoint->GetNumLocations();
if ((cur_bp_id == start_bp_id) && (start_loc_id != LLDB_INVALID_BREAK_ID))
{
for (size_t k = 0; k < num_locations; ++k)
{
BreakpointLocation * bp_loc = breakpoint->GetLocationAtIndex(k).get();
if (bp_loc->GetID() >= start_loc_id)
{
StreamString canonical_id_str;
BreakpointID::GetCanonicalReference (&canonical_id_str, cur_bp_id, bp_loc->GetID());
new_args.AppendArgument (canonical_id_str.GetData());
}
}
}
else if ((cur_bp_id == end_bp_id) && (end_loc_id != LLDB_INVALID_BREAK_ID))
{
for (size_t k = 0; k < num_locations; ++k)
{
BreakpointLocation * bp_loc = breakpoint->GetLocationAtIndex(k).get();
if (bp_loc->GetID() <= end_loc_id)
{
StreamString canonical_id_str;
BreakpointID::GetCanonicalReference (&canonical_id_str, cur_bp_id, bp_loc->GetID());
new_args.AppendArgument (canonical_id_str.GetData());
//.........这里部分代码省略.........
示例5: new_args
void
CommandInterpreter::BuildAliasCommandArgs
(
CommandObject *alias_cmd_obj,
const char *alias_name,
Args &cmd_args,
CommandReturnObject &result
)
{
OptionArgVectorSP option_arg_vector_sp = GetAliasOptions (alias_name);
if (option_arg_vector_sp.get())
{
// Make sure that the alias name is the 0th element in cmd_args
std::string alias_name_str = alias_name;
if (alias_name_str.compare (cmd_args.GetArgumentAtIndex(0)) != 0)
cmd_args.Unshift (alias_name);
Args new_args (alias_cmd_obj->GetCommandName());
if (new_args.GetArgumentCount() == 2)
new_args.Shift();
OptionArgVector *option_arg_vector = option_arg_vector_sp.get();
int old_size = cmd_args.GetArgumentCount();
int *used = (int *) malloc ((old_size + 1) * sizeof (int));
memset (used, 0, (old_size + 1) * sizeof (int));
used[0] = 1;
for (int i = 0; i < option_arg_vector->size(); ++i)
{
OptionArgPair option_pair = (*option_arg_vector)[i];
std::string option = option_pair.first;
std::string value = option_pair.second;
if (option.compare ("<argument>") == 0)
new_args.AppendArgument (value.c_str());
else
{
new_args.AppendArgument (option.c_str());
if (value.compare ("<no-argument>") != 0)
{
int index = GetOptionArgumentPosition (value.c_str());
if (index == 0)
// value was NOT a positional argument; must be a real value
new_args.AppendArgument (value.c_str());
else if (index >= cmd_args.GetArgumentCount())
{
result.AppendErrorWithFormat
("Not enough arguments provided; you need at least %d arguments to use this alias.\n",
index);
result.SetStatus (eReturnStatusFailed);
return;
}
else
{
new_args.AppendArgument (cmd_args.GetArgumentAtIndex (index));
used[index] = 1;
}
}
}
}
for (int j = 0; j < cmd_args.GetArgumentCount(); ++j)
{
if (!used[j])
new_args.AppendArgument (cmd_args.GetArgumentAtIndex (j));
}
cmd_args.Clear();
cmd_args.SetArguments (new_args.GetArgumentCount(), (const char **) new_args.GetArgumentVector());
}
else
{
result.SetStatus (eReturnStatusSuccessFinishNoResult);
// This alias was not created with any options; nothing further needs to be done.
return;
}
result.SetStatus (eReturnStatusSuccessFinishNoResult);
return;
}