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


C++ SString类代码示例

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


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

示例1: MergeFromString

 void CArgMap::MergeFromString ( const SString& strLine, bool bAllowMultiValues )
 {
     std::vector < SString > parts;
     strLine.Split( m_strPartsSep, parts );
     for ( uint i = 0 ; i < parts.size () ; i++ )
     {
         SString strCmd, strArg;
         parts[i].Split ( m_strArgSep, &strCmd, &strArg );
         if ( !bAllowMultiValues )
             m_Map.erase ( strCmd );
         if ( strCmd.length () ) // Key can not be empty
             MapInsert ( m_Map, strCmd, strArg );
     }
 }
开发者ID:0x688,项目名称:gtasa_crashfix,代码行数:14,代码来源:SharedUtil.Misc.hpp

示例2: currentPath

////////////////////////////////////////////////////////////////////////
// 描    述:  取当前路径
// 作    者:  邵凯田
// 创建时间:  2011-11-18 11:44
// 参数说明:  void
// 返 回 值:  当前路径,含路径分隔符
//////////////////////////////////////////////////////////////////////////
SString SDir::currentPath()
{
	SString str;
	char currentName[SKT_PATH_MAX+1];
	memset(currentName,0,SKT_PATH_MAX+1);
#ifdef WIN32
	GetModuleFileName(NULL,currentName,SKT_PATH_MAX);
	str = currentName;
	int pos=str.findRev("/");
	if(pos<0)
		pos = str.findRev("\\");
	if(pos>0)
		str = str.left(pos+1);
#else
	if(getcwd(currentName,SKT_PATH_MAX))
		str = currentName;
	else
		str = "";
	if(str.right(1) != "/")
		str += "/";
#endif
	return str;
}
开发者ID:song-kang,项目名称:Qt_RMS601-2,代码行数:30,代码来源:SFile.cpp

示例3: FormatMessageA

///////////////////////////////////////////////////////////////////////////
//
// SharedUtil::GetSystemErrorMessage
//
// Get Windows error message text from a last error code.
//
///////////////////////////////////////////////////////////////////////////
SString SharedUtil::GetSystemErrorMessage ( uint uiError, bool bRemoveNewlines, bool bPrependCode )
{
    SString strResult;

    LPSTR szErrorText = NULL;
    FormatMessageA ( FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_IGNORE_INSERTS,
                    NULL, uiError, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR)&szErrorText, 0, NULL );

    if ( szErrorText )
    {
        strResult = szErrorText;
        LocalFree ( szErrorText );
        szErrorText = NULL;
    }

    if ( bRemoveNewlines )
        strResult = strResult.Replace ( "\n", "" ).Replace ( "\r", "" );

    if ( bPrependCode )
        strResult = SString ( "Error %u: %s", uiError, *strResult );

    return strResult;
}
开发者ID:0x688,项目名称:gtasa_crashfix,代码行数:30,代码来源:SharedUtil.Misc.hpp

示例4: ShouldUseExeCopy

//////////////////////////////////////////////////////////
//
// ShouldUseExeCopy
//
// Returns true if patches should be applied to exe copy
//
//////////////////////////////////////////////////////////
bool ShouldUseExeCopy( void )
{
    SString strUseCopyReason;
    if ( GetApplicationSettingInt( "nvhacks", "optimus" ) )
        strUseCopyReason = GetApplicationSettingInt( "nvhacks", "optimus-rename-exe" ) == 0 ? "" : "optimus-rename-exe";
    else
        strUseCopyReason = GetApplicationSettingInt( "driver-overrides-disabled" ) == 0 ? "" : "driver-overrides-disabled";

    if ( GetPatchRequirementAltModules() )
        strUseCopyReason += " AltModules";

    if ( RequiresAltTabFix() )
        strUseCopyReason += " AltTabFix";

    // Log reason for using proxy_sa
    static SString strUseCopyReasonPrevious;
    if ( strUseCopyReasonPrevious != strUseCopyReason )
    {
        WriteDebugEventAndReport( 3500, SString( "Using proxy_sa because: %s", *strUseCopyReason ) );
        strUseCopyReasonPrevious = strUseCopyReason;
    }
    return !strUseCopyReason.empty();
}
开发者ID:Anubhav652,项目名称:mtasa-blue,代码行数:30,代码来源:CExePatchedStatus.cpp

示例5: GetRegistryValue

