Index: /trunk/FACT++/src/FileEntry.h
===================================================================
--- /trunk/FACT++/src/FileEntry.h	(revision 19804)
+++ /trunk/FACT++/src/FileEntry.h	(revision 19804)
@@ -0,0 +1,201 @@
+#ifndef FACT_FileEntry
+#define FACT_FileEntry
+
+#include <vector>
+#include <string>
+#include <iomanip>
+
+namespace FileEntry
+{
+    enum BasicType_t
+    {
+        kNone = 0,
+        kConst,
+        kVarchar,
+        kBool,
+        kInt8,
+        kUInt8,
+        kFloat,
+        kDouble,
+        kInt16,
+        kUInt16,
+        kInt32,
+        kUInt32,
+        kInt64,
+        kUInt64,
+    };
+
+    struct Type
+    {
+        BasicType_t type;
+        std::string root;
+        char fits;
+        std::string sql;
+    };
+
+    struct Types : std::vector<Type>
+    {
+        Types(std::initializer_list<Type> il, const allocator_type& alloc = allocator_type())
+               : std::vector<Type>(il, alloc)
+        {
+        }
+
+        // Note that the result is not unique!
+        const std::vector<Type>::const_iterator root(const std::string &str) const
+        {
+            for (auto it=cbegin(); it!=cend(); it++)
+                if (str==it->root)
+                    return it;
+            return cend();
+        }
+
+        // Note that the result is not unique!
+        const std::vector<Type>::const_iterator type(const BasicType_t &t) const
+        {
+            for (auto it=cbegin(); it!=cend(); it++)
+                if (t==it->type)
+                    return it;
+            return cend();
+        }
+
+        const std::vector<Type>::const_iterator fits(const char &f) const
+        {
+            for (auto it=cbegin(); it!=cend(); it++)
+                if (f==it->fits)
+                    return it;
+            return cend();
+        }
+
+        const std::vector<Type>::const_iterator sql(const std::string &str) const
+        {
+            for (auto it=cbegin(); it!=cend(); it++)
+                if (str==it->sql)
+                    return it;
+            return cend();
+        }
+    };
+
+    static const Types LUT =
+    {
+        { kVarchar,  "Char_t",    'A', "VARCHAR"           },
+        { kVarchar,  "Char_t",    'a', "VARCHAR"           },
+        { kBool,     "Bool_t",    'L', "BOOLEAN"           },
+        { kBool,     "Bool_t",    'l', "BOOLEAN"           },
+        { kInt8,     "Char_t",    'B', "TINYINT"           },
+        { kUInt8,    "UInt8_t",   'b', "TINYINT UNSIGNED"  },
+        { kInt16,    "Short_t",   'I', "SMALLINT"          },
+        { kUInt16,   "UShort_t",  'i', "SMALLINT UNSIGNED" },
+        { kInt32,    "Int_t",     'J', "INT"               },
+        { kUInt32,   "UInt_t",    'j', "INT UNSIGNED"      },
+        { kInt64,    "Long64_t",  'K', "BIGINT"            },
+        { kUInt64,   "ULong64_t", 'k', "BIGINT UNSIGNED"   },
+        { kFloat,    "Float_t",   'E', "FLOAT"             },
+        { kFloat,    "Float_t",   'e', "FLOAT"             },
+        { kDouble,   "Double_t",  'D', "DOUBLE"            },
+        { kDouble,   "Double_t",  'd', "DOUBLE"            },
+    };
+
+    struct Container
+    {
+        static std::map<void*, size_t> counter;
+
+        std::string branch; // branch name
+        std::string column; // column name
+
+        BasicType_t type;
+
+        size_t num;
+        void *ptr;
+
+        // Root File (do not mix with FitsFile!)
+        Container(const std::string &b, const std::string &c,
+                  const BasicType_t &t, const size_t &n)
+            : branch(b), column(c), type(t), num(n), ptr(0)
+        {
+            std::cout << "Add 1" << std::endl;
+            switch (t)
+            {
+            case kInt8:   ptr = new int8_t[n];   break;
+            case kUInt8:  ptr = new uint8_t[n];  break;
+            case kBool:   ptr = new uint8_t[n];  break;
+            case kFloat:  ptr = new float[n];    break;
+            case kDouble: ptr = new double[n];   break;
+            case kInt16:  ptr = new int16_t[n];  break;
+            case kUInt16: ptr = new uint16_t[n]; break;
+            case kInt32:  ptr = new int32_t[n];  break;
+            case kUInt32: ptr = new uint32_t[n]; break;
+            case kInt64:  ptr = new int64_t[n];  break;
+            case kUInt64: ptr = new uint64_t[n]; break;
+            case kVarchar:
+            case kConst:
+            case kNone:
+                break;
+            }
+            // Indicate that this was allocated and how often
+            counter[ptr]++;
+        }
+
+        Container(const std::string &c, const std::string &value)
+            : branch(value), column(c), type(kConst), num(1), ptr(0)
+        {
+        }
+
+        Container(const Container &c) : branch(c.branch), column(c.column),
+            type(c.type), num(c.num), ptr(c.ptr)
+        {
+            // If this was not allocated in the constructor do not increate the counter
+            if (counter[ptr])
+                counter[ptr]++;
+        }
+
+        // FitsFile (do not mix with RootFile!)
+        Container(const std::string &b, const std::string &c,
+                  const BasicType_t &t, const size_t &n, void *_ptr)
+            : branch(b), column(c), type(t), num(n), ptr(_ptr)
+        {
+        }
+
+        ~Container()
+        {
+            // Count how often it gets deleted.
+            counter[ptr]--;
+            // Now it is time to delete it. Note that pointers which were
+            // never allocated (counter==0) now are != 0
+            if (counter[ptr]==0)
+                ::operator delete[](ptr); // It seems root is deleting it already
+        }
+
+        std::string fmt(const size_t &index) const
+        {
+            std::ostringstream str;
+
+            switch (type)
+            {
+            case kVarchar: str << std::string(reinterpret_cast<char*>(ptr), num).c_str(); break;
+            case kFloat:   str << std::setprecision(8) << reinterpret_cast<float*>(ptr)[index];  break;
+            case kDouble:  str << std::setprecision(16) << reinterpret_cast<double*>(ptr)[index]; break;
+            case kBool:
+            case kInt8:    str << int32_t(reinterpret_cast<int8_t*>(ptr)[index]); break;
+            case kUInt8:   str << uint32_t(reinterpret_cast<uint8_t*>(ptr)[index]); break;
+            case kInt16:   str << reinterpret_cast<int16_t*>(ptr)[index]; break;
+            case kUInt16:  str << reinterpret_cast<uint16_t*>(ptr)[index]; break;
+            case kInt32:   str << reinterpret_cast<int32_t*>(ptr)[index]; break;
+            case kUInt32:  str << reinterpret_cast<uint32_t*>(ptr)[index]; break;
+            case kInt64:   str << reinterpret_cast<int64_t*>(ptr)[index]; break;
+            case kUInt64:  str << reinterpret_cast<uint64_t*>(ptr)[index]; break;
+            case kConst:   str << branch; break;
+            case kNone:
+                break;
+            }
+
+            //if (str.str()=="nan" || str.str()=="-nan" || str.str()=="inf" || str.str()=="-inf")
+            //    return "NULL";
+
+            return str.str();
+        }
+    };
+
+    std::map<void*, size_t> Container::counter;
+}
+
+#endif
Index: /trunk/FACT++/src/fits2sql.cc
===================================================================
--- /trunk/FACT++/src/fits2sql.cc	(revision 19803)
+++ /trunk/FACT++/src/fits2sql.cc	(revision 19804)
@@ -8,4 +8,5 @@
 #include "Time.h"
 #include "Configuration.h"
