From fafae9081dc6cf6fe8fbc39cbca53708e83813ab Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Wed, 6 Oct 2021 23:27:34 +0300 Subject: [PATCH] Return the object from DynamicObjectLoader::store_object This provides an easy way to both store the object and also use it. --- source/dynamicobjectloader.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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 -- 2.43.0