本文整理汇总了C++中StringA::length方法的典型用法代码示例。如果您正苦于以下问题:C++ StringA::length方法的具体用法?C++ StringA::length怎么用?C++ StringA::length使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringA
的用法示例。
在下文中一共展示了StringA::length方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _FileIterator_BuildFilePathIfNeeded
//---------------------------------------------------------------------------
static void _FileIterator_BuildFilePathIfNeeded (StringA& strFilePath, const StringA& strDir, const StringA& strName)
{
if (strFilePath.isEmpty())
{
strFilePath.grow(strDir.length() + strName.length() + 2, false);
strFilePath = strDir;
strFilePath.pathAppend(strName);
}
}
示例2: ReadLine
StringA ReadLine()
{
StringA str;
while (1)
{
char c;
Read(&c, 1);
if (c == '\r')
{
char c2;
Read(&c2, 1);
if (c2 == '\n')
{
break;
}
else
{
if (str.length() == 512)
throw -1;
str += c;
if (str.length() == 512)
throw -1;
str += c2;
}
}
else
{
if (str.length() == 512)
throw -1;
str += c;
}
}
TRACE("%s\n", str.c_str());
return str;
}
示例3: OnRender
void CallStackWnd::OnRender(UI::Graphics* pGraphics)
{
// HFONT hOldFont = dc.SelectFont((HFONT)GetStockObject(ANSI_FIXED_FONT));
{
LDraw::SolidBrush* brush = new LDraw::SolidBrush(LDraw::Color(255, 255, 255));
pGraphics->FillRectangle(brush, 0, 0, m_computedSize.Width, m_computedSize.Height);
}
for (int i = 0; i < m_callstack.size(); i++)
{
DebugFrame* pDebugFrame = m_callstack[i];
// if (m_pFrame->m_Eip >= line->u.instr.address && m_pFrame->m_Eip < line->u.instr.address+line->u.instr.nbytes)
// {
// }
if (i == 0)
{
DrawYellowArrow(pGraphics, i*16 + 8);
}
if (m_selected == i)
{
if (i != 0)
{
DrawGreenArrow(pGraphics, i*16 + 8);
}
}
pGraphics->DrawString(pDebugFrame->m_str, GetFont(), LDraw::PointF(14, i*16), new LDraw::SolidBrush(LDraw::Color::Black));
}
// dc.SelectFont(hOldFont);
#if 0
if (g_pt)
{
if (m_pFrame->m_ctx && m_pFrame->m_ctx->m_pDebugProcess && !m_pFrame->m_ctx->m_pDebugProcess->m_bRunning)
{
HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, m_pFrame->m_dwProcessId);
int n = 0;
// DWORD eip = g_pt->m_context.Eip;
// DWORD ebp = g_pt->m_context.Ebp;
STACK_FRAME frame;
frame.Ebp = (STACK_FRAME*)g_pt->m_context.Ebp;
frame.Ret_Addr = (PBYTE)g_pt->m_context.Eip;
while (frame.Ebp)
{
StringA str = "";
for (int i = 0; i < m_pFrame->m_ctx->m_modules.size(); i++)
{
DebugModule* pModule = m_pFrame->m_ctx->m_modules[i];
if ((ULONG)frame.Ret_Addr >= pModule->base && (ULONG)frame.Ret_Addr < pModule->base + pModule->size)
{
str = pModule->name.c_str();
tysymbolmap::iterator psymi = NULL;
tysymbolmap::iterator symi = pModule->symbols.begin();
while (symi != pModule->symbols.end())
{
if ((*symi).first > (ULONG)frame.Ret_Addr)
{
break;
}
psymi = symi;
symi++;
}
if (psymi != NULL)
{
char s[512];
sprintf(s, "%s + %X", (*psymi).second->m_name.c_str(), frame.Ret_Addr - (*psymi).first);
str += s;
}
break;
}
}
if (str.length()==0)
{
char buf[64];
sprintf(buf, "%X", frame.Ret_Addr);
str = buf;
}
/*
for (i = 0; i < m_pFrame->m_ctx->sourceFiles.size(); i++)
{
SourceFile* sourceFile = m_pFrame->m_ctx->sourceFiles[i];
if (eip >= sourceFile->startAddress &&
eip < sourceFile->endAddress)
{
// sprintf(str, "%s() - %X", sourceFile->sourceFileName, eip);
// break;
//.........这里部分代码省略.........
示例4: OnReceive
void CGnutellaSocket::OnReceive(int nErrorCode)
{
TRACE("OnRead\n");
/*
if (nErrorCode)
{
ASSERT(0);
return;
}
*/
if (m_state == 0 || m_state == 1)
{
/*
time_t timer1;
time(&timer1);
double diff = difftime(timer1, m_timer0);
m_timer0 = timer1;
ATLTRACE("", diff);
*/
ULONG n;
ioctlsocket(m_socket, FIONREAD, &n);
char buf[256+1];
while (n)
{
int len = 256;
if (len > n)
len = n;
int nread = Receive(buf, len);
//if (nread == SOCKET_ERROR)
if (nread < len)
{
m_state = -1;
Close();
return;
}
n -= nread;
buf[nread] = 0;
m_strHandshake += buf;
}
/*
std::string line;
while (1)
{
line = ReadLine();
m_strHandshake += line + "\r\n";
if (line.length() == 0)
break;
}
*/
if (m_strHandshake.length() > 4096)
{
// Handshake overflow
ASSERT(0);
m_state = -1;
Close();
return;//break;
}
if (m_state == 0)
{
if (m_strHandshake.length() >= 12)
{
if (strncmp(m_strHandshake.c_str(), "GNUTELLA/0.6", 12))
{
// Not a gnutella peer (disconnect)
m_state = -1;
Close();
return;//break;
}
m_state = 1; // Now we know it's a gnutella peer (keep receiving handshake)
}
}
if (m_state == 1)
{
if (strstr(m_strHandshake.c_str(), "\r\n\r\n"))
{
m_state = 2; // Have read entire handshake string
}
}
if (m_state == 2)
{
int m_code = ParseHandshake();
m_pComm->ProcessHeaders(this);
if (m_code == 200) // OK
//.........这里部分代码省略.........
示例5: ParseHandshake
int CGnutellaSocket::ParseHandshake()
{
const char* p = m_strHandshake.c_str();
const char* pend = p+m_strHandshake.length();
if (!strncmp(p, "GNUTELLA/0.6", 12))
{
p += 12;
p++;
long code = strtol(p, (char**)&p, 10);
p++;
StringA codemsg;
while (p < pend)
{
if (p[0] == '\r' && p[1] == '\n')
{
break;
}
codemsg += *p;
p++;
}
if (*p++ != '\r') ASSERT(0);
if (*p++ != '\n') ASSERT(0);
// HttpHeaders headers;
m_headers.AddHeaders(p);
/*
while (p < pend)
{
std::string header;
while (p < pend)
{
if (p[0] == '\r' && p[1] == '\n')
{
break;
}
header += *p;
p++;
}
if (*p++ != '\r') ASSERT(0);
if (*p++ != '\n') ASSERT(0);
m_headers.push_back(header);
}
ASSERT(*p == 0);
*/
return code;
}
else
{
ASSERT(0);
return 0;
}
}
示例6: GetNewMail
//.........这里部分代码省略.........
StringA line = pSocket->ReadLine();
if (!strcmp(line.c_str(), ".")) // Multiline message ends with '.\r\n'
{
break;
}
lines += line;
lines += "\r\n";
}
const char *p = lines.c_str();
while (*p)
{
if (p[0] == '\r' && p[1] == '\n') // End of headers
break;
// field name
StringA fieldName;
while (*p)
{
if (isspace(*p) || *p == ':')
break;
fieldName += *p;
p++;
}
while (isspace(*p)) p++;
if (*p++ != ':') throw -1;
while (isspace(*p)) p++;
// field body
StringA fieldBody;
while (*p)
{
if (p[0] == '\r' && p[1] == '\n')
{
if (p[2] == '\t' || p[2] == ' ') // continuation on next line
{
p += 3;
}
else
{
p += 2;
break; // End of this field
}
}
else
{
fieldBody += *p;
p++;
}
}
if (!stricmp(fieldName.c_str(), "Subject"))
{
pMessage->GetField(1)->SetData(fieldBody.c_str(), fieldBody.length());
}
else if (!stricmp(fieldName.c_str(), "From"))
{
pMessage->GetField(2)->SetData(fieldBody.c_str(), fieldBody.length());
}
}
pMessage->GetField(3)->SetData(lines.c_str(), p - lines.c_str());
if (p[0] != '\r' || p[1] != '\n')
throw -1;
p += 2;
pMessage->GetField(4)->SetData(p, lines.length() - (p - lines.c_str()));
pMessage->Write();
// The message isn't actually deleted from the server until we issue a QUIT command
{
char msg[256];
sprintf(msg, "DELE %d\r\n", message_numbers[i]);
TRACE(msg);
pSocket->Write(msg, strlen(msg));
StringA response = pSocket->ReadLine();
if (strncmp(response.c_str(), "+OK", 3))
throw -1;
}
}
/*
fclose(fp_index);
fclose(fp_text);
*/
}
{
char* msg = "QUIT\r\n";
pSocket->Write(msg, strlen(msg));
StringA response = pSocket->ReadLine();
if (strncmp(response.c_str(), "+OK", 3))
throw -1;
}
}