Пример #1
0
void processQuery(const CommandTable& c, const std::string& cmd)
{
    std::vector<std::string> args = split_args(strip_comments(cmd));
    if (args.size() == 0) return;

    auto it = c.find(args[0]);
    if (it != c.end())
    {
        it->second(args);
    }
    else
    {
        std::cout << "Unknown command: " << args[0] << std::endl;
    }
}
Пример #2
0
char *cmd_generator(const char *text, int state)
{
    static CommandTable::const_iterator it;

    if (state == 0)
    {
        it = cmds.begin();
    }

    while (it != cmds.end())
    {
        auto s = it->first;
        ++it;
        if (boost::starts_with(s, text))
        {
            return strdup(s.c_str());
        }
    }

    return NULL;
}