src/main.cpp
/** Read resistances from a variable length vector.
 * 
 * If size of the vector is < 4, 0 is used as a default value.
 * 
 * @param args Resistances in order: fire, cold, lightning, and chaos
 * 
 * @returns resistance object
 */
Read resistances from a variable length vector.

If size of the vector is < 4, 0 is used as a default value.

@param args Resistances in order: fire, cold, lightning, and chaos

@returns resistance object
Read resistances from a variable length vector . If size of the vector is < 4 0 is used as a default value . @param args Resistances in order : fire cold lightning and chaos @returns resistance object
recap::resistance read_resistance_arg(const std::string& name, boost::program_options::variables_map& vm)
{
    using namespace recap;
    if (!vm.count(name))
    {
        throw invalid_arg_error{ "Missing required argument: " + name };
    }
    auto args = vm[name].as<std::vector<resistance::item_t>>();
    if (args.size() <= 0 || args.size() > 4)
    {
        throw invalid_arg_error{ 
            "Wrong number of resistances. Expected at most 4, got " + 
            std::to_string(args.size()) };
    }
    return resistance{ 
        args.size() > 0 ? args[0] : resistance::item_t{ 0 },  
        args.size() > 1 ? args[1] : resistance::item_t{ 0 },
        args.size() > 2 ? args[2] : resistance::item_t{ 0 },
        args.size() > 3 ? args[3] : resistance::item_t{ 0 }
    };
}
recap :: resistance read_resistance_arg ( const std :: string & name , boost :: program_options :: variables_map & vm ) { using namespace recap ; if ( ! vm . count ( name ) ) { throw invalid_arg_error { " " + name } ; } auto args = vm [ name ] . as < std :: vector < resistance :: item_t > > ( ) ; if ( args . size ( ) <= 0 || args . size ( ) > 4 ) { throw invalid_arg_error { " " + std :: to_string ( args . size ( ) ) } ; } return resistance { args . size ( ) > 0 ? args [ 0 ] : resistance :: item_t { 0 } , args . size ( ) > 1 ? args [ 1 ] : resistance :: item_t { 0 } , args . size ( ) > 2 ? args [ 2 ] : resistance :: item_t { 0 } , args . size ( ) > 3 ? args [ 3 ] : resistance :: item_t { 0 } } ; }
Read resistances from a variable length vector.
Read resistances from a variable length vector .