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


C++ CGString类代码示例

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


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

示例1: DecorateName

void CChat::DecorateName(CGString &sName, const CChatChanMember * pMember, bool fSystem) // static
{
	ADDTOCALLSTACK("CChat::DecorateName");
	CChatChannel * pChannel = NULL;
	if (pMember)
		pChannel = pMember->GetChannel();
	// 0 = yellow
	// 1 = purple
	// 2 = blue
	// 3 = purple
	// 4 = white
	// 5 = green
	int iResult = 0;
	if (!pMember || !pChannel) // Must be a system command if these are invalid
	{
		if (fSystem)
			iResult = 5;
		else
			iResult = 4;
	}
	else if (pChannel->IsModerator(pMember->GetChatName()))
		iResult = 1;
	else if (!pChannel->HasVoice(pMember->GetChatName()))
		iResult = 2;

	if (!pMember || !pChannel)
		sName.Format("%i%s", iResult, "SYSTEM");
	else
		sName.Format("%i%s", iResult, static_cast<LPCTSTR>(pMember->GetChatName()));
}
开发者ID:WangXYZ,项目名称:SphereServer_Source,代码行数:30,代码来源:CChat.cpp

示例2: StringFunction

static void StringFunction( int iFunc, LPCTSTR pszKey, CGString &sVal )
{
	GETNONWHITESPACE(pszKey);
	if ( *pszKey == '(' )
		pszKey++;

	TCHAR * ppCmd[4];
	int iCount = Str_ParseCmds( const_cast<TCHAR *>(pszKey), ppCmd, COUNTOF(ppCmd), ",)" );
	if ( ! iCount )
	{
		DEBUG_ERR(( "Bad string function usage. missing )\n" ));
		return;
	}

	TCHAR * psArg1	= ppCmd[0];

	switch ( iFunc )
	{
		case SSC_CHR:
			sVal.Format( "%c", Exp_GetSingle( ppCmd[0] ) );
			return;
		case SSC_StrToLower:	// strlower(str) = lower case the string
			sVal = ppCmd[0];
			sVal.MakeLower();
			return;
		case SSC_StrToUpper:	// strupper(str) = upper case the string
			sVal = ppCmd[0];
			sVal.MakeUpper();
			return;
	}
}
开发者ID:GenerationOfWorlds,项目名称:Sphere,代码行数:31,代码来源:CScriptObj.cpp

示例3: ADDTOCALLSTACK

void CResourceBase::AddResourceDir( LPCTSTR pszDirName )
{
	ADDTOCALLSTACK("CResourceBase::AddResourceDir");
	if ( pszDirName[0] == '\0' )
		return;

	CGString sFilePath = CGFile::GetMergedFileName( pszDirName, "*" GRAY_SCRIPT );

	CFileList filelist;
	int iRet = filelist.ReadDir( sFilePath, false );
	if ( iRet < 0 )
	{
		// also check script file path
		sFilePath = CGFile::GetMergedFileName(m_sSCPBaseDir, sFilePath.GetPtr());

		iRet = filelist.ReadDir( sFilePath, true );
		if ( iRet < 0 )
		{
			DEBUG_ERR(( "DirList=%d for '%s'\n", iRet, static_cast<LPCTSTR>(pszDirName) ));
			return;
		}
	}

	if ( iRet <= 0 )	// no files here.
	{
		return;
	}

	CGStringListRec * psFile = filelist.GetHead();
	for ( ; psFile; psFile = psFile->GetNext())
	{
		sFilePath = CGFile::GetMergedFileName( pszDirName, *psFile );
		AddResourceFile( sFilePath );
	}
}
开发者ID:roberpot,项目名称:Source,代码行数:35,代码来源:CResourceBase.cpp

示例4: r_WriteVal

