Update of /cvsroot/objecthandler/ObjectHandler/ohxl/Conversions
In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv14288/ohxl/Conversions
Modified Files:
opertoscalar.cpp opertoscalar.hpp
Log Message:
- reinstate from OH 0.1.3 some previously deprecated code for converting boost::any <-> OPER
- consolidate ohFilter1/ohFilter2 into ohFilter and enable Function Wizard
Index: opertoscalar.hpp
===================================================================
RCS file: /cvsroot/objecthandler/ObjectHandler/ohxl/Conversions/opertoscalar.hpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** opertoscalar.hpp 4 Jan 2007 11:18:36 -0000 1.6
--- opertoscalar.hpp 8 Jan 2007 19:55:31 -0000 1.7
***************
*** 22,25 ****
--- 22,26 ----
#include <xlsdk/xlsdkdefines.hpp>
#include <string>
+ #include <boost/any.hpp>
namespace ObjHandler {
***************
*** 29,32 ****
--- 30,34 ----
DLL_API void operToScalar(const OPER &xScalar, bool &ret);
DLL_API void operToScalar(const OPER &xScalar, std::string &ret);
+ DLL_API void operToScalar(const OPER &xScalar, boost::any &ret);
template <class T>
Index: opertoscalar.cpp
===================================================================
RCS file: /cvsroot/objecthandler/ObjectHandler/ohxl/Conversions/opertoscalar.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** opertoscalar.cpp 4 Jan 2007 11:18:36 -0000 1.4
--- opertoscalar.cpp 8 Jan 2007 19:55:31 -0000 1.5
***************
*** 18,21 ****
--- 18,22 ----
#include <ohxl/Conversions/opertoscalar.hpp>
+ #include <oh/exception.hpp>
namespace ObjHandler {
***************
*** 85,87 ****
--- 86,105 ----
}
+ DLL_API void operToScalar(const OPER &xScalar, boost::any &ret) {
+ if (xScalar.xltype & xltypeErr)
+ throw std::exception("input value is #NULL (xltypeErr)");
+ if (xScalar.xltype & (xltypeMissing | xltypeNil))
+ ret = boost::any();
+ else if (xScalar.xltype == xltypeNum)
+ ret = xScalar.val.num;
+ else if (xScalar.xltype == xltypeBool)
+ ret = xScalar.val.boolean != 0;
+ else if (xScalar.xltype == xltypeStr) {
+ std::string value;
+ operToScalar(xScalar, value);
+ ret = value;
+ } else {
+ OH_FAIL("operToScalar: unexpected datatype: " << xScalar.xltype);
+ }
+ }
}
|