当前位置: 首页>>代码示例>>C++>>正文


C++ CvString::find_first_of方法代码示例

本文整理汇总了C++中CvString::find_first_of方法的典型用法代码示例。如果您正苦于以下问题:C++ CvString::find_first_of方法的具体用法?C++ CvString::find_first_of怎么用?C++ CvString::find_first_of使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CvString的用法示例。


在下文中一共展示了CvString::find_first_of方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: isCommaFile

bool CvXMLLoadUtilityModTools::isCommaFile(CvString *pszTextVal, const char* szDirName)
{
#if (DEBUG_IS_MODULAR_ART == 1)
	CvString szDebugBuffer;
	szDebugBuffer.Format("=== isCommaFile BEGIN ===");
	gDLL->logMsg("CvXMLLoadUtilityModTools_isCommaFile.log", szDebugBuffer.c_str());

	szDebugBuffer.Format(" Text value: %s,  Directory name: '%s'", pszTextVal->c_str(), szDirName);
	gDLL->logMsg("CvXMLLoadUtilityModTools_isCommaFile.log", szDebugBuffer.c_str());
#endif

	string::size_type posComma = (*pszTextVal).find_first_of(',');

	if(posComma != string::npos) //if no comma found at all, return false
	{

#if (DEBUG_IS_MODULAR_ART == 1)
		szDebugBuffer.Format(" Found a ',' at position %i (total length %i)", (int)posComma, (*pszTextVal).GetLength());
		gDLL->logMsg("CvXMLLoadUtilityModTools_isCommaFile.log", szDebugBuffer.c_str());
#endif
		CvString szTempLocation;
		CvString szAppend = " ";
		int iCountComma = 0;
		CvString szLocationNameStripComma;
		// Check how many comma's we have in the string and how many Button Files		

#if (DEBUG_IS_MODULAR_ART == 1)
		std::vector<CvString> asTagParts;
		pszTextVal->getTokens(CvString(","), asTagParts);
		iCountComma = asTagParts.size();

		szDebugBuffer.Format(" Total number of ',' in pszTextVal: %i", iCountComma);
		gDLL->logMsg("CvXMLLoadUtilityModTools_isCommaFile.log", szDebugBuffer.c_str());
		for (std::vector<CvString>::iterator it = asTagParts.begin(); it != asTagParts.end(); it++)
		{
			szDebugBuffer.Format("  - Token %s", (*it).c_str());
			gDLL->logMsg("CvXMLLoadUtilityModTools_isCommaFile.log", szDebugBuffer.c_str());
		}
#else
		szLocationNameStripComma = *pszTextVal;
		for ( int i = 0; i < szLocationNameStripComma.GetLength(); i++)
		{
			if (szLocationNameStripComma[i] == 44) // "," = 44 (ASCII)
			{
			  iCountComma++;
			}
		}		
#endif

		

#if (DEBUG_IS_MODULAR_ART == 1)
		CvString szButtonsString;
		for (std::vector<CvString>::iterator it = asTagParts.begin(); it != asTagParts.end(); it++)
		{
			bool bDigitsOnly = true;
			for (int i = 0; i < (*it).GetLength(); i++)
			{
				if (!isdigit((*it)[i]))
					bDigitsOnly = false;
			}
			if (!bDigitsOnly)
				szButtonsString += ((*it) + ",");
		}
		// Eliminate comma at end of string, if there is one
		if (szButtonsString.GetLength() > 0 && szButtonsString[szButtonsString.GetLength()] == ',')
			szButtonsString = szButtonsString.substr(0, szButtonsString.GetLength() - 1);

		szDebugBuffer.Format(" Button art string after eliminating numerical indices: %s", szButtonsString.c_str());
		gDLL->logMsg("CvXMLLoadUtilityModTools_isCommaFile.log", szDebugBuffer.c_str());

#else
		// determine the append string at the end of the tag
		bool bContinue = true;
		szTempLocation = *pszTextVal;
		while ( bContinue)
		{
			posComma = szTempLocation.find_first_of(',');
			if(posComma != string::npos) //Prevent Null pointer deletion
			{
				szTempLocation = szTempLocation.substr(szTempLocation.find(",")+1);
				if (isdigit(szTempLocation[0]))  //We found the Append
				{					
					bContinue = false;
				}
			}
			else break;			
		}
		if (!bContinue )
		{
			szAppend = "," + szTempLocation;
		}
#endif

std::vector<CvString> vecButtonArtFile;
#if (DEBUG_IS_MODULAR_ART == 1)
	szButtonsString.getTokens(CvString(","), vecButtonArtFile);
	szDebugBuffer.Format(" Button art vector size after tokenizing by ',': %i", vecButtonArtFile.size());
	gDLL->logMsg("CvXMLLoadUtilityModTools_isCommaFile.log", szDebugBuffer.c_str());
#else
//.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:101,代码来源:


注:本文中的CvString::find_first_of方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。