#include "options.h" #include #include #include namespace vmml { options::options() : _generic_options( "Generic options" ) { _generic_options.add_options() ("input-file,i", "specify input file") ("ops,O", boost_po::value< std::vector< std::string > >()->composing(), "specify operators " ) ; _positional_desc.add( "ops", -1 ); } void options::setup( int argc, char* argv[] ) { _all_options.add( _generic_options ); boost_po::store( boost_po::command_line_parser( argc, argv ) .options( _all_options ) .positional( _positional_desc ) //.allow_unregistered() .run(), _options_map ); boost_po::notify( _options_map ); } void options::get_operator_chain( std::vector< std::string >& op_chain ) { if ( _options_map.count("ops") ) { const std::vector< std::string >& ops = _options_map["ops"].as< std::vector< std::string > >(); op_chain = ops; } } }//namespace vmml int main( int argc, char** argv ) { vmml::options opt; opt.setup( argc, argv ); std::vector< std::string > ops; opt.get_operator_chain( ops ); std::vector< std::string >::iterator it = ops.begin(); std::vector< std::string >::iterator itend = ops.end(); for( ; it != itend; ++it ) { std::cout << *it << std::endl; } }