Index: lemon/arg_parser.cc
===================================================================
--- lemon/arg_parser.cc	(revision 2391)
+++ lemon/arg_parser.cc	(revision 2402)
@@ -29,5 +29,5 @@
   ArgParser::ArgParser(int argc, char **argv) :_argc(argc), _argv(argv),
 					       _command_name(argv[0]) {
-    option("-help","Print a short help message",_showHelp,this);
+    refOption("-help","Print a short help message",_showHelp,this);
     synonym("help","-help");
     synonym("h","-help");
@@ -35,5 +35,90 @@
   }
 
-  ArgParser &ArgParser::option(const std::string &name,
+  ArgParser::~ArgParser()
+  {
+    for(Opts::iterator i=_opts.begin();i!=_opts.end();++i)
+      if(i->second.self_delete)
+	switch(i->second.type) {
+	case BOOL:
+	  delete i->second.bool_p;
+	  break;
+	case STRING:
+	  delete i->second.string_p;
+	  break;
+	case DOUBLE:
+	  delete i->second.double_p;
+	  break;
+	case INTEGER:
+	  delete i->second.int_p;
+	  break;
+	case UNKNOWN:
+	  break;
+	case FUNC:
+	  break;
+	}
+  }
+  
+
+  ArgParser &ArgParser::intOption(const std::string &name,
+			       const std::string &help,
+			       int value, bool obl)
+  {
+    ParData p;
+    p.int_p=new int(value);
+    p.self_delete=true;
+    p.help=help;
+    p.type=INTEGER;
+    p.mandatory=obl;
+    p.self_delete=true;
+    _opts[name]=p;
+    return *this;
+  }
+
+  ArgParser &ArgParser::doubleOption(const std::string &name,
+			       const std::string &help,
+			       double value, bool obl)
+  {
+    ParData p;
+    p.double_p=new double(value);
+    p.self_delete=true;
+    p.help=help;
+    p.type=DOUBLE;
+    p.mandatory=obl;
+    _opts[name]=p;
+    return *this;
+  }
+
+  ArgParser &ArgParser::boolOption(const std::string &name,
+			       const std::string &help,
+			       bool value, bool obl)
+  {
+    ParData p;
+    p.bool_p=new bool(value);
+    p.self_delete=true;
+    p.help=help;
+    p.type=BOOL;
+    p.mandatory=obl;
+    _opts[name]=p;
+
+    value = false;
+
+    return *this;
+  }
+
+  ArgParser &ArgParser::stringOption(const std::string &name,
+			       const std::string &help,
+			       std::string value, bool obl)
+  {
+    ParData p;
+    p.string_p=new std::string(value);
+    p.self_delete=true;
+    p.help=help;
+    p.type=STRING;
+    p.mandatory=obl;
+    _opts[name]=p;
+    return *this;
+  }
+
+  ArgParser &ArgParser::refOption(const std::string &name,
 			       const std::string &help,
 			       int &value, bool obl)
@@ -41,4 +126,5 @@
     ParData p;
     p.int_p=&value;
+    p.self_delete=false;
     p.help=help;
     p.type=INTEGER;
@@ -48,5 +134,5 @@
   }
 
-  ArgParser &ArgParser::option(const std::string &name,
+  ArgParser &ArgParser::refOption(const std::string &name,
 			       const std::string &help,
 			       double &value, bool obl)
@@ -54,4 +140,5 @@
     ParData p;
     p.double_p=&value;
+    p.self_delete=false;
     p.help=help;
     p.type=DOUBLE;
@@ -61,5 +148,5 @@
   }
 
-  ArgParser &ArgParser::option(const std::string &name,
+  ArgParser &ArgParser::refOption(const std::string &name,
 			       const std::string &help,
 			       bool &value, bool obl)
@@ -67,4 +154,5 @@
     ParData p;
     p.bool_p=&value;
+    p.self_delete=false;
     p.help=help;
     p.type=BOOL;
@@ -77,5 +165,5 @@
   }
 
-  ArgParser &ArgParser::option(const std::string &name,
+  ArgParser &ArgParser::refOption(const std::string &name,
 			       const std::string &help,
 			       std::string &value, bool obl)
@@ -83,4 +171,5 @@
     ParData p;
     p.string_p=&value;
+    p.self_delete=false;
     p.help=help;
     p.type=STRING;
@@ -90,5 +179,5 @@
   }
 
-  ArgParser &ArgParser::option(const std::string &name,
+  ArgParser &ArgParser::refOption(const std::string &name,
 			       const std::string &help,
 			       void (*func)(void *),void *data)
@@ -97,4 +186,5 @@
     p.func_p.p=func;
     p.func_p.data=data;
+    p.self_delete=false;
     p.help=help;
     p.type=FUNC;
@@ -103,4 +193,5 @@
     return *this;
   }
+
   ArgParser &ArgParser::optionGroup(const std::string &group,
 				    const std::string &opt)
@@ -378,4 +469,4 @@
     return *this;
   }  
-    
+
 }
