本文整理汇总了C++中Args::ParseArgsForCompletion方法的典型用法代码示例。如果您正苦于以下问题:C++ Args::ParseArgsForCompletion方法的具体用法?C++ Args::ParseArgsForCompletion怎么用?C++ Args::ParseArgsForCompletion使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Args
的用法示例。
在下文中一共展示了Args::ParseArgsForCompletion方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: HandleArgumentCompletion
int
CommandObject::HandleCompletion
(
Args &input,
int &cursor_index,
int &cursor_char_position,
int match_start_point,
int max_return_elements,
bool &word_complete,
StringList &matches
)
{
// Default implmentation of WantsCompletion() is !WantsRawCommandString().
// Subclasses who want raw command string but desire, for example,
// argument completion should override WantsCompletion() to return true,
// instead.
if (WantsRawCommandString() && !WantsCompletion())
{
// FIXME: Abstract telling the completion to insert the completion character.
matches.Clear();
return -1;
}
else
{
// Can we do anything generic with the options?
Options *cur_options = GetOptions();
CommandReturnObject result;
OptionElementVector opt_element_vector;
if (cur_options != NULL)
{
// Re-insert the dummy command name string which will have been
// stripped off:
input.Unshift ("dummy-string");
cursor_index++;
// I stick an element on the end of the input, because if the last element is
// option that requires an argument, getopt_long will freak out.
input.AppendArgument ("<FAKE-VALUE>");
input.ParseArgsForCompletion (*cur_options, opt_element_vector, cursor_index);
input.DeleteArgumentAtIndex(input.GetArgumentCount() - 1);
bool handled_by_options;
handled_by_options = cur_options->HandleOptionCompletion (input,
opt_element_vector,
cursor_index,
cursor_char_position,
match_start_point,
max_return_elements,
word_complete,
matches);
if (handled_by_options)
return matches.GetSize();
}
// If we got here, the last word is not an option or an option argument.
return HandleArgumentCompletion (input,
cursor_index,
cursor_char_position,
opt_element_vector,
match_start_point,
max_return_elements,
word_complete,
matches);
}
}