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


C++ TString::compare方法代码示例

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


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

示例1: reservedErrorCheck

//
// For now, keep it simple:  if it starts "gl_", it's reserved, independent
// of scope.  Except, if the symbol table is at the built-in push-level,
// which is when we are parsing built-ins.
// Also checks for "webgl_" and "_webgl_" reserved identifiers if parsing a
// webgl shader.
//
// Returns true if there was an error.
//
bool TParseContext::reservedErrorCheck(int line, const TString& identifier)
{
    static const char* reservedErrMsg = "reserved built-in name";
    if (!symbolTable.atBuiltInLevel()) {
        if (identifier.compare(0, 3, "gl_") == 0) {
            error(line, reservedErrMsg, "gl_", "");
            return true;
        }
        if (shaderSpec == SH_WEBGL_SPEC) {
            if (identifier.compare(0, 6, "webgl_") == 0) {
                error(line, reservedErrMsg, "webgl_", "");
                return true;
            }
            if (identifier.compare(0, 7, "_webgl_") == 0) {
                error(line, reservedErrMsg, "_webgl_", "");
                return true;
            }
        }
        if (identifier.find("__") != TString::npos) {
            //error(line, "Two consecutive underscores are reserved for future use.", identifier.c_str(), "", "");
            //return true;
            infoSink.info.message(EPrefixWarning, "Two consecutive underscores are reserved for future use.", line);
            return false;
        }
    }

    return false;
}
开发者ID:Anachid,项目名称:mozilla-central,代码行数:37,代码来源:ParseHelper.cpp

示例2: reservedErrorCheck

//
// For now, keep it simple:  if it starts "gl_", it's reserved, independent
// of scope.  Except, if the symbol table is at the built-in push-level,
// which is when we are parsing built-ins.
// Also checks for "webgl_" and "_webgl_" reserved identifiers if parsing a
// webgl shader.
//
// Returns true if there was an error.
//
bool TParseContext::reservedErrorCheck(int line, const TString& identifier)
{
    static const char* reservedErrMsg = "reserved built-in name";
    if (!symbolTable.atBuiltInLevel()) {
        if (identifier.compare(0, 3, "gl_") == 0) {
            error(line, reservedErrMsg, "gl_");
            return true;
        }
        if (isWebGLBasedSpec(shaderSpec)) {
            if (identifier.compare(0, 6, "webgl_") == 0) {
                error(line, reservedErrMsg, "webgl_");
                return true;
            }
            if (identifier.compare(0, 7, "_webgl_") == 0) {
                error(line, reservedErrMsg, "_webgl_");
                return true;
            }
            if (shaderSpec == SH_CSS_SHADERS_SPEC && identifier.compare(0, 4, "css_") == 0) {
                error(line, reservedErrMsg, "css_");
                return true;
            }
        }
        if (identifier.find("__") != TString::npos) {
            error(line, "identifiers containing two consecutive underscores (__) are reserved as possible future keywords", identifier.c_str());
            return true;
        }
    }

    return false;
}
开发者ID:Ajunboys,项目名称:mozilla-os2,代码行数:39,代码来源:ParseHelper.cpp

示例3: Load

bool CShader::Load()
{
    TString strExtension = CFilePathTool::GetInstance()->Extension(GetFilePath().c_str());
    bool bIsVS = strExtension.compare(_T(".vs")) == 0;
    m_shaderType = bIsVS ? GL_VERTEX_SHADER : GL_FRAGMENT_SHADER;

    if (m_commonHeader.GetWritePos() == 0)
    {
#if (BEYONDENGINE_PLATFORM == PLATFORM_ANDROID)
        const char* pszPlatformDef = "#define PLATFORM_ANDROID\r\n";
#elif (BEYONDENGINE_PLATFORM == PLATFORM_IOS)
        const char* pszPlatformDef = "#define PLATFORM_IOS\r\n";
#else
        const char* pszPlatformDef = "#define PLATFORM_WIN32\r\n";
#endif
        m_commonHeader.Serialize((const void *)pszPlatformDef, strlen(pszPlatformDef));
        TString strPath = CResourceManager::GetInstance()->GetFullPath(_T("commonheader.txt"), eRT_Shader);
        m_commonHeader.Serialize(strPath.c_str());
    }

    BEATS_ASSERT(m_pData == NULL);
    m_pData = new CSerializer(m_commonHeader);
    BEATS_ASSERT(CFilePathTool::GetInstance()->Exists(m_strPath.m_value.c_str()), "Can't find shader file %s", m_strPath.m_value.c_str())
    m_pData->Serialize(m_strPath.m_value.c_str());
    super::Load();
    return true;
}
开发者ID:BeyondEngine,项目名称:BeyondEngine,代码行数:27,代码来源:Shader.cpp

示例4: EndsWith

 bool EndsWith(const TString &str, const TString&& suffix) {
     if (str.length() >= suffix.length()) {
        return (0 == str.compare (str.length() - suffix.length(), suffix.length(), suffix));
     } else {
         return false;
     }
 }
开发者ID:alexeyche,项目名称:alexeyche-junk,代码行数:7,代码来源:string.cpp

示例5: Create

