]> git.tdb.fi Git - libs/datafile.git/blobdiff - source/loader.cpp
Make use of KeyError's key parameter
[libs/datafile.git] / source / loader.cpp
index cf1a5acae89dc0e4abe7583358e3926ab629277c..67668cdea1f5bc52b76c7c02c401fda501d9531e 100644 (file)
@@ -34,12 +34,24 @@ Loader::~Loader()
                delete i->second;
 }
 
+void Loader::add(const string &k, LoaderAction *a)
+{
+       ActionMap::iterator i=actions.find(k);
+       if(i!=actions.end())
+       {
+               delete i->second;
+               i->second=a;
+       }
+       else
+               actions[k]=a;
+}
+
 void Loader::load_statement(const Statement &st)
 {
        cur_st=&st;
        ActionMap::iterator j=actions.find(st.keyword);
        if(j==actions.end())
-               throw KeyError(st.get_location()+": Unknown keyword '"+st.keyword+"'");
+               throw KeyError(st.get_location()+": Unknown keyword", st.keyword);
        if(j->second)
                j->second->execute(*this, st);
        cur_st=0;