Index: /trunk/FACT++/src/root2sql.cc
===================================================================
--- /trunk/FACT++/src/root2sql.cc	(revision 19062)
+++ /trunk/FACT++/src/root2sql.cc	(revision 19063)
@@ -24,5 +24,6 @@
 std::istream &operator>>(std::istream &in, Map &m)
 {
-    string txt(istreambuf_iterator<char>(in), {});
+    const istreambuf_iterator<char> eos;
+    string txt(istreambuf_iterator<char>(in), eos);
 
     const boost::regex expr("((.*)[^\\\\])/(.*)");
@@ -42,6 +43,11 @@
     po::options_description control("Root to SQL");
     control.add_options()
-        ("uri,u",          var<string>()->required(), "Database link as in\n\tuser:password@server[:port]/database.")
+        ("uri,u",          var<string>()
+#if BOOST_VERSION >= 104200
+         ->required()
+#endif
+         , "Database link as in\n\tuser:password@server[:port]/database.")
         ("file",           var<string>(""),           "The root file to read from")
+        ("force",          po_switch(),               "Force processing even if there is no database connection")
         ("create",         po_switch(),               "Create the database if not existing")
         ("drop",           po_switch(),               "Drop the table (implies create)")
@@ -101,5 +107,5 @@
         "once. They are applied in sequence. A single match does not stop the sequence.\n"
         "\n"
-        "Sometimes it might also be convenient to skip a leaf. Tis can be done with "
+        "Sometimes it might also be convenient to skip a leaf. This can be done with "
         "the --ignore resource. If the given regular expresion yield a match, the "
         "leaf will be ignored. Note that the regular expression work on the raw-name "
@@ -139,5 +145,5 @@
         "end.\n"
         "\n"
-        "Using a higher verbosity level, an overview of the written columns or all "
+        "Using a higher verbosity level (-v), an overview of the written columns or all "
         "processed leaves is printed depending on the verbosity level. The output looks "
         "like the following\n"
@@ -265,4 +271,5 @@
     const int64_t  max           = conf.Get<int64_t>("max");
 
+    const bool force             = conf.Get<bool>("force");
     const bool drop              = conf.Get<bool>("drop");
     const bool create            = conf.Get<bool>("create") || drop;
@@ -354,7 +361,7 @@
 
         bool found = false;
-        for (const auto &b: _ignore)
+        for (auto b=_ignore.cbegin(); b!=_ignore.cend(); b++)
         {
-            if (boost::regex_match(name, boost::regex(b)))
+            if (boost::regex_match(name, boost::regex(*b)))
             {
                 found = true;
@@ -380,6 +387,6 @@
             cout << '\n' << o->GetName() << " [" << L->GetTypeName() << "]";
 
-        for (const auto &m: mymap)
-            name = boost::regex_replace(name, boost::regex(m.first), m.second);
+        for (auto m=mymap.cbegin(); m!=mymap.cend(); m++)
+            name = boost::regex_replace(name, boost::regex(m->first), m->second);
 
         if (verbose>1)
@@ -388,7 +395,7 @@
         string sqltype = it->second.second;
 
-        for (const auto &m: sqltypes)
-            if (m.first==name)
-                sqltype = m.second;
+        for (auto m=sqltypes.cbegin(); m!=sqltypes.cend(); m++)
+            if (m->first==name)
+                sqltype = m->second;
 
         query += ",\n   `"+name+"` "+sqltype+" NOT NULL COMMENT '"+o->GetName()+"'";
@@ -408,6 +415,6 @@
     // Setiing up branch status (must be after all SetBranchAddress)
     T->SetBranchStatus("*", 0);
-    for (const auto &c: vec)
-        T->SetBranchStatus(c.branch.c_str(), 1);
+    for (auto c=vec.cbegin(); c!=vec.cend(); c++)
+        T->SetBranchStatus(c->branch.c_str(), 1);
 
     if (has_datatype)
@@ -416,4 +423,17 @@
         if (verbose>0)
             cout << "Rows with DataType.fVal!=1 will be skipped." << endl;
+    }
+
+    // -------------------------------------------------------------------------
+
+    try
+    {
+        if (!force)
+            Database(uri).connected();
+    }
+    catch (const exception &e)
+    {
+        cerr << "SQL connection failed: " << e.what() << endl;
+        return 3;
     }
 
@@ -448,5 +468,5 @@
         cerr << "DROP TABLE `" << table << "`\n\n";
         cerr << "SQL query failed:\n" << e.what() << endl;
-        return 3;
+        return 4;
     }
 
@@ -460,5 +480,5 @@
         cerr << query << "\n\n";
         cerr << "SQL query failed:\n" << e.what() << endl;
-        return 4;
+        return 5;
     }
 
@@ -479,6 +499,6 @@
         "   `Night`";
 
-    for (const auto &c: vec)
-        query += ",\n   `"+c.column+"`";
+    for (auto c=vec.cbegin(); c!=vec.cend(); c++)
+        query += ",\n   `"+c->column+"`";
 
     query +=
@@ -496,6 +516,10 @@
 
         query += "(\n   0";
-        for (const auto &c: vec)
-            query += ",\n   "+c.fmt()+" /* "+c.column+" -> "+c.branch+" */";
+        for (auto c=vec.cbegin(); c!=vec.cend(); c++)
+        {
+            query += ",\n   "+c->fmt();
+            if (print_insert)
+                query += " /* "+c->column+" -> "+c->branch+" */";
+        }
         query += "\n)";  // ON DUPLICATE KEY UPDATE\n";
 
@@ -528,5 +552,5 @@
         cerr << query << "\n\n";
         cerr << "SQL query failed:\n" << e.what() << endl;
-        return 5;
+        return 6;
     }
 
