コード例 #1
0
ファイル: IMediaType.cpp プロジェクト: gmoromisato/Hexarc
bool CRawMediaType::DecodeFromBuffer (const CString &sMediaType, const IMemoryBlock &Buffer)

//	DecodeFromBuffer

	{
	m_sMediaType = sMediaType;
	m_sBody = CString(Buffer.GetPointer(), Buffer.GetLength());
	return true;
	}
コード例 #2
0
ファイル: XMLParser.cpp プロジェクト: gmoromisato/Hexarc
ParserCtx::ParserCtx (IMemoryBlock &Stream, IXMLParserController *pController) : 
		m_pController(pController)
	{
	pPos = Stream.GetPointer();
	pEndPos = pPos + Stream.GetLength();
	pElement = NULL;
	iToken = tkEOF;
	iLine = 1;
	m_bParseRootElement = false;
	m_bParseRootTag = false;

	m_pParentCtx = NULL;
	}
コード例 #3
0
ファイル: CBabelData.cpp プロジェクト: Ttech/Transcendence
CBabelData ReadBabel (IMemoryBlock &Input)

//	ReadBabel
//
//	Reads and loads babel text. Throws CException if there are errors

{
    char *pPos = Input.GetPointer();
    char *pEndPos = pPos + Input.GetLength();

    CParser theParser(pPos, pEndPos);

    return theParser.Parse();
}
コード例 #4
0
ファイル: IIOCPEntry.cpp プロジェクト: kronosaur/Hexarc
bool IIOCPEntry::BeginWrite (const CString &sData, CString *retsError)

//	BeginWrite
//
//	Overlapped write on the given handle. Returns FALSE if we get an error.

	{
	//	Must be in the proper state

	HANDLE hHandle = GetCompletionHandle();
	if (hHandle == INVALID_HANDLE_VALUE
			|| m_iCurrentOp != opNone)
		{
		if (retsError) *retsError = ERR_INVALID_STATE;
		return false;
		}

	m_iCurrentOp = opWrite;
	m_dwOpStartTime = sysGetTickCount64();

	//	If we don't have a buffer, then we're done.

	IMemoryBlock *pBuffer = GetBuffer();
	if (pBuffer == NULL)
		{
		m_iCurrentOp = opNone;
		if (retsError) *retsError = ERR_INVALID_STATE;
		return false;
		}

	//	Initialize operation

	utlMemSet(&m_Overlapped, sizeof(m_Overlapped));

	//	Let our subclasses know (this also initializes the buffer)

	OnBeginWrite(sData);

	//	Write into the buffer

	DWORD lasterror = 0;
	if (!::WriteFile(hHandle,
			pBuffer->GetPointer(),
			pBuffer->GetLength(),
			NULL,
			&m_Overlapped))
		lasterror = GetLastError();

	//	If IO is pending or we succeeded, then nothing to do--we will get an
	//	event on the completion port.

	if (lasterror == ERROR_IO_PENDING
			|| lasterror == 0)
		return true;

	//	If another error or 0 bytes read, then we fail

	else
		{
		m_iCurrentOp = opNone;

		if (retsError)
			*retsError = strPattern(ERR_FILE_ERROR, lasterror);

		return false;
		}
	}