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


C++ string_type::find_first_not_of方法代码示例

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


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

示例1: CheckName

 /** \brief Check if a given name contains invalid characters. 
     \param a_strName The name to check
     \param a_szCharSet The characterset
     \throw ParserException if the name contains invalid charakters.
 */
 void ParserXBase::CheckName(const string_type &a_strName, 
                             const string_type &a_szCharSet) const
 {
   if ( !a_strName.length() || 
       (a_strName.find_first_not_of(a_szCharSet)!=string_type::npos) ||
       (a_strName[0]>=(char_type)'0' && a_strName[0]<=(char_type)'9'))
   {
     Error(ecINVALID_NAME);
   }
 }
开发者ID:zhanxw,项目名称:mycode,代码行数:15,代码来源:mpParserBase.cpp

示例2: BYTE_ConvertFromHexStringToArray

int CCommonFnc::BYTE_ConvertFromHexStringToArray(string_type hexaString, BYTE* pArray, DWORD* pbArrayLen) {
    int         status = STAT_OK;
    DWORD       pos = 0;
    DWORD       pos2 = 0;
	string_type     hexNum;
    DWORD       num;
    BYTE*       pTempArray = NULL;
    DWORD       tempArrayPos = 0;

    // EAT SPACES
    //hexaString.TrimLeft(); hexaString.TrimRight();
	hexaString.erase(hexaString.find_last_not_of(_CONV(" ")) + 1);
	size_t startpos = hexaString.find_first_not_of(_CONV(" "));
	if (string_type::npos != startpos) {
		hexaString = hexaString.substr(startpos);
	}
    hexaString += _CONV(" ");
    hexaString.length();

    if (status == STAT_OK) {
        pTempArray = new BYTE[hexaString.length()];
        memset(pTempArray, 0, hexaString.length());

        pos = pos2 = 0;
        /*while ((pos = hexaString.Find(' ', pos2)) != -1) {
            hexNum = hexaString.Mid(pos2, pos - pos2);
            hexNum.TrimLeft(); hexNum.TrimRight();
            if (hexNum.GetLength() > 0) {
                num = strtol((LPCTSTR) hexNum, NULL, 16);
        
                if (num == 0xFF) pTempArray[tempArrayPos] = 0xFF;
                else pTempArray[tempArrayPos] = (BYTE) num & 0xFF;
                
                tempArrayPos++;
            }
            pos2 = pos + 1;
        }*/
		while ((pos = hexaString.find(' ', pos2)) != string_type::npos) {
			hexNum = hexaString.substr((pos2, pos - pos2));
			hexNum.erase(hexNum.find_last_not_of(_CONV(" ")) + 1);
			size_t startpos2 = hexNum.find_first_not_of(_CONV(" "));
			if (string_type::npos != startpos2) {
				hexNum = hexNum.substr(startpos2);
			}
			if (hexNum.length() > 0) {
				num = type_to_int((LPCTSTR)hexNum.c_str(), NULL, 16);

				if (num == 0xFF) pTempArray[tempArrayPos] = 0xFF;
				else pTempArray[tempArrayPos] = (BYTE)num & 0xFF;

				tempArrayPos++;
			}
			pos2 = pos + 1;
		}

        if (tempArrayPos > *pbArrayLen) {
            status = STAT_NOT_ENOUGHT_MEMORY;
        }  
        else {
            memcpy(pArray, pTempArray, tempArrayPos);
        }
        *pbArrayLen = tempArrayPos;

        if (pTempArray) delete[] pTempArray;
    }

    return status;
}
开发者ID:,项目名称:,代码行数:68,代码来源:


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