Index: lemon/arg_parser.cc
===================================================================
--- lemon/arg_parser.cc	(revision 2406)
+++ lemon/arg_parser.cc	(revision 2410)
@@ -27,6 +27,6 @@
   }
 
-  ArgParser::ArgParser(int argc, char **argv) :_argc(argc), _argv(argv),
-					       _command_name(argv[0]) {
+  ArgParser::ArgParser(int argc, const char **argv) :_argc(argc), _argv(argv),
+                                                     _command_name(argv[0]) {
     funcOption("-help","Print a short help message",_showHelp,this);
     synonym("help","-help");
@@ -135,6 +135,6 @@
 
   ArgParser &ArgParser::refOption(const std::string &name,
-			       const std::string &help,
-			       double &ref, bool obl)
+                                  const std::string &help,
+                                  double &ref, bool obl)
   {
     ParData p;
@@ -149,6 +149,6 @@
 
   ArgParser &ArgParser::refOption(const std::string &name,
-			       const std::string &help,
-			       bool &ref, bool obl)
+                                  const std::string &help,
+                                  bool &ref, bool obl)
   {
     ParData p;
@@ -198,11 +198,10 @@
   {
     Opts::iterator i = _opts.find(opt);
-    if(i==_opts.end()) throw LogicError();
-    else if(i->second.ingroup) throw LogicError();
-    else {
-      GroupData &g=_groups[group];
-      g.opts.push_back(opt);
-      i->second.ingroup=true;
-    }
+    LEMON_ASSERT(i!=_opts.end(), "Unknown option: '"+opt+"'");
+    LEMON_ASSERT(!(i->second.ingroup), 
+                 "Option already in option group: '"+opt+"'");
+    GroupData &g=_groups[group];
+    g.opts.push_back(opt);
+    i->second.ingroup=true;
     return *this;
   }
@@ -220,14 +219,12 @@
     Opts::iterator o = _opts.find(opt);
     Opts::iterator s = _opts.find(syn);
-    if(o==_opts.end()||s!=_opts.end())
-      throw LogicError();
-    else {
-      ParData p;
-      p.help=opt;
-      p.mandatory=false;
-      p.syn=true;
-      _opts[syn]=p;
-      o->second.has_syn=true;
-    }
+    LEMON_ASSERT(o!=_opts.end(), "Unknown option: '"+opt+"'");
+    LEMON_ASSERT(s==_opts.end(), "Option already used: '"+syn+"'");
+    ParData p;
+    p.help=opt;
+    p.mandatory=false;
+    p.syn=true;
+    _opts[syn]=p;
+    o->second.has_syn=true;
     return *this;
   }
Index: lemon/arg_parser.h
===================================================================
--- lemon/arg_parser.h	(revision 2407)
+++ lemon/arg_parser.h	(revision 2410)
@@ -48,5 +48,5 @@
     
     int _argc;
-    char **_argv;
+    const char **_argv;
     
     enum OptType { UNKNOWN=0, BOOL=1, STRING=2, DOUBLE=3, INTEGER=4, FUNC=5 };
@@ -108,5 +108,5 @@
 
     ///\e
-    ArgParser(int argc, char **argv);
+    ArgParser(int argc, const char **argv);
 
     ~ArgParser();
Index: lemon/error.h
===================================================================
--- lemon/error.h	(revision 2391)
+++ lemon/error.h	(revision 2410)
@@ -476,7 +476,9 @@
 
   template <typename Exception>
-  inline void assert_fail(const char *file, int line, const char *func,
-		   Exception exception, const char *assertion = 0,
-		   bool do_abort=true)
+  inline void assert_fail(const char *file, int line, 
+                          const char *func,
+                          Exception exception, 
+                          const char *assertion = 0,
+                          bool do_abort=true)
   {
     using namespace std;
@@ -511,4 +513,14 @@
   }
 
+  template <>
+  inline void assert_fail<std::string>(const char *file, int line, 
+                                       const char *func,
+                                       std::string message, 
+                                       const char *assertion,
+                                       bool do_abort)
+  {
+    assert_fail(file, line, func, message.c_str(), assertion, do_abort);
+  }
+
   template <typename Exception>
   inline void assert_fail_failure(const char *file, int line, const char *func,
@@ -522,10 +534,20 @@
   template <>
   inline void assert_fail_failure<const char *>(const char *file, int line, 
-					 const char *func,
-					 const char *message, 
-					 const char *assertion,
-					 bool)
+                                                const char *func,
+                                                const char *message, 
+                                                const char *assertion,
+                                                bool)
   {
     throw AssertionFailedError(file, line, func, message, assertion);
+  }
+
+  template <>
+  inline void assert_fail_failure<std::string>(const char *file, int line, 
+                                               const char *func,
+                                               std::string message, 
+                                               const char *assertion,
+                                               bool)
+  {
+    assert_fail_failure(file, line, func, message.c_str(), assertion, true);
   }
 
@@ -546,4 +568,14 @@
   {
     throw AssertionFailedError(file, line, func, message, assertion);
+  }
+
+  template <>
+  inline void assert_fail_exception<std::string>(const char *file, int line, 
+                                                 const char *func,
+                                                 std::string message, 
+                                                 const char *assertion,
+                                                 bool)
+  {
+    assert_fail_exception(file, line, func, message.c_str(), assertion, true);    
   }
 
Index: tools/dim_to_lgf.cc
===================================================================
--- tools/dim_to_lgf.cc	(revision 2404)
+++ tools/dim_to_lgf.cc	(revision 2410)
@@ -19,5 +19,5 @@
 ///\ingroup demos
 ///\file
-///\brief DIMACS to LGF converter (demo).
+///\brief DIMACS to LGF converter.
 ///
 /// This program converts various DIMACS formats to the LEMON Graph Format
@@ -34,29 +34,8 @@
 #include <lemon/graph_writer.h>
 
+#include <lemon/arg_parser.h>
+
 using namespace std;
 using namespace lemon;
-
-const char* versionString =
-"dim_to_lgf - part of lemon library\n";
-
-const char* helpString =
-"DIMACS to LGF converter\n"
-"Usage: dim_to_lgf [OPTIONS]\n"
-"\n"
-"Examples:\n"
-"  dim_to_lgf --type shortestpath --input graph.dim --output graph.lgf\n"
-"\n"
-"Options:\n"
-"  -i FILE, --input FILE    use FILE as input instead of standard input\n"
-"  -o FILE, --output FILE   use FILE as output instead of standard output\n"
-"  -t TYPE, --type TYPE     set up the type of the graph\n"
-"                             Possible types:\n"
-"                               mincostflow\n"
-"                               maxflow (default)\n"
-"                               shortestpath\n"
-"                               capacitated\n"
-"                               plain\n"
-"  -v, --version            shows the version of the converter\n"
-"  -h, --help               shows the help of the converter\n";
 
 
@@ -74,64 +53,44 @@
   std::string typeName;
 
-  bool help = false;
-  bool version = false;
+  bool mincostflow;
+  bool maxflow;
+  bool shortestpath;
+  bool capacitated;
+  bool plain;
 
-  for (int arg = 1; arg < argc; ++arg) {
-    if (strcmp(argv[arg], "--type") == 0 || 
-	strcmp(argv[arg], "-t") == 0) {
-      if (!typeName.empty()) {
-	cerr << "Multiple type description" << endl;
-	return -1;
-      }
-      if (arg + 1 == argc) {
-	cerr << "Parameter without value" << endl;
-	return -1;
-      }
-      typeName = argv[++arg];
-    }
-    else if (strcmp(argv[arg], "--input") == 0 || 
-	     strcmp(argv[arg], "-i") == 0) {
-      if (!inputName.empty()) {
-	cerr << "Multiple input description" << endl;
-	return -1;
-      }
-      if (arg + 1 == argc) {
-	cerr << "Parameter without value" << endl;
-	return -1;
-      }
-      inputName = argv[++arg];
-    }
-    else if (strcmp(argv[arg], "--output") == 0 || 
-	     strcmp(argv[arg], "-o") == 0) {
-      if (!outputName.empty()) {
-	cerr << "Multiple input description" << endl;
-	return -1;
-      }
-      if (arg + 1 == argc) {
-	cerr << "Parameter without value" << endl;
-	return -1;
-      }
-      outputName = argv[++arg];
-    } else if (strcmp(argv[arg], "--help") == 0 ||
-	       strcmp(argv[arg], "-h") == 0) {
-      help = true;
-    } else if (strcmp(argv[arg], "--version") == 0 ||
-	       strcmp(argv[arg], "-v") == 0) {
-      version = true;
-    } else {
-      cerr << "Invalid option: " << argv[arg] << endl;
-      return -1;
-    }
-  }
+  bool version;
 
-  if (version) {
-    cout << versionString;
-  }
-  if (help) {
-    cout << helpString;
-  }
-  if (help || version) {
-    return 0;
-  }
+  ArgParser ap(argc, argv);
+  ap.refOption("-input", 
+               "use FILE as input instead of standard input", 
+               inputName).synonym("i", "-input")
+    .refOption("-output", 
+               "use FILE as output instead of standard output", 
+               outputName).synonym("o", "-output")
+    .refOption("-mincostflow", 
+               "set the type of the graph to \"mincostflow\" graph", 
+               mincostflow)
+    .optionGroup("type", "-mincostflow").synonym("mcf", "-mincostflow")
+    .refOption("-maxflow", 
+               "set the type of the graph to \"maxflow\" graph", 
+               maxflow)
+    .optionGroup("type", "-maxflow").synonym("mf", "-maxflow")
+    .refOption("-shortestpath", 
+               "set the type of the graph to \"shortestpath\" graph", 
+               shortestpath)
+    .optionGroup("type", "-shortestpath").synonym("sp", "-shortestpath")
+    .refOption("-capacitated", 
+               "set the type of the graph to \"capacitated\" graph", 
+               capacitated)
+    .optionGroup("type", "-capacitated").synonym("cap", "-capacitated")
+    .refOption("-plain", 
+               "set the type of the graph to \"plain\" graph", 
+               plain)
+    .optionGroup("type", "-plain").synonym("pl", "-plain")
+    .onlyOneGroup("type")
+    .mandatoryGroup("type")
+    .refOption("-version", "show version information", version)
+    .synonym("v", "-version")
+    .run();
 
   ifstream input;
@@ -155,9 +114,5 @@
   ostream& os = (outputName.empty() ? cout : output);
 
-  if (typeName.empty()) {
-    typeName = "maxflow";
-  }
-
-  if (typeName == "mincostflow") {
+  if (mincostflow) {
     Graph graph;
     Node s, t;
@@ -170,5 +125,5 @@
       writeEdgeMap("cost", cost).
       run();
-  } else if (typeName == "maxflow") {
+  } else if (maxflow) {
     Graph graph;
     Node s, t;
@@ -180,5 +135,5 @@
       writeNode("target", t).
       run();
-  } else if (typeName == "shortestpath") {
+  } else if (shortestpath) {
     Graph graph;
     Node s;
@@ -189,5 +144,5 @@
       writeNode("source", s).
       run();
-  } else if (typeName == "capacitated") {
+  } else if (capacitated) {
     Graph graph;
     DoubleMap capacity(graph);
@@ -196,5 +151,5 @@
       writeEdgeMap("capacity", capacity).
       run();
-  } else if (typeName == "plain") {
+  } else if (plain) {
     Graph graph;
     readDimacs(is, graph);
Index: tools/lgf-gen.cc
===================================================================
--- tools/lgf-gen.cc	(revision 2402)
+++ tools/lgf-gen.cc	(revision 2410)
@@ -280,5 +280,5 @@
 
 
-int main(int argc,char **argv) 
+int main(int argc,const char **argv) 
 {
   ArgParser ap(argc,argv);
