[QuantLibAddin-cvs] QuantLibAddin/gensrc/stubs stub.excel.xladdin, NONE, 1.1
Brought to you by:
ericehlers,
nando
|
From: Eric E. <eri...@us...> - 2006-10-02 21:00:32
|
Update of /cvsroot/quantlibaddin/QuantLibAddin/gensrc/stubs In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv29349/gensrc/stubs Added Files: stub.excel.xladdin Log Message: restore ohParseField()/ohPack() --- NEW FILE: stub.excel.xladdin --- #include <ohxl/objhandlerxl.hpp> #include <qlo/qladdindefines.hpp> #include <qlxl/Register/register_all.hpp> /* Use BOOST_MSVC instead of _MSC_VER since some other vendors (Metrowerks, for example) also #define _MSC_VER */ #if defined BOOST_MSVC // Microsoft Visual C++ # define BOOST_LIB_DIAGNOSTIC # include <qlo/auto_link.hpp> # include <oh/auto_link.hpp> # if defined(XLL_STATIC) #include <ohxl/Register/register_all.hpp> #include <ohxl/export.hpp> #pragma message("XLL_STATIC is defined") # elif defined(XLL_IMPORTS) #include <xlsdk/auto_link.hpp> #pragma message("XLL_IMPORTS is defined") # endif # undef BOOST_LIB_DIAGNOSTIC #endif #if defined COMPILING_XLL # pragma message("COMPILING_XLL is defined") #else # pragma message("COMPILING_XLL is NOT defined") #endif #include <string> #include <sstream> #ifdef XLL_STATIC // instantiate the objecthandler singleton ObjHandler::ObjectHandlerXL oh; #endif DLLEXPORT void xlAutoFree(XLOPER *px) { if (px->xltype & xltypeStr && px->val.str) delete [] px->val.str; else if (px->xltype & xltypeMulti && px->val.array.lparray) { int size = px->val.array.rows * px->val.array.columns; for (int i=0; i<size; i++) if (px->val.array.lparray[i].xltype & xltypeStr && px->val.array.lparray[i].val.str) delete [] px->val.array.lparray[i].val.str; delete [] px->val.array.lparray; } } DLLEXPORT XLOPER *xlAddInManagerInfo(XLOPER *xlAction) { XLOPER xlReturn; static XLOPER xlLongName; // Coerce the argument XLOPER to an integer. Excel(xlCoerce, &xlReturn, 2, xlAction, TempInt(xltypeInt)); // The only valid argument value is 1. In this case we return the // long name for the XLL. Any other value should result in the // return of a #VALUE! error. if (1 == xlReturn.val.w) { ObjHandler::scalarToXloper(xlLongName, std::string("QuantLibAddin 0.3.14")); } else { xlLongName.xltype = xltypeErr; xlLongName.val.err = xlerrValue; } return &xlLongName; } DLLEXPORT int xlAutoOpen() { XLOPER xDll; try { Excel(xlGetName, &xDll, 0); #ifdef XLL_STATIC registerFunctions(xDll); Excel(xlfRegister, 0, 11, &xDll, TempStrNoSize("\x06""ohPack"), // function code name TempStrNoSize("\x03""RP#"), // parameter codes TempStrNoSize("\x06""ohPack"), // function display name TempStrNoSize("\x10""inputRange"), // comma-delimited list of parameter names TempStrNoSize("\x01""1"), // function type (1 = worksheet function) TempStrNoSize("\x0D""ObjectHandler"), // function category TempStrNoSize("\x00"""), // shortcut text (command macros only) TempStrNoSize("\x00"""), // path to help file TempStrNoSize("\x3D""trim #ERR/empty values from bottom/right edges of input range"), // function description TempStrNoSize("\x1D""range of cells to be packed ")); // description of parameter 1 Excel(xlfRegister, 0, 14, &xDll, TempStrNoSize("\x0C""ohParseField"), // function code name TempStrNoSize("\x06""RCNCP#"), // parameter codes TempStrNoSize("\x0C""ohParseField"), // function display name TempStrNoSize("\x19""line,index,type,delimiter"), // comma-delimited list of parameter names TempStrNoSize("\x01""1"), // function type (1 = worksheet function) TempStrNoSize("\x0D""ObjectHandler"), // function category TempStrNoSize("\x00"""), // shortcut text (command macros only) TempStrNoSize("\x00"""), // path to help file TempStrNoSize("\x41""Extract the ith number from a whitespace-delimited list of fields"), // function description TempStrNoSize("\x11""text to be parsed"), // description of parameter 1 TempStrNoSize("\x20""index (1-based) of desired field"), // description of parameter 2 TempStrNoSize("\x21""required datatype (string/number)"), // description of parameter 3 TempStrNoSize("\x29""field delimiter (default is whitespace) ")); // description of parameter 3 #endif %(registerFunctions)s Excel(xlFree, 0, 1, &xDll); return 1; } catch (const std::exception &e) { std::ostringstream err; err << "Error loading QuantLibAddin: " << e.what(); Excel(xlcAlert, 0, 1, TempStrStl(err.str())); Excel(xlFree, 0, 1, &xDll); return 0; } catch (...) { Excel(xlFree, 0, 1, &xDll); return 0; } } DLLEXPORT int xlAutoClose() { static XLOPER xDll; try { Excel(xlGetName, &xDll, 0); #ifdef XLL_STATIC XLOPER xlRegID; unregisterFunctions(xDll); Excel(xlfRegister, 0, 11, &xDll, TempStrNoSize("\x06""ohPack"), // function code name TempStrNoSize("\x03""RP#"), // parameter codes TempStrNoSize("\x06""ohPack"), // function display name TempStrNoSize("\x10""inputRange"), // comma-delimited list of parameter names TempStrNoSize("\x01""0"), // function type (0 = hidden function) TempStrNoSize("\x0D""ObjectHandler"), // function category TempStrNoSize("\x00"""), // shortcut text (command macros only) TempStrNoSize("\x00"""), // path to help file TempStrNoSize("\x3D""trim #ERR/empty values from bottom/right edges of input range"), // function description TempStrNoSize("\x1D""range of cells to be packed ")); // description of parameter 1 Excel4(xlfRegisterId, &xlRegID, 2, &xDll, TempStrNoSize("\x06""ohPack")); // function code name Excel4(xlfUnregister, 0, 1, &xlRegID); Excel(xlfRegister, 0, 14, &xDll, TempStrNoSize("\x0C""ohParseField"), // function code name TempStrNoSize("\x06""RCNCP#"), // parameter codes TempStrNoSize("\x0C""ohParseField"), // function display name TempStrNoSize("\x19""line,index,type,delimiter"), // comma-delimited list of parameter names TempStrNoSize("\x01""0"), // function type (0 = hidden function) TempStrNoSize("\x0D""ObjectHandler"), // function category TempStrNoSize("\x00"""), // shortcut text (command macros only) TempStrNoSize("\x00"""), // path to help file TempStrNoSize("\x41""Extract the ith number from a whitespace-delimited list of fields"), // function description TempStrNoSize("\x11""text to be parsed"), // description of parameter 1 TempStrNoSize("\x20""index (1-based) of desired field"), // description of parameter 2 TempStrNoSize("\x21""required datatype (string/number)"), // description of parameter 3 TempStrNoSize("\x29""field delimiter (default is whitespace) ")); // description of parameter 3 Excel4(xlfRegisterId, &xlRegID, 2, &xDll, TempStrNoSize("\x0C""ohParseField")); // function code name #endif %(unregisterFunctions)s Excel(xlFree, 0, 1, &xDll); return 1; } catch (...) { Excel(xlFree, 0, 1, &xDll); return 0; } } |