From: Mikko Rasa Date: Wed, 6 Oct 2021 20:27:34 +0000 (+0300) Subject: Return the object from DynamicObjectLoader::store_object X-Git-Url: http://git.tdb.fi/?p=libs%2Fdatafile.git;a=commitdiff_plain;h=fafae9081dc6cf6fe8fbc39cbca53708e83813ab Return the object from DynamicObjectLoader::store_object This provides an easy way to both store the object and also use it. --- diff --git a/source/dynamicobjectloader.h b/source/dynamicobjectloader.h index b5830b8..726d19c 100644 --- a/source/dynamicobjectloader.h +++ b/source/dynamicobjectloader.h @@ -48,7 +48,7 @@ private: public: T *get_object() { T *o = object; object = 0; return o; } - void store_object(Collection &, const std::string &); + T *store_object(Collection &, const std::string &); private: void type(const Symbol &); @@ -83,13 +83,15 @@ void DynamicObjectLoader::init_actions() } template -void DynamicObjectLoader::store_object(Collection &c, const std::string &name) +T *DynamicObjectLoader::store_object(Collection &c, const std::string &name) { if(!store_func) throw std::logic_error("no store function"); + T *o = object; store_func(c, name, object); object = 0; + return o; } template