// Processes completion for a module command's parameter static char* handle_complete(const char *line, const char *word, int pos, int state, const char* msgid) { char *ret = NULL; try { BOOST_ASSERT(line); const std::string strline(line); BOOST_ASSERT(word); const std::string strword(word); ModuleProcessor *processor = Factory::instance()->getModuleProcessor(); ParameterVector completions = processor->getCompletion(strline, strword, pos, msgid); if (completions.empty()) { // no completions return NULL; } size_t wordlen = strlen(word); int which = 0; for (ParameterVector::iterator i = completions.begin(); i != completions.end(); i++) { if (!strncasecmp(word, i->c_str(), wordlen) && ++which > state) { std::string found = *i; // is there any spaces if (found.find(' ') != std::string::npos) { found = "\"" + found + "\""; } ret = strdup(found.c_str()); break; } } } catch(const std::exception& err) { klk_log(KLKLOG_ERROR, "Error in handle_complete(): %s", err.what()); } catch(...) { klk_log(KLKLOG_ERROR, "Unknown error in handle_complete()"); } return ret; }
void Algorithm::SetParameterCollection(const ParameterVector& parameters){ _parameterCollection.assign(parameters.begin(), parameters.end()); }