#include <animal/argumentParser.h>
using std::istream;
using std::ostream;
using std::cout;
using std::cin;
using std::endl;
struct MyComplex {
double real, imaginary;
MyComplex( double r=0, double i=0 ): real(r), imaginary(i) {}
};
ostream& operator << ( ostream& str, const MyComplex& c ) {
str << c.real << " " << c.imaginary;
return str;
}
istream& operator >> ( istream& str, MyComplex& c ) {
str >> c.real >> c.imaginary;
return str;
}
main( int argc, char* argv[] )
{
double d=2.2;
int i=0;
MyComplex c;
bool f1=false;
bool f2=false;
animal::parse("This is a test program \
for the Argumentparser class. This parser allows you to easily parse a command \
line including short or long names for arguments. Short names start with prefix - and \
consist of one character. They can be concatenated, e.g. -ifd. Long names start with \
prefix -- and can not be concatenated.")
.parameter( &d, 'd', "double", "what my double means" )
.option( &i, 0, "int", "what my integer means" )
.parameter( &c, 'c', "", "what my complex means" )
.option( &f1, 'f', "flag1", "what my first flag means" )
.option( &f2, 'g', "flag2", "what my second flag means" )
( argc, argv );
cout << "d = " << d << endl;
cout << "i = " << i << endl;
cout << "c = " << c << endl;
if( f1 ) cout << "flag 1 is set" << endl;
if( f2 ) cout << "flag 2 is set" << endl;
}