From 13a7a98abe5164750776bb567e41cebd1b724bdc Mon Sep 17 00:00:00 2001 From: Sandu Liviu Catalin Date: Sat, 11 Sep 2021 20:35:22 +0300 Subject: [PATCH] Update sqratArray.h --- module/Sqrat/sqratArray.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/module/Sqrat/sqratArray.h b/module/Sqrat/sqratArray.h index 9e2189c4..f87d957e 100644 --- a/module/Sqrat/sqratArray.h +++ b/module/Sqrat/sqratArray.h @@ -612,6 +612,30 @@ public: //sq_pop(vm,1); // pop array return *this; } + + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + /// Appends values to the end of the Array + /// + /// \param vec Vector to be appended to the array + /// + /// \tparam T Type of value (usually doesnt need to be defined explicitly) + /// + /// \return The Array itself so the call can be chained + /// + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + template + ArrayBase& AppendFromVector(const std::vector< T > & vec) { + HSQUIRRELVM vm = SqVM(); + const StackGuard sg(vm); + sq_pushobject(vm, GetObj()); + for (const auto & v : vec) + { + Var< const T & >::push(vm, v); + sq_arrayappend(vm, -2); + } + //sq_pop(vm,1); // pop array + return *this; + } }; /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////