int CommandObject::AddNamesMatchingPartialString (CommandObject::CommandMap &in_map, const char *cmd_str, StringList &matches) { int number_added = 0; CommandDictCommandPartialMatch matcher(cmd_str); CommandObject::CommandMap::iterator matching_cmds = std::find_if (in_map.begin(), in_map.end(), matcher); while (matching_cmds != in_map.end()) { ++number_added; matches.AppendString((*matching_cmds).first.c_str()); matching_cmds = std::find_if (++matching_cmds, in_map.end(), matcher);; } return number_added; }
std::string CommandInterpreter::FindLongestCommandWord (CommandObject::CommandMap &dict) { CommandObject::CommandMap::const_iterator pos; int max_len = 0; CommandObjectSP cmd_sp; std::string longest_word; for (pos = dict.begin(); pos != dict.end(); ++pos) { if ((max_len == 0) || (strlen (pos->first.c_str()) > max_len)) { longest_word = pos->first; max_len = strlen (longest_word.c_str()); } } return longest_word; }