//
// What to do on next restart
//
bool SharedUtil::GetOnRestartCommand ( SString& strOperation, SString& strFile, SString& strParameters, SString& strDirectory, SString& strShowCmd )
{
    SString strOnRestartCommand = GetRegistryValue ( "", "OnRestartCommand" );
    SetOnRestartCommand ( "" );

    std::vector < SString > vecParts;
    strOnRestartCommand.Split ( "\t", vecParts );
    if ( vecParts.size () > 5 && vecParts[0].length () )
    {
        SString strVersion ( "%d.%d.%d-%d.%05d", MTASA_VERSION_MAJOR, MTASA_VERSION_MINOR, MTASA_VERSION_MAINTENANCE, MTASA_VERSION_TYPE, MTASA_VERSION_BUILD );
        if ( vecParts[5] == strVersion )
        {
            strOperation = vecParts[0];
            strFile = vecParts[1];
            strParameters = vecParts[2];
            strDirectory = vecParts[3];
            strShowCmd = vecParts[4];
            return true;
        }
        AddReportLog( 4000, SString ( "OnRestartCommand disregarded due to version change %s -> %s", vecParts[5].c_str (), strVersion.c_str () ) );
    }
    return false;
}
开发者ID:0x688,项目名称:gtasa_crashfix,代码行数:26,代码来源:SharedUtil.Misc.hpp

示例6: PathConform

///////////////////////////////////////////////////////////////
//
// FindFiles
//
// Find all files or directories at a path
// If sorted by date, returns last modified last
//
///////////////////////////////////////////////////////////////
std::vector < SString > SharedUtil::FindFiles ( const SString& strInMatch, bool bFiles, bool bDirectories, bool bSortByDate )
{
    std::vector < SString > strResult;
    std::multimap < uint64, SString > sortMap;

    SString strMatch = PathConform ( strInMatch );
    if ( strMatch.Right ( 1 ) == PATH_SEPERATOR )
        strMatch += "*";

    WIN32_FIND_DATAW findData;
    HANDLE hFind = FindFirstFileW ( FromUTF8( strMatch ), &findData );
    if( hFind != INVALID_HANDLE_VALUE )
    {
        do
        {
            if ( ( findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ) ? bDirectories : bFiles )
                if ( wcscmp ( findData.cFileName, L"." ) && wcscmp ( findData.cFileName, L".." ) )
                {
                    if ( bSortByDate )
                        MapInsert( sortMap, (uint64&)findData.ftLastWriteTime, ToUTF8( findData.cFileName ) );
                    else
                        strResult.push_back ( ToUTF8( findData.cFileName ) );
                }
        }
        while( FindNextFileW( hFind, &findData ) );
        FindClose( hFind );
    }

    // Resolve sorted map if required
    if ( !sortMap.empty() )
    {
        for ( std::multimap < uint64, SString >::iterator iter = sortMap.begin() ; iter != sortMap.end() ; ++iter )
            strResult.push_back ( iter->second );
    }

    return strResult;
}
开发者ID:Cazomino05,项目名称:Test1,代码行数:45,代码来源:SharedUtil.File.hpp

示例7: argStream

int CLuaFunctionDefs::AddAccount ( lua_State* luaVM )
{
    //  account addAccount ( string name, string pass[, bool allowCaseVariations = false ] )
    SString strName; SString strPassword; bool bAllowCaseVariations;

    CScriptArgReader argStream ( luaVM );
    argStream.ReadString ( strName );
    argStream.ReadString ( strPassword );
    argStream.ReadBool ( bAllowCaseVariations, false );

    if ( !argStream.HasErrors () )
    {
        if ( !bAllowCaseVariations )
        {
            // Message for new behaviour
            SString strCaseVariation = m_pAccountManager->GetActiveCaseVariation( strName );
            if ( !strCaseVariation.empty() )
                argStream.SetCustomError ( SString( "Already an account using a case variation of that name ('%s')", *strCaseVariation ) );
        }

        if ( !argStream.HasErrors () )
        {
            CAccount* pAccount;
            if ( ( pAccount = CStaticFunctionDefinitions::AddAccount ( strName, strPassword ) ) )
            {
                lua_pushaccount ( luaVM, pAccount );
                return 1;
            }
        }
    }

    if ( argStream.HasErrors () )
        m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage () );

    lua_pushboolean ( luaVM, false );
    return 1;
}
开发者ID:AdiBoy,项目名称:mtasa-blue,代码行数:37,代码来源:CLuaFunctionDefs.Account.cpp

示例8: dir

////////////////////////////////////////////////////////////////////////
// 描    述:  清除指定目录下的全部内容,同时递归清除全部子目录,不清除指定的目录自身
// 作    者:  邵凯田
// 创建时间:  2011-11-18 11:40
// 参数说明:  @dir为指定的目录
// 返 回 值:  true清除成功,false表示清除失败
//////////////////////////////////////////////////////////////////////////
bool SDir::clearDir(SString sPath)//清除指定目录下的全部内容
{
	if(sPath.Right(1) != "\\" && sPath.Right(1) != "/")
	{
#ifdef WIN32
		sPath += "\\";
#else
		sPath += "/";
#endif
	}
	SDir dir(sPath,"*");
	bool err = false;
	int i,cnt = dir.count();
	for(i=0;i<cnt;i++)
	{
		SString sFile = dir[i];
		if(sFile == "." || sFile == "..")
			continue;
		SString attr = dir.attribute(i);
		if(SString::GetAttributeValueI(attr,"isdir") == 1)
		{
			if(!clearDir(sPath+sFile))
				err = true;
			if(!SDir::removeDir(sPath+sFile))
				err = true;
		}
		else
		{
			if(!SFile::remove(sPath+sFile))
				err = true;
		}
	}
	if(err)
		return false;
	return true;
}
开发者ID:song-kang,项目名称:Qt_RMS601-2,代码行数:43,代码来源:SFile.cpp

