本文整理汇总了C++中tinyxml2::XMLDocument::Error方法的典型用法代码示例。如果您正苦于以下问题:C++ XMLDocument::Error方法的具体用法?C++ XMLDocument::Error怎么用?C++ XMLDocument::Error使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tinyxml2::XMLDocument
的用法示例。
在下文中一共展示了XMLDocument::Error方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Exception
//! Constructor to create a snapshot from a given file
CSnapshot(const Ogre::String &sValidPath) {
m_XMLDoc.LoadFile(sValidPath.c_str());
if (m_XMLDoc.Error()) {
throw Ogre::Exception(Ogre::Exception::ERR_FILE_NOT_FOUND,
"XMLdoc parsing error with file: " + sValidPath,
__FILE__);
}
// read the document
readDocument();
}
示例2: throwIfError
/** Unfortunately, TinyXML2 does not provide good ways of reporting XML parsing
* errors. We could try to use GetErrorStr1() and GetErrorStr2(), but those
* just return pointers to parts of the document, and it is not OK to print
* parts of the document without carefully escaping special characters in it,
* which is probably not worthwhile. */
static void throwIfError(const tinyxml2::XMLDocument & doc)
{
if(!doc.Error()) { return; }
std::string msg("XML error.");
// doc.ErrorName is not available in Ubuntu's libtinyxml2-dev/trusty-backports package
// (2.1.0). But it would be nice to use it eventually once everyone has upgraded:
// std::string msg("XML error: ");
// msg += doc.ErrorName();
// msg += ".";
throw std::runtime_error(msg);
}