]> git.tdb.fi Git - libs/datafile.git/blobdiff - source/objectloader.h
Cosmetic changes
[libs/datafile.git] / source / objectloader.h
index 4dcb981864e7c2d924a61dcbd44e552dfffa6cb0..978366f730e51cc197fe7dd20ab7f56f4b52e84e 100644 (file)
@@ -1,18 +1,12 @@
 #ifndef MSP_DATAFILE_OBJECTLOADER_H_
 #define MSP_DATAFILE_OBJECTLOADER_H_
 
-#include <typeinfo>
+#include "except.h"
 #include "loader.h"
 
 namespace Msp {
 namespace DataFile {
 
-class no_collection: public std::runtime_error
-{
-public:
-       no_collection(const std::type_info &);
-};
-
 class Collection;
 
 /**
@@ -20,7 +14,7 @@ Provides the basic functionality of an object loader.  Deriving from this
 allows loading values directly into member variables of the objects.
 */
 template<typename O>
-class ObjectLoader: public Loader
+class ObjectLoader: virtual public Loader
 {
 public:
        typedef O Object;
@@ -48,7 +42,8 @@ public:
 protected:
        O &obj;
 
-       DerivedObjectLoader(O &o): B(o), obj(o) { }
+       template<typename... Args>
+       DerivedObjectLoader(O &o, Args &&... a): B(o, std::forward<Args>(a)...), obj(o) { }
 
 public:
        O &get_object() const { return obj; }
@@ -66,7 +61,7 @@ public:
        typedef C Collection;
 
 protected:
-       C *coll;
+       C *coll = nullptr;
 
        CollectionObjectLoader(O &o, C *c): ObjectLoader<O>(o), coll(c) { }