X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Floader.h;h=48d4f9b4757842a7fcdf983d12badb15895d7499;hb=8ff59df1f2e603557eceacbc81a8dc44de051dae;hp=c6936f96f6eef5869f62ffe3ed9307f34038dd2c;hpb=47597fd1b0b11c915466dd7f3f1281906442377c;p=libs%2Fdatafile.git diff --git a/source/loader.h b/source/loader.h index c6936f9..48d4f9b 100644 --- a/source/loader.h +++ b/source/loader.h @@ -1,20 +1,21 @@ -/* -This file is part of libmspparser +/* $Id$ + +This file is part of libmspdatafile Copyright © 2006 Mikko Rasa, Mikkosoft Productions Distributed under the LGPL */ -#ifndef MSP_PARSER_LOADER_H_ -#define MSP_PARSER_LOADER_H_ +#ifndef MSP_DATAFILE_LOADER_H_ +#define MSP_DATAFILE_LOADER_H_ #include #include -#include +#include "error.h" #include "parser.h" #include "statement.h" #include "value.h" namespace Msp { -namespace Parser { +namespace DataFile { class Loader; class Statement; @@ -37,7 +38,7 @@ public: LoaderFunc0(FuncType f): func(f) { } void execute(Loader &l, const Statement &st) const { - if(st.args.size()!=0) throw TypeError("Wrong number of arguments"); + if(st.args.size()!=0) throw TypeError(st.get_location()+": Wrong number of arguments"); (dynamic_cast(l).*func)(); }; private: @@ -53,7 +54,7 @@ public: LoaderFunc1(FuncType f): func(f) { } void execute(Loader &l, const Statement &st) const { - if(st.args.size()!=1) throw TypeError("Wrong number of arguments"); + if(st.args.size()!=1) throw TypeError(st.get_location()+": Wrong number of arguments"); (dynamic_cast(l).*func)(st.args[0].get()); } private: @@ -69,7 +70,7 @@ public: LoaderFunc2(FuncType f): func(f) { } void execute(Loader &l, const Statement &st) const { - if(st.args.size()!=2) throw TypeError("Wrong number of arguments"); + if(st.args.size()!=2) throw TypeError(st.get_location()+": Wrong number of arguments"); (dynamic_cast(l).*func)(st.args[0].get(), st.args[1].get()); } private: @@ -85,7 +86,7 @@ public: LoaderFunc3(FuncType f): func(f) { } void execute(Loader &l, const Statement &st) const { - if(st.args.size()!=3) throw TypeError("Wrong number of arguments"); + if(st.args.size()!=3) throw TypeError(st.get_location()+": Wrong number of arguments"); (dynamic_cast(l).*func)(st.args[0].get(), st.args[1].get(), st.args[2].get()); } private: @@ -101,7 +102,7 @@ public: LoaderFunc4(FuncType f): func(f) { } void execute(Loader &l, const Statement &st) const { - if(st.args.size()!=4) throw TypeError("Wrong number of arguments"); + if(st.args.size()!=4) throw TypeError(st.get_location()+": Wrong number of arguments"); (dynamic_cast(l).*func)(st.args[0].get(), st.args[1].get(), st.args[2].get(), st.args[3].get()); } private: @@ -117,7 +118,7 @@ public: LoadValue(PointerType p): ptr(p) { } void execute(Loader &l, const Statement &st) const { - if(st.args.size()!=1) throw TypeError("Wrong number of arguments"); + if(st.args.size()!=1) throw TypeError(st.get_location()+": Wrong number of arguments"); dynamic_cast(l).get_object().*ptr=st.args[0].get(); } private: @@ -218,7 +219,7 @@ void load(T &obj, const std::string &fn) loader.load(parser); } -} // namespace Parser +} // namespace DataFile } // namespace Msp #endif