本文整理汇总了C++中CGString::GetPtr方法的典型用法代码示例。如果您正苦于以下问题:C++ CGString::GetPtr方法的具体用法?C++ CGString::GetPtr怎么用?C++ CGString::GetPtr使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CGString
的用法示例。
在下文中一共展示了CGString::GetPtr方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AddResourceDir
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 );
}
}
示例2: 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;
}
示例3: r_Verb
//.........这里部分代码省略.........
if ( iArgQty > 4 )
{
// Font and mode are actually ignored here, but they never made a difference
// anyway.. I'd like to keep the syntax similar to SAYUA
NCHAR szBuffer[ MAX_TALK_BUFFER ];
CvtSystemToNUNICODE( szBuffer, COUNTOF(szBuffer), pszArgs[4], -1 );
addBarkUNICODE( szBuffer, NULL, static_cast<HUE_TYPE>(Exp_GetVal(pszArgs[0])), TALKMODE_SYSTEM, FONT_NORMAL, pszArgs[3] );
}
}
break;
case CV_SMSGL:
case CV_SYSMESSAGELOC:
{
TCHAR * ppArgs[256];
size_t iArgQty = Str_ParseCmds( s.GetArgRaw(), ppArgs, COUNTOF(ppArgs), "," );
if ( iArgQty > 1 )
{
int hue = -1;
if ( ppArgs[0] )
hue = Exp_GetVal( ppArgs[0] );
int iClilocId = Exp_GetVal( ppArgs[1] );
if ( hue == -1 ) hue = HUE_TEXT_DEF;
CGString CArgs;
for ( size_t i = 2; i < iArgQty; i++ )
{
if ( CArgs.GetLength() )
CArgs += "\t";
CArgs += ( !strcmp(ppArgs[i], "NULL") ? " " : ppArgs[i] );
}
addBarkLocalized(iClilocId, NULL, static_cast<HUE_TYPE>(hue), TALKMODE_SYSTEM, FONT_NORMAL, CArgs.GetPtr());
}
}
break;
case CV_SMSGLEX:
case CV_SYSMESSAGELOCEX:
{
TCHAR * ppArgs[256];
size_t iArgQty = Str_ParseCmds( s.GetArgRaw(), ppArgs, COUNTOF(ppArgs), "," );
if ( iArgQty > 2 )
{
int hue = -1;
int affix = 0;
if ( ppArgs[0] )
hue = Exp_GetVal( ppArgs[0] );
int iClilocId = Exp_GetVal( ppArgs[1] );
if ( ppArgs[2] )
affix = Exp_GetVal( ppArgs[2] );
if ( hue == -1 ) hue = HUE_TEXT_DEF;
CGString CArgs;
for ( size_t i = 4; i < iArgQty; i++ )
{
if ( CArgs.GetLength() )
CArgs += "\t";
CArgs += ( !strcmp(ppArgs[i], "NULL") ? " " : ppArgs[i] );
}
addBarkLocalizedEx( iClilocId, NULL, static_cast<HUE_TYPE>(hue), TALKMODE_SYSTEM, FONT_NORMAL, static_cast<AFFIX_TYPE>(affix), ppArgs[3], CArgs.GetPtr() );
}
}
break;
示例4: ServPage
bool CWebPageDef::ServPage( CClient * pClient, TCHAR * pszPage, CGTime * pdateIfModifiedSince ) // static
{
ADDTOCALLSTACK("CWebPageDef::ServPage");
// make sure this is a valid format for the request.
TCHAR szPageName[_MAX_PATH];
Str_GetBare( szPageName, pszPage, sizeof(szPageName), "!\"#$%&()*,:;<=>?[]^{|}-+'`" );
int iError = 404;
CWebPageDef * pWebPage = g_Cfg.FindWebPage(szPageName);
if ( pWebPage )
{
iError = pWebPage->ServPageRequest(pClient, szPageName, pdateIfModifiedSince);
if ( ! iError )
return true;
}
// Is it a file in the Script directory ?
if ( iError == 404 )
{
const RESOURCE_ID ridjunk( RES_UNKNOWN, 1 );
CWebPageDef tmppage( ridjunk );
if ( tmppage.SetSourceFile( szPageName, pClient ))
{
if ( !tmppage.ServPageRequest(pClient, szPageName, pdateIfModifiedSince) )
return true;
}
}
// Can't find it !?
// just take the default page. or have a custom 404 page ?
pClient->m_Targ_Text = pszPage;
TCHAR *pszTemp = Str_GetTemp();
sprintf(pszTemp, GRAY_FILE "%d.htm", iError);
pWebPage = g_Cfg.FindWebPage(pszTemp);
if ( pWebPage )
{
if ( ! pWebPage->ServPageRequest( pClient, pszPage, NULL ))
return true;
}
// Hmm we should do something !!!?
// Try to give a reasonable default error msg.
LPCTSTR pszErrText;
switch (iError)
{
case 401: pszErrText = "Authorization Required"; break;
case 403: pszErrText = "Forbidden"; break;
case 404: pszErrText = "Object Not Found"; break;
case 500: pszErrText = "Internal Server Error"; break;
default: pszErrText = "Unknown Error"; break;
}
CGTime datetime = CGTime::GetCurrentTime();
const char *sDate = datetime.FormatGmt(NULL);
CGString sMsgHead;
CGString sText;
sText.Format(
"<html><head><title>Error %d</title>"
"<meta name=robots content=noindex>"
"</head><body>"
"<h2>HTTP Error %d</h2><p><strong>%d %s</strong></p>"
"<p>The " GRAY_TITLE " server cannot deliver the file or script you asked for.</p>"
"<p>Please contact the server's administrator if this problem persists.</p>"
"</body></html>",
iError,
iError,
iError,
static_cast<LPCTSTR>(pszErrText));
sMsgHead.Format(
"HTTP/1.1 %d %s\r\n"
"Date: %s\r\n"
"Server: " GRAY_TITLE " V " GRAY_VERSION "\r\n"
"Content-Type: text/html\r\n"
"Content-Length: %d\r\n"
"Connection: close\r\n"
"\r\n%s",
iError, static_cast<LPCTSTR>(pszErrText),
static_cast<LPCTSTR>(sDate),
sText.GetLength(),
static_cast<LPCTSTR>(sText));
new PacketWeb(pClient, reinterpret_cast<const BYTE *>(sMsgHead.GetPtr()), sMsgHead.GetLength());
return false;
}
示例5:
CGString::CGString(const CGString &s)
{
m_iMaxLength = m_iLength = 0;
m_pchData = NULL;
Copy(s.GetPtr());
}
示例6: r_Verb
//.........这里部分代码省略.........
TCHAR *ppArgs[5];
size_t iArgQty = Str_ParseCmds(s.GetArgRaw(), ppArgs, COUNTOF(ppArgs));
if ( iArgQty > 4 )
{
// Font and mode are actually ignored here, but they never made a difference anyway.. I'd like to keep the syntax similar to SAYUA
NCHAR szBuffer[MAX_TALK_BUFFER];
CvtSystemToNUNICODE(szBuffer, COUNTOF(szBuffer), ppArgs[4], -1);
addBarkUNICODE(szBuffer, NULL, static_cast<HUE_TYPE>(Exp_GetLLVal(ppArgs[0])), TALKMODE_SYSTEM, FONT_NORMAL, ppArgs[3]);
}
break;
}
case CV_SMSGL:
case CV_SYSMESSAGELOC:
{
TCHAR *ppArgs[256];
size_t iArgQty = Str_ParseCmds(s.GetArgRaw(), ppArgs, COUNTOF(ppArgs), ",");
if ( iArgQty > 1 )
{
HUE_TYPE hue = HUE_TEXT_DEF;
if ( ATOI(ppArgs[0]) > 0 )
hue = static_cast<HUE_TYPE>(Exp_GetLLVal(ppArgs[0]));
DWORD dwClilocId = static_cast<DWORD>(Exp_GetLLVal(ppArgs[1]));
CGString sVal;
for ( size_t i = 2; i < iArgQty; ++i )
{
if ( sVal.GetLength() )
sVal += "\t";
sVal += !strcmp(ppArgs[i], "NULL") ? " " : ppArgs[i];
}
addBarkLocalized(dwClilocId, NULL, hue, TALKMODE_SYSTEM, FONT_NORMAL, sVal.GetPtr());
}
break;
}
case CV_SMSGLEX:
case CV_SYSMESSAGELOCEX:
{
TCHAR *ppArgs[256];
size_t iArgQty = Str_ParseCmds(s.GetArgRaw(), ppArgs, COUNTOF(ppArgs), ",");
if ( iArgQty > 2 )
{
HUE_TYPE hue = HUE_TEXT_DEF;
AFFIX_TYPE affix = AFFIX_APPEND;
if ( ATOI(ppArgs[0]) > 0 )
hue = static_cast<HUE_TYPE>(Exp_GetLLVal(ppArgs[0]));
DWORD dwClilocId = static_cast<DWORD>(Exp_GetLLVal(ppArgs[1]));
if ( ppArgs[2] )
affix = static_cast<AFFIX_TYPE>(Exp_GetLLVal(ppArgs[2]));
CGString sVal;
for ( size_t i = 4; i < iArgQty; ++i )
{
if ( sVal.GetLength() )
sVal += "\t";
sVal += !strcmp(ppArgs[i], "NULL") ? " " : ppArgs[i];
}
addBarkLocalizedEx(dwClilocId, NULL, hue, TALKMODE_SYSTEM, FONT_NORMAL, affix, ppArgs[3], sVal.GetPtr());
}
break;
}