|
leoargmain.cppThere is an example of this class
#include <LeoArg.hh> #include <iostream> using std::cout; using std::endl; #define bfunc( f ) if( f ) cout << "true "; else cout << "false "; #define plist( l ) for( LeoArg::ArgListIt it = l.begin(); it != l.end(); it++ ) cout << *it << " "; int main( int argc, char** argv ) { try { LeoArg arg( argc, argv ); // has parameters cout << "has parameters: "; bfunc( arg.has_parameters() ); cout << endl; // first std::string s1; cout << "first: "; bfunc( arg.get_first( s1 ) ); cout << s1 << endl; // first list LeoArg::ArgList al; cout << "first list: "; bfunc( arg.get_first( al ) ); plist( al ); cout << endl; // last cout << "last: "; bfunc( arg.get_last( s1 ) ); cout << s1 << endl; // last list al.clear(); cout << "last list: "; bfunc( arg.get_last( al ) ); plist( al ); cout << endl; LeoArg::Option o( "infile", "if" ); arg.get_option( o ); cout << "option infile: " << "long option: " << o.long_option << endl << "short option: " << o.short_option << endl << "flag: " << o.flag << endl << "bool: " << o.bool_value << endl << "int: " << o.int_num << endl << "double: " << o.double_num << endl << "string: " << o.str << endl << "list: "; plist( o.arglist ); cout << endl << endl; o = LeoArg::Option( "sos", "s" ); arg.short_option_string( true ); arg.get_option( o ); cout << "option sos: " << "flag: " << o.flag; cout << endl; } catch( LeoArg::InvalidSetting is ) { cout << is.err << endl; } catch( LeoArg::InvalidOption io ) { cout << io.err << endl; } return 0; }
LeoArg (C) under the terms of the
GPL
by
King Leo (Martin Oberzalek)
Documentation created by Doxygen 1.2.2 |