bool CItemSpawn::r_WriteVal(LPCTSTR pszKey, CGString & sVal, CTextConsole *pSrc)
{
	ADDTOCALLSTACK("CitemSpawn:r_WriteVal");
	EXC_TRY("WriteVal");
	if (!strnicmp(pszKey, "amount", 6))
	{
		sVal.FormatVal(GetAmount());
		return true;
	}
	else if ( !strnicmp(pszKey, "at.", 3) )
	{
		pszKey += 3;
		int objIndex = Exp_GetVal(pszKey);
		if ( m_obj[objIndex].ItemFind() )
			return m_obj[objIndex].ItemFind()->r_WriteVal(pszKey, sVal, pSrc);
		else if ( m_obj[objIndex].CharFind() )
			return m_obj[objIndex].CharFind()->r_WriteVal(pszKey, sVal, pSrc);
		return true;
	}
	else if ( !strnicmp(pszKey, "count", 5) )
	{
		sVal.FormatVal(GetCount());
		return true;
	}
	EXC_CATCH;
	return CItem::r_WriteVal(pszKey, sVal, pSrc);
}
开发者ID:DarkLotus,项目名称:Source,代码行数:27,代码来源:CItemSpawn.cpp

示例5: r_WriteVal

bool CWebPageDef::r_WriteVal( LPCTSTR pszKey, CGString & sVal, CTextConsole * pSrc )
{
	ADDTOCALLSTACK("CWebPageDef::r_WriteVal");
	EXC_TRY("WriteVal");
	switch ( FindTableSorted( pszKey, sm_szLoadKeys, COUNTOF( sm_szLoadKeys )-1 ))
	{
		case WC_PLEVEL:
			sVal.FormatVal( m_privlevel );
			break;
		case WC_WEBPAGEFILE:
			sVal = m_sDstFilePath;
			break;
		case WC_WEBPAGELOG:
			sVal.FormatVal( m_iUpdateLog );
			break;
		case WC_WEBPAGESRC:
			sVal = m_sSrcFilePath;
			break;
		case WC_WEBPAGEUPDATE:	// (seconds)
			sVal.FormatVal( m_iUpdatePeriod / TICK_PER_SEC );
			break;
		default:
			return( g_Serv.r_WriteVal( pszKey, sVal, pSrc ));
	}
	return true;
	EXC_CATCH;

	EXC_DEBUG_START;
	EXC_ADD_KEYRET(pSrc);
	EXC_DEBUG_END;
	return false;
}
开发者ID:Sphereserver,项目名称:Source,代码行数:32,代码来源:CWebPage.cpp

示例6: FormatName

void CChat::FormatName(CGString &sName, const CChatMember *pMember, bool bSystem)	//static
{
	ADDTOCALLSTACK("CChat::FormatName");
	// Format chat name with proper color
	// 0 = Yellow (user)
	// 1 = Purple (moderator)
	// 2 = Blue (muted)
	// 3 = Purple (unused?)
	// 4 = White (me)
	// 5 = Green (system)

	int iColor = 0;
	if ( pMember )
	{
		CChatChannel *pChannel = pMember->GetChannel();
		if ( pChannel )
		{
			LPCTSTR pszName = const_cast<CChatMember *>(pMember)->GetChatName();
			if ( pChannel->IsModerator(pszName) )
				iColor = 1;
			else if ( !pChannel->HasVoice(pszName) )
				iColor = 2;

			sName.Format("%d%s", iColor, pszName);
			return;
		}
	}

	iColor = bSystem ? 5 : 4;
	sName.Format("%d%s", iColor, "SYSTEM");
}
开发者ID:bucketyied,项目名称:Source,代码行数:31,代码来源:CChat.cpp

示例7: r_WriteValContainer

