[ObjectHandler-cvs] ObjectHandler/ohxl/Functions manual.cpp, 1.13, 1.14
Brought to you by:
ericehlers,
nando
From: Ferdinando A. <na...@us...> - 2007-01-02 11:08:18
|
Update of /cvsroot/objecthandler/ObjectHandler/ohxl/Functions In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv16320/ohxl/Functions Modified Files: manual.cpp Log Message: ohSplit implementation is not manual anymore Index: manual.cpp =================================================================== RCS file: /cvsroot/objecthandler/ObjectHandler/ohxl/Functions/manual.cpp,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** manual.cpp 12 Dec 2006 15:04:19 -0000 1.13 --- manual.cpp 2 Jan 2007 11:08:16 -0000 1.14 *************** *** 196,256 **** } } - - XLL_DEC OPER *ohSplit( - char *line, - OPER *delimOper, - OPER *index) { - - boost::shared_ptr<ObjHandler::FunctionCall> functionCall; - - try { - functionCall = boost::shared_ptr<ObjHandler::FunctionCall> - ( new ObjHandler::FunctionCall("ohSplit") ); - - // reset the calling cell - - ObjHandler::ObjectHandlerXL::instance().resetCaller(); - - // convert the inputs - - std::string delim = - ObjHandler::operToScalar<std::string>(*delimOper, ",;", "delim"); - - // invoke the utility function - - std::vector<std::string> fields = ObjHandler::split(line, delim); - - static OPER xRet; - - if (index->xltype == xltypeNum) { - - // the user has specified a value for index, - // so return fields[index] as a scalar string value - - OH_REQUIRE(index->val.num > 0, "Error parsing string -" << std::endl - << line << std::endl << "- index of requested field must be > 0" - << " - the value supplied was " << index->val.num); - - unsigned int i = static_cast<unsigned int>(index->val.num); - - OH_REQUIRE(i <= fields.size(),"Error parsing string -" << std::endl - << line << std::endl << "- requested field index " << i - << " exceeds #fields (" << fields.size() << ") found in string"); - - ObjHandler::scalarToOper(xRet, fields[i-1]); - - } else { - // the user hasn't specified a valid number for the index, - // so return all of the fields in the input as a list of strings - - ObjHandler::vectorToOper(xRet, fields); - } - - return &xRet; - - } catch (const std::exception &e) { - ObjHandler::ObjectHandlerXL::instance().logError(e.what()); - return 0; - } - } - --- 196,197 ---- |