void Serialized::CreateObjects(const wxXmlNode& root) { wxString uid; if (root.GetPropVal(wxT("uid"), &uid)) { if (m_Objects.find(uid) == m_Objects.end()) { wxString classname = root.GetName(); std::map<wxString, Creator>::iterator it = m_Creators.find(classname); if (it == m_Creators.end()) { THROW(TXT("Class \"%s\" not found."), root.GetName().c_str()); } Serialized *obj = (it->second)(root); m_Objects.insert(std::pair<wxString, Serialized *>(uid, obj)); } } wxXmlNode *child = root.GetChildren(); while (child != NULL) { CreateObjects(*child); child = child->GetNext(); } }
wxString GetStringAttribute(const wxXmlNode& node, const wxString& name, const wxString& def) { wxString value; if (!node.GetPropVal(name, &value)) { if (def == wxEmptyString) { THROW("Couldn't find attribute \"%s\" in element <%s>.", name.c_str(), node.GetName().c_str()); } value = def; } return value; }