diff options
author | Christian Linke <christian.linke@bmw.de> | 2015-04-15 19:05:53 +0200 |
---|---|---|
committer | Christian Linke <christian.linke@bmw.de> | 2015-04-15 19:05:53 +0200 |
commit | 64944e1fa72f346f1161da60c033de2e10513bea (patch) | |
tree | 12f668bf4024365311dd46bd3dc904f57e00f8fa /tclap-1.2.1/examples/test13.cpp | |
parent | a0b06e2a9b466cfcc6f6810a66d9522a56872cbb (diff) | |
download | audiomanager-64944e1fa72f346f1161da60c033de2e10513bea.tar.gz |
* implemend command line options for plugins. rework of command line
* add tclap as template library
* implement bug 344
Signed-off-by: Christian Linke <christian.linke@bmw.de>
Diffstat (limited to 'tclap-1.2.1/examples/test13.cpp')
-rw-r--r-- | tclap-1.2.1/examples/test13.cpp | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/tclap-1.2.1/examples/test13.cpp b/tclap-1.2.1/examples/test13.cpp new file mode 100644 index 0000000..12fa8bc --- /dev/null +++ b/tclap-1.2.1/examples/test13.cpp @@ -0,0 +1,57 @@ +#include <iostream> +#include <string> + +#include <tclap/CmdLine.h> + +using namespace TCLAP; + +// +// This file tests that we can parse args from a vector +// of strings rather than argv. This also tests a bug +// where a single element in the vector contains both +// the flag and value AND the value contains the flag +// from another switch arg. This would fool the parser +// into thinking that the string was a combined switches +// string rather than a flag value combo. +// +// This should not print an error +// +// Contributed by Nico Lugil. +// +int main() +{ + + try + { + CmdLine cmd("Test", ' ', "not versioned",true); + + MultiArg<std::string> Arg("X","fli","fli module",false,"string"); + cmd.add(Arg); + MultiSwitchArg ArgMultiSwitch("d","long_d","example"); + cmd.add(ArgMultiSwitch); + + std::vector<std::string> in; + in.push_back("prog name"); + in.push_back("-X module"); + cmd.parse(in); + + std::vector<std::string> s = Arg.getValue(); + for(unsigned int i = 0 ; i < s.size() ; i++) + { + std::cout << s[i] << "\n"; + } + std::cout << "MultiSwtichArg was found " << ArgMultiSwitch.getValue() << " times.\n"; + + } + catch (ArgException &e) // catch any exceptions + { + std::cerr << "error: " << e.error() << " for arg " << e.argId() << std::endl; + } + + std::cout << "done...\n"; + + return 0; +} + + + |