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(); } }
void Group::DeserializeChildren(const wxXmlNode& root) { wxXmlNode *child = root.GetChildren(); while (child != NULL) { wxString uid = XML::GetStringAttribute(*child, wxT("uid")); Serialized *obj = Serialized::GetObjectByUID(uid); obj->Deserialize(*child); Shape *shape = static_cast<Shape *>(obj); shape->SetParent(this); m_children.Add(shape); child = child->GetNext(); } }
void DeleteChild(wxXmlNode& node, wxXmlNodeType type) { wxXmlNode *child = node.GetChildren(); while (child != NULL) { if (child->GetType() == type) { node.RemoveChild(child); DESTROY(child); return; } child = child->GetNext(); } }
void ShaderObject::DeserializeMethods(const wxXmlNode& root) { wxXmlNode *child = root.GetChildren(); while (child != NULL) { if (child->GetName() == wxT("method")) { wxString name = XML::GetStringAttribute(*child, wxT("name")); wxString target = XML::GetStringAttribute(*child, wxT("target")); wxString type = XML::GetStringAttribute(*child, wxT("type")); Method *method = DeserializeMethod(*child); AddMethod(name, target, method); } child = child->GetNext(); } }
void MethodVarParse::Deserialize(const wxXmlNode& root) { m_pattern = root.GetNodeContent(); m_source = Compile(m_pattern); wxXmlNode *child = root.GetChildren(); while (child != NULL) { if (child->GetType() == wxXML_TEXT_NODE || child->GetType() == wxXML_CDATA_SECTION_NODE) { break; } child = child->GetNext(); } child->SetContent(m_source); MethodLua::Deserialize(root); child->SetContent(m_pattern); }
void TwitterUser::ParseXmlNode(const wxXmlNode& node) { wxXmlNode *child = node.GetChildren(); while (child) { const wxString& tagName = child->GetName(); wxString value = child->GetNodeContent(); if (tagName == _T("id")) { id = strtoull(value.mb_str(), NULL, 10); // value.ToULongLong(&id); (GCC doesn't like this) } else if (tagName == _T("name")) { name = value; } else if (tagName == _T("screen_name")) { screen_name = value; } else if (tagName == _T("description")) { description = value; } else if (tagName == _T("location")) { location = value; } else if (tagName == _T("profile_image_url")) { profile_image_url = value; } else if (tagName == _T("url")) { url = value; } else if (tagName == _T("protected")) { protected_ = value == _T("true") ? true : false; } else if (tagName == _T("followers_count")) { value.ToULong(&followers_count); } child = child->GetNext(); } }
SelectionVOI::SelectionVOI( const wxXmlNode selObjNode, const wxString &rootPath ) : SelectionObject( selObjNode ), m_voiSize( 0 ), m_generationThreshold( 0.0f ), m_thresType( THRESHOLD_INVALID ), m_pIsoSurface( NULL ), m_sourceAnatIndex( 0 ) { m_objectType = VOI_TYPE; wxXmlNode *pChildNode = selObjNode.GetChildren(); while( pChildNode != NULL ) { wxString nodeName = pChildNode->GetName(); wxString propVal; if( nodeName == wxT("voi_properties") ) { double temp; pChildNode->GetAttribute( wxT("gen_threshold"), &propVal ); propVal.ToDouble(&temp); m_generationThreshold = temp; pChildNode->GetAttribute( wxT("thres_op_type"), &propVal ); m_thresType = Helper::getThresholdingTypeFromString( propVal ); wxXmlNode *pAnatNode = pChildNode->GetChildren(); if( pAnatNode->GetName() == wxT("generation_anatomy") ) { wxString anatPath = pAnatNode->GetNodeContent(); // Get full path, since this is how it is stored in the dataset. wxFileName fullAnatPath( rootPath + wxFileName::GetPathSeparator() + anatPath ); // Find the anatomy related to this file. vector< Anatomy* > anats = DatasetManager::getInstance()->getAnatomies(); for( vector< Anatomy* >::iterator anatIt( anats.begin() ); anatIt != anats.end(); ++anatIt ) { if( (*anatIt)->getPath() == fullAnatPath.GetFullPath() ) { m_sourceAnatIndex = (*anatIt)->getDatasetIndex(); break; } } if( !m_sourceAnatIndex.isOk() ) { wxString err( wxT("Anatomy: ") ); err << anatPath << wxT(" does not exist when creating VOI called: ") << getName() << wxT("."); throw err; } Anatomy *pCurAnat = dynamic_cast< Anatomy* >( DatasetManager::getInstance()->getDataset( m_sourceAnatIndex ) ); buildSurface( pCurAnat ); } } pChildNode = pChildNode->GetNext(); } }