void RuleSet::fromXml(const QDomElement& ele) throw(XmlParseException) { QDomNodeList list = ele.childNodes(); int len = list.length(); QDomElement current; for(int i = 0; i < len; i++) { current = list.item(i).toElement(); if(!current.isNull()) { if(current.nodeName() == "book") m_book = current.text().simplified(); else if(current.nodeName() == "version") m_version = current.text().simplified(); else if(current.nodeName() == "edition") m_edition = current.text().simplified(); else if(current.nodeName() == "rules") RuleList::fromXml(current); else throw XmlParseException("invalid node" , current); } } if(m_book.isEmpty()) throw XmlParseException("missing ruleset book node", ele); if(m_edition.isEmpty()) throw XmlParseException("missing ruleset edition node", ele); if(m_version.isEmpty()) throw XmlParseException("missing ruleset version node", ele); }
void XMLReader::fatalError( const xercesc::SAXParseException &e ) { int line = e.getLineNumber(); std::string message( transcodeString( e.getMessage() ) ); throw XmlParseException( boost::str( boost::format( "XML parse error (line: %d): %s" ) % line % message ) ); }
Race::Race(const QDomDocument& doc) throw(XmlParseException) : UnitList(), WargearList(), RuleSet(), m_name(), m_id() { m_game = NULL; QDomElement root = doc.documentElement(); if(root.isNull() || root.nodeName() != "race") throw XmlParseException("missing root race node"); fromXml(root); }
nodeBuildFn_t XMLNodeData::getBuildFnFor( const std::string &nodeName ) { nodeBuildFnMap_t::iterator findIt = m_nodeFnBuildMap.find( nodeName ); if ( findIt == m_nodeFnBuildMap.end() ) { // Can't find the tag - make a nice error throw XmlParseException( "Cannot find build fn for: " + nodeName ); } return findIt->second; }
void Race::fromXml(const QDomElement& ele) throw(XmlParseException) { QDomNodeList list = ele.childNodes(); int len = list.length(); QDomElement current; for(int i = 0; i < len; i++) { current = list.item(i).toElement(); if(!current.isNull()) { if(current.nodeName() == "id") m_id = current.text().simplified(); else if(current.nodeName() == "name") m_name = current.text().simplified(); else if(current.nodeName() == "game") m_unresolvedGame = UnresolvedReference(current); else if(current.nodeName() == "rule_set") RuleSet::fromXml(current); else if(current.nodeName() == "wargears") WargearList::fromXml(current); else if(current.nodeName() == "units") UnitList::fromXml(current); else throw XmlParseException("invalid race node", current); } } if(m_id.isEmpty()) throw XmlParseException("missing race id node", ele); if(m_name.isEmpty()) throw XmlParseException("missing race name node", ele); if(m_unresolvedGame.isNull()) throw XmlParseException("missing race game reference node", ele); }
void WargearList::fromXml(const QDomElement& ele) throw(XmlParseException) { QDomNodeList list = ele.childNodes(); int len = list.length(); QDomElement current; for(int i = 0; i < len; i++) { current = list.item(i).toElement(); if(!current.isNull()) { if(current.nodeName() == "wargear") { Wargear wg(current, race()); m_wargears.insert(wg.id(), wg); } else throw XmlParseException("invalid wargear list node", current); } } }
void RuleRefList::fromXml(const QDomElement& ele) throw(XmlParseException) { QDomNodeList list = ele.childNodes(); int len = list.length(); QDomElement node; for(int i = 0; i < len; i++) { node = list.item(i).toElement(); if(!node.isNull()) { if(node.nodeName() == "rule_ref") { UnresolvedReference ref(node); m_unresolvedRules.append(ref); } else throw XmlParseException("invalid rule ref list node", node); } } }