这是我的第一篇文章,如果我犯了错误,请见谅。我目前在我的 Visual C++ 2010 express 项目中使用 CMarkup,它是由 FirstObject 制作的 XML 修改器/解析器。当我尝试使用其函数 CMarkup::Load("Filename.xml") 加载 xml 文件时,一切编译正常,但我得到一个运行时错误,我认为这是一个错误的指针,但这是我不明白的!这是我使用的代码
g_XMLSeamanConversations.Load(MCD_T("SeamanVocabulary.xml"));
g_XMLSeamanConversations.FindElem(MCD_T("SeamanVocabulary"));
g_XMLSeamanConversations.IntoElem();
g_XMLSeamanConversations.FindElem(MCD_T("SeamanQuestions"));
g_XMLSeamanConversations.IntoElem();
当我的代码调用 Load(); 函数程序在此停止
template <class _T1, class _T2>
inline void _Param_Construct_aux(_T1* __p, const _T2& __val, const __true_type&)
{
// We use binary copying for POD types since it results
// in a considerably better code at least on MSVC.
// This is the problem -----> *__p = _T1(__val);
}
此“错误”代码位于“_Construct.h”中
在此之后我的代码将不会运行。如果有人能对此有所了解或编造故事,我将欠下巨额债务!先谢谢了!!!
编辑:好的,这是通话顺序
bool CMarkup::Load( MCD_CSTR_FILENAME szFileName )
{
if ( m_nDocFlags & (MDF_READFILE|MDF_WRITEFILE) )
return false;
if ( ! ReadTextFile(szFileName, m_strDoc, &m_strResult, &m_nDocFlags) )
return false;
return x_ParseDoc();
}
然后
bool CMarkup::ReadTextFile( MCD_CSTR_FILENAME szFileName, MCD_STR& strDoc,
MCD_STR* pstrResult, int* pnDocFlags, MCD_STR* pstrEncoding )
{
// Static utility method to load text file into strDoc
//
FilePos file;
file.m_nDocFlags = (pnDocFlags?*pnDocFlags:0) | MDF_READFILE;
bool bSuccess = file.FileOpen( szFileName );
if ( pstrResult )
*pstrResult = file.m_strIOResult;
MCD_STRCLEAR(strDoc);
if ( bSuccess )
{
file.FileSpecifyEncoding( pstrEncoding );
file.m_nOpFileByteLen = (int)((MCD_INTFILEOFFSET)
(file.m_nFileByteLen - file.m_nFileByteOffset));
bSuccess = file.FileReadText( strDoc );
file.FileClose();
if ( pstrResult )
*pstrResult += file.m_strIOResult;
if ( pnDocFlags )
*pnDocFlags = file.m_nDocFlags;
}
return bSuccess;
}
然后
public: // Append, operator+=, push_back.
_Self& operator+=(const _Self& __s) { return append(__s); }
然后
public:
_Self& append(const _Self& __s)
{ return _M_append(__s._M_Start(), __s._M_Finish()); }
然后
template <class _CharT, class _Traits, class _Alloc>
basic_string<_CharT, _Traits, _Alloc>&
basic_string<_CharT, _Traits, _Alloc>::_M_append(const _CharT* __first,
const _CharT* __last) {
if (__first != __last) {
size_type __n = __STATIC_CAST(size_type, __last - __first);
if (__n >= this->_M_rest()) {
size_type __len = _M_compute_next_size(__n);
pointer __new_start = this->_M_start_of_storage.allocate(__len, __len);
pointer __new_finish = _STLP_PRIV __ucopy(this->_M_Start(),
this->_M_Finish(), __new_start);
__new_finish = _STLP_PRIV __ucopy(__first, __last, __new_finish);
_M_construct_null(__new_finish);
this->_M_deallocate_block();
this->_M_reset(__new_start, __new_finish, __new_start + __len);
}
else {
const _CharT* __f1 = __first;
++__f1;
_STLP_PRIV __ucopy(__f1, __last, this->_M_finish + 1);
_M_construct_null(this->_M_finish + __n);
_Traits::assign(*end(), *__first);
this->_M_finish += __n;
}
}
return *this;
}
然后
template <class _RandomAccessIter, class _OutputIter>
inline _OutputIter __ucopy(_RandomAccessIter __first,
_RandomAccessIter __last, _OutputIter __result)
{ return __ucopy(__first, __last, __result,
random_access_iterator_tag(), (ptrdiff_t*)0); }
然后
template <class _RandomAccessIter, class _OutputIter, class _Distance>
inline _OutputIter __ucopy(_RandomAccessIter __first, _RandomAccessIter __last,
_OutputIter __result, const random_access_iterator_tag &, _Distance*) {
_OutputIter __cur = __result;
_STLP_TRY {
for (_Distance __n = __last - __first; __n > 0; --__n) {
_Param_Construct(&*__cur, *__first);
++__first;
++__cur;
}
return __cur;
}
_STLP_UNWIND(_STLP_STD::_Destroy_Range(__result, __cur))
_STLP_RET_AFTER_THROW(__cur)
}
然后
template <class _T1, class _T2>
inline void _Param_Construct_aux(_T1* __p, const _T2& __val, const __true_type&) {
// We use binary copying for POD types since it results
// in a considerably better code at least on MSVC.
*__p = _T1(__val);
}
最后
template <class _T1, class _T2>
inline void _Param_Construct_aux(_T1* __p, const _T2& __val, const __true_type&) {
// We use binary copying for POD types since it results
// in a considerably better code at least on MSVC.
*__p = _T1(__val);
}
希望这可以帮助!!!!