X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;ds=sidebyside;f=source%2Floader.h;h=574ecce0c11b5bac9af56d82b6a0782a5288d8b6;hb=708ef339d3e4d3661c8b3a75e3b01bafbed0f568;hp=9736d269d90ffdde9e83ea7a835032cad98ebd16;hpb=e1b8089be727f651fc2022d6e7ff775047730e85;p=libs%2Fdatafile.git diff --git a/source/loader.h b/source/loader.h index 9736d26..574ecce 100644 --- a/source/loader.h +++ b/source/loader.h @@ -36,7 +36,11 @@ See also classes ObjectLoader and CollectionObjectLoader in objectloader.h. class Loader: private NonCopyable { protected: - typedef std::map ActionMap; + class ActionMap: public std::map, private NonCopyable + { + public: + ~ActionMap(); + }; private: ActionMap local_actions; @@ -52,7 +56,7 @@ protected: Loader(); public: - virtual ~Loader(); + virtual ~Loader() { } /** Loads statements from a parser. */ void load(Parser &p); @@ -104,36 +108,15 @@ protected: void add(const std::string &k, void (L::*func)(A0)) { add(k, new LoaderFunc1(func)); } -#if __cplusplus>=201103L template void add(const std::string &k, void (L::*func)(Args...)) { add(k, new LoaderFuncN(func)); } -#else - template - void add(const std::string &k, void (L::*func)(A0, A1)) - { add(k, new LoaderFunc2(func)); } - - template - void add(const std::string &k, void (L::*func)(A0, A1, A2)) - { add(k, new LoaderFunc3(func)); } - - template - void add(const std::string &k, void (L::*func)(A0, A1, A2, A3)) - { add(k, new LoaderFunc4(func)); } - - template - void add(const std::string &k, void (L::*func)(A0, A1, A2, A3, A4)) - { add(k, new LoaderFunc5(func)); } -#endif - -#if __cplusplus>=201103L /** Adds a keyword that is loaded by calling a function with a bound first argument. */ template void add(const std::string &k, void (L::*func)(B0, Args...), const typename RemoveReference::Type &b0) { add(k, new LoaderFuncNBound1(func, b0)); } -#endif /** Adds a keyword that is loaded into a member of the loaded object. */ template @@ -172,7 +155,6 @@ protected: }; -#if __cplusplus>=201103L /** Loads an object from a file. The object must have a public Loader class. Any extra arguments are passed to the Loader constructor. @@ -188,7 +170,7 @@ void load(T &obj, const std::string &fn, Args &... args) } /** -Loads an object from a file stored in a collection. The object must havea +Loads an object from a file stored in a collection. The object must have a public Loader class. The collection is passed to the Loader constructor, followed by any extra arguments. */ @@ -220,36 +202,6 @@ typename EnableIf::value, void>::No load(T & loader.load(parser); } -#else - -/** -Loads an object from a file. The object must have a public Loader class. -*/ -template -void load(T &obj, const std::string &fn) -{ - IO::BufferedFile in(fn); - - Parser parser(in, fn); - typename T::Loader loader(obj); - loader.load(parser); -} - -/** -Loads an object from a file, passing one extra argument to the Loader -constructor. The object must have a public Loader class. -*/ -template -void load(T &obj, const std::string &fn, U &arg) -{ - IO::BufferedFile in(fn); - - Parser parser(in, fn); - typename T::Loader loader(obj, arg); - loader.load(parser); -} -#endif - } // namespace DataFile } // namespace Msp