当前位置: 首页>>代码示例>>C++>>正文


C++ StringList::GetSize方法代码示例

本文整理汇总了C++中StringList::GetSize方法的典型用法代码示例。如果您正苦于以下问题:C++ StringList::GetSize方法的具体用法?C++ StringList::GetSize怎么用?C++ StringList::GetSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在StringList的用法示例。


在下文中一共展示了StringList::GetSize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: tmp_buf

size_t
FileSpec::ResolvePartialUsername (const char *partial_name, StringList &matches)
{
#ifdef LLDB_CONFIG_TILDE_RESOLVES_TO_USER
    size_t extant_entries = matches.GetSize();

    setpwent();
    struct passwd *user_entry;
    const char *name_start = partial_name + 1;
    std::set<std::string> name_list;

    while ((user_entry = getpwent()) != NULL)
    {
        if (strstr(user_entry->pw_name, name_start) == user_entry->pw_name)
        {
            std::string tmp_buf("~");
            tmp_buf.append(user_entry->pw_name);
            tmp_buf.push_back('/');
            name_list.insert(tmp_buf);
        }
    }
    std::set<std::string>::iterator pos, end = name_list.end();
    for (pos = name_list.begin(); pos != end; pos++)
    {
        matches.AppendString((*pos).c_str());
    }
    return matches.GetSize() - extant_entries;
#else
    // Resolving home directories is not supported, just copy the path...
    return 0;
#endif // #ifdef LLDB_CONFIG_TILDE_RESOLVES_TO_USER    
}
开发者ID:carlokok,项目名称:lldb,代码行数:32,代码来源:FileSpec.cpp

示例2: strlen

size_t
StringList::AutoComplete (const char *s, StringList &matches, size_t &exact_idx) const
{
    matches.Clear();
    exact_idx = SIZE_MAX;
    if (s && s[0])
    {
        const size_t s_len = strlen (s);
        const size_t num_strings = m_strings.size();
        
        for (size_t i=0; i<num_strings; ++i)
        {
            if (m_strings[i].find(s) == 0)
            {
                if (exact_idx == SIZE_MAX && m_strings[i].size() == s_len)
                    exact_idx = matches.GetSize();
                matches.AppendString (m_strings[i]);
            }
        }
    }
    else
    {
        // No string, so it matches everything
        matches = *this;
    }
    return matches.GetSize();
}
开发者ID:AAZemlyanukhin,项目名称:freebsd,代码行数:27,代码来源:StringList.cpp

示例3: HandleCompletion

int CommandObjectMultiword::HandleCompletion(Args &input, int &cursor_index,
                                             int &cursor_char_position,
                                             int match_start_point,
                                             int max_return_elements,
                                             bool &word_complete,
                                             StringList &matches) {
  // Any of the command matches will provide a complete word, otherwise the
  // individual
  // completers will override this.
  word_complete = true;

  const char *arg0 = input.GetArgumentAtIndex(0);
  if (cursor_index == 0) {
    AddNamesMatchingPartialString(m_subcommand_dict, arg0, matches);

    if (matches.GetSize() == 1 && matches.GetStringAtIndex(0) != nullptr &&
        strcmp(arg0, matches.GetStringAtIndex(0)) == 0) {
      StringList temp_matches;
      CommandObject *cmd_obj = GetSubcommandObject(arg0, &temp_matches);
      if (cmd_obj != nullptr) {
        if (input.GetArgumentCount() == 1) {
          word_complete = true;
        } else {
          matches.DeleteStringAtIndex(0);
          input.Shift();
          cursor_char_position = 0;
          input.AppendArgument("");
          return cmd_obj->HandleCompletion(
              input, cursor_index, cursor_char_position, match_start_point,
              max_return_elements, word_complete, matches);
        }
      }
    }
    return matches.GetSize();
  } else {
    CommandObject *sub_command_object = GetSubcommandObject(arg0, &matches);
    if (sub_command_object == nullptr) {
      return matches.GetSize();
    } else {
      // Remove the one match that we got from calling GetSubcommandObject.
      matches.DeleteStringAtIndex(0);
      input.Shift();
      cursor_index--;
      return sub_command_object->HandleCompletion(
          input, cursor_index, cursor_char_position, match_start_point,
          max_return_elements, word_complete, matches);
    }
  }
}
开发者ID:karwa,项目名称:swift-lldb,代码行数:49,代码来源:CommandObjectMultiword.cpp

