From 47597fd1b0b11c915466dd7f3f1281906442377c Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Mon, 27 Nov 2006 19:22:34 +0000 Subject: [PATCH] Add a shortcut function for loading something from a file. --- source/loader.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/source/loader.h b/source/loader.h index 6e9c4f8..c6936f9 100644 --- a/source/loader.h +++ b/source/loader.h @@ -6,6 +6,7 @@ Distributed under the LGPL #ifndef MSP_PARSER_LOADER_H_ #define MSP_PARSER_LOADER_H_ +#include #include #include #include "parser.h" @@ -205,6 +206,18 @@ private: } }; +template +void load(T &obj, const std::string &fn) +{ + std::ifstream in(fn.c_str()); + if(!in) + throw Exception("Couldn't open "+fn); + + Parser parser(in, fn); + typename T::Loader loader(obj); + loader.load(parser); +} + } // namespace Parser } // namespace Msp -- 2.45.2