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


C++ CStdString::GetAt方法代码示例

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


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

示例1: UnEscapeUrl

void UrlSerializer::UnEscapeUrl(CStdString& in, CStdString& out)
{
	// Translates all %xx escaped sequences to corresponding ascii characters
	out = "";
	char pchHex[3];
	for (unsigned int i = 0; i<in.size(); i++)
	{
		switch (in.GetAt(i))
		{
			case '+':
				out += ' ';
				break;
			case '%':
				if (in.GetAt(++i) == '%')
				{
					out += '%';
					break;
				}
				pchHex[0] = in.GetAt(i);
				pchHex[1] = in.GetAt(++i);
				pchHex[2] = 0;
				out += (char)strtol(pchHex, NULL, 16);
				break;
			default:
				out += in.GetAt(i);
		}
	}
}
开发者ID:HiPiH,项目名称:Oreka,代码行数:28,代码来源:UrlSerializer.cpp

示例2: FileEscapeName

void FileEscapeName(CStdString& in, CStdString& out)
{
	// Translates all the characters that are not in file_ok_chars string into %xx sequences
	// %xx specifies the character ascii code in hexadecimal
	out = "";
	for (unsigned int i = 0 ; i<in.size() ; i++)
	{
		if (strchr(file_ok_chars, in.GetAt(i)))
		{
			out += in.GetAt(i);
		}
		else
		{
			out += '%';
			out += hex_digits[((unsigned char) in.GetAt(i)) >> 4];
			out += hex_digits[in.GetAt(i) & 0x0F];
		}
	}
}
开发者ID:uchitaso,项目名称:orkweb,代码行数:19,代码来源:Utils.cpp

示例3: EscapeUrl

void UrlSerializer::EscapeUrl(CStdString& in, CStdString& out)
{
	// Translates all the characters that are not in url_ok_chars string into %xx sequences
	// %xx specifies the character ascii code in hexadecimal
	out = "";
	for (unsigned int i = 0 ; i<in.size() ; i++)
	{
		if (in.GetAt(i) == ' ')
			out += '+';
		else if (strchr(url_ok_chars, in.GetAt(i)))
			out += in.GetAt(i);
		else
		{
			out += '%';
			out += hex_digits[((unsigned char) in.GetAt(i)) >> 4];
			out += hex_digits[in.GetAt(i) & 0x0F];
		}
	}
}
开发者ID:HiPiH,项目名称:Oreka,代码行数:19,代码来源:UrlSerializer.cpp

示例4: StringIsDigit

bool StringIsDigit(CStdString& string)
{
	int size = string.size();
	for(int i=0; i<size; i++)
	{
		if(isdigit(string.GetAt(i)) == false)
		{
			return false;
		}
	}
	return true;
}
开发者ID:uchitaso,项目名称:orkweb,代码行数:12,代码来源:Utils.cpp

示例5: StringIsPhoneNumber

bool StringIsPhoneNumber(CStdString& string)
{
	int size = string.size();
	for(int i=0; i<size; i++)
	{
		char c = string.GetAt(i);
		if(isdigit(c) == false && c != '-' && c != '*' && c != '#')
		{
			return false;
		}
	}
	return true;
}
开发者ID:uchitaso,项目名称:orkweb,代码行数:13,代码来源:Utils.cpp

示例6: GenerateUniquePathNameFromDocID

CStdString DocProvHelper::GenerateUniquePathNameFromDocID(CStdString sDocumentID) const
{
	sDocumentID.Trim();

	/* TXTEX_IGNORE */ 	sDocumentID.Replace( '\\', _T('/') );
	/* TXTEX_IGNORE */ 	sDocumentID.Replace( _T("://"), _T("/") );

	int nLastPeriod = (x64_int_cast)sDocumentID.length() - 4;
	/* TXTEX_IGNORE */ 	if( nLastPeriod >= 0 && sDocumentID.GetAt( nLastPeriod ) == _T('.') )
		/* TXTEX_IGNORE */ 		sDocumentID.SetAt( nLastPeriod, _T('_') );

	return ReplaceInvalidFileNameChars(sDocumentID);

}
开发者ID:killbug2004,项目名称:WSProf,代码行数:14,代码来源:DocProvHelper.cpp