示例4: completion_str

int
CommandObjectRegexCommand::HandleCompletion (Args &input,
                                             int &cursor_index,
                                             int &cursor_char_position,
                                             int match_start_point,
                                             int max_return_elements,
                                             bool &word_complete,
                                             StringList &matches)
{
    if (m_completion_type_mask)
    {
        std::string completion_str (input.GetArgumentAtIndex (cursor_index), cursor_char_position);
        CommandCompletions::InvokeCommonCompletionCallbacks (m_interpreter,
                                                             m_completion_type_mask,
                                                             completion_str.c_str(),
                                                             match_start_point,
                                                             max_return_elements,
                                                             nullptr,
                                                             word_complete,
                                                             matches);
        return matches.GetSize();
    }
    else
    {
        matches.Clear();
        word_complete = false;
    }
    return 0;
}
开发者ID:CODECOMMUNITY,项目名称:lldb,代码行数:29,代码来源:CommandObjectRegexCommand.cpp

示例5: SettingsNames

int CommandCompletions::SettingsNames(CommandInterpreter &interpreter,
                                      CompletionRequest &request,
                                      SearchFilter *searcher) {
  // Cache the full setting name list
  static StringList g_property_names;
  if (g_property_names.GetSize() == 0) {
    // Generate the full setting name list on demand
    lldb::OptionValuePropertiesSP properties_sp(
        interpreter.GetDebugger().GetValueProperties());
    if (properties_sp) {
      StreamString strm;
      properties_sp->DumpValue(nullptr, strm, OptionValue::eDumpOptionName);
      const std::string &str = strm.GetString();
      g_property_names.SplitIntoLines(str.c_str(), str.size());
    }
  }

  size_t exact_matches_idx = SIZE_MAX;
  StringList matches;
  g_property_names.AutoComplete(request.GetCursorArgumentPrefix(), matches,
                                exact_matches_idx);
  request.SetWordComplete(exact_matches_idx != SIZE_MAX);
  request.AddCompletions(matches);
  return request.GetNumberOfMatches();
}
开发者ID:FreeBSDFoundation,项目名称:freebsd,代码行数:25,代码来源:CommandCompletions.cpp

示例6: completer

int
CommandCompletions::SourceFiles(CommandInterpreter &interpreter,
                                const char *partial_file_name,
                                int match_start_point,
                                int max_return_elements,
                                SearchFilter *searcher,
                                bool &word_complete,
                                StringList &matches)
{
    word_complete = true;
    // Find some way to switch "include support files..."
    SourceFileCompleter completer (interpreter,
                                   false, 
                                   partial_file_name, 
                                   match_start_point, 
                                   max_return_elements,
                                   matches);

    if (searcher == nullptr)
    {
        lldb::TargetSP target_sp = interpreter.GetDebugger().GetSelectedTarget();
        SearchFilterForUnconstrainedSearches null_searcher (target_sp);
        completer.DoCompletion (&null_searcher);
    }
    else
    {
        completer.DoCompletion (searcher);
    }
    return matches.GetSize();
}
开发者ID:32bitmicro,项目名称:riscv-lldb,代码行数:30,代码来源:CommandCompletions.cpp

示例7: GetDesiredIndentation

int
REPL::IOHandlerFixIndentation (IOHandler &io_handler,
                               const StringList &lines,
                               int cursor_position)
{
    if (!m_enable_auto_indent) return 0;
    
    if (!lines.GetSize())
    {
        return 0;
    }
    
    int tab_size = io_handler.GetDebugger().GetTabSize();

    lldb::offset_t desired_indent = GetDesiredIndentation(lines,
                                                          cursor_position,
                                                          tab_size);
    
    int actual_indent = REPL::CalculateActualIndentation(lines);
    
    if (desired_indent == LLDB_INVALID_OFFSET)
        return 0;
    
    return (int)desired_indent - actual_indent;
}
开发者ID:Aj0Ay,项目名称:lldb,代码行数:25,代码来源:REPL.cpp

示例8: strlen

size_t
OptionValueEnumeration::AutoComplete (CommandInterpreter &interpreter,
                                      const char *s,
                                      int match_start_point,
                                      int max_return_elements,
                                      bool &word_complete,
                                      StringList &matches)
{
    word_complete = false;
    matches.Clear();
    
    const uint32_t num_enumerators = m_enumerations.GetSize();
    if (s && s[0])
    {
        const size_t s_len = strlen(s);
        for (size_t i=0; i<num_enumerators; ++i)
        {
            const char *name = m_enumerations.GetCStringAtIndex(i);
            if (::strncmp(s, name, s_len) == 0)
                matches.AppendString(name);
        }
    }
    else
    {
        // only suggest "true" or "false" by default
        for (size_t i=0; i<num_enumerators; ++i)
            matches.AppendString(m_enumerations.GetCStringAtIndex(i));
    }
    return matches.GetSize();
}
开发者ID:AAZemlyanukhin,项目名称:freebsd,代码行数:30,代码来源:OptionValueEnumeration.cpp

示例9: completer

int
CommandCompletions::Symbols 
(
    CommandInterpreter &interpreter,
    const char *partial_file_name,
    int match_start_point,
    int max_return_elements,
    SearchFilter *searcher,
    bool &word_complete,
    StringList &matches)
{
    word_complete = true;
    SymbolCompleter completer (interpreter,
                               partial_file_name, 
                               match_start_point, 
                               max_return_elements, 
                               matches);

    if (searcher == NULL)
    {
        lldb::TargetSP target_sp = interpreter.GetDebugger().GetSelectedTarget();
        SearchFilterForUnconstrainedSearches null_searcher (target_sp);
        completer.DoCompletion (&null_searcher);
    }
    else
    {
        completer.DoCompletion (searcher);
    }
    return matches.GetSize();
}
开发者ID:BlueRiverInteractive,项目名称:lldb,代码行数:30,代码来源:CommandCompletions.cpp

示例10: AutoComplete

size_t OptionValue::AutoComplete(CommandInterpreter &interpreter, const char *s,
                                 int match_start_point, int max_return_elements,
                                 bool &word_complete, StringList &matches) {
  word_complete = false;
  matches.Clear();
  return matches.GetSize();
}
开发者ID:CodaFi,项目名称:swift-lldb,代码行数:7,代码来源:OptionValue.cpp

示例11: completion_str

int
CommandObjectFile::HandleArgumentCompletion (CommandInterpreter &interpreter,
                              Args &input,
                              int &cursor_index,
                              int &cursor_char_position,
                              OptionElementVector &opt_element_vector,
                              int match_start_point,
                              int max_return_elements,
                              bool &word_complete,
                              StringList &matches)
{
        std::string completion_str (input.GetArgumentAtIndex(cursor_index));
        completion_str.erase (cursor_char_position);

        CommandCompletions::InvokeCommonCompletionCallbacks (interpreter, 
                                                             CommandCompletions::eDiskFileCompletion,
                                                             completion_str.c_str(),
                                                             match_start_point,
                                                             max_return_elements,
                                                             NULL,
                                                             word_complete,
                                                             matches);
        return matches.GetSize();
    
}
开发者ID:ice799,项目名称:lldb,代码行数:25,代码来源:CommandObjectFile.cpp

示例12: properties_sp

