Example #1
0
void runner::register_options(const po::options_description& options)
{
    assert(m_impl);

    const auto& opt = options.options();
    for (const auto& o: opt)
        m_impl->m_options_description.add(o);
}
Example #2
0
string getParameterDescription(po::options_description& options, const po::variables_map& vm)  {
    std::stringstream stream;
    std::vector<boost::shared_ptr<po::option_description> > optionsVec = options.options();
    for (unsigned int i=0; i<optionsVec.size(); ++i) {
        boost::any value = vm[optionsVec[i]->long_name()].value();
        stream << optionsVec[i]->long_name() << " = ";
        if (value.type() == typeid(bool))
            stream << boost::any_cast<bool>(value) << " (bool)" <<std::endl;
        else if (value.type() == typeid(int))
            stream << boost::any_cast<int>(value) << " (int)" << std::endl;
        else if (value.type() == typeid(unsigned int))
            stream << boost::any_cast<unsigned int>(value) << " (unsigned int)" << std::endl;
        else if (value.type() == typeid(float))
            stream << boost::any_cast<float>(value) << " (float)" << std::endl;
        else if (value.type() == typeid(std::string))
            stream << boost::any_cast<std::string>(value) << " (std::string)" << std::endl;
        else
            std::cerr << "the type of the option " << optionsVec[i]->long_name() << " (" << i << ") is not int, float or string." << std::endl;
    }

    return stream.str();
}