示例7: GetListTokens

int GetListTokens(CStdString strTokens,  CStdString token ,LstString& lstTokens)
{
	CStdString sAux,sTmp;
	char buffer[512];
	int i,j;

	if ( strTokens != "" ){
		sAux = strTokens.GetAt( strTokens.GetLength( ) - 1 ) ;
		if ( sAux != token ){
			sAux = strTokens + token;
		}
		else{
			sAux = strTokens;
		}

		i = 0;
		j = sAux.find_first_of( token );

		for ( ;; ){
			memset( (char *)buffer, 0, sizeof( buffer ) );

			if ( j-i > 1 ){
				sAux.copy( buffer, j-i, i );
			}

			sTmp = buffer;

			if ( sTmp != "" )
			{
				lstTokens.push_back( (LPCSTR)sTmp );
			}

			i = ++j;
			j = sAux.find_first_of( token, i );

			if ( j == -1 ) {
				break;
			}
		}
	}
	return 0;
}
开发者ID:rdmeneze,项目名称:SMSBox-PIC,代码行数:42,代码来源:functions.cpp

示例8: TestReturnPathIncludesCorrectDrive

void CTestLongNameOpen::TestReturnPathIncludesCorrectDrive()
{
	Gen::CFilePath wrd;
	TCHAR pszShortname[MAX_PATH] = {0};
	DWORD  dwSize = GetShortPathName(sLongFileNameDifferentDrive.c_str(), pszShortname, MAX_PATH);
	if(dwSize == 0)
	{
		assertTest(_T("Failed to extract short name") == false);
	}

	TCHAR chExpectedDriveLetter = sLongFileNameDifferentDrive.GetAt(0);
	TCHAR chExpUpperLetter;
	TCHAR chExpLowerLetter;
	if (chExpectedDriveLetter <= _T('Z'))	// It's upper case
	{
		chExpUpperLetter = chExpectedDriveLetter;
		chExpLowerLetter = chExpUpperLetter + (_T('a') - _T('A'));
	}
	else
	{
		chExpLowerLetter = chExpectedDriveLetter;
		chExpUpperLetter = chExpLowerLetter - (_T('a') - _T('A'));
	}

	assertTest((pszShortname[0] == chExpUpperLetter) || (pszShortname[0] == chExpLowerLetter));
	CStdString stInput, stOutput;
	stInput = pszShortname;
	bool bOK = wrd.GenerateLongFilePath(stInput, stOutput);
	assertMessage(bOK, _T("Call to GenerateLongFilePath returned failure"));

	CStdString sMsg;
	sMsg.Format(_T("Expected GenerateLongFilePath to generate %s.  Instead got %s"),
		sLongFileNameDifferentDrive.c_str(),
		stOutput.c_str());
	assertMessage(stOutput.CompareNoCase(sLongFileNameDifferentDrive) == 0, sMsg);

	assertTest((stOutput[0] == chExpUpperLetter) || (stOutput[0] == chExpLowerLetter));
}
开发者ID:killbug2004,项目名称:WSProf,代码行数:38,代码来源:TestLongNameOpen.cpp

示例9: SetSettings

