📄 smlffpln.cpp
字号:
}
else if ( pData[ulPos] == '>' )
{
m_fileState = InContent;
}
else if ( pData[ulPos] == '\"' )
{
pCb[m_ulCurrentBufferPos++] = '\\';
}
else if ( pData[ulPos] == '\\' )
{
pCb[m_ulCurrentBufferPos++] = '\\';
}
pCb[m_ulCurrentBufferPos++] = pData[ulPos];
}
break;
case InDTDMarkup:
{
if ( pData[ulPos] == ']' )
{
m_fileState = InDTD;
}
else if ( pData[ulPos] == '\"' )
{
pCb[m_ulCurrentBufferPos++] = '\\';
}
else if ( pData[ulPos] == '\\' )
{
pCb[m_ulCurrentBufferPos++] = '\\';
}
pCb[m_ulCurrentBufferPos++] = pData[ulPos];
}
break;
case InCDATA:
{
if ( pData[ulPos] == ']' && pData[ulPos+1] == ']' && pData[ulPos+2] == '>' )
{
pCb[m_ulCurrentBufferPos++] = pData[ulPos++];
m_fileState = InContent;
}
else if ( pData[ulPos] == '\"' )
{
pCb[m_ulCurrentBufferPos++] = '\\';
}
else if ( pData[ulPos] == '\\' )
{
pCb[m_ulCurrentBufferPos++] = '\\';
}
pCb[m_ulCurrentBufferPos++] = pData[ulPos];
}
break;
case InTagName:
{
// go to first white space
// let's escape " and \ even though they are ilegal.
if ( isspace(pData[ulPos]) )
{
m_fileState = InBeginAttributeName;
}
else if ( pData[ulPos] == '>' )
{
m_fileState = InContent;
}
else if ( pData[ulPos] == '\"' )
{
ReportError(HXR_XML_GENERALERROR, XML_BAD_TAG_NAME);
pCb[m_ulCurrentBufferPos++] = '\\';
}
else if ( pData[ulPos] == '\\' )
{
ReportError(HXR_XML_GENERALERROR, XML_BAD_TAG_NAME);
pCb[m_ulCurrentBufferPos++] = '\\';
}
pCb[m_ulCurrentBufferPos++] = pData[ulPos];
}
break;
case InTag:
{
if ( pData[ulPos] == '>' || (pData[ulPos] == '/' &&
pData[ulPos+1] == '>'))
{
pCb[m_ulCurrentBufferPos++] = pData[ulPos];
m_fileState = InContent;
}
else
{
// grab the first char... keep it and switch states.
// it should be a space... but if it isn't we will
// not complain because the renderer accepts no
// space.
pCb[m_ulCurrentBufferPos++] = pData[ulPos];
m_fileState = InBeginAttributeName;
if (!isspace(pData[ulPos]))
{
ReportError(HXR_XML_GENERALERROR,
XML_MISSING_SPACE);
}
}
}
break;
case InBeginAttributeName:
{
if ( isspace(pData[ulPos]) )
{
// preserve all lines so line numbers in error messages
// are accurate
if (pData[ulPos] == '\n' || ('\r' == pData[ulPos] &&
ulPos+1 < ulSize && '\n' != pData[ulPos+1]) )
{
if ('\r' == pData[ulPos])
{
pCb[m_ulCurrentBufferPos++] = '\n';
}
else
{
pCb[m_ulCurrentBufferPos++] = pData[ulPos];
}
}
// continue...
}
else if ( pData[ulPos] == '=' )
{
ReportError(HXR_XML_GENERALERROR,
XML_BAD_ATTRIBUTE_NAME);
m_fileState = InBeginAttributeValue;
pCb[m_ulCurrentBufferPos++] = pData[ulPos];
}
else if ( pData[ulPos] == '>' || (pData[ulPos] == '/'
&& pData[ulPos+1] == '>'))
{
m_fileState = InContent;
pCb[m_ulCurrentBufferPos++] = pData[ulPos];
}
else
{
m_fileState = InAttributeName;
pCb[m_ulCurrentBufferPos++] = pData[ulPos];
}
}
break;
case InAttributeName:
{
if ( isspace(pData[ulPos]) )
{
m_fileState = InEndAttributeName;
pCb[m_ulCurrentBufferPos++] = pData[ulPos];
}
else if ( pData[ulPos] == '=' )
{
m_fileState = InBeginAttributeValue;
pCb[m_ulCurrentBufferPos++] = pData[ulPos];
}
else if ( pData[ulPos] == '>' )
{
ReportError(HXR_XML_GENERALERROR,
XML_MISSING_ATTRIBUTE_VALUE);
m_fileState = InContent;
pCb[m_ulCurrentBufferPos++] = pData[ulPos];
}
else if (pData[ulPos] == '\'' || pData[ulPos] == '"')
{
ReportError(HXR_XML_GENERALERROR,
XML_BAD_ATTRIBUTE_NAME);
m_cQuote = pData[ulPos];
if (m_cQuote == '"')
{
pCb[m_ulCurrentBufferPos++] = '\\';
}
pCb[m_ulCurrentBufferPos++] = pData[ulPos];
m_fileState = InAttributeValue;
}
else
{
pCb[m_ulCurrentBufferPos++] = pData[ulPos];
}
}
break;
case InEndAttributeName:
{
if ( isspace(pData[ulPos]) )
{
// preserve all lines so line numbers in error messages
// are accurate
if (pData[ulPos] == '\n' || ('\r' == pData[ulPos] &&
ulPos+1 < ulSize && '\n' != pData[ulPos+1]) )
{
if ('\r' == pData[ulPos])
{
pCb[m_ulCurrentBufferPos++] = '\n';
}
else
{
pCb[m_ulCurrentBufferPos++] = pData[ulPos];
}
}
// continue..
}
else if ( pData[ulPos] == '=' )
{
m_fileState = InBeginAttributeValue;
pCb[m_ulCurrentBufferPos++] = pData[ulPos];
}
else if ( pData[ulPos] == '>' )
{
ReportError(HXR_XML_GENERALERROR,
XML_MISSING_ATTRIBUTE_VALUE);
// illegal.
m_fileState = InContent;
pCb[m_ulCurrentBufferPos++] = pData[ulPos];
}
else
{
// hmm. we got a non whitespace before the =
// push a ' ' on so the render will get this error.
pCb[m_ulCurrentBufferPos++] = ' ';
//First, let's see if we have a ["] or a [']
// (i.e., an attribute value start) in which
// case the author must have forgotten to
// put an '=' between the name/value pair.
// In this case, we need to keep the renderers
// from firing off an error with old bad content,
// so we pretend we're in the "InAttributeValue"
// state:
if ( pData[ulPos] == '\'' )
{
ReportError(HXR_XML_GENERALERROR,
XML_BAD_ATTRIBUTE_NAME);
m_cQuote = pData[ulPos];
m_fileState = InAttributeValue;
}
else if ( pData[ulPos] == '\"' )
{
ReportError(HXR_XML_GENERALERROR,
XML_BAD_ATTRIBUTE_NAME);
m_cQuote = pData[ulPos];
pCb[m_ulCurrentBufferPos++] = '\\';
m_fileState = InAttributeValue;
}
else
{
ReportError(HXR_XML_BADATTRIBUTE,
XML_BAD_ATTRIBUTE_NAME);
// lets go back to the attribute name state.
m_fileState = InAttributeName;
}
//Push the character back on so the renderer
// can deal with it:
pCb[m_ulCurrentBufferPos++] = pData[ulPos];
}
}
break;
case InBeginAttributeValue:
{
if ( isspace(pData[ulPos]) )
{
// preserve all lines so line numbers in error messages
// are accurate
if (pData[ulPos] == '\n' || ('\r' == pData[ulPos] &&
ulPos+1 < ulSize && '\n' != pData[ulPos+1]) )
{
if ('\r' == pData[ulPos])
{
pCb[m_ulCurrentBufferPos++] = '\n';
}
else
{
pCb[m_ulCurrentBufferPos++] = pData[ulPos];
}
}
// continue...
}
else if ( pData[ulPos] == '\'' )
{
m_cQuote = pData[ulPos];
m_fileState = InAttributeValue;
pCb[m_ulCurrentBufferPos++] = pData[ulPos];
}
else if ( pData[ulPos] == '\"' )
{
m_cQuote = pData[ulPos];
pCb[m_ulCurrentBufferPos++] = '\\';
pCb[m_ulCurrentBufferPos++] = '\"';
m_fileState = InAttributeValue;
}
else if ( pData[ulPos] == '>' )
{
ReportError(HXR_XML_GENERALERROR,
XML_MISSING_ATTRIBUTE_VALUE);
m_fileState = InContent;
pCb[m_ulCurrentBufferPos++] = pData[ulPos];
}
}
break;
case InAttributeValue:
{
if ( pData[ulPos] == m_cQuote )
{
if ( m_cQuote == '\"' )
{
pCb[m_ulCurrentBufferPos++] = '\\';
}
m_fileState = InTag;
}
else if ( pData[ulPos] == '\"' )
{
pCb[m_ulCurrentBufferPos++] = '\\';
}
else if ( pData[ulPos] == '\\' )
{
pCb[m_ulCurrentBufferPos++] = '\\';
}
pCb[m_ulCurrentBufferPos++] = pData[ulPos];
}
break;
case InComment:
{
if ( pData[ulPos] == '-' && pData[ulPos+1] == '-' &&
pData[ulPos+2] == '>' )
{
m_fileState = InContent;
ulPos += 2;
}
// preserve all lines so line numbers in error messages
// are accurate
else if (pData[ulPos] == '\n' || ('\r' == pData[ulPos] &&
ulPos+1 < ulSize && '\n' != pData[ulPos+1]) )
{
if ('\r' == pData[ulPos])
{
pCb[m_ulCurrentBufferPos++] = '\n';
}
else
{
pCb[m_ulCurrentBufferPos++] = pData[ulPos];
}
}
// else continue...
}
break;
default:
HX_ASSERT(FALSE);
}
}
return result;
}
HX_RESULT CSmilFileFormat::ReportError(HX_RESULT result,
const char* errStr)
{
if ( m_bLogErrors )
{
IHXErrorMessages* pLog = NULL;
m_pContext->QueryInterface(IID_IHXErrorMessages,
(void**)&pLog);
pLog->Report(HXLOG_ERR, result, 0, errStr,
"http://www.real.com");
HX_RELEASE(pLog);
}
return HXR_OK;
}
/////////////////////////////////////////////////////////////////////////
// Method:
// IHXFileResponse::WriteDone
// Purpose:
// Notification interface provided by users of the IHXFileObject
// interface. This method is called by the IHXFileObject when the
// last write to the file is complete.
//
STDMETHODIMP CSmilFileFormat::WriteDone(HX_RESULT status)
{
// We don't ever write, so we don't expect to get this...
return HXR_UNEXPECTED;
}
/////////////////////////////////////////////////////////////////////////
// Method:
// IHXFileResponse::SeekDone
// Purpose:
// Notification interface provided by users of the IHXFileObject
// interface. This method is called by the IHXFileObject when the
// last seek in the file is complete.
//
STDMETHODIMP CSmilFileFormat::SeekDone(HX_RESULT status)
{
HX_RESULT result = HXR_OK;
return result;
}
/************************************************************************
* Method:
* IHXPendingStatus::GetStatus
* Purpose:
* Called by the user to get the current pending status from an object
*/
STDMETHODIMP
CSmilFileFormat::GetStatus
(
REF(UINT16) uStatusCode,
REF(IHXBuffer*) pStatusDesc,
REF(UINT16) ulPercentDone
)
{
HX_RESULT hResult = HXR_OK;
IHXPendingStatus* pFileSystemStatus = NULL;
// asking status information from the file system object
if (m_pFileObject)
{
if (HXR_OK == m_pFileObject->QueryInterface(IID_IHXPendingStatus,(void**)&pFileSystemStatus))
{
hResult = pFileSystemStatus->GetStatus(uStatusCode, pStatusDesc, ulPercentDone);
pFileSystemStatus->Release();
return hResult;
}
}
// by default
uStatusCode = HX_STATUS_READY;
pStatusDesc = NULL;
ulPercentDone = 0;
return hResult;
}
/************************************************************************
* Method:
* IHXThreadSafeMethods::IsThreadSafe
*/
STDMETHODIMP_(UINT32)
CSmilFileFormat::IsThreadSafe()
{
return HX_THREADSAFE_METHOD_FF_GETPACKET |
HX_THREADSAFE_METHOD_FSR_READDONE;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -