X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Floader.h;h=a7d2dbdfbc9eb70f191e9e9c979f355a55174315;hb=6dd94a7fe90c6467024685fbac769067ddb74688;hp=acc84fe024dd080d702bb4d4b3af52ce4ff19e12;hpb=6678cf025ca97dd398a9304b0578f146d1f7af80;p=libs%2Fdatafile.git diff --git a/source/loader.h b/source/loader.h index acc84fe..a7d2dbd 100644 --- a/source/loader.h +++ b/source/loader.h @@ -8,8 +8,9 @@ Distributed under the LGPL #ifndef MSP_DATAFILE_LOADER_H_ #define MSP_DATAFILE_LOADER_H_ -#include #include +#include +#include #include "except.h" #include "parser.h" #include "statement.h" @@ -196,7 +197,7 @@ public: { if(st.args.size()!=1) throw TypeError(st.get_location()+": Wrong number of arguments"); typename L::Loader &ldr=dynamic_cast(l); - ldr.get_object().*ptr0=&ldr.get_collection().template get(st.args[0].get()); + ldr.get_object().*ptr0=ldr.get_collection().template get(st.args[0].get()); } private: Pointer0Type ptr0; @@ -343,6 +344,8 @@ protected: throw InvalidState("get_source called without current statement"); return cur_st->source; } + + virtual void finish() { } private: typedef std::map ActionMap; @@ -359,11 +362,10 @@ Loads an object from a file. The object must have a public Loader class. template void load(T &obj, const std::string &fn) { - std::ifstream in(fn.c_str()); - if(!in) - throw Exception("Couldn't open "+fn); + IO::File in(fn); + IO::Buffered buf(in); - Parser parser(in, fn); + Parser parser(buf, fn); typename T::Loader loader(obj); loader.load(parser); } @@ -371,9 +373,8 @@ void load(T &obj, const std::string &fn) template void load(T &obj, const std::string &fn, U arg) { - std::ifstream in(fn.c_str()); - if(!in) - throw Exception("Couldn't open "+fn); + IO::File in(fn); + IO::Buffered buf(in); Parser parser(in, fn); typename T::Loader loader(obj, arg);