[ObjectHandler-cvs] ObjectHandler/ohxl/Functions manual.cpp, 1.7, 1.8
Brought to you by:
ericehlers,
nando
From: Eric E. <eri...@us...> - 2006-11-19 13:08:30
|
Update of /cvsroot/objecthandler/ObjectHandler/ohxl/Functions In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv29592/ohxl/Functions Modified Files: manual.cpp Log Message: support for coercion Index: manual.cpp =================================================================== RCS file: /cvsroot/objecthandler/ObjectHandler/ohxl/Functions/manual.cpp,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** manual.cpp 16 Nov 2006 12:38:41 -0000 1.7 --- manual.cpp 19 Nov 2006 13:08:27 -0000 1.8 *************** *** 32,35 **** --- 32,64 ---- #define SET_SESSION_ID + void operToOper(OPER *xTarget, const OPER *xSource) { + if (xSource->xltype == xltypeNum) { + xTarget->xltype = xltypeNum; + xTarget->val.num = xSource->val.num; + return; + } else if (xSource->xltype == xltypeStr) { + int len = xSource->val.str[0]; + xTarget->val.str = new char[ len + 1 ]; + if (!xTarget->val.str) + throw ObjHandler::Exception("operToOper: error calling new"); + xTarget->xltype = xltypeStr | xlbitDLLFree; + xTarget->val.str[0] = len; + if (len) + strncpy(xTarget->val.str + 1, xSource->val.str + 1, len); + return; + } else if (xSource->xltype == xltypeErr) { + xTarget->xltype = xltypeErr; + xTarget->val.err = xSource->val.err; + return; + } else if (xSource->xltype == xltypeNil) { + xTarget->xltype = xltypeNil; + return; + } else { + std::ostringstream msg; + msg << "operToOper: unexpected OPER type: " << xSource->xltype; + throw ObjHandler::Exception(msg.str()); + } + } + XLL_DEC long *ohDependsOn( XLOPER *dummy0, *************** *** 92,96 **** } ! int countValidRows(const XLOPER &xMulti) { for (int numValidRows=xMulti.val.array.rows; numValidRows; numValidRows--) { for (int i=0; i<xMulti.val.array.columns; i++) { --- 121,125 ---- } ! int countValidRows(const OPER &xMulti) { for (int numValidRows=xMulti.val.array.rows; numValidRows; numValidRows--) { for (int i=0; i<xMulti.val.array.columns; i++) { *************** *** 103,107 **** } ! int countValidCols(const XLOPER &xMulti) { for (int numValidCols=xMulti.val.array.columns; numValidCols; numValidCols--) { for (int i=0; i<xMulti.val.array.rows; i++) { --- 132,136 ---- } ! int countValidCols(const OPER &xMulti) { for (int numValidCols=xMulti.val.array.columns; numValidCols; numValidCols--) { for (int i=0; i<xMulti.val.array.rows; i++) { *************** *** 114,122 **** } ! XLL_DEC XLOPER *ohPack(OPER *xInputRange) { boost::shared_ptr < ObjHandler::FunctionCall > functionCall; ! XLOPER xMulti; ! static XLOPER xRet; xRet.val.array.lparray = 0; --- 143,151 ---- } ! XLL_DEC OPER *ohPack(OPER *xInputRange) { boost::shared_ptr < ObjHandler::FunctionCall > functionCall; ! OPER xMulti; ! static OPER xRet; xRet.val.array.lparray = 0; *************** *** 132,136 **** xRet.val.array.rows = numValidRows; xRet.val.array.columns = numValidCols; ! xRet.val.array.lparray = new XLOPER[numValidRows * numValidCols]; if (!xRet.val.array.lparray) throw ObjHandler::Exception("ohPack: error on call to new"); --- 161,165 ---- xRet.val.array.rows = numValidRows; xRet.val.array.columns = numValidCols; ! xRet.val.array.lparray = new OPER[numValidRows * numValidCols]; if (!xRet.val.array.lparray) throw ObjHandler::Exception("ohPack: error on call to new"); *************** *** 141,145 **** int indexSource = i * xMulti.val.array.columns + j; int indexTarget = i * numValidCols + j; ! ObjHandler::operToOper(&xRet.val.array.lparray[indexTarget], &xMulti.val.array.lparray[indexSource]); } --- 170,174 ---- int indexSource = i * xMulti.val.array.columns + j; int indexTarget = i * numValidCols + j; ! operToOper(&xRet.val.array.lparray[indexTarget], &xMulti.val.array.lparray[indexSource]); } *************** *** 169,173 **** } ! XLL_DEC XLOPER *ohParseField( char *line, long *index, --- 198,202 ---- } ! XLL_DEC OPER *ohParseField( char *line, long *index, *************** *** 187,195 **** // convert the inputs ! std::string typeStr; ! ObjHandler::operToScalar(typeStr, *type, "NUMBER"); ! std::string delimStr; ! ObjHandler::operToScalar(delimStr, *delim, "[:space:]"); // invoke the utility function --- 216,224 ---- // convert the inputs ! std::string typeStr = ! ObjHandler::operToScalar<std::string>(*type, "NUMBER", "type"); ! std::string delimStr = ! ObjHandler::operToScalar<std::string>(*delim, "[:space:]", "delim"); // invoke the utility function *************** *** 213,217 **** } ! static XLOPER xRet; if (typeStr.empty() || ObjHandler::uppercase(typeStr) == "NUMBER") { --- 242,246 ---- } ! static OPER xRet; if (typeStr.empty() || ObjHandler::uppercase(typeStr) == "NUMBER") { *************** *** 227,233 **** throw ObjHandler::Exception(msg.str()); } ! ObjHandler::scalarToXloper(xRet, ret); } else if (ObjHandler::uppercase(typeStr) == "STRING") { ! ObjHandler::scalarToXloper(xRet, fields[i-1]); } else { std::stringstream msg; --- 256,262 ---- throw ObjHandler::Exception(msg.str()); } ! ObjHandler::scalarToOper(xRet, ret); } else if (ObjHandler::uppercase(typeStr) == "STRING") { ! ObjHandler::scalarToOper(xRet, fields[i-1]); } else { std::stringstream msg; |