bool CContainer::r_WriteValContainer(LPCTSTR pszKey, CGString & sVal, CTextConsole *pSrc)
{
	ADDTOCALLSTACK("CContainer::r_WriteValContainer");
	EXC_TRY("WriteVal");

	static LPCTSTR const sm_szParams[] =
	{
		"count",
		"fcount",
		"rescount",
		"restest"
	};

	int i = FindTableHeadSorted(pszKey, sm_szParams, COUNTOF(sm_szParams));
	if ( i < 0 )
		return false;

	LPCTSTR	pKey = pszKey + strlen(sm_szParams[i]);
	SKIP_SEPARATORS(pKey);
	switch ( i )
	{
		case 0:			//	count
		{
			int iTotal = 0;

			for ( CItem* pItem = GetContentHead(); pItem != NULL; pItem = pItem->GetNext() )
				iTotal++;

			sVal.FormatVal(iTotal);
		} break;

		case 1:			//	fcount
			sVal.FormatVal(ContentCountAll());
			break;

		case 2:			//	rescount
			sVal.FormatVal(*pKey ? ContentCount(g_Cfg.ResourceGetID(RES_ITEMDEF, pKey)) : GetCount());
			break;

		case 3:			//	restest
		{
			CResourceQtyArray Resources;
			sVal.FormatVal(Resources.Load(pKey) ? ResourceConsume(&Resources, 1, true) : 0);
		} break;

		default:
			return false;
	}
	return true;

	EXC_CATCH;
	EXC_DEBUG_START;
	EXC_ADD_KEYRET(pSrc);
	EXC_DEBUG_END;
	return false;
}
开发者ID:greeduomacro,项目名称:Source,代码行数:56,代码来源:CContain.cpp

示例8: indexOf

int CGString::indexOf(CGString str, int offset)
{
	if (offset < 0)
		return -1;

    int len = strlen(m_pchData);
	if (offset >= len)
		return -1;

	int slen = str.GetLength();
	if (slen > len)
		return -1;

	TCHAR * str_value = new TCHAR[slen + 1];
	strcpy(str_value, str.GetPtr());
	TCHAR firstChar = str_value[0];

	for(int i = offset; i < len; i++)
	{
		TCHAR c = m_pchData[i];
		if ( c == firstChar )
		{
			int rem = len - i;
			if ( rem >= slen )
			{
				int j = i;
				int k = 0;
				bool found = true;
				while ( k < slen )
				{
					if(m_pchData[j] != str_value[k])
					{
						found = false;
						break;
					}
					j++; k++;
				}
				if (found)
				{
					delete[] str_value;
					return i;
				}
			}
		}
	}

	delete[] str_value;
	return -1;
}
开发者ID:roberpot,项目名称:Source,代码行数:49,代码来源:CString.cpp

示例9: if

void CChat::GenerateChatName(CGString &sName, const CClient * pClient) // static
{
	if (pClient == NULL)
		return;

	// decide upon 'base' name
	LPCTSTR pszName = NULL;
	if (pClient->GetChar() != NULL)
		pszName = pClient->GetChar()->GetName();
	else if (pClient->GetAccount() != NULL)
		pszName = pClient->GetAccount()->GetName();

	if (pszName == NULL)
		return;

	// try the base name
	CGString sTempName(pszName);
	if (g_Accounts.Account_FindChat(sTempName.GetPtr()) != NULL)
	{
		sTempName.Empty();

		// append (n) to the name to make it unique
		for (unsigned int attempts = 2; attempts <= g_Accounts.Account_GetCount(); attempts++)
		{
			sTempName.Format("%s (%u)", pszName, attempts);
			if (g_Accounts.Account_FindChat(static_cast<LPCTSTR>(sTempName)) == NULL)
				break;

			sTempName.Empty();
		}
	}

	// copy name to output
	sName.Copy(sTempName.GetPtr());
}
开发者ID:WangXYZ,项目名称:SphereServer_Source,代码行数:35,代码来源:CChat.cpp

示例10: r_WriteVal

