X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Floaderaction.h;h=a6eb552e981e38f329ab626c34d2cae9c7afc504;hb=e4beb0453a1cfe200fc97607afab94c3ddee1c65;hp=6eebeccc76f47c8144fac9f5ceeb93a35dff0a93;hpb=215e719d0ef85f748898660d15d01e77ac551de9;p=libs%2Fdatafile.git diff --git a/source/loaderaction.h b/source/loaderaction.h index 6eebecc..a6eb552 100644 --- a/source/loaderaction.h +++ b/source/loaderaction.h @@ -1,10 +1,3 @@ -/* $Id$ - -This file is part of libmspdatafile -Copyright © 2008, 2010 Mikko Rasa, Mikkosoft Productions -Distributed under the LGPL -*/ - #ifndef MSP_DATAFILE_LOADERACTION_H_ #define MSP_DATAFILE_LOADERACTION_H_ @@ -28,6 +21,8 @@ public: /** Called to process a statement. */ virtual void execute(Loader &, const Statement &) const = 0; + + virtual std::string get_signature() const = 0; }; @@ -45,11 +40,13 @@ private: public: LoaderFunc0(FuncType f): func(f) { } - virtual void execute(Loader &l, const Statement &st) const + virtual void execute(Loader &l, const Statement &) const { - if(st.args.size()!=0) throw TypeError("Wrong number of arguments"); (dynamic_cast(l).*func)(); }; + + virtual std::string get_signature() const + { return std::string(); } }; @@ -69,9 +66,11 @@ public: virtual void execute(Loader &l, const Statement &st) const { - if(st.args.size()!=1) throw TypeError("Wrong number of arguments"); (dynamic_cast(l).*func)(st.args[0].get()); } + + virtual std::string get_signature() const + { return std::string(1, TypeInfo::signature); } }; @@ -97,6 +96,14 @@ public: values.push_back(i->get()); (dynamic_cast(l).*func)(values); } + + virtual std::string get_signature() const + { + std::string result; + result += TypeInfo::signature; + result += '*'; + return result; + } }; @@ -118,6 +125,9 @@ public: { (dynamic_cast(l).*func)(st); } + + virtual std::string get_signature() const + { return "*"; } }; @@ -134,9 +144,16 @@ public: virtual void execute(Loader &l, const Statement &st) const { - if(st.args.size()!=2) throw TypeError("Wrong number of arguments"); (dynamic_cast(l).*func)(st.args[0].get(), st.args[1].get()); } + + virtual std::string get_signature() const + { + std::string result; + result += TypeInfo::signature; + result += TypeInfo::signature; + return result; + } }; @@ -153,9 +170,17 @@ public: virtual void execute(Loader &l, const Statement &st) const { - if(st.args.size()!=3) throw TypeError("Wrong number of arguments"); (dynamic_cast(l).*func)(st.args[0].get(), st.args[1].get(), st.args[2].get()); } + + virtual std::string get_signature() const + { + std::string result; + result += TypeInfo::signature; + result += TypeInfo::signature; + result += TypeInfo::signature; + return result; + } }; @@ -172,9 +197,18 @@ public: virtual void execute(Loader &l, const Statement &st) const { - if(st.args.size()!=4) throw TypeError("Wrong number of arguments"); (dynamic_cast(l).*func)(st.args[0].get(), st.args[1].get(), st.args[2].get(), st.args[3].get()); } + + virtual std::string get_signature() const + { + std::string result; + result += TypeInfo::signature; + result += TypeInfo::signature; + result += TypeInfo::signature; + result += TypeInfo::signature; + return result; + } }; @@ -191,9 +225,19 @@ public: virtual void execute(Loader &l, const Statement &st) const { - if(st.args.size()!=5) throw TypeError("Wrong number of arguments"); (dynamic_cast(l).*func)(st.args[0].get(), st.args[1].get(), st.args[2].get(), st.args[3].get(), st.args[4].get()); } + + virtual std::string get_signature() const + { + std::string result; + result += TypeInfo::signature; + result += TypeInfo::signature; + result += TypeInfo::signature; + result += TypeInfo::signature; + result += TypeInfo::signature; + return result; + } }; @@ -210,9 +254,11 @@ public: virtual void execute(Loader &l, const Statement &st) const { - if(st.args.size()!=1) throw TypeError("Wrong number of arguments"); - dynamic_cast(l).get_object().*ptr0=st.args[0].get(); + dynamic_cast(l).get_object().*ptr0 = st.args[0].get(); } + + virtual std::string get_signature() const + { return std::string(1, TypeInfo::signature); } }; @@ -229,10 +275,12 @@ public: virtual void execute(Loader &l, const Statement &st) const { - if(st.args.size()!=1) throw TypeError("Wrong number of arguments"); - typename L::Loader &ldr=dynamic_cast(l); - ldr.get_object().*ptr0=ldr.get_collection().template get(st.args[0].get()); + typename L::Loader &ldr = dynamic_cast(l); + ldr.get_object().*ptr0 = ldr.get_collection().template get(st.args[0].get()); } + + virtual std::string get_signature() const + { return std::string(1, TypeInfo::signature); } }; @@ -251,9 +299,16 @@ public: virtual void execute(Loader &l, const Statement &st) const { - if(st.args.size()!=2) throw TypeError("Wrong number of arguments"); - dynamic_cast(l).get_object().*ptr0=st.args[0].get(); - dynamic_cast(l).get_object().*ptr1=st.args[1].get(); + dynamic_cast(l).get_object().*ptr0 = st.args[0].get(); + dynamic_cast(l).get_object().*ptr1 = st.args[1].get(); + } + + virtual std::string get_signature() const + { + std::string result; + result += TypeInfo::signature; + result += TypeInfo::signature; + return result; } };