给sql填充数据

int CSQLMake::MakeSqlFit(std::string &strSql, CParaSet &oInPara)
{

int iRet = 0;
std::string::size_type iPos = strSql.find("where");
if (iPos == std::string::npos)
{
return iRet;
}
std::string strSelect = strSql.substr(0, iPos);
// 此处来处理on的情况

std::string strOn;
std::string::size_type stOn = strSelect.find("on");
if (std::string::npos != stOn)
{
strOn = strSelect.substr(stOn+2);
strSelect = strSelect.substr(0, stOn);
MakeOnFilter(strOn, oInPara);
if (!strOn.empty()) {
strSelect += "on" + strOn;
}
else {
strSelect = strSelect + strOn;
}
}

std::string strFilter = strSql.substr(iPos+5);
iRet = MakeFilter(strFilter, oInPara);

// 这里暂时先加一个判断条件 strFilter != ")", 如果strFilter只有一个)时,不需要加where
if (!strFilter.empty() && strFilter != ")")
{
strSql = strSelect + "where" + strFilter;
}
else
{
strSql = strSelect + strFilter;
}
return iRet;
}

你可能感兴趣的:(C++)