int CGenerateSQLFile::_CheckLine( VrtLinesConT& vrtAllLines ) { int nFunRes = 0; VrtLinesConIterT iterAllLine; std::string strOneLineTmp; iterAllLine = vrtAllLines.begin(); while ( iterAllLine != vrtAllLines.end() ) { strOneLineTmp.clear(); strOneLineTmp = *iterAllLine; if (!strOneLineTmp.empty() &&std::string::npos == strOneLineTmp.find(";") && std::string::npos == strOneLineTmp.find("+") && std::string::npos == strOneLineTmp.find("=") && std::string::npos == strOneLineTmp.find("[") && std::string::npos == strOneLineTmp.find("[[") && std::string::npos == strOneLineTmp.find("AQ")) { _SysLog(SourceFLInfo, DebugError, "inVaild Line:%s", strOneLineTmp.c_str()); nFunRes = -1; break; }//if iterAllLine++; }//while return nFunRes; }
int CGenerateSQLFile::_RemoveBlackLine( VrtLinesConT& vrtAllLines ) { int nFunRet = 0; VrtLinesConIterT vtrLineIter; _TrimLines(vrtAllLines); vtrLineIter = vrtAllLines.begin(); while (vtrLineIter != vrtAllLines.end()) { if ( (*vtrLineIter).empty()) { vrtAllLines.erase(vtrLineIter); vtrLineIter = vrtAllLines.begin(); } else { vtrLineIter++; } }//while return nFunRet; }
int CGenerateSQLFile::_TrimLines( VrtLinesConT& vrtAllLines ) { int nFunRet = 0; VrtLinesConIterT iterAllLine; iterAllLine = vrtAllLines.begin(); while ( iterAllLine != vrtAllLines.end() ) { CUtilityFun::getInstance().trim(*iterAllLine); iterAllLine++; }//while return nFunRet; }
int CGenerateSQLFile::_MutiLinesToSingleLine( VrtLinesConT& vrtAllLines ) { int nFunRet = 0; std::string strGetLine; std::string strTmp; VrtLinesConIterT iterAllLine = vrtAllLines.begin(); VrtLinesConIterT iterTmp = vrtAllLines.begin(); bool bFindJia = false; strGetLine.clear(); strTmp.clear(); while ( iterAllLine != vrtAllLines.end() ) { strGetLine.clear(); strGetLine = (*iterAllLine); if (!strGetLine.empty()) { bFindJia = false; if (LINE_ADD == strGetLine[0]) { bFindJia = true; } if (bFindJia) { strTmp += "\\"; strTmp += "\n"; strTmp +=strGetLine.substr(1); //'+' -- '\' '\r\n' (*iterAllLine) = ""; } else { if (!strTmp.empty()) { //strTmp += "\r\n"; (*iterTmp) = strTmp; strTmp.clear(); } iterTmp = iterAllLine; strTmp +=strGetLine; } }//if iterAllLine++; }//while //last one line if ((iterAllLine == vrtAllLines.end()) && (iterTmp != vrtAllLines.end())) { if (!strTmp.empty()) { //strTmp += "\r\n"; (*iterTmp) = strTmp; strTmp.clear(); strGetLine.clear(); } } nFunRet = 0; return nFunRet; }
int CTableInfo::analyzeData(VrtLinesConT& VtrOneTable) { int nFunRes = 0; VrtLinesConIterT VtrIterTable; VrtLinesConT VtrOneDb; if (VtrOneTable.empty()) { nFunRes = -1; return nFunRes; } VtrIterTable = VtrOneTable.begin(); while (VtrIterTable != VtrOneTable.end()) { std::string strLineTmp = (*VtrIterTable); //check this line is [TABLE] if (std::string::npos != strLineTmp.find("[") && std::string::npos == strLineTmp.find("[[")) {//[] m_strTableName = strLineTmp; VtrIterTable++; continue; } //check this line is [[DB]] if (std::string::npos != strLineTmp.find("[") && std::string::npos != strLineTmp.find("[[")) { //[[]] if (VtrOneDb.size() > 0) { CSQLType* pNewSQLType = new CSQLType(); nFunRes = pNewSQLType->analyzeData(VtrOneDb); VtrOneDb.clear(); m_LstDBInfo.push_back(pNewSQLType); pNewSQLType = NULL; } } VtrOneDb.push_back(strLineTmp); VtrIterTable++; if (VtrOneTable.end() == VtrIterTable) { CSQLType* pNewSQLType = new CSQLType(); nFunRes = pNewSQLType->analyzeData(VtrOneDb); VtrOneDb.clear(); m_LstDBInfo.push_back(pNewSQLType); pNewSQLType = NULL; } if (0 != nFunRes) { nFunRes = -1; return nFunRes; } }//while return nFunRes; }