Hi All,
I'm a software dev and I'm working on a project that interfaces a C++ program with Angelscript for running custom functions. As a result I need parse between Angelscript's Array of Array of Doubles and a C++ STL library vector of vector of doubles (and ints).
Angelscript:
array<array<double>> dblMat = {{ data } { data }};
C++ STL object
std::vector < std::vector < double > >dblMat = {{data } { data }};
The program uses CScriptArray to get vectors of data in and out between the two, and it successfully handles not-nested vectors for input and output, and we're able to get a matrix OUTPUT from C++ STL to AngelScript, but we haven't gotten it from STl to Angelscript.
We have a method called FillSTLVector that takes a CScriptArray and an STL vector pointer as an input and transfers the data between the two as follows:
template < class T >
void ScriptMgrSingleton::FillSTLVector( CScriptArray* in, vector < T > & out )
{
out.resize( in->GetSize() );
for ( int i = 0 ; i < ( int )in->GetSize() ; i++ )
{
out[i] = * ( T* ) ( in->At( i ) );
}
}
And I've been trying to implement one for matrices, with the assumption that the CScriptArray has a vector of CScriptArrays inside of it:
template < class T >
void ScriptMgrSingleton::FillSTLMatrix( CScriptArray* in, vector < vector < T > > & out )
{
out.resize( in->GetSize() );
for ( int i = 0 ; i < ( int )in->GetSize() ; i++ )
{
CScriptArray* row = ( CScriptArray* ) ( in->At( i ) );
if ( row )
{
FillSTLVector( row, out[i] );
}
}
}
When attempting to run this code, I get an error in the FillSTLVector called by FillSTLMatrix; the first attempt to get the size of its CScriptArray fails as it's somehow an incompatible type. I understand the casting to CScriptArray might be a broad assumption in FillSTLMatrix but it should work as passing the CScriptArrays I know are nested should work out.
Does anyone know what to do about this?
Thanks everyone in advance!