示例9: LOGBASEDEBUG

bool SPostgres::Execute(SString sql)
{
	LOGBASEDEBUG("into SPostgres::Execute(%s)",sql.data());
	sql = sql.replace("\\","\\\\");//postgres数据库SQL中\为转义符
	if(m_pConn == NULL)
	{
		LOGWARN("m_pConn is NULL is SPostgres::Execute, Connect it at first!");
		Connect();
		if(m_pConn == NULL)
		{
			LOGWARN("m_pConn is NULL is SPostgres::Execute, Connect error!");
			return false;
		}
	}
	 
	PGresult *pRes = PQexec(m_pConn,sql.data());
	if(PQresultStatus(pRes) != PGRES_COMMAND_OK )
	{
		SString err;
		err.sprintf("Error in SPostgres::Execute(%s), err=%s",sql.data(),PQresultErrorMessage(pRes));
		LOGERROR("%s",err.data());
		if(pRes != NULL)
			PQclear(pRes);
		if(TestConnect() == true)//连接可用
			return false;

		//失败自动重连一次数据库
		if(!Reconnect())
			return false;//连接失败
		pRes = PQexec(m_pConn,sql.data());
		if(PQresultStatus(pRes)!=PGRES_COMMAND_OK) 
		{
			LOGERROR("Error in SPostgres::Execute(%s), err=%s",sql.data(),PQresultErrorMessage(pRes));
			if(pRes != NULL)
				PQclear(pRes);
			return false;
		}
	}
	PQclear(pRes);
	return true;
}
开发者ID:song-kang,项目名称:Qt_RMS601-2,代码行数:41,代码来源:SPostgres.cpp

示例10: GetCachedPathFilename

ResponseCode CResourceFile::Request(HttpRequest* ipoHttpRequest, HttpResponse* ipoHttpResponse)
{
    // HACK - Use http-client-files if possible as the resources directory may have been changed since the resource was loaded.
    SString strDstFilePath = GetCachedPathFilename();

    FILE* file = File::Fopen(strDstFilePath.c_str(), "rb");
    if (!file)
        file = File::Fopen(m_strResourceFileName.c_str(), "rb");

    // its a raw page
    if (file)
    {
        // Grab the filesize. Don't use the above method because it doesn't account for a changing
        // filesize incase of for example an included resource (causing bug #2676)
        fseek(file, 0, SEEK_END);
        long lBufferLength = ftell(file);
        rewind(file);

        // Allocate and read the entire file
        // TODO: This is inefficient.
        char* szBuffer = new char[lBufferLength + 1];
        fread(szBuffer, 1, lBufferLength, file);
        fclose(file);

        //
        ipoHttpResponse->oResponseHeaders["content-type"] = "application/octet-stream";            // not really the right mime-type
        ipoHttpResponse->SetBody(szBuffer, lBufferLength);
        delete[] szBuffer;
        return HTTPRESPONSECODE_200_OK;
    }
    else
    {
        ipoHttpResponse->SetBody("Can't read file!", strlen("Can't read file!"));
        return HTTPRESPONSECODE_500_INTERNALSERVERERROR;
    }
}
开发者ID:Audifire,项目名称:mtasa-blue,代码行数:36,代码来源:CResourceFile.cpp

示例11: argStream

int CLuaMatrixDefs::ToString(lua_State* luaVM)
{
    CLuaMatrix* pMatrix = NULL;

    CScriptArgReader argStream(luaVM);
    argStream.ReadUserData(pMatrix);

    if (!argStream.HasErrors())
    {
        SString string = SString("Matrix: { %.3f, %.3f, %.3f } { %.3f, %.3f, %.3f } { %.3f, %.3f, %.3f } { %.3f, %.3f, %.3f }", pMatrix->vRight.fX,
                                 pMatrix->vRight.fY, pMatrix->vRight.fZ, pMatrix->vFront.fX, pMatrix->vFront.fY, pMatrix->vFront.fZ, pMatrix->vUp.fX,
                                 pMatrix->vUp.fY, pMatrix->vUp.fZ, pMatrix->vPos.fX, pMatrix->vPos.fY, pMatrix->vPos.fZ);

        lua_pushstring(luaVM, string.c_str());
        return 1;
    }
    else
    {
        m_pScriptDebugging->LogCustom(luaVM, argStream.GetFullErrorMessage());
    }

    lua_pushboolean(luaVM, false);
    return 1;
}
开发者ID:Audifire,项目名称:mtasa-blue,代码行数:24,代码来源:CLuaMatrixDefs.cpp