bool CItemMessage::r_WriteVal( LPCTSTR pszKey, CGString &sVal, CTextConsole * pSrc )
{
	EXC_TRY(("r_WriteVal('%s',,%x)", pszKey, pSrc));
	// Load the message body for a book or a bboard message.
	if ( ! strnicmp( pszKey, "BODY", 4 ))
	{
		pszKey += 4;
		int iPage = Exp_GetVal(pszKey);
		if ( iPage < 0 || iPage >= m_sBodyLines.GetCount())
			return( false );
		sVal = *m_sBodyLines[iPage];
		return( true );
	}
	switch ( FindTableSorted( pszKey, sm_szLoadKeys, COUNTOF( sm_szLoadKeys )-1 ))
	{
	case CIC_AUTHOR:
		sVal = m_sAuthor;
		return( true );
	case CIC_BODY:	// handled above.
		return( false );
	case CIC_PAGES:	// not settable. (used for resource stuff)
		sVal.FormatVal( m_sBodyLines.GetCount());
		return( true );
	case CIC_TITLE:
		sVal = GetName();
		return( true );
	}
	return CItemVendable::r_WriteVal(pszKey, sVal, pSrc);
	EXC_CATCH("CItemMessage");
	return false;
}
开发者ID:GenerationOfWorlds,项目名称:Sphere,代码行数:31,代码来源:CItemSp.cpp

示例11: r_WriteVal

bool CVarDefContNum::r_WriteVal( LPCTSTR pKey, CGString & sVal, CTextConsole * pSrc = NULL )
{
	UNREFERENCED_PARAMETER(pKey);
	UNREFERENCED_PARAMETER(pSrc);
	sVal.FormatLLVal( GetValNum() );
	return( true );
}
开发者ID:roberpot,项目名称:Source,代码行数:7,代码来源:CVarDefMap.cpp

示例12: r_WriteVal

bool CSkillClassDef::r_WriteVal( LPCTSTR pszKey, CGString & sVal, CTextConsole * pSrc )
{
	ADDTOCALLSTACK("CSkillClassDef::r_WriteVal");
	EXC_TRY("WriteVal");
	switch ( FindTableSorted( pszKey, sm_szLoadKeys, COUNTOF( sm_szLoadKeys )-1 ))
	{
	case SCC_NAME: // "NAME"
		sVal = m_sName;
		break;
	case SCC_SKILLSUM:
		sVal.FormatVal( m_SkillSumMax );
		break;
	case SCC_STATSUM:
		sVal.FormatVal( m_StatSumMax );
		break;
	default:
		{
			int i = g_Cfg.FindSkillKey( pszKey);
			if ( i != SKILL_NONE )
			{
				ASSERT( i >= 0 && static_cast<size_t>(i) < COUNTOF(m_SkillLevelMax));
				sVal.FormatVal( m_SkillLevelMax[i] );
				break;
			}
			i = g_Cfg.FindStatKey( pszKey);
			if ( i >= 0 )
			{
				ASSERT( static_cast<size_t>(i) < COUNTOF(m_StatMax));
				sVal.FormatVal( m_StatMax[i] );
				break;
			}
		}
		return( CResourceDef::r_WriteVal( pszKey, sVal, pSrc ));
	}
	return true;
	EXC_CATCH;

	EXC_DEBUG_START;
	EXC_ADD_KEYRET(pSrc);
	EXC_DEBUG_END;
	return false;
}
开发者ID:swak,项目名称:Source,代码行数:42,代码来源:CResourceDef.cpp

示例13: r_WriteVal