+#include "FileEntry.h"
 
 #include "zfits.h"
@@ -15,26 +16,4 @@
 
 // ------------------------------------------------------------------------
-
-struct Map : pair<string, string>
-{
-    Map() { }
-};
-
-std::istream &operator>>(std::istream &in, Map &m)
-{
-    const istreambuf_iterator<char> eos;
-    string txt(istreambuf_iterator<char>(in), eos);
-
-    const boost::regex expr("((.*)[^\\\\])/(.*)");
-    boost::smatch match;
-    if (!boost::regex_match(txt, match, expr))
-        throw runtime_error("Could not evaluate map argument: "+txt);
-
-    m.first  = match[1].str();
-    m.second = match[3].str();
-
-    return in;
-}
-
 
 void SetupConfiguration(Configuration &conf)
@@ -48,6 +27,6 @@
         ("extension,e",    var<string>(""),           "Name of the fits extension (table) to convert")
         ("table",          var<string>(""),           "Name of the table to use (default is the tree name)")
-        ("map",            vars<Map>(),               "A regular expression which is applied to the leaf name befoee it is used as SQL column name)")
-        ("sql-type",       vars<Map>(),               "Allows to overwrite the calculated SQL type for a given column e.g. 'sql-column-name/UNSIGNED IN'")
+        ("map",            vars<Configuration::Map>(),"A regular expression which is applied to the leaf name befoee it is used as SQL column name)")
+        ("sql-type",       vars<Configuration::Map>(),"Allows to overwrite the calculated SQL type for a given column e.g. 'sql-column-name/UNSIGNED IN'")
         ("ignore",         vars<string>(),            "Ignore the given leaf, if the given regular expression matches")
         ("unsigned",       vars<string>(),            "In fits files per default columns are signed. This interpretss the column as unsigned value. Use the FITS column name.")
