int CSQLMake::MergeSql(std::string &strSql, std::vector<std::string> &vctSql){ int iRet = 0; boost::regex regEx("@@([\\d]+)"); boost::match_flag_type flags = boost::match_default; std::vector<std::string>::iterator itr; std::string strTemp; std::string::const_iterator start, end; int iCount = 0; for (itr=vctSql.begin(); itr!=vctSql.end(); itr++) { boost::match_results<std::string::const_iterator> what; strTemp = *itr; while (boost::regex_search(strTemp, what, regEx, flags)) { std::string str(what[1].first, what[1].second); int iIndex = ACE_OS::atoi(str.c_str()); std::string::size_type stPos = strTemp.find(what[0]); std::string strLeft = strTemp.substr(0, stPos); std::string strRight = strTemp.substr(stPos + (what[0].second - what[0].first)); strTemp = strLeft + vctSql[iIndex] + strRight; } vctSql[iCount] = strTemp; iCount ++; } strSql = strTemp; return iRet;}
详细解决方案
将多个sql话语给合并成一个sql
热度:19 发布时间:2016-05-05 13:39:04.0
相关解决方案