コード例 #1
0
ファイル: Snapshot.hpp プロジェクト: ChWick/Mencus
  //! 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
0
ファイル: firmware_archive.cpp プロジェクト: bhunting/p-load
/** 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);
}
コード例 #3
0
ファイル: Snapshot.hpp プロジェクト: ChWick/Mencus
  CSnapshot(const void *pointer, const size_t size) {
    memcpy(&m_eCurrentGameState, pointer, sizeof(CGameState::EGameStates));
    char *pChar = new char[size];
    memcpy(pChar, static_cast<const CGameState::EGameStates*>(pointer) + 1, size - sizeof(CGameState::EGameStates));

    m_XMLDoc.Parse(pChar);
    if (m_XMLDoc.Error()) {
      throw Ogre::Exception(Ogre::Exception::ERR_FILE_NOT_FOUND, "Save state xml document cout not be parsed. Error code"
			    + Ogre::StringConverter::toString(m_XMLDoc.ErrorID())
			    + " File content:\n" + Ogre::String(pChar), __FILE__);
    }
    
    delete [] pChar;


    // read the document
    readDocument();
  }