@@ -63,4 +42,5 @@
         ("delete",         po_switch(),               "Delete all entries first which fit all constant columns defined by --const")
         ("index",          po_switch(),               "If a table is created, all const columns are used as a single index")
+        ("unique",         po_switch(),               "If a table is created, all const columns are used as a unqiue index (UNIQUE)")
         ;
 
@@ -213,91 +193,4 @@
 }
 
-enum BasicType_t
-{
-    kNone = 0,
-    kConst,
-    kVarchar,
-    kBool,
-    kFloat,
-    kDouble,
-    kInt8,
-    kUInt8,
-    kInt16,
-    kUInt16,
-    kInt32,
-    kUInt32,
-    kInt64,
-    kUInt64,
-//    kMJD,
-};
-
-static const map<char, pair<BasicType_t, string>> ConvFits =
-{
-    { 'A', { kVarchar, "VARCHAR"  } },
-    { 'a', { kVarchar, "VARCHAR"  } },
-    { 'L', { kBool,    "BOOLEAN"  } },
-    { 'l', { kBool,    "BOOLEAN"  } },
-    { 'B', { kInt8,    "TINYINT"  } },
-    { 'b', { kUInt8,   "TINYINT UNSIGNED"  } },
-    { 'I', { kInt16,   "SMALLINT" } },
-    { 'i', { kUInt16,  "SMALLINT UNSIGNED" } },
-    { 'J', { kInt32,   "INT"      } },
-    { 'j', { kUInt32,  "INT UNSIGNED"      } },
-    { 'K', { kInt64,   "BIGINT"   } },
-    { 'k', { kUInt64,  "BIGINT UNSIGNED"   } },
-    { 'E', { kFloat,   "FLOAT"    } },
-    { 'e', { kFloat,   "FLOAT"    } },
-    { 'D', { kDouble,  "DOUBLE"   } },
-    { 'd', { kDouble,  "DOUBLE"   } },
-};
-
-struct Container
-{
-    string branch; // fits column name
-    string column; // sql  column name
-    BasicType_t type;
-    size_t num;
-//    double offset;
-    void *ptr;
-
-    Container(const string &b, const string &c, const BasicType_t &t, const size_t &n/*, const double &offset=0*/) : branch(b), column(c), type(t), num(n), ptr(0)
-    {
-    }
-    Container(const string &c, const string &value) : branch(value), column(c), type(kConst), num(1), ptr(0)
-    {
-    }
-    ~Container()
-    {
-    }
-
-    string fmt(const size_t &index) const
-    {
-        ostringstream str;
-
-        switch (type)
-        {
-        //case kVarchar: str << string(reinterpret_cast<char*>(ptr), num); break;
-        case kVarchar: str << string(reinterpret_cast<char*>(ptr), num).c_str(); break;
-        case kFloat:   str << setprecision(8) << reinterpret_cast<float*>(ptr)[index];  break;
-//        case kMJD:     str << setprecision(16) << reinterpret_cast<double*>(ptr)[0]+offset; break;
-        case kDouble:  str << setprecision(16) << reinterpret_cast<double*>(ptr)[index]; break;
-        case kBool:
-        case kInt8:    str << int32_t(reinterpret_cast<int8_t*>(ptr)[index]); break;
-        case kUInt8:   str << uint32_t(reinterpret_cast<uint8_t*>(ptr)[index]); break;
-        case kInt16:   str << reinterpret_cast<int16_t*>(ptr)[index]; break;
-        case kUInt16:  str << reinterpret_cast<uint16_t*>(ptr)[index]; break;
-        case kInt32:   str << reinterpret_cast<int32_t*>(ptr)[index]; break;
-        case kUInt32:  str << reinterpret_cast<uint32_t*>(ptr)[index]; break;
-        case kInt64:   str << reinterpret_cast<int64_t*>(ptr)[index]; break;
-        case kUInt64:  str << reinterpret_cast<uint64_t*>(ptr)[index]; break;
-        case kConst:   str << branch; break;
-        case kNone:
-            break;
-        }
-
-        return str.str();
-    }
-};
-
 int main(int argc, const char* argv[])
 {
@@ -343,6 +236,7 @@
     const bool print_delete      = conf.Get<bool>("print-delete");
 
-    const vector<Map> mymap      = conf.Vec<Map>("map");
-    const vector<Map> sqltypes   = conf.Vec<Map>("sql-type");
+    const auto mymap    = conf.Vec<Configuration::Map>("map");
+    const auto sqltypes = conf.Vec<Configuration::Map>("sql-type");
+
     const vector<string> _ignore = conf.Vec<string>("ignore");
     const vector<string> primary = conf.Vec<string>("primary");
@@ -353,5 +247,4 @@
     if (first>=max)
         cerr << "WARNING: Resource `first` (" << first << ") exceeds `max` (" << max << ")" << endl;
-
 
     // -------------------------------------------------------------------------
@@ -415,5 +308,5 @@
         "(\n";
 
-    vector<Container> vec;
+    vector<FileEntry::Container> vec;
 
     const auto fixed = conf.GetWildcardOptions("const.*");
@@ -492,6 +385,6 @@
             tolower(col.type) : toupper(col.type);
 
-        auto it = ConvFits.find(tn);
-        if (it==ConvFits.end())
+        const auto it = FileEntry::LUT.fits(tn);
+        if (it==FileEntry::LUT.cend())
         {
             if (verbose>2)
@@ -509,5 +402,5 @@
             cout << " (" << name << ")";
 
-        string sqltype = it->second.second;
+        string sqltype = it->sql;
 
         for (auto m=sqltypes.cbegin(); m!=sqltypes.cend(); m++)
@@ -537,10 +430,9 @@
         }
 
-        const BasicType_t bt =
+        const FileEntry::BasicType_t bt =
             /*ic.first=="Time" && col.num==1 && col.unit=="MJD" && it->second.first==kDouble ?
-            kMJD :*/ it->second.first;
-
-        vec.emplace_back(ic->first, name, bt, col.num/*, mjdref*/);
-        vec.back().ptr = f.SetPtrAddress(ic->first);
+            kMJD :*/ it->type;
+
+        vec.emplace_back(ic->first, name, bt, col.num, f.SetPtrAddress(ic->first));
     }
 
