mirror of
https://github.com/VCMP-SqMod/SqMod.git
synced 2024-11-08 00:37:15 +01:00
Update sqratArray.h
This commit is contained in:
parent
f8ebb0e2b1
commit
13a7a98abe
@ -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<class T>
|
||||
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;
|
||||
}
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
Loading…
Reference in New Issue
Block a user