void ProjectPanel::buildProjectXml(TiXmlNode *node, HTREEITEM hItem, const TCHAR* fn2write) { TCHAR textBuffer[MAX_PATH]; TVITEM tvItem; tvItem.mask = TVIF_TEXT | TVIF_PARAM; tvItem.pszText = textBuffer; tvItem.cchTextMax = MAX_PATH; for (HTREEITEM hItemNode = _treeView.getChildFrom(hItem); hItemNode != NULL; hItemNode = _treeView.getNextSibling(hItemNode)) { tvItem.hItem = hItemNode; SendMessage(_treeView.getHSelf(), TVM_GETITEM, 0,(LPARAM)&tvItem); if (tvItem.lParam != NULL) { generic_string *fn = (generic_string *)tvItem.lParam; generic_string newFn = getRelativePath(*fn, fn2write); TiXmlNode *fileLeaf = node->InsertEndChild(TiXmlElement(TEXT("File"))); fileLeaf->ToElement()->SetAttribute(TEXT("name"), newFn.c_str()); } else { TiXmlNode *folderNode = node->InsertEndChild(TiXmlElement(TEXT("Folder"))); folderNode->ToElement()->SetAttribute(TEXT("name"), tvItem.pszText); buildProjectXml(folderNode, hItemNode, fn2write); } } }
TiXmlElement* TransformComponent::GenerateXml() { TiXmlElement* pBaseElement = CB_NEW TiXmlElement(GetName()); // initial transform -> position TiXmlElement* pPosition = CB_NEW TiXmlElement("Position"); Vec3 pos(m_Transform.GetPosition()); pPosition->SetAttribute("x", ToStr(pos.x).c_str()); pPosition->SetAttribute("y", ToStr(pos.y).c_str()); pPosition->SetAttribute("z", ToStr(pos.z).c_str()); pBaseElement->LinkEndChild(pPosition); // initial transform -> LookAt TiXmlElement* pDirection = CB_NEW TiXmlElement("YawPitchRoll"); Vec3 orient(m_Transform.GetYawPitchRoll()); orient.x = RADIANS_TO_DEGREES(orient.x); orient.y = RADIANS_TO_DEGREES(orient.y); orient.z = RADIANS_TO_DEGREES(orient.z); pDirection->SetAttribute("x", ToStr(orient.x).c_str()); pDirection->SetAttribute("y", ToStr(orient.y).c_str()); pDirection->SetAttribute("z", ToStr(orient.z).c_str()); pBaseElement->LinkEndChild(pDirection); return pBaseElement; }
//--------------------------------------------------------------------- void XMLSkeletonSerializer::writeSkeleton(const Skeleton* pSkel) { TiXmlElement* rootNode = mXMLDoc->RootElement(); TiXmlElement* bonesElem = rootNode->InsertEndChild(TiXmlElement("bones"))->ToElement(); unsigned short numBones = pSkel->getNumBones(); LogManager::getSingleton().logMessage("There are " + StringConverter::toString(numBones) + " bones."); unsigned short i; for (i = 0; i < numBones; ++i) { LogManager::getSingleton().logMessage(" Exporting Bone number " + StringConverter::toString(i)); Bone* pBone = pSkel->getBone(i); writeBone(bonesElem, pBone); } // Write parents TiXmlElement* hierElem = rootNode->InsertEndChild(TiXmlElement("bonehierarchy"))->ToElement(); for (i = 0; i < numBones; ++i) { Bone* pBone = pSkel->getBone(i); String name = pBone->getName() ; if ((pBone->getParent())!=NULL) // root bone { Bone* pParent = (Bone*)pBone->getParent(); writeBoneParent(hierElem, name, pParent->getName()); } } }
bool wxsMenuItem::OnXmlWrite(TiXmlElement* Element,bool IsXRC,bool IsExtra) { bool Ret = wxsParent::OnXmlWrite(Element,IsXRC,IsExtra); if ( IsXRC ) { // Type information is stored differently switch ( m_Type ) { case Separator: Element->SetAttribute("class","separator"); break; case Break: Element->SetAttribute("class","break"); break; case Radio: Element->InsertEndChild(TiXmlElement("radio"))->ToElement()->InsertEndChild(TiXmlText("1")); break; case Check: Element->InsertEndChild(TiXmlElement("checkable"))->ToElement()->InsertEndChild(TiXmlText("1")); break; case Normal: break; } } return Ret; }
bool wxsToolBarItem::OnXmlWrite(TiXmlElement* Element,bool IsXRC,bool IsExtra) { bool Ret = wxsParent::OnXmlWrite(Element,IsXRC,IsExtra); if ( IsXRC ) { Element->SetAttribute("class","tool"); switch ( m_Type ) { case Separator: Element->SetAttribute("class","separator"); break; case Radio: Element->InsertEndChild(TiXmlElement("radio"))->ToElement()->InsertEndChild(TiXmlText("1")); break; case Check: Element->InsertEndChild(TiXmlElement("check"))->ToElement()->InsertEndChild(TiXmlText("1")); break; case Normal: break; } } return Ret; }
bool ProjectPanel::writeWorkSpace(TCHAR *projectFileName) { //write <NotepadPlus>: use the default file name if new file name is not given const TCHAR * fn2write = projectFileName?projectFileName:_workSpaceFilePath.c_str(); TiXmlDocument projDoc(fn2write); TiXmlNode *root = projDoc.InsertEndChild(TiXmlElement(TEXT("NotepadPlus"))); TCHAR textBuffer[MAX_PATH]; TVITEM tvItem; tvItem.mask = TVIF_TEXT; tvItem.pszText = textBuffer; tvItem.cchTextMax = MAX_PATH; //for each project, write <Project> HTREEITEM tvRoot = _treeView.getRoot(); if (!tvRoot) return false; for (HTREEITEM tvProj = _treeView.getChildFrom(tvRoot); tvProj != NULL; tvProj = _treeView.getNextSibling(tvProj)) { tvItem.hItem = tvProj; SendMessage(_treeView.getHSelf(), TVM_GETITEM, 0,(LPARAM)&tvItem); //printStr(tvItem.pszText); TiXmlNode *projRoot = root->InsertEndChild(TiXmlElement(TEXT("Project"))); projRoot->ToElement()->SetAttribute(TEXT("name"), tvItem.pszText); buildProjectXml(projRoot, tvProj, fn2write); } projDoc.SaveFile(); return true; }
TiXmlElement* TransformComponent::VGenerateXml(void) { TiXmlElement* pBaseElement = AC_NEW TiXmlElement(VGetName()); // initial transform -> position TiXmlElement* pPosition = AC_NEW TiXmlElement("Position"); Vec3 pos(m_transform.GetPosition()); pPosition->SetAttribute("x", ToStr(pos.x).c_str()); pPosition->SetAttribute("y", ToStr(pos.y).c_str()); pPosition->SetAttribute("z", ToStr(pos.z).c_str()); pBaseElement->LinkEndChild(pPosition); // initial transform -> LookAt TiXmlElement* pDirection = AC_NEW TiXmlElement("YawPitchRoll"); Vec3 orient(m_transform.GetYawPitchRoll()); orient.x = RADIANS_TO_DEGREES(orient.x); orient.y = RADIANS_TO_DEGREES(orient.y); orient.z = RADIANS_TO_DEGREES(orient.z); pDirection->SetAttribute("x", ToStr(orient.x).c_str()); pDirection->SetAttribute("y", ToStr(orient.y).c_str()); pDirection->SetAttribute("z", ToStr(orient.z).c_str()); pBaseElement->LinkEndChild(pDirection); /*** // This is not supported yet // initial transform -> position TiXmlElement* pScale = AC_NEW TiXmlElement("Scale"); pPosition->SetAttribute("x", ToStr(m_scale.x).c_str()); pPosition->SetAttribute("y", ToStr(m_scale.y).c_str()); pPosition->SetAttribute("z", ToStr(m_scale.z).c_str()); pBaseElement->LinkEndChild(pScale); **/ return pBaseElement; }
//------------------------------------------------------------------------------ void CToolsHistory::SaveFile( ) { TiXmlDocument aDoc; TiXmlNode* pRootNode = aDoc.InsertEndChild( TiXmlElement( "cache" )); TiXmlNode* pSceneNode = pRootNode->InsertEndChild( TiXmlElement("Scenes")); TiXmlNode* pPathsNode = pRootNode->InsertEndChild( TiXmlElement("paths")); //Scene for( unsigned i=0; i<m_sceneHistory.size(); ++i ) { TiXmlElement aHistoryNode("history"); aHistoryNode.SetAttribute("Scene", m_sceneHistory[i].first.c_str()); aHistoryNode.SetAttribute("path", m_sceneHistory[i].second.c_str()); pSceneNode->InsertEndChild(aHistoryNode); } //path for( unsigned i=0; i<m_pathHistory.size(); ++i ) { TiXmlElement aHistoryNode("history"); aHistoryNode.SetAttribute("path", m_pathHistory[i].c_str()); pPathsNode->InsertEndChild(aHistoryNode); } //default editor TiXmlElement aEditorNode("default_editor"); aEditorNode.SetAttribute("path", m_strDefaultEditor.c_str()); pRootNode->InsertEndChild(aEditorNode); aDoc.SaveFile(m_strCacheFile.c_str()); }
//--------------------------------------------------------------------- void XMLSkeletonSerializer::writeAnimation(TiXmlElement* animsNode, const Animation* anim) { TiXmlElement* animNode = animsNode->InsertEndChild(TiXmlElement("animation"))->ToElement(); animNode->SetAttribute("name", anim->getName()); animNode->SetAttribute("length", StringConverter::toString(anim->getLength())); // Optional base keyframe information if (anim->getUseBaseKeyFrame()) { TiXmlElement* baseInfoNode = animNode->InsertEndChild(TiXmlElement("baseinfo"))->ToElement(); baseInfoNode->SetAttribute("baseanimationname", anim->getBaseKeyFrameAnimationName()); baseInfoNode->SetAttribute("basekeyframetime", StringConverter::toString(anim->getBaseKeyFrameTime())); } // Write all tracks TiXmlElement* tracksNode = animNode->InsertEndChild(TiXmlElement("tracks"))->ToElement(); Animation::NodeTrackIterator trackIt = anim->getNodeTrackIterator(); while (trackIt.hasMoreElements()) { writeAnimationTrack(tracksNode, trackIt.getNext()); } }
void wxsProject::WriteConfiguration(TiXmlElement* element) { TiXmlElement* SmithElement = element->FirstChildElement("wxsmith"); if ( !m_GUI && m_Resources.empty() && m_UnknownConfig.NoChildren() && m_UnknownResources.NoChildren() ) { // Nothing to write if ( SmithElement ) { element->RemoveChild(SmithElement); } return; } if ( !SmithElement ) { SmithElement = element->InsertEndChild(TiXmlElement("wxsmith"))->ToElement(); } SmithElement->Clear(); SmithElement->SetAttribute("version",CurrentVersionStr); // saving GUI item if ( m_GUI ) { TiXmlElement* GUIElement = SmithElement->InsertEndChild(TiXmlElement("gui"))->ToElement(); GUIElement->SetAttribute("name",cbU2C(m_GUI->GetName())); m_GUI->WriteConfig(GUIElement); } // saving resources if ( !m_Resources.empty() || !m_UnknownResources.NoChildren() ) { TiXmlElement* ResElement = SmithElement->InsertEndChild(TiXmlElement("resources"))->ToElement(); size_t Count = m_Resources.Count(); for ( size_t i=0; i<Count; i++ ) { const wxString& Name = m_Resources[i]->GetResourceName(); const wxString& Type = m_Resources[i]->GetResourceType(); TiXmlElement* Element = ResElement->InsertEndChild(TiXmlElement(cbU2C(Type)))->ToElement(); // TODO: Check value returned from WriteConfig m_Resources[i]->WriteConfig(Element); Element->SetAttribute("name",cbU2C(Name)); } // Saving all unknown resources for ( TiXmlNode* Node = m_UnknownResources.FirstChild(); Node; Node=Node->NextSibling() ) { SmithElement->InsertEndChild(*Node); } } // Saving all unknown configuration nodes for ( TiXmlNode* Node = m_UnknownConfig.FirstChild(); Node; Node=Node->NextSibling() ) { SmithElement->InsertEndChild(*Node); } }
static int _Encode( TiXmlNode *pNode, sqbind::CSqMulti *pData, int bIndexed, int nDepth = 0 ) {_STT(); if ( !pNode || !pData ) return 0; // For each element for ( sqbind::CSqMulti::iterator it = pData->list().begin(); it != pData->list().end(); it++ ) { // Key name? if ( it->first == oexT( "$" ) ) ; // Ignore else { // Is it just an attribute if ( nDepth && !it->second.size() ) { ((TiXmlElement*)pNode)->SetAttribute( oexStrToMbPtr( it->first.c_str() ), oexStrToMbPtr( it->second.str().c_str() ) ); } // end else if // Handle nested tag else { TiXmlNode *pItem = oexNULL; if ( !bIndexed ) { if ( it->first.length() ) pItem = pNode->InsertEndChild( TiXmlElement( oexStrToMbPtr( it->first.c_str() ) ) ); } // end if else if ( it->second.isset( oexT( "$" ) ) && it->second[ oexT( "$" ) ].str().length() ) pItem = pNode->InsertEndChild( TiXmlElement( oexStrToMbPtr( it->second[ oexT( "$" ) ].str().c_str() ) ) ); // Did we get an item? if ( pItem ) { // Default value? if ( it->second.str().length() ) pItem->InsertEndChild( TiXmlText( oexStrToMbPtr( it->second.str().c_str() ) ) ); // Encode sub items _Encode( pItem, &it->second, bIndexed, nDepth + 1 ); } // end if } // end else if } // end if } // end for return 1; }
void GridRenderComponent::CreateInheritedXmlElements(TiXmlElement* pBaseElement) { TiXmlElement* pTextureNode = CB_NEW TiXmlElement("Texture"); TiXmlText* pTextureText = CB_NEW TiXmlText(m_TextureResource.c_str()); pTextureNode->LinkEndChild(pTextureText); pBaseElement->LinkEndChild(pTextureNode); TiXmlElement* pDivisionNode = CB_NEW TiXmlElement("Division"); TiXmlText* pDivisionText = CB_NEW TiXmlText(ToStr(m_Squares).c_str()); pDivisionNode->LinkEndChild(pDivisionText); pBaseElement->LinkEndChild(pDivisionNode); }
void wxsVersionConverter::GatherExtraFromOldResourceReq(TiXmlElement* Object,TiXmlElement* Extra,bool Root) const { // The only extra information in old wxSmith was: // * variable / member attributes of <object> node // * event handlers enteries // These fields are extracted and put into wxs file if ( !strcmp(Object->Value(),"object") ) { if ( Object->Attribute("class") && (Root || Object->Attribute("name")) ) { TiXmlElement* ThisExtra = 0; // Checking if we got variable name if ( Object->Attribute("variable") && Object->Attribute("member") ) { ThisExtra = Extra->InsertEndChild(TiXmlElement("object"))->ToElement(); ThisExtra->SetAttribute("variable",Object->Attribute("variable")); ThisExtra->SetAttribute("member",Object->Attribute("member")); } // Checking for event handlers for ( TiXmlElement* Handler = Object->FirstChildElement("handler"); Handler; Handler = Handler->NextSiblingElement("handler") ) { if ( !ThisExtra ) { ThisExtra = Extra->InsertEndChild(TiXmlElement("object"))->ToElement(); } ThisExtra->InsertEndChild(*Handler); } if ( ThisExtra ) { if ( Root ) { ThisExtra->SetAttribute("root","1"); } else { ThisExtra->SetAttribute("name",Object->Attribute("name")); ThisExtra->SetAttribute("class",Object->Attribute("class")); } } } } for ( TiXmlElement* Child = Object->FirstChildElement(); Child; Child = Child->NextSiblingElement() ) { GatherExtraFromOldResourceReq(Child,Extra,false); } }
void GupExtraOptions::writeProxyInfo(const char *fn, const char *proxySrv, long port) { TiXmlDocument newProxySettings(fn); TiXmlNode *root = newProxySettings.InsertEndChild(TiXmlElement("GUPOptions")); TiXmlNode *proxy = root->InsertEndChild(TiXmlElement("Proxy")); TiXmlNode *server = proxy->InsertEndChild(TiXmlElement("server")); server->InsertEndChild(TiXmlText(proxySrv)); TiXmlNode *portNode = proxy->InsertEndChild(TiXmlElement("port")); char portStr[10]; sprintf(portStr, "%d", port); portNode->InsertEndChild(TiXmlText(portStr)); newProxySettings.SaveFile(); }
ConfigManager* CfgMgrBldr::Build(const wxString& name_space) { if (name_space.IsEmpty()) cbThrow(_T("You attempted to get a ConfigManager instance without providing a namespace.")); wxCriticalSectionLocker locker(cs); NamespaceMap::iterator it = namespaces.find(name_space); if (it != namespaces.end()) return it->second; TiXmlElement* docroot; if (name_space.StartsWith(_T("volatile:"))) { if (!volatile_doc) { volatile_doc = new TiXmlDocument(); volatile_doc->InsertEndChild(TiXmlElement("CodeBlocksConfig")); volatile_doc->SetCondenseWhiteSpace(false); } docroot = volatile_doc->FirstChildElement("CodeBlocksConfig"); } else { docroot = doc->FirstChildElement("CodeBlocksConfig"); if (!docroot) { wxString err(_("Fatal error parsing supplied configuration file.\nParser error message:\n")); err << wxString::Format(_T("%s\nAt row %d, column: %d."), cbC2U(doc->ErrorDesc()).c_str(), doc->ErrorRow(), doc->ErrorCol()); cbThrow(err); } } TiXmlElement* root = docroot->FirstChildElement(cbU2C(name_space)); if (!root) // namespace does not exist { docroot->InsertEndChild(TiXmlElement(cbU2C(name_space))); root = docroot->FirstChildElement(cbU2C(name_space)); } if (!root) // now what! cbThrow(_T("Unable to create namespace in document tree (actually not possible..?)")); ConfigManager *c = new ConfigManager(root); namespaces[name_space] = c; return c; }
CfgMgrBldr::CfgMgrBldr() : doc(nullptr), volatile_doc(nullptr), r(false) { TiXmlBase::SetCondenseWhiteSpace(false); wxString personality(Manager::Get()->GetPersonalityManager()->GetPersonality()); if (personality.StartsWith(_T("http://"))) { SwitchToR(personality); return; } cfg = FindConfigFile(personality + _T(".conf")); if (cfg.IsEmpty()) { #ifdef __WINDOWS__ cfg = GetPortableConfigDir() + wxFILE_SEP_PATH + personality + _T(".conf"); #else cfg = wxStandardPathsBase::Get().GetUserDataDir() + wxFILE_SEP_PATH + personality + _T(".conf"); #endif doc = new TiXmlDocument(); doc->InsertEndChild(TiXmlDeclaration("1.0", "UTF-8", "yes")); doc->InsertEndChild(TiXmlElement("CodeBlocksConfig")); doc->FirstChildElement("CodeBlocksConfig")->SetAttribute("version", CfgMgrConsts::version); return; } SwitchTo(cfg); }
TiXmlElement* BaseScriptComponent::VGenerateXml(void) { TiXmlElement* pBaseElement = AC_NEW TiXmlElement(VGetName()); // ScriptObject TiXmlElement* pScriptObjectElement = AC_NEW TiXmlElement("ScriptObject"); if (!m_scriptObjectName.empty()) pScriptObjectElement->SetAttribute("var", m_scriptObjectName.c_str()); if (!m_constructorName.empty()) pScriptObjectElement->SetAttribute("constructor", m_constructorName.c_str()); if (!m_destructorName.empty()) pScriptObjectElement->SetAttribute("destructor", m_destructorName.c_str()); pBaseElement->LinkEndChild(pScriptObjectElement); return pBaseElement; }
int UpdateName2ID(map<string,int> *pmapName2ID,TiXmlDocument *pXmlDocName2ID,TiXmlElement *pXmlEleLayer,int & nCurID) { int nRet=0; const char * strName=pXmlEleLayer->Attribute("name"); int nID=0; pXmlEleLayer->Attribute("id",&nID); if(strName && pmapName2ID->find(strName)==pmapName2ID->end()) { TiXmlElement pNewNamedID=TiXmlElement("name2id"); pNewNamedID.SetAttribute("name",strName); if(nID==0) nID=++nCurID; pNewNamedID.SetAttribute("id",nID); const char * strRemark=pXmlEleLayer->Attribute("fun"); if(strRemark) { pNewNamedID.SetAttribute("remark",strRemark); } pXmlDocName2ID->InsertEndChild(pNewNamedID); (*pmapName2ID)[strName]=nID; nRet++; } TiXmlElement *pXmlChild=pXmlEleLayer->FirstChildElement(); if(pXmlChild) nRet+=UpdateName2ID(pmapName2ID,pXmlDocName2ID,pXmlChild,nCurID); TiXmlElement *pXmlSibling=pXmlEleLayer->NextSiblingElement(); if(pXmlSibling) nRet+=UpdateName2ID(pmapName2ID,pXmlDocName2ID,pXmlSibling,nCurID); return nRet; }
CfgMgrBldr::CfgMgrBldr() : doc(nullptr), volatile_doc(nullptr), r(false) { ConfigManager::MigrateFolders(); TiXmlBase::SetCondenseWhiteSpace(false); wxString personality(Manager::Get()->GetPersonalityManager()->GetPersonality()); if (personality.StartsWith(_T("http://"))) { SwitchToR(personality); return; } cfg = FindConfigFile(personality + _T(".conf")); if (cfg.IsEmpty()) { cfg = ConfigManager::GetConfigFolder() + wxFILE_SEP_PATH + personality + _T(".conf"); doc = new TiXmlDocument(); doc->InsertEndChild(TiXmlDeclaration("1.0", "UTF-8", "yes")); doc->InsertEndChild(TiXmlElement("CodeBlocksConfig")); doc->FirstChildElement("CodeBlocksConfig")->SetAttribute("version", CfgMgrConsts::version); return; } SwitchTo(cfg); }
void COptions::SetXmlValue(unsigned int nID, wxString value) { if (!m_pXmlFile) return; // No checks are made about the validity of the value, that's done in SetOption char *utf8 = ConvUTF8(value); if (!utf8) return; TiXmlElement *settings = m_pXmlFile->GetElement()->FirstChildElement("Settings"); if (!settings) { TiXmlNode *node = m_pXmlFile->GetElement()->InsertEndChild(TiXmlElement("Settings")); if (!node) { delete [] utf8; return; } settings = node->ToElement(); if (!settings) { delete [] utf8; return; } } else { TiXmlNode *node = 0; while ((node = settings->IterateChildren("Setting", node))) { TiXmlElement *setting = node->ToElement(); if (!setting) continue; const char *attribute = setting->Attribute("name"); if (!attribute) continue; if (strcmp(attribute, options[nID].name)) continue; setting->RemoveAttribute("type"); setting->Clear(); setting->SetAttribute("type", (options[nID].type == string) ? "string" : "number"); setting->InsertEndChild(TiXmlText(utf8)); delete [] utf8; return; } } wxASSERT(options[nID].name[0]); TiXmlElement setting("Setting"); setting.SetAttribute("name", options[nID].name); setting.SetAttribute("type", (options[nID].type == string) ? "string" : "number"); setting.InsertEndChild(TiXmlText(utf8)); settings->InsertEndChild(setting); delete [] utf8; }
void CEditInfo::saveReference() { if ( m_ref_parent_set.empty() ) return; TiXmlNode* ref_root_node = m_xml_doc.FirstChild(REF_ROOT_NODE); if ( !ref_root_node ) ref_root_node = m_xml_doc.InsertEndChild(TiXmlElement(REF_ROOT_NODE)); // get existed reference info, used to check multiple reference. ReferenceSet exist_ref_set; TiXmlElement* cur_ref_elem = ref_root_node->FirstChildElement(REF_ELEMENT_NODE); while ( cur_ref_elem != 0 ) { exist_ref_set.insert(cur_ref_elem->GetText()); cur_ref_elem = cur_ref_elem->NextSiblingElement(); } // add reference info and check multiple reference. ReferenceSet::iterator ref_iter = m_ref_parent_set.begin(); for ( ; ref_iter != m_ref_parent_set.end(); ++ref_iter ) { string ref_parent = *ref_iter; if ( exist_ref_set.find(ref_parent) != exist_ref_set.end() ) continue; TiXmlElement ref_element(REF_ELEMENT_NODE); TiXmlText ref_text(ref_parent); ref_element.InsertEndChild(ref_text); ref_root_node->InsertEndChild(ref_element); } }
TiXmlElement* CImportDialog::GetFolderWithName(TiXmlElement* pElement, const wxString& name) { TiXmlElement* pChild; for (pChild = pElement->FirstChildElement("Server"); pChild; pChild = pChild->NextSiblingElement("Server")) { wxString childName = GetTextElement(pChild); childName.Trim(true); childName.Trim(false); if (!name.CmpNoCase(childName)) return 0; } for (pChild = pElement->FirstChildElement("Folder"); pChild; pChild = pChild->NextSiblingElement("Folder")) { wxString childName = GetTextElement(pChild); childName.Trim(true); childName.Trim(false); if (!name.CmpNoCase(childName)) return pChild; } pChild = pElement->InsertEndChild(TiXmlElement("Folder"))->ToElement(); AddTextElement(pChild, name); return pChild; }
void wxWidgetsGUI::OnWriteConfig(TiXmlElement* element) { element->SetAttribute("src",cbU2C(m_AppFile)); element->SetAttribute("main",cbU2C(m_MainResource)); if ( m_CallInitAll && m_CallInitAllNecessary ) { element->SetAttribute("init_handlers","necessary"); } else if ( m_CallInitAll ) { element->SetAttribute("init_handlers","always"); } else { element->SetAttribute("init_handlers","never"); } element->SetAttribute("language",cbU2C(wxsCodeMarks::Name(m_AppLanguage))); for ( size_t i=0; i<m_LoadedResources.GetCount(); ++i ) { TiXmlElement* LoadRes = element->InsertEndChild(TiXmlElement("load_resource"))->ToElement(); LoadRes->SetAttribute("file",cbU2C(m_LoadedResources[i])); } }
bool wxsCustomWidget::OnXmlWrite(TiXmlElement* Element,bool IsXRC,bool IsExtra) { bool Ret = wxsItem::OnXmlWrite(Element,IsXRC,IsExtra); if ( IsXRC ) { if ( !(GetPropertiesFlags() & flSource) ) { Element->SetAttribute("class",cbU2C(GetUserClass())); Element->RemoveAttribute("subclass"); Element->InsertEndChild(TiXmlElement("style"))->InsertEndChild(TiXmlText(cbU2C(m_Style))); for ( TiXmlElement* Child = m_XmlDataDoc.FirstChildElement(); Child; Child = Child->NextSiblingElement() ) { // Skipping all standard elements wxString Name = cbC2U(Child->Value()); if ( Name != _T("pos") && Name != _T("size") && Name != _T("style") && Name != _T("enabled") && Name != _T("focused") && Name != _T("hidden") && Name != _T("fg") && Name != _T("bg") && Name != _T("font") && Name != _T("handler") ) { Element->InsertEndChild(*Child); } } } } return Ret; }
//--------------------------------------------------------------------- void XMLSkeletonSerializer::writeBone(TiXmlElement* bonesElement, const Bone* pBone) { TiXmlElement* boneElem = bonesElement->InsertEndChild(TiXmlElement("bone"))->ToElement(); // Bone name & handle boneElem->SetAttribute("id", StringConverter::toString(pBone->getHandle())); boneElem->SetAttribute("name", pBone->getName()); // Position TiXmlElement* subNode = boneElem->InsertEndChild(TiXmlElement("position"))->ToElement(); Vector3 pos = pBone->getPosition(); subNode->SetAttribute("x", StringConverter::toString(pos.x)); subNode->SetAttribute("y", StringConverter::toString(pos.y)); subNode->SetAttribute("z", StringConverter::toString(pos.z)); // Orientation subNode = boneElem->InsertEndChild(TiXmlElement("rotation"))->ToElement(); // Show Quaternion as angle / axis Radian angle; Vector3 axis; pBone->getOrientation().ToAngleAxis(angle, axis); TiXmlElement* axisNode = subNode->InsertEndChild(TiXmlElement("axis"))->ToElement(); subNode->SetAttribute("angle", StringConverter::toString(angle.valueRadians())); axisNode->SetAttribute("x", StringConverter::toString(axis.x)); axisNode->SetAttribute("y", StringConverter::toString(axis.y)); axisNode->SetAttribute("z", StringConverter::toString(axis.z)); // Scale optional Vector3 scale = pBone->getScale(); if (scale != Vector3::UNIT_SCALE) { TiXmlElement* scaleNode = boneElem->InsertEndChild(TiXmlElement("scale"))->ToElement(); scaleNode->SetAttribute("x", StringConverter::toString(scale.x)); scaleNode->SetAttribute("y", StringConverter::toString(scale.y)); scaleNode->SetAttribute("z", StringConverter::toString(scale.z)); } }
TiXmlElement* LuaScriptComponent::GenerateXml() { // serialize this component to an xml element TiXmlElement* pBaseElement = CB_NEW TiXmlElement(GetName()); TiXmlElement* pScriptObjectElement = CB_NEW TiXmlElement("ScriptObject"); if (!m_ScriptObjectName.empty()) pScriptObjectElement->SetAttribute("var", m_ScriptObjectName.c_str()); if (!m_ConstructorName.empty()) pScriptObjectElement->SetAttribute("constructor", m_ConstructorName.c_str()); if (!m_DestructorName.empty()) pScriptObjectElement->SetAttribute("destructor", m_DestructorName.c_str()); pBaseElement->LinkEndChild(pScriptObjectElement); return pBaseElement; }
TiXmlElement* Vec2::GernerateXML( void ) const { TiXmlElement* pRetNode = ENG_NEW TiXmlElement( "Vector2" ); pRetNode->SetAttribute( "x", ToStr( x ).c_str() ); pRetNode->SetAttribute( "y", ToStr( y ).c_str() ); return pRetNode; }
void SkyRenderComponent::CreateInheritedXmlElements(TiXmlElement* pBaseElement) { TiXmlElement* pTextureNode = CB_NEW TiXmlElement("Texture"); TiXmlText* pTextureText = CB_NEW TiXmlText(m_TextureResource.c_str()); pTextureNode->LinkEndChild(pTextureText); pBaseElement->LinkEndChild(pTextureNode); }
TiXmlElement* ConfigManager::GetUniqElement(TiXmlElement* p, const wxString& q) { TiXmlElement* r; if ((r = p->FirstChildElement(cbU2C(q)))) return r; return (TiXmlElement*)(p->InsertEndChild(TiXmlElement(cbU2C(q)))); }
void SphereRenderComponent::CreateInheritedXmlElements(TiXmlElement* pBaseElement) { TiXmlElement* pMesh = CB_NEW TiXmlElement("Sphere"); pMesh->SetAttribute("radius", ToStr(m_Radius).c_str()); pMesh->SetAttribute("segments", ToStr(m_Segments).c_str()); pBaseElement->LinkEndChild(pMesh); }