IvwDeserializer::IvwDeserializer(std::string fileName, bool allowReference) : IvwSerializeBase(fileName, allowReference) { try { doc_.LoadFile(); rootElement_ = doc_.FirstChildElement(); storeReferences(rootElement_); } catch (TxException& e) { throw AbortException(e.what(), IvwContext); } }
void IvwDeserializer::storeReferences(TxElement* node) { std::string id = node->GetAttributeOrDefault("id", ""); if (id != "") { referenceLookup_[id] = node; } ticpp::Iterator<ticpp::Element> child; for (child = child.begin(node); child != child.end(); child++) { storeReferences(child.Get()); } }
Deserializer::Deserializer(Deserializer& s, bool allowReference) : SerializeBase(s.getFileName(), allowReference) { try { doc_.LoadFile(); rootElement_ = doc_.FirstChildElement(); storeReferences(rootElement_); } catch (TxException& e) { throw AbortException(e.what(), IvwContext); } }
IvwDeserializer::IvwDeserializer(std::istream& stream, const std::string& path, bool allowReference) : IvwSerializeBase(stream, path, allowReference) { try { // Base streamed in the xml data. Get the first node. rootElement_ = doc_.FirstChildElement(); storeReferences(rootElement_); } catch (TxException& e) { throw AbortException(e.what(), IvwContext); } }
void IvwDeserializer::convertVersion(VersionConverter* converter) { converter->convert(rootElement_); // Re-generate the reference table referenceLookup_.clear(); storeReferences(doc_.FirstChildElement()); }