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


C++ WString::length方法代码示例

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


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

示例1: if

std::string WideToUTF8(const WString &inWideString)
{
  int len = 0;
  const wchar_t *chars = inWideString.c_str();
  for(int i=0;i<inWideString.length();i++)
   {
      int c = chars[i];
      if( c <= 0x7F ) len++;
      else if( c <= 0x7FF ) len+=2;
      else if( c <= 0xFFFF ) len+=3;
      else len+= 4;
   }


   std::string result;
   result.resize(len);
   unsigned char *data =  (unsigned char *) &result[0];
   for(int i=0;i<inWideString.length();i++)
   {
      int c = chars[i];
      if( c <= 0x7F )
         *data++ = c;
      else if( c <= 0x7FF )
      {
         *data++ = 0xC0 | (c >> 6);
         *data++ = 0x80 | (c & 63);
      }
      else if( c <= 0xFFFF )
开发者ID:madrazo,项目名称:nme,代码行数:28,代码来源:Utils.cpp

示例2: DelTree

///////////////////////////////////////////////////////////////
//
// DelTree
//
//
//
///////////////////////////////////////////////////////////////
bool SharedUtil::DelTree ( const SString& strPath, const SString& strInsideHere )
{
    // Safety: Make sure strPath is inside strInsideHere
    WString wstrPath = FromUTF8( strPath );
    WString wstrInsideHere = FromUTF8( strInsideHere );
    if ( !wstrPath.BeginsWithI( wstrInsideHere ) )
    {
        assert ( 0 );
        return false;
    }

    DWORD dwBufferSize = ( wstrPath.length() + 3 ) * sizeof( wchar_t );
    wchar_t *szBuffer = static_cast < wchar_t* > ( alloca ( dwBufferSize ) );
    memset ( szBuffer, 0, dwBufferSize );
    wcsncpy ( szBuffer, wstrPath, wstrPath.length() );
    SHFILEOPSTRUCTW sfos;

    sfos.hwnd = NULL;
    sfos.wFunc = FO_DELETE;
    sfos.pFrom = szBuffer;  // Double NULL terminated
    sfos.pTo = NULL;
    sfos.fFlags = FOF_NOCONFIRMATION | FOF_NOERRORUI | FOF_SILENT | FOF_ALLOWUNDO;

    int status = SHFileOperationW(&sfos);
    return status == 0;
}
开发者ID:Cazomino05,项目名称:Test1,代码行数:33,代码来源:SharedUtil.File.hpp

示例3: TrimEnd

//
// Remove szOlds from the end of the string.
//
WString WString::TrimEnd ( const wchar_t* szOld ) const
{
    const size_t uiOldLength = wcslen ( szOld );
    WString strResult = *this;
    while ( strResult.length () >= uiOldLength && strResult.substr ( strResult.length () - uiOldLength ) == szOld )
        strResult = strResult.substr ( 0, strResult.length () - uiOldLength );
    return strResult;
}
开发者ID:Barashuk,项目名称:Moder-Funcs,代码行数:11,代码来源:WString.hpp

示例4: String

	String md5(const WString& source)
	{
		MD5 md5;
		md5.update((UINT8*)source.c_str(), (UINT32)source.length() * sizeof(WString::value_type));
		md5.finalize();

		UINT8 digest[16];
		md5.decdigest(digest, sizeof(digest));

		char buf[33];
		for (int i = 0; i < 16; i++)
			sprintf(buf + i * 2, "%02x", digest[i]);
		buf[32] = 0;
		
		return String(buf);
	}
开发者ID:MarcoROG,项目名称:BansheeEngine,代码行数:16,代码来源:BsUtil.cpp

示例5: Split

//
// Split into parts
//
void WString::Split ( const WString& strDelim, std::vector < WString >& outResult, unsigned int uiMaxAmount, unsigned int uiMinAmount ) const
{
    outResult.clear ();
    unsigned long ulStartPoint = 0;

    while ( true )
    {
        size_t ulPos = find ( strDelim, ulStartPoint );

        if ( ulPos == npos || ( uiMaxAmount > 0 && uiMaxAmount <= outResult.size () + 1 ) )
        {
            if ( ulStartPoint <= length () )
                outResult.push_back ( substr ( ulStartPoint ) );
            break;
        }

        outResult.push_back ( substr ( ulStartPoint, ulPos - ulStartPoint ) );

        ulStartPoint = ulPos + strDelim.length ();
    }

    while ( outResult.size () < uiMinAmount )
        outResult.push_back ( L"" );        
}
开发者ID:Barashuk,项目名称:Moder-Funcs,代码行数:27,代码来源:WString.hpp

示例6: if

	//-----------------------------------------------------------------------
	void UnicodeFileSystemArchive::FileFinder::_run(const String& _dir, const WString& _wFullDir)
	{
		wchar_t wFindPattern[MAX_PATH];
		wcscpy(wFindPattern, _wFullDir.c_str());
		wcscpy(&wFindPattern[_wFullDir.length()], L"*");
       
        long lHandle;
		struct _wfinddata_t wTagData;
        lHandle = _wfindfirst(wFindPattern, &wTagData);

		String  tagDataName;
		String  dir2;
		WString wFullDir2;

		while(lHandle != -1)
		{
			bool isSubDir = ((wTagData.attrib & _A_SUBDIR) != 0);
			bool isHidden = ((wTagData.attrib & _A_HIDDEN) != 0);
			if((!mIgnoreHidden || !isHidden)
				&& !isReservedDir(wTagData.name)
				&& ((isSubDir == mDirs) || (isSubDir && mRecursive)))
			{
				tagDataName = mArchive->toString(wTagData.name);

				if(isSubDir == mDirs
					&& (mMask.empty() || StrUtil::match(tagDataName, mMask)))
				{
					if (mSimpleList)
					{
						mSimpleList->push_back(String());
						String& back = mSimpleList->back();
						back = _dir;
						back += tagDataName;
					}
					else if (mDetailList)
					{
						FileInfo fi;
						fi.archive = mArchive;
						fi.filename = _dir;
						fi.filename += tagDataName;
						fi.basename = tagDataName;
						fi.path = _dir;
						fi.compressedSize = wTagData.size;
						fi.uncompressedSize = wTagData.size;
						mDetailList->push_back(fi);
					}
				}

				if(isSubDir && mRecursive)
				{
					dir2 = _dir;
					dir2 += tagDataName;
					dir2 += '/';
					
					wFullDir2 = _wFullDir;
					wFullDir2 += wTagData.name;
					wFullDir2 += '/';
					
					_run(dir2, wFullDir2);
				}
			}
			
			if(_wfindnext( lHandle, &wTagData ) == -1)
			{
				_findclose(lHandle);
				lHandle = -1;
			}
        }
    }
开发者ID:raduetsya,项目名称:GothOgre,代码行数:70,代码来源:WinUnicodeFileSystem.cpp

示例7: BeginsWithI

bool WString::BeginsWithI ( const WString& strOther ) const
{
    return _wcsicmp ( Left ( (int)strOther.length () ), strOther ) == 0;
}
开发者ID:Barashuk,项目名称:Moder-Funcs,代码行数:4,代码来源:WString.hpp

示例8: BeginsWith

bool WString::BeginsWith ( const WString& strOther ) const
{
    return Left ( (int)strOther.length () ) == strOther;
}
开发者ID:Barashuk,项目名称:Moder-Funcs,代码行数:4,代码来源:WString.hpp

示例9: EndsWithI

bool WString::EndsWithI ( const WString& strOther ) const
{
    return _wcsicmp ( Right ( (int)strOther.length () ), strOther ) == 0;
}
开发者ID:Barashuk,项目名称:Moder-Funcs,代码行数:4,代码来源:WString.hpp

示例10: EndsWith

bool WString::EndsWith ( const WString& strOther ) const
{
    return Right ( (int)strOther.length () ) == strOther;
}
开发者ID:Barashuk,项目名称:Moder-Funcs,代码行数:4,代码来源:WString.hpp

示例11: request


//.........这里部分代码省略.........

    // if the client allows to sync over https even if the server
    // has an invalid certificate, the flag is false. By default it is true
    //if (getSSLVerifyServer() == false) {
    /*DWORD extraSSLDwFlags = 0;
	DWORD dwBuffLen = sizeof(extraSSLDwFlags);
    extraSSLDwFlags |= SECURITY_FLAG_IGNORE_REVOCATION | SECURITY_FLAG_IGNORE_WRONG_USAGE 
                    | SECURITY_FLAG_IGNORE_CERT_CN_INVALID | SECURITY_FLAG_IGNORE_CERT_DATE_INVALID;

 	InternetSetOption (req, INTERNET_OPTION_SECURITY_FLAGS,
                         &extraSSLDwFlags, sizeof (extraSSLDwFlags) );
*/
    if (url.isSecure()) {
        DWORD dwFlags, dwBuffLen = sizeof(dwFlags);
        InternetQueryOption (req, INTERNET_OPTION_SECURITY_FLAGS, (LPVOID)&dwFlags, &dwBuffLen);    
        if (getSSLVerifyServer() == false) {            
            dwFlags |= SECURITY_FLAG_IGNORE_UNKNOWN_CA | SECURITY_FLAG_IGNORE_REVOCATION | SECURITY_FLAG_IGNORE_WRONG_USAGE 
                    | SECURITY_FLAG_IGNORE_CERT_CN_INVALID | SECURITY_FLAG_IGNORE_CERT_DATE_INVALID;
            
        } else {
             dwFlags = dwFlags| INTERNET_FLAG_SECURE;
        }
        InternetSetOption (req, INTERNET_OPTION_SECURITY_FLAGS, &dwFlags, sizeof (dwFlags));     
    }
     
    bool retry = false;

    // give a chance to submit again if error is ERROR_INTERNET_SEC_CERT_REV_FAILED
    bool retryFlagRevocation = true;

    BufferIn.dwStructSize = sizeof( INTERNET_BUFFERS ); // Must be set or error will occur
    BufferIn.Next = NULL;
    BufferIn.lpcszHeader = headers.c_str();
    BufferIn.dwHeadersLength = headers.length(); 
    BufferIn.dwHeadersTotal = 0;
    BufferIn.lpvBuffer = NULL;
    BufferIn.dwBufferLength = 0;
    BufferIn.dwBufferTotal = 0; //contentLen;
    BufferIn.dwOffsetLow = 0;
    BufferIn.dwOffsetHigh = 0;

    do {
        retry = false;
        if (!HttpSendRequestEx(req, &BufferIn, NULL, HSR_INITIATE, 0)) {
            DWORD err = GetLastError();
            if (err == ERROR_INTERNET_SEC_CERT_REV_FAILED && retryFlagRevocation) {
                LOG.info("%s: error ERROR_INTERNET_SEC_CERT_REV_FAILED: retry once a time", __FUNCTION__);
                DWORD dwFlags, dwBuffLen = sizeof(dwFlags);
                InternetQueryOption (req, INTERNET_OPTION_SECURITY_FLAGS, (LPVOID)&dwFlags, &dwBuffLen);    
                dwFlags |= SECURITY_FLAG_IGNORE_REVOCATION;
                InternetSetOption (req, INTERNET_OPTION_SECURITY_FLAGS, &dwFlags, sizeof (dwFlags));    
                retryFlagRevocation = false;
                retry = true;
                continue;
            }
                
            const char* msg = createHttpErrorMessage(err);
            LOG.error("HttpSendRequestEx failed: code %d: %s", err, msg);
            delete [] msg;
            return StatusNetworkError;
        }

#ifdef USE_ZLIB
        if (compression_enabled) {        
            if (sendData((const char *)cBuf, cBufLen) != 0) {
                delete [] cBuf;
开发者ID:fieldwind,项目名称:syncsdk,代码行数:67,代码来源:HttpConnection.cpp


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