diff --git a/examples/Makefile.am b/examples/Makefile.am index ab1ada7..7287468 100644 --- a/examples/Makefile.am +++ b/examples/Makefile.am @@ -1,17 +1,19 @@ -noinst_PROGRAMS = test1 test2 test3 +noinst_PROGRAMS = test1 test2 test3 test4 test1_SOURCES = test1.cpp test2_SOURCES = test2.cpp test3_SOURCES = test3.cpp +test4_SOURCES = test4.cpp test1_LDADD = $(top_builddir)/src/libtclap.a test2_LDADD = $(top_builddir)/src/libtclap.a test3_LDADD = $(top_builddir)/src/libtclap.a +test4_LDADD = $(top_builddir)/src/libtclap.a INCLUDES = -I$(top_builddir)/include diff --git a/examples/test4.cpp b/examples/test4.cpp new file mode 100644 index 0000000..6cceca7 --- /dev/null +++ b/examples/test4.cpp @@ -0,0 +1,65 @@ + + +#include +#include +#include + +using namespace TCLAP; + +bool _boolTestB; +bool _boolTestA; +string _stringTest; + +void parseOptions(int argc, char** argv); + +int main(int argc, char** argv) +{ + + parseOptions(argc,argv); + + cout << "for string we got : " << _stringTest<< endl + << "for bool B we got : " << _boolTestB << endl + << "for bool A we got : " << _boolTestA << endl; + +} + + +void parseOptions(int argc, char** argv) +{ + try { + + CmdLine cmd("this is a message", ' ', "0.99" ); + + // + // Define arguments + // + + SwitchArg btest("B","sB", "exist Test B", false); + SwitchArg atest("A","sA", "exist Test B", false); + + ValueArg stest("s", "Bs", "string test", true, "homer", + "string"); + cmd.add( stest ); + cmd.add( btest ); + cmd.add( atest ); + + // + // Parse the command line. + // + cmd.parse(argc,argv); + + + // + // Set variables + // + _stringTest = stest.getValue(); + _boolTestB = btest.getValue(); + _boolTestA = atest.getValue(); + + + } catch ( ArgException e ) + { cout << "ERROR: " << e.error() << " " << e.argId() << endl; } +} + + +