Update of /cvsroot/objecthandler/ObjectHandler/ohxl
In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv13394/ohxl
Modified Files:
conversions.hpp
Log Message:
functions which loop on input parameter - match dimensions of return value with that of loop parameter
Index: conversions.hpp
===================================================================
RCS file: /cvsroot/objecthandler/ObjectHandler/ohxl/conversions.hpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** conversions.hpp 8 Jun 2006 09:37:27 -0000 1.5
--- conversions.hpp 8 Jun 2006 11:33:38 -0000 1.6
***************
*** 50,54 ****
return;
}
! xVector.xltype = xltypeMulti | xlbitDLLFree;
if (FunctionCall::instance().getCallerDimensions() == Row) {
xVector.val.array.columns = v.size();
--- 50,54 ----
return;
}
!
if (FunctionCall::instance().getCallerDimensions() == Row) {
xVector.val.array.columns = v.size();
***************
*** 61,64 ****
--- 61,93 ----
if (!xVector.val.array.lparray)
throw Exception("vectorToXloper: error on call to new");
+ xVector.xltype = xltypeMulti | xlbitDLLFree;
+ for (unsigned int i=0; i<v.size(); i++)
+ scalarToXloper(xVector.val.array.lparray[i], v[i]);
+ }
+
+ template < class T >
+ void vectorToXloper(XLOPER &xVector, const std::vector < T > &v, const XLOPER *xInput) {
+ // set xVector with contents of v and dimensions of xInput
+
+ if (v.empty()) {
+ //xVector.xltype = xltypeNum;
+ //xVector.val.num = 0;
+ xVector.xltype = xltypeErr;
+ xVector.val.err = xlerrNA;
+ return;
+ }
+ if (!xInput || xInput->xltype != xltypeMulti)
+ throw Exception("vectorToXloper: input parameter is not an array");
+
+ xVector.val.array.columns = xInput->val.array.columns;
+ xVector.val.array.rows = xInput->val.array.rows;
+ int inputSize = xVector.val.array.columns * xVector.val.array.rows;
+ if (inputSize != v.size())
+ throw Exception("vectorToXloper: input array dimensions incompatible with data");
+ xVector.val.array.lparray = new XLOPER[inputSize];
+ if (!xVector.val.array.lparray)
+ throw Exception("vectorToXloper: error on call to new");
+ xVector.xltype = xltypeMulti | xlbitDLLFree;
+
for (unsigned int i=0; i<v.size(); i++)
scalarToXloper(xVector.val.array.lparray[i], v[i]);
***************
*** 74,78 ****
return;
}
- xMatrix.xltype = xltypeMulti | xlbitDLLFree;
xMatrix.val.array.rows = vv.size();
xMatrix.val.array.columns = vv[0].size();
--- 103,106 ----
***************
*** 80,83 ****
--- 108,112 ----
if (!xMatrix.val.array.lparray)
throw Exception("matrixToXloper: error on call to new");
+ xMatrix.xltype = xltypeMulti | xlbitDLLFree;
for (unsigned int i=0; i<vv.size(); i++) {
std::vector < T > v = vv[i];
|