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


C++ StringA::c_str方法代码示例

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


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

示例1: GetList

void NewsAccount::GetList()
{
	char* request = "LIST\r\n";
	m_pSocket->Write(request, strlen(request));
	StringA response = m_pSocket->ReadLine();

	while (1)
	{
		StringA line = m_pSocket->ReadLine();
		if (!strcmp(line.c_str(), "."))
		{
			break;
		}

		char group[1024];
		int last;
		int first;
		char p;
		sscanf(line.c_str(), "%s", group, &last, &first, &p);

		TRACE("%s\n", group);

		Record pRecord = m_list.NewRecord();

		pRecord.get_Fields()[1].SetData(group);

		pRecord.Update();
	}
}
开发者ID:sigurdle,项目名称:FirstProject2,代码行数:29,代码来源:MailReaderFrame.cpp

示例2: Connect

void NewsAccount::Connect()
{
	int port = 119;
	m_pSocket = new NNTPClient;
	m_pSocket->Create();
	m_pSocket->Connect(m_server.c_str(), port);

	{
		StringA response = m_pSocket->ReadLine();
	}
};
开发者ID:sigurdle,项目名称:FirstProject2,代码行数:11,代码来源:MailReaderFrame.cpp

示例3: ReadLine

	StringA ReadLine()
	{
		StringA str;

		while (1)
		{
			char c;
			if (Read(&c, 1) != 1)
				break;
			if (c == '\r')
			{
				char c2;
				if (Read(&c2, 1) != 1)
					break;
				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() == 4096)
					throw -1;
					*/
				str += c;
			}
		}

		TRACE("%s\n", str.c_str());
		return str;
	}
开发者ID:sigurdle,项目名称:FirstProject2,代码行数:46,代码来源:GnutellaNetwork.cpp

示例4: main


//.........这里部分代码省略.........
#endif

	printf("pass1\n");
	linker.pass1();

/*
	GlobalSymbol* pSymbol = linker.m_globsyms[new StringA("_main")];
	pSymbol->m_defined = true;
	pSymbol->ResolvedValue = (DWORD)MyMain;
*/
//	linker.AddSymbol(new StringA("_main"), (DWORD)MyMain);

	printf("loading first object file\n");
#if 1
	linker.LoadObjectFile(linker.m_objectFiles[0]);
	if (true)
	{
		for (int i = 1; i < linker.m_objectFiles.size(); i++)
		{
			printf("loading %d object file\n", i);
			linker.LoadObjectFile(linker.m_objectFiles[i]);
		}
	}

	printf("Here\n");
	TRACE("\n\n");

	{
		for (int i = 0; i < linker.m_loadedObjectFiles.size(); i++)
		{
			OFile2* ofile = linker.m_loadedObjectFiles[i];

			if (ofile->m_afilename)
				TRACE("%s:%s\n", ofile->m_afilename->c_str(), ofile->m_ofilename->c_str());
			else
				TRACE("%s\n", ofile->m_ofilename->c_str());
		}
	}
#endif

	printf("before sets\n");

	linker.sets();

	printf("LoadObjectfile2\n");

	OFile* pOFile = linker.LoadObjectFile2(linker.m_objectFiles[0]);

	if (true)
	{
		for (int i = 1; i < linker.m_objectFiles.size(); i++)
		{
			linker.LoadObjectFile2(linker.m_objectFiles[i]);
		}
	}

