int CGenerateSQLFile::setParam(int argc, char *argv[])
{
	int nFunRes = 0;
	VrtLinesConT vecArgs;
	std::string strLogError;

	if (1 == argc || argc > 3)
	{
		nFunRes = -1;
		return nFunRes;
	}

	for (int nIndex = 0; nIndex < argc; nIndex++)
	{
		vecArgs.push_back(argv[nIndex]);
	}

	nFunRes = _ParseCmdLine(vecArgs);
	vecArgs.clear();
	
	m_strDirSqlCodeTxt = defSQLFileName_IN_SQLCODETXT;
	m_strDirSqlH = defSQLFileName_Out_SQLH;
	m_strDirSqlMacrodefH = defSQLFileName_Out_SQLMACRODEFH;
	m_strDirErrorReport = defSQLFilename_OUT_ERRORREPORT;
	m_strDirErrorReportReserve = defSQLFilename_OUT_ERRORREPORT;
	if (false == m_strParamInputFile.empty())
	{
		m_strDirSqlCodeTxt = m_strParamInputFile;
	}

	if (false == m_strParamOutpath.empty())
	{
		m_strDirSqlH = m_strParamOutpath  + "/";
		m_strDirSqlH += defSQLFileName_Out_SQLH;

		m_strDirSqlMacrodefH = m_strParamOutpath  + "/";
		m_strDirSqlMacrodefH += defSQLFileName_Out_SQLMACRODEFH;

		//	/u02/tabuild/3001_MYSQL/C955_Build/Base_3001/Base/SqlGenErrorReport.log
		m_strDirErrorReport = "../../../../";
		m_strDirErrorReport += defSQLFilename_OUT_ERRORREPORT;
		
		// /u02/tabuild/3001_MYSQL/C955_Build/Base_3001/Base/code/transactive/core/data_access_interface/src/SqlGenErrorReport.log 
		m_strDirErrorReportReserve = m_strParamOutpath  + "/";
		m_strDirErrorReportReserve += defSQLFilename_OUT_ERRORREPORT; 
	} 	
	  
	return nFunRes;	
}
Beispiel #2
0
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;
}