@@ -714,5 +606,5 @@
             query += ",\n";
 
-        const size_t N = c->type==kVarchar ? 1 : c->num;
+        const size_t N = c->type==FileEntry::kVarchar ? 1 : c->num;
         for (size_t i=0; i<N; i++)
         {
@@ -748,8 +640,8 @@
                 query += ",\n";
 
-            const size_t N = c->type==kVarchar ? 1 : c->num;
+            const size_t N = c->type==FileEntry::kVarchar ? 1 : c->num;
             for (size_t i=0; i<N; i++)
             {
-                if (c->type==kVarchar)
+                if (c->type==FileEntry::kVarchar)
                     query += "   '"+c->fmt(i)+"'";
                 else
Index: /trunk/FACT++/src/root2csv.cc
===================================================================
--- /trunk/FACT++/src/root2csv.cc	(revision 19803)
+++ /trunk/FACT++/src/root2csv.cc	(revision 19804)
@@ -15,29 +15,10 @@
 #include <TTreeFormulaManager.h>
 
+#include "FileEntry.h"
+
 using namespace std;
 namespace fs = boost::filesystem;
 
 // ------------------------------------------------------------------------
-
-struct Map : pair<string, string>
-{
-    Map() { }
-};
-
-std::istream &operator>>(std::istream &in, Map &m)
-{
-    const istreambuf_iterator<char> eos;
-    string txt(istreambuf_iterator<char>(in), eos);
-
-    const boost::regex expr("((.*)[^\\\\])/(.*)");
-    boost::smatch match;
-    if (!boost::regex_match(txt, match, expr))
-        throw runtime_error("Could not evaluate map argument: "+txt);
-
-    m.first  = match[1].str();
-    m.second = match[3].str();
-
-    return in;
-}
 
 void SetupConfiguration(Configuration &conf)
@@ -52,5 +33,5 @@
         ("ignore",         vars<string>(),            "Ignore the given leaf, if the given regular expression matches")
         ("alias.*",        var<string>(),             "Define an alias")
-        ("auto-alias",     vars<Map>(),               "Regular expression to define aliases from the branch names automatically")
+        ("auto-alias",     vars<Configuration::Map>(),"Regular expression to define aliases from the branch names automatically")
         ("header",         var<uint16_t>(uint16_t(0)),"Type of header line (0: preceeding #, 1: without preceeding #, 2: none)")
         ("add.*",          var<string>(),             "Define an additional column")
@@ -170,102 +151,4 @@
 }
 
-enum BasicType_t
-{
-    kNone = 0,
-    kConst,
-    kFloat,
-    kDouble,
-    kInt16,
-    kUInt16,
-    kInt32,
-    kUInt32,
-    kInt64,
-    kUInt64,
-};
-
-static const map<string, pair<BasicType_t, string>> ConvRoot =
-{
-    { "Float_t",   { kFloat,  "FLOAT"             } },
-    { "Double_t",  { kDouble, "DOUBLE"            } },
-    { "ULong64_t", { kUInt64, "BIGINT UNSIGNED"   } },
-    { "Long64_t",  { kInt64,  "BIGINT"            } },
-    { "UInt_t",    { kUInt32, "INT UNSIGNED"      } },
-    { "Int_t",     { kInt32,  "INT"               } },
-    { "UShort_t",  { kUInt16, "SMALLINT UNSIGNED" } },
-    { "Short_t",   { kInt16,  "SMALLINT"          } },
-};
-
-struct Container
-{
-    static map<void*, size_t> counter;
-
-    string branch; // branch name
-    string column; // column name
-    BasicType_t type;
-    size_t num;
-    void *ptr;
-
-    Container(const string &b, const string &c, const BasicType_t &t, const size_t n=1) : branch(b), column(c), type(t), num(n), ptr(0)
-    {
-        switch (t)
-        {
-        case kFloat:  ptr = new Float_t[n];   break;
-        case kDouble: ptr = new Double_t[n];  break;
-        case kInt16:  ptr = new Short_t[n];   break;
-        case kUInt16: ptr = new UShort_t[n];  break;
-        case kInt32:  ptr = new Int_t[n];     break;
-        case kUInt32: ptr = new UInt_t[n];    break;
-        case kInt64:  ptr = new Long64_t[n];  break;
-        case kUInt64: ptr = new ULong64_t[n]; break;
-        case kConst:
-        case kNone:
-            break;
-        }
-        counter[ptr]++;
-    }
-    Container(const string &c, const string &value) : branch(value), column(c), type(kConst), num(1), ptr(0)
-    {
-    }
-
-    Container(const Container &c) : branch(c.branch), column(c.column), type(c.type), num(c.num), ptr(c.ptr)
-    {
-        counter[ptr]++;
-    }
-
-    ~Container()
-    {
-        counter[ptr]--;
-        if (counter[ptr]==0)
-            ::operator delete[](ptr); // It seems root is deleting it already
-    }
-
-    string fmt(const size_t &index) const
-    {
-        ostringstream str;
-
-        switch (type)
-        {
-        case kFloat:   str << setprecision(8) << reinterpret_cast<Float_t*>(ptr)[index];  break;
-        case kDouble:  str << setprecision(16) << reinterpret_cast<Double_t*>(ptr)[index]; break;
-        case kInt16:   str << reinterpret_cast<Short_t*>(ptr)[index]; break;
-        case kUInt16:  str << reinterpret_cast<UShort_t*>(ptr)[index]; break;
-        case kInt32:   str << reinterpret_cast<Int_t*>(ptr)[index]; break;
-        case kUInt32:  str << reinterpret_cast<UInt_t*>(ptr)[index]; break;
-        case kInt64:   str << reinterpret_cast<Long64_t*>(ptr)[index]; break;
-        case kUInt64:  str << reinterpret_cast<ULong64_t*>(ptr)[index]; break;
-        case kConst:   str << branch; break;
-        case kNone:
-            break;
-        }
-
-        //if (str.str()=="nan" || str.str()=="-nan" || str.str()=="inf" || str.str()=="-inf")
-        //    return "NULL";
-
-        return str.str();
-    }
-};
-
-map<void*, size_t> Container::counter;
-
 void ErrorHandlerAll(Int_t level, Bool_t abort, const char *location, const char *msg)
 {
@@ -279,5 +162,5 @@
 
 // --------------------------- Write Header --------------------------------
-void WriteHeader(ostream &out, const vector<Container> &vec, const vector<TTreeFormula*> &form, bool skip, uint16_t header)
+void WriteHeader(ostream &out, const vector<FileEntry::Container> &vec, const vector<TTreeFormula*> &form, bool skip, uint16_t header)
 {
     if (header>1)
@@ -384,6 +267,6 @@
     const bool print_leaves      = conf.Get<bool>("print-leaves");
 
-    const vector<string> _ignore = conf.Vec<string>("ignore");
-    const vector<Map> autoalias  = conf.Vec<Map>("auto-alias");
+    const auto  _ignore   = conf.Vec<string>("ignore");
+    const auto  autoalias = conf.Vec<Configuration::Map>("auto-alias");
 
     // -------------------------------------------------------------------------
@@ -459,5 +342,5 @@
         cout << "\n-------------------------- Evaluating output -----------------------" << endl;
 
-    vector<Container> vec;
+    vector<FileEntry::Container> vec;
 
 /*
@@ -571,6 +454,6 @@
             const string tn = L->GetTypeName();
 
-            auto it = ConvRoot.find(tn);
-            if (it==ConvRoot.end())
+            const auto it = FileEntry::LUT.root(tn);
+            if (it==FileEntry::LUT.cend())
             {
                 if (verbose>2)
@@ -585,5 +468,5 @@
                 cout << " (" << name << ")";
 
-            vec.emplace_back(o->GetTitle(), name, it->second.first, L->GetLenStatic());
+            vec.emplace_back(o->GetTitle(), name, it->type, L->GetLenStatic());
             c.SetBranchAddress(o->GetTitle(), vec.back().ptr);
         }
@@ -690,6 +573,6 @@
         const string tn = L->GetTypeName();
 
-        auto it = ConvRoot.find(tn);
-        if (it==ConvRoot.end())
+        const auto it = FileEntry::LUT.root(tn);
+        if (it==FileEntry::LUT.cend())
         {
             if (verbose>2)
@@ -704,5 +587,5 @@
             cout << " (" << *l << ")";
 
-        vec.emplace_back(l->c_str(), l->c_str(), it->second.first, L->GetLenStatic());
+        vec.emplace_back(l->c_str(), l->c_str(), it->type, L->GetLenStatic());
         c.SetBranchAddress(l->c_str(), vec.back().ptr);
     }
@@ -718,5 +601,5 @@
     c.SetBranchStatus("*", 0);
     for (auto v=vec.cbegin(); v!=vec.cend(); v++)
-        if (v->type!=kConst)
+        if (v->type!=FileEntry::kConst)
             c.SetBranchStatus(v->branch.c_str(), 1);
 
Index: /trunk/FACT++/src/root2sql.cc
===================================================================
--- /trunk/FACT++/src/root2sql.cc	(revision 19803)
+++ /trunk/FACT++/src/root2sql.cc	(revision 19804)
@@ -15,4 +15,6 @@
 #include <TError.h>
 
+#include "FileEntry.h"
+
 using namespace std;
 namespace fs = boost::filesystem;
@@ -20,4 +22,5 @@
 // ------------------------------------------------------------------------
 
+/*
 struct Map : pair<string, string>
 {
@@ -40,5 +43,5 @@
     return in;
 }
-
+*/
 
 void SetupConfiguration(Configuration &conf)
@@ -52,6 +55,6 @@
         ("tree,t",         var<string>("Events"),     "Name of the root tree to convert")
         ("table",          var<string>(""),           "Name of the table to use (default is the tree name)")
-        ("map",            vars<Map>(),               "A regular expression which is applied to the leaf name befoee it is used as SQL column name)")
-        ("sql-type",       vars<Map>(),               "Allows to overwrite the calculated SQL type for a given column e.g. 'sql-column-name/UNSIGNED IN'")
+        ("map",            vars<Configuration::Map>(),"A regular expression which is applied to the leaf name befoee it is used as SQL column name)")
+        ("sql-type",       vars<Configuration::Map>(),"Allows to overwrite the calculated SQL type for a given column e.g. 'sql-column-name/UNSIGNED IN'")
         ("ignore",         vars<string>(),            "Ignore the given leaf, if the given regular expression matches")
         ("primary",        vars<string>(),            "List of columns to be used as primary keys during table creation (in connection with --create)")
@@ -223,102 +226,4 @@
 }
 
-enum BasicType_t
-{
-    kNone = 0,
-    kConst,
-    kFloat,
-    kDouble,
-    kInt16,
-    kUInt16,
-    kInt32,
-    kUInt32,
-    kInt64,
-    kUInt64,
-};
-
-static const map<string, pair<BasicType_t, string>> ConvRoot =
-{
-    { "Float_t",   { kFloat,  "FLOAT"             } },
-    { "Double_t",  { kDouble, "DOUBLE"            } },
-    { "ULong64_t", { kUInt64, "BIGINT UNSIGNED"   } },
-    { "Long64_t",  { kInt64,  "BIGINT"            } },
-    { "UInt_t",    { kUInt32, "INT UNSIGNED"      } },
-    { "Int_t",     { kInt32,  "INT"               } },
-    { "UShort_t",  { kUInt16, "SMALLINT UNSIGNED" } },
-    { "Short_t",   { kInt16,  "SMALLINT"          } },
-};
-
-struct Container
-{
-    static map<void*, size_t> counter;
-
-    string branch; // branch name
-    string column; // column name
-    BasicType_t type;
-    size_t num;
-    void *ptr;
-
-    Container(const string &b, const string &c, const BasicType_t &t, const size_t &n) : branch(b), column(c), type(t), num(n), ptr(0)
-    {
-        switch (t)
-        {
-        case kFloat:  ptr = new Float_t[n];   break;
-        case kDouble: ptr = new Double_t[n];  break;
-        case kInt16:  ptr = new Short_t[n];   break;
-        case kUInt16: ptr = new UShort_t[n];  break;
-        case kInt32:  ptr = new Int_t[n];     break;
-        case kUInt32: ptr = new UInt_t[n];    break;
-        case kInt64:  ptr = new Long64_t[n];  break;
-        case kUInt64: ptr = new ULong64_t[n]; break;
-        case kConst:
-        case kNone:
-            break;
-        }
-        counter[ptr]++;
-    }
-    Container(const string &c, const string &value) : branch(value), column(c), type(kConst), num(1), ptr(0)
-    {
-    }
-
-    Container(const Container &c) : branch(c.branch), column(c.column), type(c.type), num(c.num), ptr(c.ptr)
-    {
-        counter[ptr]++;
-    }
-
-    ~Container()
-    {
-        counter[ptr]--;
-        if (counter[ptr]==0)
-            ::operator delete[](ptr); // It seems root is deleting it already
-    }
-
-    string fmt(const size_t &index) const
-    {
-        ostringstream str;
-
-        switch (type)
-        {
-        case kFloat:   str << setprecision(8) << reinterpret_cast<Float_t*>(ptr)[index];  break;
-        case kDouble:  str << setprecision(16) << reinterpret_cast<Double_t*>(ptr)[index]; break;
-        case kInt16:   str << reinterpret_cast<Short_t*>(ptr)[index]; break;
-        case kUInt16:  str << reinterpret_cast<UShort_t*>(ptr)[index]; break;
-        case kInt32:   str << reinterpret_cast<Int_t*>(ptr)[index]; break;
-        case kUInt32:  str << reinterpret_cast<UInt_t*>(ptr)[index]; break;
-        case kInt64:   str << reinterpret_cast<Long64_t*>(ptr)[index]; break;
-        case kUInt64:  str << reinterpret_cast<ULong64_t*>(ptr)[index]; break;
-        case kConst:   str << branch; break;
-        case kNone:
-            break;
-        }
-
-        //if (str.str()=="nan" || str.str()=="-nan" || str.str()=="inf" || str.str()=="-inf")
-        //    return "NULL";
-
-        return str.str();
-    }
-};
-
-map<void*, size_t> Container::counter;
-
 void ErrorHandlerAll(Int_t level, Bool_t abort, const char *location, const char *msg)
 {
@@ -380,6 +285,7 @@
     const bool print_delete      = conf.Get<bool>("print-delete");
 
-    const vector<Map> mymap      = conf.Vec<Map>("map");
-    const vector<Map> sqltypes   = conf.Vec<Map>("sql-type");
+    const auto mymap    = conf.Vec<Configuration::Map>("map");
+    const auto sqltypes = conf.Vec<Configuration::Map>("sql-type");
+
     const vector<string> _ignore = conf.Vec<string>("ignore");
     const vector<string> primary = conf.Vec<string>("primary");
@@ -451,5 +357,5 @@
         "(\n";
 
-    vector<Container> vec;
+    vector<FileEntry::Container> vec;
 
     const auto fixed = conf.GetWildcardOptions("const.*");
@@ -537,6 +443,6 @@
         const string tn = L->GetTypeName();
 
-        auto it = ConvRoot.find(tn);
-        if (it==ConvRoot.end())
+        const auto it = FileEntry::LUT.root(tn);
+        if (it==FileEntry::LUT.cend())
         {
             if (verbose>2)
@@ -554,5 +460,5 @@
             cout << " (" << name << ")";
 
-        string sqltype = it->second.second;
+        string sqltype = it->sql;
 
         for (auto m=sqltypes.cbegin(); m!=sqltypes.cend(); m++)
@@ -574,5 +480,5 @@
         }
 
-        vec.emplace_back(o->GetTitle(), name, it->second.first, L->GetLenStatic());
+        vec.emplace_back(o->GetTitle(), name, it->type, L->GetLenStatic());
         T->SetBranchAddress(o->GetTitle(), vec.back().ptr);
     }
@@ -593,5 +499,5 @@
     T->SetBranchStatus("*", 0);
     for (auto c=vec.cbegin(); c!=vec.cend(); c++)
-        if (c->type!=kConst)
+        if (c->type!=FileEntry::kConst)
             T->SetBranchStatus(c->branch.c_str(), 1);
 