/*****************************************************************************
** Procedure:  CEventFactory::Create
**
** Arguments: 'strCommand' - String from PBX
**
** Returns:    Derivative CEventBlock for this PBX command
**
** Description: This function creates a new CEventBlock object
**
*****************************************************************************/
CEventBlock* CEventFactory::Create(TString& strData)
{
	// We should have at least one object in our event list
	_TSP_ASSERT(m_pHead != NULL);

	// The first element is always the command.
	TString strCommand = GetNextElem(strData);
	if (strCommand.empty())
		return NULL;

	// Uppercase the command string
	CharUpperBuff(&strCommand[0], strCommand.length());

	// Convert the command string into its numerical equivelant for
	// quick lookup.
	enum CEventBlock::PBXEvent evtType = CEventBlock::Unknown;
	for (int i = 0; g_StringToEvent[i].pszEvent != NULL; i++)
	{
		if (!strCommand.compare(g_StringToEvent[i].pszEvent))
		{
			evtType = g_StringToEvent[i].evtType;
			break;
		}
	}

	// If the event is unknown, it means we have not completely defined
	// the interface and have a problem!
	_TSP_ASSERT (evtType != CEventBlock::Unknown);

	// Return the event object which encapsulates this command
	return m_pHead->Create(evtType, strData);

}// CEventFactory::Create
开发者ID:junction,项目名称:jn-tapi,代码行数:43,代码来源:EventTypes.cpp

示例6: Decorate

TString Decorate(const TString &string)
{
    if (string.compare(0, 3, "gl_") != 0)
    {
        return "_" + string;
    }

    return string;
}
开发者ID:luke-chang,项目名称:gecko-1,代码行数:9,代码来源:UtilsHLSL.cpp

示例7: RPC_caller

	explicit RPC_caller(const TString& module_name) : hModule(LoadLibraryEx(module_name.c_str(), NULL, 0))
	{
		PROCESSENTRY32 entry;
		entry.dwSize = sizeof(PROCESSENTRY32);

		HandleHolder snapshot(CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, NULL));

		if (Process32First(snapshot(), &entry) == TRUE)
		{
			while (Process32Next(snapshot(), &entry) == TRUE)
			{
				if (module_name.compare(entry.szExeFile) == 0)
				{  
					hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, entry.th32ProcessID);
					if(!hProcess())
						throw rpc_call_error(TString(_TEXT("Unable to open process ")) + module_name);
					base = this->GetModuleBase(hProcess(), module_name);
				}
			}
		}
	}
开发者ID:morm,项目名称:mor_t,代码行数:21,代码来源:rpc_caller.hpp

示例8: Test_String

// ----------------------------------------------------------------------------
// String.h
bool Test_String()
{
    TTRACE(_T("====================================================="));
    // StrRCSpn テスト。
    {
        const TCHAR* strCharSet = _T("abc");
        int ret;

        const TCHAR* str1 = _T("nakayama");
        ret = StrRCSpn(str1, strCharSet);
        if (ret != 7)
        {
            TTRACE(_T("StrRCSpn# failed! ret=%d"), ret);
            return false;
        }

        const TCHAR* str2 = _T("erio");
        ret = StrRCSpn(str2, strCharSet);
        if (ret != -1)
        {
            TTRACE(_T("StrRCSpn# failed! ret=%d"), ret);
            return false;
        }

        const TCHAR* str3 = _T("nakayama erio");
        ret = StrRCSpn(str3, strCharSet);
        if (ret != 7)
        {
            TTRACE(_T("StrRCSpn# failed! ret=%d"), ret);
            return false;
        }
    }

    // StrRStr テスト。
    {
        const TCHAR* result = NULL;

        const TCHAR* str1 = _T("Romancing SaGa, SaGa Frontier, Unlimited SaGa");
        result = StrRStr(str1, _T("SaGa"));
        if (result == NULL || _tcscmp(_T("SaGa"), result) != 0)
        {
            TTRACE(_T("StrRStr# failed! result=%s"), result);
            return false;
        }

        const TCHAR* str2 = _T("Romancing SaGa, SaGa Frontier, Unlimited SaGa, Romancing SaGa -Minstrel Song-");
        result = StrRStr(str2, _T("SaGa"));
        if (result == NULL || _tcscmp(_T("SaGa -Minstrel Song-"), result) != 0)
        {
            TTRACE(_T("StrRStr# failed! result=%s"), result);
            return false;
        }

        result = StrRStr(str2, _T("Itoken"));
        if (result != NULL)
        {
            TTRACE(_T("StrRStr# failed! result=%s"), result);
            return false;
        }
    }

    // Tokens テスト。
    {
        Tokens<TCHAR> tokens;
        tokens.Set(_T("I love \"Romancing SaGa\" (Super Famicom software)"), _T(" "), _T("\"\"()"));
        TString token;
        if (!tokens.Next(token) || token.compare(_T("I")) != 0)
        {
            TTRACE(_T("Tokens# failed! result=%s"), token.c_str());
            return false;
        }

        if (!tokens.Next(token) || token.compare(_T("love")) != 0)
        {
            TTRACE(_T("Tokens# failed! result=%s"), token.c_str());
            return false;
        }

        if (!tokens.Next(token) || token.compare(_T("Romancing SaGa")) != 0)
        {
            TTRACE(_T("Tokens# failed! result=%s"), token.c_str());
            return false;
        }

        if (!tokens.Next(token) || token.compare(_T("Super Famicom software")) != 0)
        {
            TTRACE(_T("Tokens# failed! result=%s"), token.c_str());
            return false;
        }

        if (tokens.Next(token))
        {
            TTRACE(_T("Tokens# failed!"));
            return false;
        }

        if (tokens.Next(token))
        {
//.........这里部分代码省略.........
开发者ID:erio-nk,项目名称:MyCxxProgram2011,代码行数:101,代码来源:Test.cpp


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