本文整理汇总了C++中CGString::GetLength方法的典型用法代码示例。如果您正苦于以下问题:C++ CGString::GetLength方法的具体用法?C++ CGString::GetLength怎么用?C++ CGString::GetLength使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CGString
的用法示例。
在下文中一共展示了CGString::GetLength方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: r_Verb
//.........这里部分代码省略.........
LPCTSTR Args[7];
size_t ArgsCount = 0;
for ( int i = 0; i < 7; ++i )
{
Args[i] = ppArgs[i + 4];
if ( Args[i] != NULL )
ArgsCount++;
}
addBuff(static_cast<BUFF_ICONS>(iArgs[0]), iArgs[1], iArgs[2], static_cast<WORD>(iArgs[3]), Args, ArgsCount);
}
break;
case CV_REMOVEBUFF:
{
BUFF_ICONS IconId = static_cast<BUFF_ICONS>(s.GetArgVal());
if (IconId < BI_START || IconId > BI_QTY/* || IconId == 0x3EB || IconId == 0x3EC*/) {
DEBUG_ERR(("Invalid RemoveBuff icon ID\n"));
break;
}
removeBuff(IconId);
}
break;
case CV_ADDCLILOC:
// Add cliloc in @ClientTooltip trigger
{
TCHAR * ppLocArgs[256];
size_t qty = Str_ParseCmds(s.GetArgRaw(), ppLocArgs, COUNTOF(ppLocArgs), ",");
DWORD clilocid = Exp_GetVal(ppLocArgs[0]);
CGString LocArgs;
for ( size_t y = 1 ; y < qty; y++ )
{
if ( LocArgs.GetLength() )
LocArgs += "\t";
LocArgs += ( !strcmp(ppLocArgs[y], "NULL") ? " " : ppLocArgs[y] );
}
if ( g_Cfg.m_wDebugFlags & DEBUGF_SCRIPTS )
g_Log.EventDebug("SCRIPT: addcliloc(%lu,'%s')\n", clilocid, static_cast<LPCTSTR>(LocArgs));
this->m_TooltipData.Add(new CClientTooltip(clilocid, LocArgs));
}
break;
case CV_ADDCONTEXTENTRY:
{
TCHAR * ppLocArgs[20];
if ( Str_ParseCmds(s.GetArgRaw(), ppLocArgs, COUNTOF(ppLocArgs), ",") > 4 )
{
DEBUG_ERR(("Bad AddContextEntry usage: Function takes maximum of 4 arguments!\n"));
return true;
}
if (m_pPopupPacket == NULL)
{
DEBUG_ERR(("Bad AddContextEntry usage: Not used under a @ContextMenuRequest/@itemContextMenuRequest trigger!\n"));
return true;
}
for ( int i = 0; i < 4; i++ )
{
if ( i > 1 && IsStrEmpty(ppLocArgs[i]) )
continue;
if ( !IsStrNumeric(ppLocArgs[i]) )
{
DEBUG_ERR(("Bad AddContextEntry usage: Argument %d must be a number!\n", i+1));
示例3: 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;
}
示例4: ParseText
//.........这里部分代码省略.........
continue;
iBegin = i;
sm_fBrackets = true;
}
continue;
}
if ( ch == '<' ) // recursive brackets
{
if ( !( isalnum( pszResponse[i+1] ) || pszResponse[i+1] == '<' ) ) // ignore this.
continue;
if (sm_iReentrant > 32 )
{
EXC_SET(m_ExcKeys[0]);
ASSERT( sm_iReentrant < 32 );
}
sm_iReentrant++;
sm_fBrackets = false;
int ilen = ParseText( pszResponse+i, pSrc, 2, pArgs );
sm_fBrackets = true;
sm_iReentrant--;
i += ilen;
// DEBUG_CHECK( ilen < 256 );
continue;
}
if ( ch == chEnd )
{
sm_fBrackets = false;
pszResponse[i] = '\0';
CGString sVal;
pszKey = (LPCTSTR) pszResponse+iBegin+1;
if ( !strnicmp( pszKey, "CALL", 4 ) && isspace(pszKey[4]) )
{
EXC_SET(m_ExcKeys[1]);
pszKey += 4;
GETNONWHITESPACE( pszKey );
LPCTSTR pszArgs = strchr( pszKey, ' ' );
if ( pszArgs )
GETNONWHITESPACE( pszArgs );
if ( !pszArgs || !*pszArgs )
{
fRes = this->r_Call( pszKey, pSrc, pArgs, &sVal );
}
else
{
CScriptTriggerArgs Args( pszArgs );
if ( pArgs )
Args.m_VarsLocal = pArgs->m_VarsLocal;
fRes = this->r_Call( pszKey, pSrc, &Args, &sVal );
if ( pArgs )
pArgs->m_VarsLocal = Args.m_VarsLocal;
}
}
else
{
if ( !strnicmp( pszKey, "SRC", 3 ) && pszKey[3] == '\0' )
{
pszKey = pszKey;
}
EXC_SET(m_ExcKeys[2]);
if ( !( fRes = r_WriteVal( pszKey, sVal, pSrc ) ) )
{
EXC_SET(m_ExcKeys[2]);
if ( pArgs && pArgs->r_WriteVal( pszKey, sVal, pSrc ) )
fRes = true;
}
}
if ( !fRes )
{
DEBUG_ERR(( "Can't resolve <%s>\n", pszKey ));
// Just in case this really is a <= operator ?
pszResponse[i] = chEnd;
// continue; // by Kell
}
resolved:
if ( sVal.IsEmpty() && fHTML )
{
sVal = " ";
}
int len = sVal.GetLength();
EXC_SET(m_ExcKeys[3]);
memmove( pszResponse+iBegin+len, pszResponse+i+1, strlen( pszResponse+i+1 ) + 1 );
EXC_SET(m_ExcKeys[3]);
memcpy( pszResponse+iBegin, (LPCTSTR) sVal, len );
i = iBegin+len-1;
if ( iFlags&2 ) // just do this one then bail out.
return( i );
}
}
EXC_CATCH("Script parse text");
return( i );
}
示例5: r_Verb
//.........这里部分代码省略.........
LPCTSTR pszArgs[7];
size_t iArgQty = 0;
for ( int i = 0; i < 7; ++i )
{
pszArgs[i] = ppArgs[i + 4];
if ( pszArgs[i] != NULL )
++iArgQty;
}
addBuff(static_cast<BUFF_ICONS>(iArgs[0]), static_cast<DWORD>(iArgs[1]), static_cast<DWORD>(iArgs[2]), static_cast<WORD>(iArgs[3]), pszArgs, iArgQty);
break;
}
case CV_REMOVEBUFF:
{
BUFF_ICONS IconId = static_cast<BUFF_ICONS>(s.GetArgVal());
if ( (IconId < 0) || (IconId > USHRT_MAX) )
{
DEBUG_ERR(("Invalid RemoveBuff icon ID\n"));
break;
}
removeBuff(IconId);
break;
}
case CV_ADDCLILOC:
{
// Add cliloc in @ClientTooltip trigger
TCHAR *ppArgs[256];
size_t iArgQty = Str_ParseCmds(s.GetArgRaw(), ppArgs, COUNTOF(ppArgs), ",");
DWORD dwClilocId = static_cast<DWORD>(Exp_GetLLVal(ppArgs[0]));
CGString sVal;
for ( size_t i = 1; i < iArgQty; ++i )
{
if ( sVal.GetLength() )
sVal += "\t";
sVal += !strcmp(ppArgs[i], "NULL") ? " " : ppArgs[i];
}
if ( g_Cfg.m_wDebugFlags & DEBUGF_SCRIPTS )
g_Log.EventDebug("SCRIPT: addcliloc(%lu,'%s')\n", dwClilocId, static_cast<LPCTSTR>(sVal));
m_TooltipData.Add(new CClientTooltip(dwClilocId, sVal));
break;
}
case CV_ADDCONTEXTENTRY:
{
TCHAR *ppArgs[20];
if ( Str_ParseCmds(s.GetArgRaw(), ppArgs, COUNTOF(ppArgs), ",") > 4 )
{
DEBUG_ERR(("Bad AddContextEntry usage: Function takes maximum of 4 arguments!\n"));
return true;
}
if ( !m_pPopupPacket )
{
DEBUG_ERR(("Bad AddContextEntry usage: Not used under a @ContextMenuRequest/@itemContextMenuRequest trigger!\n"));
return true;
}
for ( int i = 0; i < 4; ++i )
{
if ( (i > 1) && IsStrEmpty(ppArgs[i]) )
continue;
if ( !IsStrNumeric(ppArgs[i]) )
{
DEBUG_ERR(("Bad AddContextEntry usage: Argument %d must be a number!\n", i + 1));
return true;