]> git.tdb.fi Git - libs/datafile.git/blobdiff - source/loader.h
Use IO::BufferedFile instead of separate File and Buffered objects
[libs/datafile.git] / source / loader.h
index 6f7e61464db509bf50e5c62fe26d851018f5d342..221361694282228b3e3e1c9b3508505d5b327f9c 100644 (file)
@@ -9,7 +9,6 @@ Distributed under the LGPL
 #define MSP_DATAFILE_LOADER_H_
 
 #include <map>
-#include <msp/io/buffered.h>
 #include <msp/io/file.h>
 #include "except.h"
 #include "loaderaction.h"
@@ -56,14 +55,19 @@ private:
 
        typedef std::map<ActionKey, LoaderAction *> ActionMap;
 
-       ActionMap       actions;
+       ActionMap actions;
        const Statement *cur_st;
-
+       bool sub_loaded;
 protected:
-       Loader(): cur_st(0) { }
+       bool allow_pointer_reload;
+       bool check_sub_loads;
+
+       Loader();
 public:
        virtual ~Loader();
 
+       bool is_pointer_reload_allowed() const { return allow_pointer_reload; }
+
        /** Loads statements from a parser. */
        void load(Parser &p);
 
@@ -197,10 +201,9 @@ Loads an object from a file.  The object must have a public Loader class.
 template<typename T>
 void load(T &obj, const std::string &fn)
 {
-       IO::File in(fn);
-       IO::Buffered buf(in);
+       IO::BufferedFile in(fn);
 
-       Parser parser(buf, fn);
+       Parser parser(in, fn);
        typename T::Loader loader(obj);
        loader.load(parser);
 }
@@ -208,10 +211,9 @@ void load(T &obj, const std::string &fn)
 template<typename T, typename U>
 void load(T &obj, const std::string &fn, U &arg)
 {
-       IO::File in(fn);
-       IO::Buffered buf(in);
+       IO::BufferedFile in(fn);
 
-       Parser parser(buf, fn);
+       Parser parser(in, fn);
        typename T::Loader loader(obj, arg);
        loader.load(parser);
 }