void CNetworkInterfaceLinux::SetSettings(NetworkAssignment& assignment, CStdString& ipAddress, CStdString& networkMask, CStdString& defaultGateway, CStdString& essId, CStdString& key, EncMode& encryptionMode)
{
#if defined(TARGET_LINUX)
    FILE* fr = fopen("/etc/network/interfaces", "r");
    if (!fr)
    {
        // TODO
        return;
    }

    FILE* fw = fopen("/tmp/interfaces.temp", "w");
    if (!fw)
    {
        // TODO
        fclose(fr);
        return;
    }

    char* line = NULL;
    size_t linel = 0;
    CStdString s;
    bool foundInterface = false;
    bool dataWritten = false;

    while (getdelim(&line, &linel, '\n', fr) > 0)
    {
        vector<CStdString> tokens;

        s = line;
        s.TrimLeft(" \t").TrimRight(" \n");

        // skip comments
        if (!foundInterface && (s.length() == 0 || s.GetAt(0) == '#'))
        {
            fprintf(fw, "%s", line);
            continue;
        }

        // look for "iface <interface name> inet"
        CUtil::Tokenize(s, tokens, " ");
        if (tokens.size() == 2 &&
                tokens[0].Equals("auto") &&
                tokens[1].Equals(GetName()))
        {
            continue;
        }
        else if (!foundInterface &&
                 tokens.size() == 4 &&
                 tokens[0].Equals("iface") &&
                 tokens[1].Equals(GetName()) &&
                 tokens[2].Equals("inet"))
        {
            foundInterface = true;
            WriteSettings(fw, assignment, ipAddress, networkMask, defaultGateway, essId, key, encryptionMode);
            dataWritten = true;
        }
        else if (foundInterface &&
                 tokens.size() == 4 &&
                 tokens[0].Equals("iface"))
        {
            foundInterface = false;
            fprintf(fw, "%s", line);
        }
        else if (!foundInterface)
        {
            fprintf(fw, "%s", line);
        }
    }
    free(line);

    if (!dataWritten && assignment != NETWORK_DISABLED)
    {
        fprintf(fw, "\n");
        WriteSettings(fw, assignment, ipAddress, networkMask, defaultGateway, essId, key, encryptionMode);
    }

    fclose(fr);
    fclose(fw);

    // Rename the file
    if (rename("/tmp/interfaces.temp", "/etc/network/interfaces") < 0)
    {
        // TODO
        return;
    }

    std::string cmd = "/sbin/ifdown " + GetName();
    if (system(cmd.c_str()) != 0)
        CLog::Log(LOGERROR, "Unable to stop interface %s", GetName().c_str());
    else
        CLog::Log(LOGINFO, "Stopped interface %s", GetName().c_str());

    if (assignment != NETWORK_DISABLED)
    {
        cmd = "/sbin/ifup " + GetName();
        if (system(cmd.c_str()) != 0)
            CLog::Log(LOGERROR, "Unable to start interface %s", GetName().c_str());
        else
            CLog::Log(LOGINFO, "Started interface %s", GetName().c_str());
    }
//.........这里部分代码省略.........
开发者ID:jrahaim,项目名称:xbmc,代码行数:101,代码来源:NetworkLinux.cpp

示例10: GetSettings

void CNetworkInterfaceLinux::GetSettings(NetworkAssignment& assignment, CStdString& ipAddress, CStdString& networkMask, CStdString& defaultGateway, CStdString& essId, CStdString& key, EncMode& encryptionMode)
{
    ipAddress = "0.0.0.0";
    networkMask = "0.0.0.0";
    defaultGateway = "0.0.0.0";
    essId = "";
    key = "";
    encryptionMode = ENC_NONE;
    assignment = NETWORK_DISABLED;

#if defined(TARGET_LINUX)
    FILE* fp = fopen("/etc/network/interfaces", "r");
    if (!fp)
    {
        // TODO
        return;
    }

    char* line = NULL;
    size_t linel = 0;
    CStdString s;
    bool foundInterface = false;

    while (getdelim(&line, &linel, '\n', fp) > 0)
    {
        vector<CStdString> tokens;

        s = line;
        s.TrimLeft(" \t").TrimRight(" \n");

        // skip comments
        if (s.length() == 0 || s.GetAt(0) == '#')
            continue;

        // look for "iface <interface name> inet"
        CUtil::Tokenize(s, tokens, " ");
        if (!foundInterface &&
                tokens.size() >=3 &&
                tokens[0].Equals("iface") &&
                tokens[1].Equals(GetName()) &&
                tokens[2].Equals("inet"))
        {
            if (tokens[3].Equals("dhcp"))
            {
                assignment = NETWORK_DHCP;
                foundInterface = true;
            }
            if (tokens[3].Equals("static"))
            {
                assignment = NETWORK_STATIC;
                foundInterface = true;
            }
        }

        if (foundInterface && tokens.size() == 2)
        {
            if (tokens[0].Equals("address")) ipAddress = tokens[1];
            else if (tokens[0].Equals("netmask")) networkMask = tokens[1];
            else if (tokens[0].Equals("gateway")) defaultGateway = tokens[1];
            else if (tokens[0].Equals("wireless-essid")) essId = tokens[1];
            else if (tokens[0].Equals("wireless-key"))
            {
                key = tokens[1];
                if (key.length() > 2 && key[0] == 's' && key[1] == ':')
                    key.erase(0, 2);
                encryptionMode = ENC_WEP;
            }
            else if (tokens[0].Equals("wpa-ssid")) essId = tokens[1];
            else if (tokens[0].Equals("wpa-proto") && tokens[1].Equals("WPA")) encryptionMode = ENC_WPA;
            else if (tokens[0].Equals("wpa-proto") && tokens[1].Equals("WPA2")) encryptionMode = ENC_WPA2;
            else if (tokens[0].Equals("wpa-psk")) key = tokens[1];
            else if (tokens[0].Equals("auto") || tokens[0].Equals("iface") || tokens[0].Equals("mapping")) break;
        }
    }
    free(line);

    // Fallback in case wpa-proto is not set
    if (key != "" && encryptionMode == ENC_NONE)
        encryptionMode = ENC_WPA;

    fclose(fp);
#endif
}
开发者ID:jrahaim,项目名称:xbmc,代码行数:83,代码来源:NetworkLinux.cpp

示例11: SetValue

BOOL CObjectEntry::SetValue(CStdString strValue)
{
    CMmcDataConversion conversion;
    BOOL oResult(FALSE);

    //Reset
    ResetValue();

    //SetValue
    switch(m_DataType)
    {
        case ODT_BOOLEAN:
            {
                if(InitValue(sizeof(WORD)))
                {
                    if(strValue.CompareNoCase("TRUE") == 0)
                    {
                        *((WORD*)m_pValue) = TRUE;
                        oResult = TRUE;
                    }
                    else
                    {
                        *((WORD*)m_pValue) = FALSE;
                        oResult = TRUE;
                    }
                }
            };break;

        case ODT_INT8:
            {
                if(InitValue(sizeof(char)))
                {
                    oResult = conversion.CharStr2Char(strValue, ((char*)m_pValue), FALSE);
                }
            };break;
        case ODT_INT16:
            {
                if(InitValue(sizeof(short)))
                {
                    oResult = conversion.ShortStr2Short(strValue, ((short*)m_pValue), FALSE);
                }
            };break;
        case ODT_INT32:
            {
                if(InitValue(sizeof(long)))
                {
                    oResult = conversion.LongStr2Long(strValue, ((long*)m_pValue), FALSE);
                }
            };break;
        case ODT_INT64:
            {
                if(InitValue(sizeof(__int64)))
                {
                    oResult = conversion.Int64Str2Int64(strValue, ((__int64*)m_pValue), FALSE);
                }
            };break;
        case ODT_UINT8:
            {
                if(InitValue(sizeof(BYTE)))
                {
                    oResult = conversion.ByteStr2Byte(strValue, ((BYTE*)m_pValue), FALSE);
                }
            };break;
        case ODT_UINT16:
            {
                if(InitValue(sizeof(WORD)))
                {
                    oResult = conversion.WordStr2Word(strValue, ((WORD*)m_pValue));
                }
            };break;
        case ODT_UINT32:
            {
                if(InitValue(sizeof(DWORD)))
                {
                    oResult = conversion.DWordStr2DWord(strValue, ((DWORD*)m_pValue), FALSE);
                }
            };break;
        case ODT_UINT64:
            {
                if(InitValue(sizeof(unsigned __int64)))
                {
                    oResult = conversion.UInt64Str2UInt64(strValue, ((unsigned __int64*)m_pValue), FALSE);
                }
            };break;
        case ODT_FLOAT:
            {
                if(InitValue(sizeof(float)))
                {
                    oResult = conversion.FloatStr2Float(strValue, ((float*)m_pValue), FALSE);
                }
            };break;
        case ODT_STRING:
            {
                if(InitValue(strlen(strValue))*sizeof(TCHAR))
                {
                    for(DWORD d=0;d<m_dValueSize;d++)
                    {
                        *((TCHAR*)m_pValue+d) = strValue.GetAt(d);
                    }
                    oResult = TRUE;
//.........这里部分代码省略.........
开发者ID:RIVeR-Lab,项目名称:eposcmd,代码行数:101,代码来源:ObjectEntry.cpp

示例12: ExecuteUrl

bool OrkHttpClient::ExecuteUrl(const CStdString& request, CStdString& response, const CStdString& hostname, const int tcpPort, int timeout)
{
	CStdString logMsg;
	response = "";
	ACE_SOCK_Connector  connector;
	ACE_SOCK_Stream peer;
	ACE_INET_Addr peer_addr;
	if(timeout < 1){timeout = 1;}
	ACE_Time_Value aceTimeout (timeout);
	CStdString requestDetails;
	requestDetails.Format("timeout:%d http://%s:%d/%s", timeout, hostname, tcpPort, request);
	time_t beginRequestTimestamp = time(NULL);

	char szTcpPort[10];
	sprintf(szTcpPort, "%d", tcpPort);
	iovec iov[8];
	iov[0].iov_base = (IOV_TYPE)"GET ";
	iov[0].iov_len = 4; // Length of "GET ".
	iov[1].iov_base = (PSTR)(PCSTR)request;
	iov[1].iov_len = request.size();
	iov[2].iov_base = (IOV_TYPE)" HTTP/1.0\r\n";
	iov[2].iov_len = 11;
	iov[3].iov_base = (IOV_TYPE)"Host: ";
	iov[3].iov_len = 6;
	iov[4].iov_base = (PSTR)(PCSTR)hostname;
	iov[4].iov_len = hostname.size();
	iov[5].iov_base = (IOV_TYPE)":";
	iov[5].iov_len = 1;
	iov[6].iov_base = szTcpPort;
	iov[6].iov_len = strlen(szTcpPort);
	iov[7].iov_base = (IOV_TYPE)"\r\n\r\n";
	iov[7].iov_len = 4;

	if (peer_addr.set (tcpPort, (PCSTR)hostname) == -1)
	{
		logMsg.Format("peer_addr.set()  errno=%d %s", errno, requestDetails);
		LogError(logMsg);
		return false;
	}
	else if (connector.connect (peer, peer_addr, &aceTimeout) == -1)
	{
		if (errno == ETIME)
		{
		}
		logMsg.Format("connector.connect()  errno=%d %s", errno, requestDetails);
		LogError(logMsg);
		return false;
	}
	else if (peer.sendv_n (iov, 8, &aceTimeout) == -1)
	{
		logMsg.Format("peer.sendv_n  errno=%d %s", errno, requestDetails);
		LogError(logMsg);
		return false;
	}

	ssize_t numReceived = 0;
#define BUFSIZE 4096
	char buf [BUFSIZE];

	CStdString header;
	bool gotHeader = false;
	while ( ((numReceived = peer.recv (buf, BUFSIZE, &aceTimeout)) > 0)  && ((time(NULL) - beginRequestTimestamp) <= timeout) )
	{
		for(int i=0; i<numReceived; i++)
		{
			if(!gotHeader)
			{
				// extract header (delimited by CR-LF-CR-LF)
				header += buf[i];
				size_t headerSize = header.size();
				if (headerSize > 4 &&
					header.GetAt(headerSize-1) == '\n' && 
					header.GetAt(headerSize-2) == '\r' &&
					header.GetAt(headerSize-3) == '\n' &&
					header.GetAt(headerSize-4) == '\r'		)
				{
					gotHeader = true;
				}
			}
			else
			{
				// extract content
				response += buf[i];
			}
		}
	}
	peer.close();
	
	logMsg.Format("%s:%d response:%s",hostname, tcpPort, response);
	LOG4CXX_DEBUG(m_log, logMsg);
	if(numReceived < 0)
	{
		logMsg.Format("numReceived:%d %s", numReceived, requestDetails);
		LogError(logMsg);
		return false;
	}
	if(header.size() > 15 && header.GetAt(9) == '4' && header.GetAt(10) == '0' && header.GetAt(11) == '0')
	{
		logMsg.Format("HTTP header:%s ** request:%s\nIgnore this message", header, requestDetails);
		LOG4CXX_ERROR(m_log, logMsg);
//.........这里部分代码省略.........
开发者ID:havoc83,项目名称:oreka,代码行数:101,代码来源:OrkClient.cpp


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