Esempio n. 1
0
bool cSubMenu::SaveXml(char *fname )
{

    if (_fname)
    {
        TiXmlDocument xml = TiXmlDocument(fname );
        TiXmlComment  comment;
        comment.SetValue(
            " Mini-VDR cSetupConfiguration File\n"
            " (c) Ralf Dotzert\n"
            "\n\n"
            " for Example see vdr-menu.xml.example\n\n"
        );

        TiXmlElement root("menus");
        root.SetAttribute("suffix",   _menuSuffix);
        for (cSubMenuNode *node = _menuTree.First(); node; node = _menuTree.Next(node))
            node->SaveXml(&root);

        if (xml.InsertEndChild(comment) != NULL &&
                xml.InsertEndChild(root) != NULL)
        {
            return xml.SaveFile(fname);
        }
    }
    else
    {
        return false;
    }

    return true;
}
bool Wiinnertag::CreateExample(const string &filepath)
{
	if(filepath.size() == 0)
		return false;

	CreateSubfolder(filepath.c_str());

	string fullpath = filepath;
	if(fullpath[fullpath.size()-1] != '/')
		fullpath += '/';
	fullpath += "Wiinnertag.xml";

	TiXmlDocument xmlDoc;

	TiXmlDeclaration declaration("1.0", "UTF-8", "");
	xmlDoc.InsertEndChild(declaration);

	TiXmlElement Tag("Tag");
	Tag.SetAttribute("URL", "http://www.wiinnertag.com/wiinnertag_scripts/update_sign.php?key={KEY}&game_id={ID6}");
	Tag.SetAttribute("Key", "1234567890");
	xmlDoc.InsertEndChild(Tag);

	xmlDoc.SaveFile(fullpath);

	return true;
}
Esempio n. 3
0
void CUIDesignerView::OnEditCopy()
{
	ASSERT(m_cfUI != NULL);

	TiXmlDocument xmlDoc;
	TiXmlDeclaration Declaration("1.0","utf-8","yes");
	xmlDoc.InsertEndChild(Declaration);
	TiXmlElement* pCopyElm = new TiXmlElement("UICopy");
	CopyUI(pCopyElm);
	xmlDoc.InsertEndChild(*pCopyElm);
	TiXmlPrinter printer;
	xmlDoc.Accept(&printer);
	delete pCopyElm;
	CSharedFile file(GMEM_MOVEABLE, printer.Size() + 1);
	file.Write(printer.CStr(), printer.Size());
	file.Write("\0", 1);
	COleDataSource* pDataSource = NULL;
	TRY
	{
		pDataSource = new COleDataSource;
		pDataSource->CacheGlobalData(m_cfUI, file.Detach());
		pDataSource->SetClipboard();
	}
	CATCH_ALL(e)
	{
		delete pDataSource;
		THROW_LAST();
	}
	END_CATCH_ALL
}
bool wxsItemResData::SaveInMixedMode()
{
    // Should be currently up to date, but just for sure udpating it once again
    if ( !RebuildXrcFile() ) return false;

    // Storing extra data into Wxs file

    TiXmlDocument Doc;

    Doc.InsertEndChild(TiXmlDeclaration("1.0","utf-8",""));
    TiXmlElement* wxSmithNode = Doc.InsertEndChild(TiXmlElement("wxsmith"))->ToElement();

    // Now storing all extra data
    TiXmlElement* Extra = wxSmithNode->InsertEndChild(TiXmlElement("resource_extra"))->ToElement();
    SaveExtraDataReq(m_RootItem,Extra);
    for ( int i=0; i<GetToolsCount(); i++ )
    {
        SaveExtraDataReq(m_Tools[i],Extra);
    }

    if ( TinyXML::SaveDocument(m_WxsFileName,&Doc) )
    {
        m_Undo.Saved();
        return true;
    }
    return false;
}
Esempio n. 5
0
void CALLBACK CUICommandHistory::UIAdd(TiXmlNode* pNode)
{
	TiXmlElement* pElement = pNode->ToElement();
	CStringA strParentName = pElement->Attribute("parentname");
	pElement->RemoveAttribute("parentname");
	if(strParentName.IsEmpty())
		return;

	CUIDesignerView* pUIView = g_pMainFrame->GetActiveUIView();
	CPaintManagerUI* pManager = pUIView->GetPaintManager();
	CControlUI* pParentControl = pManager->FindControl(StringConvertor::Utf8ToWide(strParentName));
	if(pParentControl == NULL)
		return;

	TiXmlDocument xmlDoc;
	TiXmlDeclaration Declaration("1.0","utf-8","yes");
	xmlDoc.InsertEndChild(Declaration);
	TiXmlElement* pRootElem = new TiXmlElement("UIAdd");
	pRootElem->InsertEndChild(*pElement);
	xmlDoc.InsertEndChild(*pRootElem);
	TiXmlPrinter printer;
	xmlDoc.Accept(&printer);
	delete pRootElem;

	CDialogBuilder builder;
	CControlUI* pRoot=builder.Create(StringConvertor::Utf8ToWide(printer.CStr()), (UINT)0, NULL, pManager);
 	if(pRoot)
		pUIView->RedoUI(pRoot, pParentControl);
}
Esempio n. 6
0
bool CPluginSettings::Load(const CURL& url)
{
  m_url = url;  

  // create the users filepath
  m_userFileName.Format("P:\\plugin_data\\%s\\%s", url.GetHostName().c_str(), url.GetFileName().c_str());
  CUtil::RemoveSlashAtEnd(m_userFileName);
  CUtil::AddFileToFolder(m_userFileName, "settings.xml", m_userFileName);
  
  // Create our final path
  CStdString pluginFileName = "Q:\\plugins\\";

  CUtil::AddFileToFolder(pluginFileName, url.GetHostName(), pluginFileName);
  CUtil::AddFileToFolder(pluginFileName, url.GetFileName(), pluginFileName);

  // Replace the / at end, GetFileName() leaves a / at the end
  pluginFileName.Replace("/", "\\");

  CUtil::AddFileToFolder(pluginFileName, "resources", pluginFileName);
  CUtil::AddFileToFolder(pluginFileName, "settings.xml", pluginFileName);

  pluginFileName = _P(pluginFileName);
  m_userFileName = _P(m_userFileName);

  if (!m_pluginXmlDoc.LoadFile(pluginFileName.c_str()))
  {
    CLog::Log(LOGERROR, "Unable to load: %s, Line %d\n%s", pluginFileName.c_str(), m_pluginXmlDoc.ErrorRow(), m_pluginXmlDoc.ErrorDesc());
    return false;
  }
  
  // Make sure that the plugin XML has the settings element
  TiXmlElement *setting = m_pluginXmlDoc.RootElement();
  if (!setting || strcmpi(setting->Value(), "settings") != 0)
  {
    CLog::Log(LOGERROR, "Error loading Settings %s: cannot find root element 'settings'", pluginFileName.c_str());
    return false;
  }  
  
  // Load the user saved settings. If it does not exist, create it
  if (!m_userXmlDoc.LoadFile(m_userFileName.c_str()))
  {
    TiXmlDocument doc;
    TiXmlDeclaration decl("1.0", "UTF-8", "yes");
    doc.InsertEndChild(decl);
    
    TiXmlElement xmlRootElement("settings");
    doc.InsertEndChild(xmlRootElement);
    
    m_userXmlDoc = doc;
    
    // Don't worry about the actual settings, they will be set when the user clicks "Ok"
    // in the settings dialog
  }

  return true;
}
bool wxsItemResData::RebuildXrcFile()
{
    // First - opening file
    TiXmlDocument Doc;
    TiXmlElement* Resources = nullptr;
    TiXmlElement* Object = nullptr;

    if ( TinyXML::LoadDocument(m_XrcFileName,&Doc) )
    {
        Resources = Doc.FirstChildElement("resource");
    }

    if ( !Resources )
    {
        Doc.Clear();
        Doc.InsertEndChild(TiXmlDeclaration("1.0","utf-8",""));
        Resources = Doc.InsertEndChild(TiXmlElement("resource"))->ToElement();
        Resources->SetAttribute("xmlns","http://www.wxwidgets.org/wxxrc");
    }

    // Searching for object representing this resource
    for ( Object = Resources->FirstChildElement("object"); Object; Object = Object->NextSiblingElement("object") )
    {
        if ( cbC2U(Object->Attribute("name")) == m_ClassName )
        {
            Object->Clear();
            while ( Object->FirstAttribute() )
            {
                Object->RemoveAttribute(Object->FirstAttribute()->Name());
            }
            break;
        }
    }

    if ( !Object )
    {
        Object = Resources->InsertEndChild(TiXmlElement("object"))->ToElement();
    }

    // The only things left are: to dump item into object ...
    m_RootItem->XmlWrite(Object,true,false);
    Object->SetAttribute("name",cbU2C(m_ClassName));
    for ( int i=0; i<GetToolsCount(); i++ )
    {
        TiXmlElement* ToolElement = Object->InsertEndChild(TiXmlElement("object"))->ToElement();
        m_Tools[i]->XmlWrite(ToolElement,true,false);
    }

    // ... and save back the file
    return TinyXML::SaveDocument(m_XrcFileName,&Doc);
}
Esempio n. 8
0
bool TracksXml::SaveXml(Ogre::String file)
{
	TiXmlDocument xml;	TiXmlElement root("tracks");

	for (int i=0; i < trks.size(); ++i)
	{
		const TrackInfo& t = trks[i];
		TiXmlElement trk("track");

		trk.SetAttribute("n",			toStrC( t.n ));
		trk.SetAttribute("name",		t.name.c_str());
		trk.SetAttribute("created",		dt2s(t.created).c_str());
		trk.SetAttribute("crtver",		toStrC( t.crtver ));
		trk.SetAttribute("modified",	dt2s(t.modified).c_str());
		trk.SetAttribute("scenery",		t.scenery.c_str());
		trk.SetAttribute("author",		t.author.c_str());
		
		trk.SetAttribute("fluids",		toStrC( t.fluids ));
		trk.SetAttribute("bumps",		toStrC( t.bumps ));		trk.SetAttribute("jumps",		toStrC( t.jumps ));
		trk.SetAttribute("loops",		toStrC( t.loops ));		trk.SetAttribute("pipes",		toStrC( t.pipes ));
		trk.SetAttribute("banked",		toStrC( t.banked ));	trk.SetAttribute("frenzy",		toStrC( t.frenzy ));
		trk.SetAttribute("long",		toStrC( t.longn ));

		trk.SetAttribute("diff",		toStrC( t.diff ));
		trk.SetAttribute("rating",		toStrC( t.rating ));
		trk.SetAttribute("rateuser",	toStrC( t.rateuser ));
		trk.SetAttribute("drivenlaps",	toStrC( t.drivenlaps ));
		root.InsertEndChild(trk);
	}

	xml.InsertEndChild(root);
	return xml.SaveFile(file.c_str());
}
Esempio n. 9
0
void WriteToXml(string& strXml, vector<bool>& vecType,string& FileName)
{
	COriFileOperate oriFile(FileName);
	size_t nVecSize = vecType.size();
	if (strXml.find("chinese_simple") != -1)
	{
		for (size_t i=1;i<nVecSize;++i)
		{
			vecType[i] = false;
		}
	}
	char* szNumOrStrInfo = new char[nVecSize+1];
	for (size_t i = 0; i < nVecSize; i++)
	{
		if (vecType[i])
		{
			szNumOrStrInfo[i] = 'n';
		}
		else
		{
			szNumOrStrInfo[i] = 's';
		}
	}
	szNumOrStrInfo[nVecSize] = '\0';
	TiXmlDocument* pXmlDoc = new TiXmlDocument;
	pXmlDoc->InsertEndChild(TiXmlElement("config"));
	TiXmlNode* pXmlNode = pXmlDoc->FirstChild("config");
	pXmlNode->InsertEndChild(TiXmlElement("TableType"));
	TiXmlElement* pXmlElem = pXmlNode->FirstChildElement("TableType");
	pXmlElem->InsertEndChild(TiXmlText("S"));
	string str = szNumOrStrInfo;
	string str1 = oriFile.GetDataByRowCol(0,0);
	transform(str1.begin(),str1.end(),str1.begin(),toupper);
	for(uint32 i=1;i<=str.size();i++)
	{
		TiXmlElement* cxn = new TiXmlElement("Col");
		pXmlNode->LinkEndChild(cxn);
	//	cxn->SetAttribute("ColNum",i);
		if(str1!="NOTE:")
		{
			cxn->SetAttribute("Name",oriFile.GetDataByRowCol(0,i-1).c_str());
		}
		else
		{
			cxn->SetAttribute("Name",oriFile.GetDataByRowCol(1,i-1).c_str());
		}
		string ss;
		stringstream temp;
		temp<<szNumOrStrInfo[i-1];
		temp>>ss;
		cxn->SetAttribute("Type",ss);
	}

	pXmlDoc->SaveFile(strXml);

	delete pXmlDoc;
	pXmlDoc = NULL;
	delete[] szNumOrStrInfo;
	szNumOrStrInfo = NULL;
}
bool CWebBrowserDownloadHandler::SaveDownloadHistory()
{
  TiXmlDocument xmlDoc;
  TiXmlElement xmlRootElement("downloadhistory");
  TiXmlNode *pRoot = xmlDoc.InsertEndChild(xmlRootElement);
  if (pRoot == nullptr)
    return false;

  TiXmlElement xmlDownloadHistory("histories");
  TiXmlNode* pHistoriesNode = pRoot->InsertEndChild(xmlDownloadHistory);
  if (pHistoriesNode)
  {
    for (const auto& entry : m_finishedDownloads)
    {
      TiXmlElement xmlSetting("history");
      TiXmlNode* pHistoryNode = pHistoriesNode->InsertEndChild(xmlSetting);
      if (pHistoryNode)
      {
        XMLUtils::SetString(pHistoryNode, "name", entry.second->GetName().c_str());
        XMLUtils::SetString(pHistoryNode, "path", entry.second->GetPath().c_str());
        XMLUtils::SetString(pHistoryNode, "url", entry.second->GetURL().c_str());
        XMLUtils::SetLong(pHistoryNode, "time", static_cast<long>(entry.second->GetDownloadTime()));
      }
    }
  }

  std::string strSettingsFile = kodi::GetBaseUserPath("download_history.xml");
  if (!xmlDoc.SaveFile(strSettingsFile))
  {
    kodi::Log(ADDON_LOG_ERROR, "failed to write download history data");
    return false;
  }

  return true;
}
Esempio n. 11
0
// ----------------------------------------------------------------------------
//
void TrackInfoCacheFile::write( AudioTrackInfoCache& cache )
{
    TiXmlDocument doc;

    TiXmlElement root( "audio_track_info" );

    for (  AudioTrackInfoCache::value_type pair : cache ) {
        TiXmlElement entry( "entry" );
        add_text_element( entry, "link", pair.first );
        add_text_element( entry, "id", pair.second.id );
        add_text_element( entry, "song_type", pair.second.song_type );

        TiXmlElement attributes( "attrs" );
        add_attribute( attributes, "key", pair.second.key );
        add_attribute( attributes, "mode", pair.second.mode );
        add_attribute( attributes, "time_signature", pair.second.time_signature );
        add_attribute( attributes, "energy", pair.second.energy );
        add_attribute( attributes, "liveness", pair.second.liveness );
        add_attribute( attributes, "tempo", pair.second.tempo );
        add_attribute( attributes, "speechiness", pair.second.speechiness );
        add_attribute( attributes, "acousticness", pair.second.acousticness );
        add_attribute( attributes, "instrumentalness", pair.second.instrumentalness );
        add_attribute( attributes, "duration", pair.second.duration );
        add_attribute( attributes, "loudness", pair.second.loudness );
        add_attribute( attributes, "valence", pair.second.valence );
        add_attribute( attributes, "danceability", pair.second.danceability );

        entry.InsertEndChild( attributes );
        root.InsertEndChild( entry );
    }

    doc.InsertEndChild( root ); 
    doc.SaveFile( m_filename );
}
Esempio n. 12
0
//------------------------------------------------------------------------------
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());
}
bool CButtonMapXml::Save(void) const
{
  TiXmlDocument xmlFile;

  TiXmlDeclaration* decl = new TiXmlDeclaration("1.0", "", "");
  xmlFile.LinkEndChild(decl);

  TiXmlElement rootElement(BUTTONMAP_XML_ROOT);
  TiXmlNode* root = xmlFile.InsertEndChild(rootElement);
  if (root == NULL)
    return false;

  TiXmlElement* pElem = root->ToElement();
  if (!pElem)
    return false;

  TiXmlElement deviceElement(DEVICES_XML_ELEM_DEVICE);
  TiXmlNode* deviceNode = pElem->InsertEndChild(deviceElement);
  if (deviceNode == NULL)
    return false;

  TiXmlElement* deviceElem = deviceNode->ToElement();
  if (deviceElem == NULL)
    return false;

  CDeviceXml::Serialize(m_device, deviceElem);

  if (!SerializeButtonMaps(deviceElem))
    return false;

  return xmlFile.SaveFile(m_strResourcePath);
}
Esempio n. 14
0
//  Save progress
bool ProgressXml::SaveXml(std::string file)
{
	TiXmlDocument xml;	TiXmlElement root("progress");

	for (int i=0; i < chs.size(); ++i)
	{
		const ProgressChamp& pc = chs[i];
		TiXmlElement eCh("champ");
			eCh.SetAttribute("name",	pc.name.c_str() );
			eCh.SetAttribute("ver",		toStrC( pc.ver ));
			eCh.SetAttribute("cur",	toStrC( pc.curTrack ));
			eCh.SetAttribute("p",	toStrC( pc.points ));

			for (int i=0; i < pc.trks.size(); ++i)
			{
				const ProgressTrack& pt = pc.trks[i];
				TiXmlElement eTr("t");
				eTr.SetAttribute("p",	fToStr( pt.points, 1).c_str());
				eCh.InsertEndChild(eTr);
			}
		root.InsertEndChild(eCh);
	}
	xml.InsertEndChild(root);
	return xml.SaveFile(file.c_str());
}
Esempio n. 15
0
// ----------------------------------------------------------------------------
//
void DefinitionWriter::writeFixtureDefinition( 
            LPCSTR file_name, 
            LPCSTR author, 
            LPCSTR version, 
            FixtureDefinitionPtrArray& definitions )
{
    TiXmlElement fixtures( "fixture_definitions" );
    add_text_element( fixtures, "author", author );
    add_text_element( fixtures, "version", version );

    visit_ptr_array<FixtureDefinitionPtrArray>( fixtures, definitions );

    TiXmlDocument doc;
    TiXmlDeclaration xml_decl( "1.0", "", "" );

    doc.InsertEndChild( xml_decl );
    doc.InsertEndChild( fixtures );
    //doc.Print();

    CString output_file = file_name;

    if ( doc.SaveFile( output_file ) )
        studio.log_status( "Wrote fixture definitions to '%s'\n", output_file );
    else
        studio.log_status( "Error writing to '%s'\n", output_file );
}
Esempio n. 16
0
void CAppRegistry::Save()
{
  CSingleLock lock(m_lock);

  TiXmlElement rootElement("registry");
  CStdString key;
  for (RegistryDataIterator keyIter = m_data.begin(); keyIter != m_data.end(); keyIter++)
  {
    key = keyIter->first;
    RegistryValue& values = keyIter->second;
    
    for (size_t i = 0; i < values.size(); i++)
    {
      TiXmlElement valueElement("value");
      valueElement.SetAttribute("id", key.c_str());
      
      TiXmlText valueText(values[i]);
      valueElement.InsertEndChild(valueText);
      
      rootElement.InsertEndChild(valueElement);
    }
  }

  TiXmlDocument xmlDoc;
  xmlDoc.InsertEndChild(rootElement);

  ::CreateDirectory(m_dir, NULL);
  
  xmlDoc.SaveFile(m_fileName);
}
Esempio n. 17
0
File: Set.cpp Progetto: saisai/cAmp
//------------------------------------------------  save  ------------------------------------------------
void cAmp::ClrSave()  // unused
{
	TiXmlDocument xml;	TiXmlElement root("cAmp");

	TiXmlElement Rclrs("RatingColors");
		for (size_t i = 0; i < vRclr.size(); i++)
		{	TiXmlElement rclr("Rclr");
				sfmt(s) "%.3f %.3f %.3f", vRclr[i].r, vRclr[i].g, vRclr[i].b);
				rclr.SetAttribute("rgb", s);
			Rclrs.InsertEndChild(rclr);
		}
	root.InsertEndChild(Rclrs);

	TiXmlElement Rtx("RatingTex");
		Rtx.SetAttribute("xmin",	strF(rtx.r));
		Rtx.SetAttribute("xmax",	strF(rtx.g));
		Rtx.SetAttribute("ymin",	strF(rtx.b));
		Rtx.SetAttribute("ymax",	strF(rtx.a));
	root.InsertEndChild(Rtx);

	TiXmlElement Tclrs("TimeColors");
		Tclrs.SetAttribute("mode",	strI(tmClrMode));

		for (size_t i = 0; i < vTclr.size(); i++)
		{	TiXmlElement tclr("Tclr");
				tclr.SetAttribute("time", strF(vTclr[i].a));
				sfmt(s) "%.3f %.3f %.3f", vTclr[i].r, vTclr[i].g, vTclr[i].b);
				tclr.SetAttribute("rgb", s);
			Tclrs.InsertEndChild(tclr);
		}
	root.InsertEndChild(Tclrs);

	string p = appPath + "Media\\colors.xml";
	xml.InsertEndChild(root);  xml.SaveFile(p.c_str());
}
void savePointsAsXML(vector<Point2f> & contour){
    TiXmlDocument doc;
    TiXmlDeclaration decl("1.0", "", "");
    doc.InsertEndChild(decl);
    for(int i = 0; i < contour.size(); i++)
    {
        TiXmlElement point("point");
        point.SetAttribute("x",contour[i].x);
        point.SetAttribute("y",contour[i].y);
        doc.InsertEndChild(point);
    }
    if(doc.SaveFile(xml.c_str()))
        cout << "file saved succesfully.\n";
    else
        cout << "file not saved, something went wrong!\n";
}
//------------------------------------------------------------------------------
int WxEditorCanvasContainer::SaveFileAs(const std::string& rNewFileName)
{
	//open xml file
	TiXmlDocument aDoc;
	TiXmlElement  aNewToppestNode("guiex");
	aDoc.InsertEndChild(aNewToppestNode);

	//get page
	if( GSystem->GetUICanvas()->GetOpenedPageNum() != 0 )
	{
		CGUIWidget* pWidget = GSystem->GetUICanvas()->GetOpenedPageByIndex(0);
		if( pWidget )
		{
			//save it to doc
			if( 0 != SaveWidgetNodeToDoc( pWidget, aDoc ))
			{
				//failed
				return -1;
			}
		}
	}

	//save it to file
	if( false == aDoc.SaveFile( rNewFileName.c_str()))
	{
		//failed to save as file
		return -1;
	}

	return 0;
}
Esempio n. 20
0
bool CDSPSettings::SaveSettingsData()
{
  TiXmlDocument xmlDoc;
  TiXmlElement xmlRootElement("demo");
  TiXmlNode *pRoot = xmlDoc.InsertEndChild(xmlRootElement);
  if (pRoot == NULL)
    return false;

  TiXmlElement xmlChannelsSetting("channels");
  TiXmlNode* pChannelsNode = pRoot->InsertEndChild(xmlChannelsSetting);
  if (pChannelsNode)
  {
    for (int i = 0; i < AE_DSP_CH_MAX; i++)
    {
      TiXmlElement xmlSetting("channel");
      TiXmlNode* pChannelNode = pChannelsNode->InsertEndChild(xmlSetting);
      if (pChannelNode)
      {
        XMLUtils::SetInt(pChannelNode, "number", i);
        XMLUtils::SetString(pChannelNode, "name", m_Settings.m_channels[i].strName.c_str());
        XMLUtils::SetInt(pChannelNode, "volume", m_Settings.m_channels[i].iVolumeCorrection);
        XMLUtils::SetInt(pChannelNode, "distance", m_Settings.m_channels[i].iDistanceCorrection);
      }
    }
  }


  if (!xmlDoc.SaveFile(GetSettingsFile()))
  {
    XBMC->Log(LOG_ERROR, "failed to write speaker settings data");
    return false;
  }

  return true;
}
bool CDSPSettings::SaveSettingsData()
{
  TiXmlDocument xmlDoc;
  TiXmlElement xmlRootElement("freesurround");
  TiXmlNode *pRoot = xmlDoc.InsertEndChild(xmlRootElement);
  if (pRoot == NULL)
    return false;

  TiXmlElement xmlCS2Setting("settings");
  TiXmlNode* pNode = pRoot->InsertEndChild(xmlCS2Setting);
  if (pNode)
  {
    XMLUtils::SetFloat(pNode, "inputgain", m_Settings.fInputGain);
    XMLUtils::SetFloat(pNode, "circularwrap", m_Settings.fCircularWrap);
    XMLUtils::SetFloat(pNode, "shift", m_Settings.fShift);
    XMLUtils::SetFloat(pNode, "depth", m_Settings.fDepth);
    XMLUtils::SetFloat(pNode, "centerimage", m_Settings.fCenterImage);
    XMLUtils::SetFloat(pNode, "focus", m_Settings.fFocus);
    XMLUtils::SetFloat(pNode, "frontseparation", m_Settings.fFrontSeparation);
    XMLUtils::SetFloat(pNode, "rearseparation", m_Settings.fRearSeparation);
    XMLUtils::SetBoolean(pNode, "bassredirection", m_Settings.bLFE);
    XMLUtils::SetFloat(pNode, "lowcutoff", m_Settings.fLowCutoff);
    XMLUtils::SetFloat(pNode, "highcutoff", m_Settings.fHighCutoff);
  }

  if (!xmlDoc.SaveFile(GetSettingsFile()))
  {
    KODI->Log(LOG_ERROR, "failed to write circle surround 2 settings data");
    return false;
  }

  return true;
}
Esempio n. 22
0
XnStatus loadLicensesFile(TiXmlDocument& doc)
{
	XnStatus nRetVal = XN_STATUS_OK;
	
	XnChar strFileName[XN_FILE_MAX_PATH];

	nRetVal = resolveLicensesFile(strFileName, XN_FILE_MAX_PATH);
	XN_IS_STATUS_OK(nRetVal);

	XnBool bDoesExist = FALSE;
	nRetVal = xnOSDoesFileExist(strFileName, &bDoesExist);
	XN_IS_STATUS_OK(nRetVal);

	if (bDoesExist)
	{
		nRetVal = xnXmlLoadDocument(doc, strFileName);
		XN_IS_STATUS_OK(nRetVal);
	}
	else
	{
		TiXmlElement root(XN_XML_LICENSES_ROOT);
		doc.InsertEndChild(root);
		doc.SaveFile(strFileName);
	}
	
	return (XN_STATUS_OK);
}
Esempio n. 23
0
// Opens the specified XML file if it exists or creates a new one otherwise.
// Returns 0 on error.
TiXmlElement* GetXmlFile(wxFileName file)
{
	if (wxFileExists(file.GetFullPath()) && file.GetSize() > 0)
	{
		// File does exist, open it

		TiXmlDocument* pXmlDocument = new TiXmlDocument();
		pXmlDocument->SetCondenseWhiteSpace(false);
		if (!pXmlDocument->LoadFile(file.GetFullPath().mb_str()))
		{
			delete pXmlDocument;
			return 0;
		}
		if (!pXmlDocument->FirstChildElement("FileZilla3"))
		{
			delete pXmlDocument;
			return 0;
		}

		TiXmlElement* pElement = pXmlDocument->FirstChildElement("FileZilla3");
		if (!pElement)
		{
			delete pXmlDocument;
			return 0;
		}
		else
			return pElement;
	}
	else
	{
		// File does not exist, create new XML document

		TiXmlDocument* pXmlDocument = new TiXmlDocument();
		pXmlDocument->SetCondenseWhiteSpace(false);
		pXmlDocument->InsertEndChild(TiXmlDeclaration("1.0", "UTF-8", "yes"));
	
		pXmlDocument->InsertEndChild(TiXmlElement("FileZilla3"));

		if (!pXmlDocument->SaveFile(file.GetFullPath().mb_str()))
		{
			delete pXmlDocument;
			return 0;
		}
		
		return pXmlDocument->FirstChildElement("FileZilla3");
	}
}
Esempio n. 24
0
bool Project::write(ProgressFeedback* feedback)
{
	String pathname(mPath);
	pathname += PATHSEP;
	pathname += mName;
	pathname += ".project";

	TiXmlDocument doc;
	TiXmlDeclaration decl("1.0", "", "");
	doc.InsertEndChild(decl);

	TiXmlElement project("project");
	std::stringstream ss;
	ss << mVersion;
	std::string str(ss.str());
	project.SetAttribute("version", str.c_str());

	ss.str("");
	ss << mPackageManagers.size();
	str.assign(ss.str());
	project.SetAttribute("package_count", str.c_str());

	String packagePath(mPath);
	packagePath += "/packages/";

	for (PackageManagers::iterator it = mPackageManagers.begin(); it != mPackageManagers.end(); ++it) {
		PackageManager* pkgMgr = *it;

		TiXmlElement package("package");
		String name(pkgMgr->metadata()->getName());
		package.SetAttribute("name", name);

		name = pkgMgr->packageFilename();
		package.SetAttribute("filename", name);

		project.InsertEndChild(package);

		// write out the actual package file
		pkgMgr->save(packagePath);
	}

	doc.InsertEndChild(project);

	doc.SaveFile(pathname);

	return true;
}
Esempio n. 25
0
bool CSmartPlaylist::Save(const CStdString &path)
{
  TiXmlDocument doc;
  TiXmlDeclaration decl("1.0", "UTF-8", "yes");
  doc.InsertEndChild(decl);

  TiXmlElement xmlRootElement("smartplaylist");
  xmlRootElement.SetAttribute("type",m_playlistType.c_str());
  TiXmlNode *pRoot = doc.InsertEndChild(xmlRootElement);
  if (!pRoot) return false;
  // add the <name> tag
  TiXmlText name(m_playlistName.c_str());
  TiXmlElement nodeName("name");
  nodeName.InsertEndChild(name);
  pRoot->InsertEndChild(nodeName);
  // add the <match> tag
  TiXmlText match(m_matchAllRules ? "all" : "one");
  TiXmlElement nodeMatch("match");
  nodeMatch.InsertEndChild(match);
  pRoot->InsertEndChild(nodeMatch);
  // add <rule> tags
  for (vector<CSmartPlaylistRule>::iterator it = m_playlistRules.begin(); it != m_playlistRules.end(); ++it)
  {
    pRoot->InsertEndChild((*it).GetAsElement());
  }
  // add <limit> tag
  if (m_limit)
  {
    CStdString limitFormat;
    limitFormat.Format("%i", m_limit);
    TiXmlText limit(limitFormat);
    TiXmlElement nodeLimit("limit");
    nodeLimit.InsertEndChild(limit);
    pRoot->InsertEndChild(nodeLimit);
  }
  // add <order> tag
  if (m_orderField != CSmartPlaylistRule::FIELD_NONE)
  {
    TiXmlText order(CSmartPlaylistRule::TranslateField(m_orderField).c_str());
    TiXmlElement nodeOrder("order");
    nodeOrder.SetAttribute("direction", m_orderAscending ? "ascending" : "descending");
    nodeOrder.InsertEndChild(order);
    pRoot->InsertEndChild(nodeOrder);
  }
  return doc.SaveFile(path);
}
Esempio n. 26
0
bool CScrobbler::SaveJournal()
{
    CSingleLock lock(m_queueLock);

    if (m_vecSubmissionQueue.size() == 0)
    {
        if (XFILE::CFile::Exists(GetJournalFileName()))
            XFILE::CFile::Delete(GetJournalFileName());
        return true;
    }
    CStdString        strJournalVersion;
    TiXmlDocument     xmlDoc;
    TiXmlDeclaration  decl("1.0", "utf-8", "yes");
    TiXmlElement      xmlRootElement("asjournal");
    xmlDoc.InsertEndChild(decl);
    strJournalVersion.Format("%d", SCROBBLER_JOURNAL_VERSION);
    xmlRootElement.SetAttribute("version", strJournalVersion.c_str());
    TiXmlNode *pRoot = xmlDoc.InsertEndChild(xmlRootElement);
    if (!pRoot)
        return false;

    int i = 0;
    SCROBBLERJOURNALITERATOR it = m_vecSubmissionQueue.begin();
    for (; it != m_vecSubmissionQueue.end(); it++, i++)
    {
        TiXmlElement entryNode("entry");
        TiXmlNode *pNode = pRoot->InsertEndChild(entryNode);
        if (!pNode)
            return false;
        XMLUtils::SetString(pNode, "artist", it->strArtist);
        XMLUtils::SetString(pNode, "album", it->strAlbum);
        XMLUtils::SetString(pNode, "title", it->strTitle);
        XMLUtils::SetString(pNode, "length", it->strLength);
        XMLUtils::SetString(pNode, "starttime", it->strStartTime);
        XMLUtils::SetString(pNode, "musicbrainzid", it->strMusicBrainzID);
        XMLUtils::SetString(pNode, "tracknum", it->strTrackNum);
        XMLUtils::SetString(pNode, "source", it->strSource);
        XMLUtils::SetString(pNode, "rating", it->strRating);
    }
    lock.Leave();

    CStdString FileName = GetJournalFileName();
    CLog::Log(LOGDEBUG, "%s: Journal with %d entries saved to %s",
              m_strLogPrefix.c_str(), i, FileName.c_str());
    return xmlDoc.SaveFile(FileName);
}
Esempio n. 27
0
void object::test <1>()
{
	TiXmlDocument doc;
	TiXmlDeclaration dcl("1.0", std::string(), "no");
	doc.InsertEndChild(dcl);
	std::ostringstream os;
	os<<doc;
	tut::ensure_equals(os.str(), std::string("<?xml version=\"1.0\" standalone=\"no\" ?>"));
}
Esempio n. 28
0
void SettingsStorage::SaveFile(const String& path) const {
	TiXmlDocument doc;

	TiXmlElement root("settings");
	Save(&root);
	doc.InsertEndChild(root);

	doc.SaveFile(Mbs(path).c_str());
}
Esempio n. 29
0
bool Project::Save(const _TCHAR* filename)
{
	
	TiXmlDocument doc;

	USES_CONVERSION;
	TiXmlNode* pRoot = doc.InsertEndChild(TiXmlElement("project"));

	TiXmlElement scene("scene");

	if(m_pScene)
	{
		scene.InsertEndChild(TiXmlText(m_pScene->GetFileName().string().c_str()));
	}
	pRoot->InsertEndChild(scene);
	
	TiXmlElement clearClr("clear_color");

	char szBuffer[1024];

	sprintf_s(szBuffer,1024, "%.3f,%.3f,%.3f,%.3f", m_clearClr.r, m_clearClr.g, m_clearClr.b, m_clearClr.a);

	clearClr.InsertEndChild(TiXmlText(szBuffer));

	pRoot->InsertEndChild(clearClr);

	TiXmlElement camera("camera");

	math::Vector3 eye = m_pRenderer->GetCamera()->GetEyePos();
	math::Vector3 focus = m_pRenderer->GetCamera()->GetFocusPos();

	
	TiXmlElement eEye("eye_pos");
	sprintf_s(szBuffer,1024, "%.3f,%.3f,%.3f", eye.z, eye.y, eye.z);
	eEye.InsertEndChild(TiXmlText(szBuffer));

	TiXmlElement eFocus("focus_pos");
	sprintf_s(szBuffer,1024, "%.3f,%.3f,%.3f", focus.z, focus.y, focus.z);
	eFocus.InsertEndChild(TiXmlText(szBuffer));

	camera.InsertEndChild(eEye);
	camera.InsertEndChild(eFocus);

	pRoot->InsertEndChild(camera);

	if(false == doc.SaveFile(W2A(filename)))
	{
		return false;
	}

	m_filePath = filename;

	RestoreCurrentDirectory();

	return true;
}
status_t Converter::ConvertPDoc2FreeMind()
{
	status_t		err					= B_OK;
	BMessage		*inMessage			= new BMessage();
	BMessage		*tmpMessage			= new BMessage();
	void			*id					= NULL;

 	allConnections	= new BMessage();
	selected		= new BMessage();
	allNodes		= new BMessage();


	err = inMessage->Unflatten(in);
	if (err == B_OK)
	{
		inMessage->FindMessage("PDocument::allConnections",allConnections);
		inMessage->FindMessage("PDocument::selected",selected);
		inMessage->FindMessage("PDocument::allNodes",allNodes);
		int32 i = 0;
		while(allNodes->FindMessage("node",i,tmpMessage)==B_OK)
		{
			tmpMessage->FindPointer("this",&id);
			nodes[(int32)id]=tmpMessage;
			tmpMessage = new BMessage();
-			i++;
		}
		i = 0;
		while(allConnections->FindMessage("node",i,tmpMessage)==B_OK)
		{
			tmpMessage->FindPointer("this",&id);
			connections[(int32)id]=tmpMessage;
			tmpMessage = new BMessage();
			i++;
		}

		BMessage	*node= GuessStartNode();
		TiXmlDocument	doc;
		TiXmlElement	freeMap("map");
		freeMap.SetAttribute("version","0.9.0");
		freeMap.SetAttribute("background_color","#ffffff");
		TiXmlComment	comment("this File was gernerated by ProjectConceptor! - To view this file, download free mind mapping software FreeMind from http://freemind.sourceforge.net");
		freeMap.InsertEndChild(comment);

		tmpMessage=GuessStartNode();
	//	tmpMessage = nodes.begin()->second;
		freeMap.InsertEndChild(ProcessNode(tmpMessage));
		doc.InsertEndChild(freeMap);
		TiXmlPrinter	printer;
//		printer.SetStreamPrinting();
//		printer.SetLineBreak("\n");
//		printer.SetIndent("\t");
		doc.Accept( &printer );
		out->Write(printer.CStr(),strlen(printer.CStr()));
	}
	return err;
}