int
CommandCompletions::SettingsNames (CommandInterpreter &interpreter,
                                   const char *partial_setting_name,
                                   int match_start_point,
                                   int max_return_elements,
                                   SearchFilter *searcher,
                                   bool &word_complete,
                                   StringList &matches)
{
    // Cache the full setting name list
    static StringList g_property_names;
    if (g_property_names.GetSize() == 0)
    {
        // Generate the full setting name list on demand
        lldb::OptionValuePropertiesSP properties_sp (interpreter.GetDebugger().GetValueProperties());
        if (properties_sp)
        {
            StreamString strm;
            properties_sp->DumpValue(nullptr, strm, OptionValue::eDumpOptionName);
            const std::string &str = strm.GetString();
            g_property_names.SplitIntoLines(str.c_str(), str.size());
        }
    }
    
    size_t exact_matches_idx = SIZE_MAX;
    const size_t num_matches = g_property_names.AutoComplete (partial_setting_name, matches, exact_matches_idx);
    word_complete = exact_matches_idx != SIZE_MAX;
    return num_matches;
}
开发者ID:32bitmicro,项目名称:riscv-lldb,代码行数:29,代码来源:CommandCompletions.cpp

示例13: Execute

bool CommandObjectMultiword::Execute(const char *args_string,
                                     CommandReturnObject &result) {
  Args args(args_string);
  const size_t argc = args.GetArgumentCount();
  if (argc == 0) {
    this->CommandObject::GenerateHelpText(result);
  } else {
    const char *sub_command = args.GetArgumentAtIndex(0);

    if (sub_command) {
      if (::strcasecmp(sub_command, "help") == 0) {
        this->CommandObject::GenerateHelpText(result);
      } else if (!m_subcommand_dict.empty()) {
        StringList matches;
        CommandObject *sub_cmd_obj = GetSubcommandObject(sub_command, &matches);
        if (sub_cmd_obj != nullptr) {
          // Now call CommandObject::Execute to process and options in
          // 'rest_of_line'.  From there
          // the command-specific version of Execute will be called, with the
          // processed arguments.

          args.Shift();

          sub_cmd_obj->Execute(args_string, result);
        } else {
          std::string error_msg;
          const size_t num_subcmd_matches = matches.GetSize();
          if (num_subcmd_matches > 0)
            error_msg.assign("ambiguous command ");
          else
            error_msg.assign("invalid command ");

          error_msg.append("'");
          error_msg.append(GetCommandName());
          error_msg.append(" ");
          error_msg.append(sub_command);
          error_msg.append("'.");

          if (num_subcmd_matches > 0) {
            error_msg.append(" Possible completions:");
            for (size_t i = 0; i < num_subcmd_matches; i++) {
              error_msg.append("\n\t");
              error_msg.append(matches.GetStringAtIndex(i));
            }
          }
          error_msg.append("\n");
          result.AppendRawError(error_msg.c_str());
          result.SetStatus(eReturnStatusFailed);
        }
      } else {
        result.AppendErrorWithFormat("'%s' does not have any subcommands.\n",
                                     GetCommandName());
        result.SetStatus(eReturnStatusFailed);
      }
    }
  }

  return result.Succeeded();
}
开发者ID:karwa,项目名称:swift-lldb,代码行数:59,代码来源:CommandObjectMultiword.cpp

示例14:

void
StringList::AppendList (StringList strings)
{
    size_t len = strings.GetSize();

    for (size_t i = 0; i < len; ++i)
        m_strings.push_back (strings.GetStringAtIndex(i));
}
开发者ID:AAZemlyanukhin,项目名称:freebsd,代码行数:8,代码来源:StringList.cpp

示例15: CalculateActualIndentation

int REPL::CalculateActualIndentation(const StringList &lines) {
  std::string last_line = lines[lines.GetSize() - 1];

  int actual_indent = 0;
  for (char &ch : last_line) {
    if (ch != ' ')
      break;
    ++actual_indent;
  }

  return actual_indent;
}
开发者ID:kraj,项目名称:lldb,代码行数:12,代码来源:REPL.cpp


注:本文中的StringList::GetSize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。