]> 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 5c8726a179683c841e6439e57fd3cfa4772394e2..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);
 
@@ -156,8 +160,7 @@ protected:
 
 
 /**
-Provides the basic functionality of an object loader.  Deriving from this
-allows loading values directly into member variables of the objects.
+Deprecated.  See ObjectLoader in objectloader.h.
 */
 template<typename O>
 class BasicLoader: public Loader
@@ -175,8 +178,7 @@ public:
 
 
 /**
-Provides functionality for loading objects with a Collection.  Deriving from
-this allows loading pointers to objects in the collection automatically.
+Deprecated.  See CollectionObjectLoader in objectloader.h.
 */
 template<typename O, typename C>
 class BasicLoader2: public BasicLoader<O>
@@ -199,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);
 }
@@ -210,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);
 }