solve lvalue problem in container shift; refs #7
This commit is contained in:
		@@ -6,6 +6,9 @@
 | 
			
		||||
// 45678901234567890123456789012345678901234567890123456789012345678901234567890
 | 
			
		||||
 | 
			
		||||
#include <mrw/args.hxx>
 | 
			
		||||
#ifdef MRW__OLD_PRE11_COMPILER
 | 
			
		||||
#include <mrw/vector.hxx>
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
void test_func() {
 | 
			
		||||
  std::cout<<"test parameter was given on command line"<<std::endl;
 | 
			
		||||
@@ -19,48 +22,46 @@ int main(int argc, char** argv) try {
 | 
			
		||||
  std::string txt("Hello World");
 | 
			
		||||
  int x(0), y(0);
 | 
			
		||||
 | 
			
		||||
  std::string description("This is an example for argument processing. If the "
 | 
			
		||||
                          "description is very long, it is automatically "
 | 
			
		||||
                          "splitted over several lines and indented on each "
 | 
			
		||||
                          "new line. Arguments may have several parameters. "
 | 
			
		||||
                          "Help is generated automatically from the argument "
 | 
			
		||||
                          "declaration. The argument declaration contains long "
 | 
			
		||||
                          "and short options and a list of parameters.");
 | 
			
		||||
  std::string returns("Returns a status of 0 on success and 1 on any error.");
 | 
			
		||||
 | 
			
		||||
  // bind and evaluate options
 | 
			
		||||
#ifdef ARGS__OLD_PRE11_COMPILER
 | 
			
		||||
  mrw::args::list options;
 | 
			
		||||
  std::vector<std::shared_ptr<mrw::args::abstract_parameter> > params;
 | 
			
		||||
  params.push_back(mrw::args::help());
 | 
			
		||||
  params.push_back(mrw::args::exit());
 | 
			
		||||
  options.push_back(mrw::args::declaration("h", "help", "show this help",
 | 
			
		||||
                                           params));
 | 
			
		||||
  params.clear();
 | 
			
		||||
  params.push_back(mrw::args::param(r, "number"));
 | 
			
		||||
  options.push_back(mrw::args::declaration("r", "repeat",
 | 
			
		||||
                                           "number of repetitions",
 | 
			
		||||
                                           params));
 | 
			
		||||
  params.clear();
 | 
			
		||||
  params.push_back(mrw::args::param(flag));
 | 
			
		||||
  options.push_back(mrw::args::declaration("f", "flag", "check a flag",
 | 
			
		||||
                                           params));
 | 
			
		||||
  params.clear();
 | 
			
		||||
  params.push_back(mrw::args::param(txt, "text"));
 | 
			
		||||
  options.push_back(mrw::args::declaration("t", "text", "pass a text", params));
 | 
			
		||||
  params.clear();
 | 
			
		||||
  params.push_back(mrw::args::param(x, "x"));
 | 
			
		||||
  params.push_back(mrw::args::param(y, "y"));
 | 
			
		||||
  options.push_back(mrw::args::declaration("c", "coord",
 | 
			
		||||
                                           "add some 2D coordinates",
 | 
			
		||||
                                           params));
 | 
			
		||||
  params.clear();
 | 
			
		||||
  params.push_back(mrw::args::func(test_func));
 | 
			
		||||
  options.push_back(mrw::args::declaration("",  "test",
 | 
			
		||||
                                           "call test_func, no shortcut",
 | 
			
		||||
                                           params));
 | 
			
		||||
  mrw::args::parse(argc, argv, "This is an example for argument processing.",
 | 
			
		||||
                   options);
 | 
			
		||||
#ifdef MRW__OLD_PRE11_COMPILER
 | 
			
		||||
  mrw::args::list l;
 | 
			
		||||
  mrw::args::decl::param_list pl = mrw::args::decl::param_list();
 | 
			
		||||
  (mrw::args::decl::param_list())<<mrw::args::param(flag);
 | 
			
		||||
  l<<mrw::args::decl("f", "flag", "check a flag", pl);
 | 
			
		||||
  mrw::args::parse(argc, argv, description, mrw::args::list()
 | 
			
		||||
                   <<mrw::args::decl("h", "help", "show this help",
 | 
			
		||||
                                     mrw::args::decl::param_list()
 | 
			
		||||
                                     <<mrw::args::help()
 | 
			
		||||
                                     <<mrw::args::exit())
 | 
			
		||||
                   <<mrw::args::decl("r", "repeat", "number of repetitions",
 | 
			
		||||
                                     mrw::args::decl::param_list()
 | 
			
		||||
                                     <<mrw::args::param(r, "number"))
 | 
			
		||||
                   <<mrw::args::decl("f", "flag", "check a flag",
 | 
			
		||||
                                     mrw::args::decl::param_list()
 | 
			
		||||
                                     <<mrw::args::param(flag))
 | 
			
		||||
                   <<mrw::args::decl("t", "text", "pass a text",
 | 
			
		||||
                                     mrw::args::decl::param_list()
 | 
			
		||||
                                     <<mrw::args::param(txt, "text"))
 | 
			
		||||
                   <<mrw::args::decl("c", "coord", "add some 2D coordinates",
 | 
			
		||||
                                     mrw::args::decl::param_list()
 | 
			
		||||
                                     <<mrw::args::param(x, "x")
 | 
			
		||||
                                     <<mrw::args::param(y, "y"))
 | 
			
		||||
                   <<mrw::args::decl("",  "test", "call test_func, no shortcut",
 | 
			
		||||
                                     mrw::args::decl::param_list()
 | 
			
		||||
                                     <<mrw::args::func(test_func)),
 | 
			
		||||
                   returns);
 | 
			
		||||
#else
 | 
			
		||||
  mrw::args::parse(argc, argv,
 | 
			
		||||
                   "This is an example for argument processing. If the"
 | 
			
		||||
                   " description is very long, it is automatically splitted"
 | 
			
		||||
                   " over several lines and indented on each new line."
 | 
			
		||||
                   " Arguments may have several parameters. Help is"
 | 
			
		||||
                   " generated automatically from the argument declaration."
 | 
			
		||||
                   " The argument declaration contains long and short options"
 | 
			
		||||
                   " and a list of parameters.",
 | 
			
		||||
                   description,
 | 
			
		||||
                   {
 | 
			
		||||
                     {"h", "help", "show this help",
 | 
			
		||||
                         {mrw::args::help(), mrw::args::exit()}},
 | 
			
		||||
@@ -80,7 +81,7 @@ int main(int argc, char** argv) try {
 | 
			
		||||
                     {"",  "test", "call test_func, no shortcut",
 | 
			
		||||
                         {mrw::args::func(test_func)}},
 | 
			
		||||
                   },
 | 
			
		||||
                   "Returns a status of 0 on success and 1 on any error.");
 | 
			
		||||
                   returns);
 | 
			
		||||
#endif
 | 
			
		||||
  
 | 
			
		||||
  // show the result
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user