bool CItemMulti::r_WriteVal( LPCTSTR pszKey, CGString & sVal, CTextConsole * pSrc )
{
	if ( !strnicmp(pszKey, "COMP", 4) )
	{
		const CItemBaseMulti *pMultiDef = Multi_GetDef();
		pszKey += 4;

		// no component uid
		if ( !*pszKey )	sVal.FormatVal(pMultiDef->m_Components.GetCount());
		else if ( *pszKey == '.' )
		{
			CMultiComponentItem	item;

			SKIP_SEPERATORS(pszKey);
			int iQty = Exp_GetVal(pszKey);

			if (( iQty < 0 ) || ( iQty >= pMultiDef->m_Components.GetCount())) return false;
			SKIP_SEPERATORS(pszKey);
			item = pMultiDef->m_Components.GetAt(iQty);

			if ( !strnicmp(pszKey, "ID", 2) ) sVal.FormatVal(item.m_id);
			else if ( !strnicmp(pszKey, "DX", 2) ) sVal.FormatVal(item.m_dx);
			else if ( !strnicmp(pszKey, "DY", 2) ) sVal.FormatVal(item.m_dy);
			else if ( !strnicmp(pszKey, "DZ", 2) ) sVal.FormatVal(item.m_dz);
			else if ( !strnicmp(pszKey, "D", 1) ) sVal.Format("%i,%i,%i", item.m_dx, item.m_dy, item.m_dz);
			else sVal.Format("%i,%i,%i,%i", item.m_id, item.m_dx, item.m_dy, item.m_dz);
		}
		else return false;
		return true;
	}
	return( CItem::r_WriteVal(pszKey, sVal, pSrc));
}
开发者ID:GenerationOfWorlds,项目名称:Sphere,代码行数:32,代码来源:CItemMulti.cpp

示例14: r_WriteVal

bool CItemVendable::r_WriteVal(LPCTSTR pszKey, CGString &sVal, CTextConsole *pSrc)
{
	ADDTOCALLSTACK("CItemVendable::r_WriteVal");
	EXC_TRY("WriteVal");
	switch ( FindTableSorted( pszKey, sm_szLoadKeys, COUNTOF( sm_szLoadKeys )-1 ))
	{
	case IVC_PRICE:	// PRICE
		sVal.FormatVal( m_price );
		return true;
	case IVC_QUALITY:	// QUALITY
		sVal.FormatVal( GetQuality());
		return true;
	default:
		return CItem::r_WriteVal( pszKey, sVal, pSrc );
	}
	EXC_CATCH;

	EXC_DEBUG_START;
	EXC_ADD_KEYRET(pSrc);
	EXC_DEBUG_END;
	return false;
}
开发者ID:DarkLotus,项目名称:Source,代码行数:22,代码来源:CItemVend.cpp

示例15: r_WriteVal

bool CRegionWorld::r_WriteVal( LPCTSTR pszKey, CGString & sVal, CTextConsole * pSrc )
{
	ADDTOCALLSTACK("CRegionWorld::r_WriteVal");
	EXC_TRY("WriteVal");
	//bool	fZero	= false;
	switch ( FindTableHeadSorted( pszKey, sm_szLoadKeys, COUNTOF( sm_szLoadKeys )-1 ))
	{
		case RWC_DEFNAME: // "DEFNAME" = for the speech system.
			sVal = GetResourceName();
			break;
		case RWC_RESOURCES:
			m_Events.WriteResourceRefList( sVal );
			break;
		case RWC_REGION:
			{
				// Check that the syntax is correct.
				if ( pszKey[6] && pszKey[6] != '.' )
					return false;

				CRegionWorld * pRegionTemp = dynamic_cast <CRegionWorld*>(m_pt.GetRegion( REGION_TYPE_AREA ));

				if ( !pszKey[6] )
				{
					// We're just checking if the reference is valid.
					sVal.FormatVal( pRegionTemp? 1:0 );
					return true;
				}

				// ELSE - We're trying to retrieve a property from the region.
				pszKey += 7;
				if ( pRegionTemp && m_pt.GetRegion( REGION_TYPE_MULTI ) )
					return pRegionTemp->r_WriteVal( pszKey, sVal, pSrc );

				return( this->r_WriteVal( pszKey, sVal, pSrc ));
			}
		default:
			return( CRegionBase::r_WriteVal( pszKey, sVal, pSrc ));
	}
	return true;
	EXC_CATCH;

	EXC_DEBUG_START;
	g_Log.EventDebug("command '%s' ret '%s' [%p]\n", pszKey, static_cast<LPCTSTR>(sVal), static_cast<void *>(pSrc));
	EXC_DEBUG_END;
	return false;
}
开发者ID:bucketyied,项目名称:Source,代码行数:46,代码来源:CRegion.cpp


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