/*
	{
		GlobalSymbol* psym = linker.m_globsyms[new StringA("_DOSBase")];
		int x = *(long*)psym->ResolvedValue;
	}
*/
	printf("done\n");

	if (linker.m_undefinedReferenceCount)
	{
开发者ID:,项目名称:,代码行数:67,代码来源:

示例5: 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;
//.........这里部分代码省略.........
开发者ID:sigurdle,项目名称:FirstProject2,代码行数:101,代码来源:CallStackWnd.cpp

示例6: ReCreate

HRESULT WINAPI CZipFs::ReCreate(__in_opt void* handle, __in_opt ULONG const flags /*= 0*/)
{
	if (flags)
		m_flags = flags;

	if ((HANDLE)handle == m_handle)
		return S_OK;

	m_handle = (HANDLE)handle;

	StringA strNameA = UnicodeToAnsi(m_FileName);

	if (UNZ_OK != unzGetFilePos64((unzFile)m_handle, &m_currentFilePos))
		return E_NOT_SET;

	if (unzLocateFile((unzFile)m_handle, strNameA.c_str(), 0) != UNZ_OK)
		return E_FAIL;

	HRESULT hr = (unzOpenCurrentFile((unzFile)m_handle) == UNZ_OK) ? S_OK : E_FAIL;
	if (FAILED(hr))
	{
		m_handle = INVALID_HANDLE_VALUE;
		return hr;
	}

	if (m_stream)
	{
		m_stream->Release();
		m_stream = NULL;
	}
	m_stream = new CBufferedStream();
	if (m_stream == NULL)
	{
		Close();
		return E_OUTOFMEMORY;
	}

	int err = 0;
	unsigned char *pTemp = new unsigned char[WRITEBUFFERSIZE];
	if (pTemp)
	{
		do
		{
			err = unzReadCurrentFile((unzFile)m_handle, pTemp, WRITEBUFFERSIZE);
			if (err < 0)
			{
				break;
			}
			if (err > 0)
			{
				ULONG writtenSize;
				if (FAILED(m_stream->Write(pTemp, (ULONG)err, &writtenSize)))
					break;
				if (writtenSize == 0)
					break;
			}
		} while (err > 0);
		delete[] pTemp;
	}

	// goto the beginning of file
	ULARGE_INTEGER pos = {};
	LARGE_INTEGER distanceToMove = {};
	m_stream->Seek(&pos, distanceToMove, IFsStream::FsStreamBegin);
	m_attribute->SetFilePath(m_FileName.c_str(), handle);
	return S_OK;
}
开发者ID:MeteorAdminz,项目名称:TinyAntivirus,代码行数:67,代码来源:ZipFs.cpp

示例7: 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
//.........这里部分代码省略.........
开发者ID:sigurdle,项目名称:FirstProject2,代码行数:101,代码来源:GnutellaNetwork.cpp

示例8: 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;
	}
}
开发者ID:sigurdle,项目名称:FirstProject2,代码行数:61,代码来源:GnutellaNetwork.cpp

示例9: GetNewMail

void MailAccount::GetNewMail(ITable* pTable)
{
	int port = 110;
	POP3Client* pSocket = new POP3Client;
	pSocket->Create();
	pSocket->Connect(m_server.c_str(), port);

	StringA greeting = pSocket->ReadLine();
	if (strncmp(greeting.c_str(), "+OK", 3))
		throw -1;

	{
		char msg[512];
		sprintf(msg, "USER %s\r\n", m_username.c_str());
		pSocket->Write(msg, strlen(msg));
		StringA response = pSocket->ReadLine();
		if (strncmp(response.c_str(), "+OK", 3))
			throw -1;
	}

	{
		char msg[512];
		sprintf(msg, "PASS %s\r\n", m_password.c_str());
		pSocket->Write(msg, strlen(msg));
		StringA response = pSocket->ReadLine();
		if (strncmp(response.c_str(), "+OK", 3))
			throw -1;
	}

	CArray<int, int> message_numbers;
	{
		char* msg = "LIST\r\n";
		pSocket->Write(msg, strlen(msg));
		StringA response = pSocket->ReadLine();
		if (strncmp(response.c_str(), "+OK", 3))
			throw -1;
		while (1)
		{
			StringA line = pSocket->ReadLine();
			if (!strcmp(line.c_str(), "."))
			{
				break;
			}

			int message_number;
			int message_size;

			sscanf(line.c_str(), "%d %d", &message_number, &message_size);
			message_numbers.Add(message_number);

			TRACE("%s\n", line.c_str());
		}

	//	FILE* fp_text = fopen("C:\\mail_text", "a+b");
	//	FILE* fp_index = fopen("C:\\mail_index", "a+b");

		for (int i = 0; i < message_numbers.size(); i++)
		{
			IRecord* pMessage = pTable->NewRecord();

			pMessage->GetField((int)0)->SetValue((long)0);//m_ID;
			pMessage->GetField(5)->SetValue((long)0);
			pMessage->GetField(6)->SetValue(time(NULL));
			pMessage->GetField(7)->SetValue(m_ID);

			{
				char msg[256];
				sprintf(msg, "RETR %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;
			}

			// Read the message
			StringA lines;

			while (1)
			{
				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)
//.........这里部分代码省略.........
开发者ID:sigurdle,项目名称:FirstProject2,代码行数:101,代码来源:MailReaderFrame.cpp


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