示例12: MetaSync

// get stream title from metadata and send it as event
void CALLBACK MetaSync( HSYNC handle, DWORD channel, DWORD data, void *user )
{
    CBassAudio* pBassAudio = LockCallbackId( user );

    if ( pBassAudio )
    {
        pBassAudio->m_pVars->criticalSection.Lock ();
        DWORD pSound = pBassAudio->m_pVars->pSound;
        pBassAudio->m_pVars->criticalSection.Unlock ();

        const char* szMeta = BASS_ChannelGetTags( pSound, BASS_TAG_META );
        if ( szMeta )
        {
            SString strMeta = szMeta;
            if ( !strMeta.empty () )
            {
                pBassAudio->m_pVars->criticalSection.Lock ();
                pBassAudio->m_pVars->onClientSoundChangedMetaQueue.push_back ( strMeta );
                pBassAudio->m_pVars->criticalSection.Unlock ();
            }
        }
    }
    UnlockCallbackId();
}
开发者ID:Bargas,项目名称:mtasa-blue,代码行数:25,代码来源:CBassAudio.cpp

示例13: DelTree

///////////////////////////////////////////////////////////////
//
// DelTree
//
//
//
///////////////////////////////////////////////////////////////
bool SharedUtil::DelTree ( const SString& strPath, const SString& strInsideHere )
{
    // Safety: Make sure strPath is inside strInsideHere
    if ( strPath.ToLower ().substr ( 0, strInsideHere.length () ) != strInsideHere.ToLower () )
    {
        assert ( 0 );
        return false;
    }

    DWORD dwBufferSize = strPath.length () + 3;
    char *szBuffer = static_cast < char* > ( alloca ( dwBufferSize ) );
    memset ( szBuffer, 0, dwBufferSize );
    strncpy ( szBuffer, strPath, strPath.length () );
    SHFILEOPSTRUCT sfos;

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

    int status = SHFileOperation(&sfos);
    return status == 0;
}
开发者ID:qaisjp,项目名称:green-candy,代码行数:31,代码来源:SharedUtil.File.hpp

示例14: MyShellExecute

///////////////////////////////////////////////////////////////
//
// MyShellExecute
//
// Returns true if successful
//
///////////////////////////////////////////////////////////////
static bool MyShellExecute ( bool bBlocking, const SString& strAction, const SString& strInFile, const SString& strInParameters = "", const SString& strDirectory = "", int nShowCmd = SW_SHOWNORMAL )
{
    SString strFile = strInFile;
    SString strParameters = strInParameters;

    if ( strAction == "open" && strFile.BeginsWithI ( "http://" ) && strParameters.empty () )
    {
        strParameters = "url.dll,FileProtocolHandler " + strFile;
        strFile = "rundll32.exe";
    }

    if ( bBlocking )
    {
        SHELLEXECUTEINFO info;
        memset( &info, 0, sizeof ( info ) );
        info.cbSize = sizeof ( info );
        info.fMask = SEE_MASK_NOCLOSEPROCESS;
        info.lpVerb = strAction;
        info.lpFile = strFile;
        info.lpParameters = strParameters;
        info.lpDirectory = strDirectory;
        info.nShow = nShowCmd;
        bool bResult = ShellExecuteExA( &info ) != FALSE;
        if ( info.hProcess )
        {
            WaitForSingleObject ( info.hProcess, INFINITE );
            CloseHandle ( info.hProcess );
        }
        return bResult;
    }
    else
    {
        int iResult = (int)ShellExecute ( NULL, strAction, strFile, strParameters, strDirectory, nShowCmd );
        return iResult > 32;
    }
}
开发者ID:0x688,项目名称:gtasa_crashfix,代码行数:43,代码来源:SharedUtil.Misc.hpp

示例15: Events_OnResourceFileCheck

bool CClientWebBrowser::Events_OnResourceFileCheck ( const SString& strPath )
{
    // If no resource is set, we do not require to verify the file
    if ( !m_pResource )
        return true;
    
    auto pFile = g_pClientGame->GetResourceManager ()->GetDownloadableResourceFile ( strPath.ToLower() );

    // If we did not download this file, it has been script or user generated, nothing to verify for us
    if ( pFile == nullptr )
        return true;

    pFile->GenerateClientChecksum ();
    return pFile->DoesClientAndServerChecksumMatch ();
}
开发者ID:CyberSys,项目名称:mtasa-blue,代码行数:15,代码来源:CClientWebBrowser.cpp


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