]> git.tdb.fi Git - libs/datafile.git/blobdiff - source/loaderaction.h
Rewrite the type system
[libs/datafile.git] / source / loaderaction.h
index 2a2a8fc0ef61dfb41624a3451ba8f4606219bf1a..972757bd399fbc953cd65100567eca343cf99d7b 100644 (file)
@@ -1,7 +1,7 @@
 /* $Id$
 
 This file is part of libmspdatafile
-Copyright © 2006-2008  Mikko Rasa, Mikkosoft Productions
+Copyright © 2008, 2010  Mikko Rasa, Mikkosoft Productions
 Distributed under the LGPL
 */
 
@@ -86,7 +86,7 @@ public:
        {
                std::vector<A0> values;
                values.reserve(st.args.size());
-               for(ValueArray::const_iterator i=st.args.begin(); i!=st.args.end(); ++i)
+               for(Statement::Arguments::const_iterator i=st.args.begin(); i!=st.args.end(); ++i)
                        values.push_back(i->get<A0>());
                (dynamic_cast<L &>(l).*func)(values);
        }
@@ -95,6 +95,25 @@ private:
 };
 
 
+/**
+Loads a statement by calling a function with the statement itself as argument.
+*/
+template<typename L>
+class LoaderFunc1<L, const Statement &>: public LoaderAction
+{
+public:
+       typedef void (L::*FuncType)(const Statement &);
+
+       LoaderFunc1(FuncType f): func(f) { }
+       void execute(Loader &l, const Statement &st) const
+       {
+               (dynamic_cast<L &>(l).*func)(st);
+       }
+private:
+       FuncType func;
+};
+
+
 template<typename L, typename A0, typename A1>
 class LoaderFunc2: public LoaderAction
 {