int CGenerateSQLFile::_ParseCmdLine(const VrtLinesConT& vecArgs)
{
	int nFunRes = 0;
	unsigned int nIndex = 0;
	std::string strDefInputFile = def_Str_Argv_inputfile;
	std::string strDefOutPath = def_Str_Argv_outpath; 
	std::string strParamName;
	std::string strParamValue;
	const char* str = NULL;

	// First arg is USUALLY the program name
	if (vecArgs.size() > 0)
	{
		if (vecArgs[0].size() > 0)
		{
			if (vecArgs[0][0] != '-')
			{
				m_strParamProgName = vecArgs[0];
				nIndex = 1;
			}
		}
	}
	
	//defualt value
	m_strParamInputFile = defSQLFileName_IN_SQLCODETXT;
	m_strParamOutpath = "./";

	// The rest should be standard parameters	
	for (; nIndex < vecArgs.size(); nIndex++)
	{
		str = vecArgs[nIndex].c_str();
		if (!_ExtractArg(str, strParamName, strParamValue))
		{
			_SysLog(SourceFLInfo, DebugError, "Err: _ExtractArg() %s", str);
			nFunRes = -1;
			return nFunRes;
		}

		if (!strParamName.empty())
		{
			if (0 == CUtilityFun::getInstance().sysStricmp(strDefInputFile.c_str(), strParamName.c_str()))
			{
				m_strParamInputFile	= strParamValue;
			}
			else if (0 == CUtilityFun::getInstance().sysStricmp(strDefOutPath.c_str(), strParamName.c_str()))
			{
				m_strParamOutpath	= strParamValue;
			}

		}

	}//for

	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;
}