Example #1
0
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()->LinkEndChild(new 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->LinkEndChild(new TiXmlText(utf8));

			delete [] utf8;
			return;
		}
	}
	wxASSERT(options[nID].name[0]);
	TiXmlElement *setting = new TiXmlElement("Setting");
	setting->SetAttribute("name", options[nID].name);
	//setting->SetAttribute("type", (options[nID].type == string) ? "string" : "number");
	setting->LinkEndChild(new TiXmlText(utf8));
	settings->LinkEndChild(setting);

	delete [] utf8;
}
Example #2
0
wxMenu* CSiteManager::GetSitesMenu_Predefined(std::map<int, CSiteManagerItemData_Site*> &idMap)
{
	const wxString& defaultsDir = wxGetApp().GetDefaultsDir();
	if (defaultsDir == _T(""))
		return 0;

	wxFileName name(defaultsDir, _T("fzdefaults.xml"));
	CXmlFile file(name);

	TiXmlElement* pDocument = file.Load();
	if (!pDocument)
		return 0;

	TiXmlElement* pElement = pDocument->FirstChildElement("Servers");
	if (!pElement)
		return 0;

	wxMenu* pMenu = new wxMenu;
	CSiteManagerXmlHandler_Menu handler(pMenu, &idMap, true);

	if (!Load(pElement, &handler))
	{
		delete pMenu;
		return 0;
	}

	if (!pMenu->GetMenuItemCount())
	{
		delete pMenu;
		return 0;
	}

	return pMenu;
}
Example #3
0
xdl_int XdevLCudaImpl::readModuleInformation(TiXmlDocument* document) {
	TiXmlHandle docHandle(document);
	TiXmlElement* root = docHandle.FirstChild(XdevLCorePropertiesName.c_str()).FirstChildElement("XdevLOpenGL").ToElement();

	if (!root) {
		XDEVL_MODULE_INFO("<XdevLCuda> section not found, skipping proccess.\n");
		return ERR_OK;
	}

	if(root->Attribute("id")){
		XdevLModuleId id(root->Attribute("id"));
		if(*getId() != id){
			return ERR_OK;
		}		
	}else{
		XDEVL_MODULE_ERROR("No 'id' attribute specified.");
		return ERR_ERROR;
	}

//	if (root->Attribute("framebuffer_depth")){
//		m_ColorDepth = xstd::from_string<xdl_int>(root->Attribute("framebuffer_depth"));
//		XDEVL_MODULE_INFO("Framebuffer depth request: " << m_ColorDepth << std::endl);
//	}

	return ERR_OK;
}
	bool UIElement::Load(char* cs_FilePath){
		//Load the XML
		TiXmlDocument doc(cs_FilePath);
		if (doc.LoadFile()){
		//Check its an UIElement
			TiXmlNode* xUIElement = doc.FirstChild("UIElement");
			if (!xUIElement){
				Logger::Log("Could not find 'UIElement' Node. \n");
				return false;
			};

			TiXmlNode* xUIElementType = xUIElement->FirstChild("Type");
			if (!xUIElementType){
				Logger::Log("Could not find 'xUIElementType' Node. \n");
				return false;
			};

			TiXmlElement *xeUIElement = xUIElementType->ToElement();
			char* cs_Type = (char*)xeUIElement->Attribute("t");
			if (std::strcmp(cs_Type,"UIElement") == 0){
				Load(xUIElement);
			}else{
				return false;
			}
		}
		return true;
	}
Example #5
0
int ServerConf::ReadSendConfig(TiXmlElement *root)
{
	TiXmlElement *sendElement = root->FirstChildElement("sendcfg");
	if(!sendElement){
		AC_ERROR("read sendcfg error");
		return -1;	
	}
	const char* str;
	str = sendElement->Attribute("sendhour",&m_sendcfg.hour);
	if(!str)	
	{		
		AC_ERROR("read hour error");		
		return -1;	
	}	


	str = sendElement->Attribute("sendminute",&m_sendcfg.minute);
	if(!str)	
	{		
		AC_ERROR("read minute error");		
		return -1;	
	}	

	str = sendElement->Attribute("timeInteval",&m_sendcfg.timeInteval);
	if(!str)	
	{		
		AC_ERROR("read timeInteval error");		
		return -1;	
	}	
	AC_INFO("sendInteval is: %d",m_sendcfg.timeInteval);
	return 0;
}
std::string sqr_tools::CAnimationGroupEditImp::GetLastAGPFile( void )
{
	std::string keyName = "AddAGPBt";
	std::string pathFileValue;
	TiXmlNode* pConfigXml = CEditorConfig::GetInst()->GetEditorConfig("FileDialogSetting");
	TiXmlElement* pElement = pConfigXml->ToElement();
	TiXmlNode* pNode = NULL;

	pNode = pConfigXml->FirstChild(keyName);
	if(pNode!=NULL)
	{ 
		//结点存在 获取属性值
		pElement=pNode->ToElement();
		pathFileValue = pElement->Attribute("Path");
	}
	else
	{
		std::string temp = CPathSetImp::GetInst()->GetPath(0);
		TiXmlElement newNode(keyName);
		if (!temp.empty())
			newNode.SetAttribute("Path", temp);
		else
			newNode.SetAttribute("Path", "c:");
		pConfigXml->InsertEndChild(newNode);
		CEditorConfig::GetInst()->SaveEditorConfig();
	}
	return pathFileValue;
}
Example #7
0
//-----------------------------------------------------------------------------
// <Group::WriteXML>
// Write ourselves to an XML document
//-----------------------------------------------------------------------------
void Group::WriteXML
(
	TiXmlElement* _groupElement
)
{
	char str[16];

	snprintf( str, 16, "%d", m_groupIdx );
	_groupElement->SetAttribute( "index", str );

	snprintf( str, 16, "%d", m_maxAssociations );
	_groupElement->SetAttribute( "max_associations", str );

	_groupElement->SetAttribute( "label", m_label.c_str() );
	_groupElement->SetAttribute( "auto", m_auto ? "true" : "false" );
	if( m_multiInstance )
	{
		_groupElement->SetAttribute( "multiInstance", m_multiInstance ? "true" : "false" );
	}
	
	for( map<InstanceAssociation,AssociationCommandVec,classcomp>::iterator it = m_associations.begin(); it != m_associations.end(); ++it )
	{
		TiXmlElement* associationElement = new TiXmlElement( "Node" );
		
		snprintf( str, 16, "%d", it->first.m_nodeId );
		associationElement->SetAttribute( "id", str );
		if (it->first.m_instance != 0)
		{
			snprintf( str, 16, "%d", it->first.m_instance );
			associationElement->SetAttribute( "instance", str );
		}

		_groupElement->LinkEndChild( associationElement );
	}
}
bool wxsItemResData::LoadInSourceMode()
{
    // TODO: Check if source / header files have required blocks of code

    TiXmlDocument Doc;
    if ( !TinyXML::LoadDocument(m_WxsFileName,&Doc)  )
    {
        Manager::Get()->GetLogManager()->DebugLog(F(_T("wxSmith: Error loading wxs file (Col: %d, Row:%d): ") + cbC2U(Doc.ErrorDesc()),Doc.ErrorCol(),Doc.ErrorRow()));
        return false;
    }

    TiXmlElement* wxSmithNode = Doc.FirstChildElement("wxsmith");
    if ( !wxSmithNode ) return false;

    TiXmlElement* Object = wxSmithNode->FirstChildElement("object");
    if ( !Object ) return false;

    /*
    if ( cbC2U(Object->Attribute("name")) != m_ClassName ) return false;
    if ( cbC2U(Object->Attribute("class")) != m_ClassType ) return false;
    */

    RecreateRootItem();
    if ( !m_RootItem ) return false;
    m_RootItem->XmlRead(Object,true,true);
    LoadToolsReq(Object,true,true);

    return true;
}
void wxsItemResData::LoadToolsReq(TiXmlElement* Node,bool IsXRC,bool IsExtra)
{
    for ( TiXmlElement* Object = Node->FirstChildElement("object"); Object; Object = Object->NextSiblingElement("object") )
    {
        wxString Class = cbC2U(Object->Attribute("class"));
        if ( Class.IsEmpty() ) continue;
        const wxsItemInfo* Info = wxsItemFactory::GetInfo(Class);
        if ( !Info ) continue;
        if ( Info->Type != wxsTTool )
        {
            LoadToolsReq(Object,IsXRC,IsExtra);
            continue;
        }
        if ( !(GetPropertiesFilter()&flSource) && !Info->AllowInXRC ) continue;
        wxsItem* Item = wxsItemFactory::Build(Class,this);
        if ( !Item ) continue;
        wxsTool* Tool = Item->ConvertToTool();
        if ( !Tool )
        {
            delete Item;
            continue;
        }
        if ( InsertNewTool(Tool) )
        {
            Tool->XmlRead(Object,IsXRC,IsExtra);
        }
    }
}
Example #10
0
bool BXBoxeeServices::Parse()
{
    TiXmlHandle docHandle(&m_doc);
    TiXmlNode* pTSChild = docHandle.FirstChild("services").FirstChild("timestamp").FirstChild().Node();

    if (pTSChild)
    {
        m_timestamp = atoi(pTSChild->Value());
    }

    TiXmlElement *pChild = docHandle.FirstChild("services").Element();
    if (!pChild)
    {
        LOG(LOG_LEVEL_ERROR,"BXBoxeeServices::Parse - FAILED to find <applications> node");
        return false;
    }

    m_services.clear();

    TiXmlNode *pMsgNode = 0;
    while ((pMsgNode = pChild->IterateChildren(pMsgNode)) != NULL)
    {
        if (pMsgNode->ValueStr().compare("object") == 0)
        {
            BXObject obj;
            if (obj.FromXML(pMsgNode))
            {
                m_services.push_back(obj);
            }
        }
    }

    return true;
}
void wxsItemResData::UpdateExtraDataReq(wxsItem* Item,IdToXmlMapT& Map)
{
    if ( Item->GetPropertiesFlags() & flId )
    {
        wxString Id = Item->GetIdName();
        if ( !Id.empty() )
        {
            if ( !Item->GetParent() )
            {
                // Empty id simlates root node
                Id = _T("");
            }
            if ( Map.find(Id) != Map.end() )
            {
                TiXmlElement* Object = Map[Id];
                if ( cbC2U(Object->Attribute("class"))==Item->GetClassName() )
                {
                    Item->XmlRead(Object,false,true);
                }
            }
        }
    }

    wxsParent* AsParent = Item->ConvertToParent();
    if ( AsParent )
    {
        for ( int i=0; i<AsParent->GetChildCount(); i++ )
        {
            UpdateExtraDataReq(AsParent->GetChild(i),Map);
        }
    }
}
Example #12
0
void ControlFIFO::poll ()
{
  if (fifo == -1)
    return;

  char temp[2048];
  temp[0] = '\0';
  int len = read(fifo, temp, 2048);
  if (len < 0)
    return;

  temp[len] = '\0';
  if (!strlen(temp))
    return;

  TiXmlDocument doc;
  doc.Parse(temp);
  if (!doc.RootElement()) {
    std::cerr <<" *** Invalid control data received:\n"<< temp << std::endl;
    return;
  }

  TiXmlElement* elem = doc.RootElement()->FirstChildElement();
  for (; elem; elem = elem->NextSiblingElement())
    if (callbacks.find(elem->Value()) != callbacks.end())
      callbacks[elem->Value()]->OnControl(elem);
}
Example #13
0
/**
 * 从字符串中初始化
 */
bool tixmlCode::initFromString(const char *content)
{
    TiXmlDocument doc;
    doc.Parse(content);
    static std::string CODE="code";
    static std::string READ="read";
    TiXmlHandle hDoc(&doc);
    TiXmlElement* pElem = NULL;
    pElem=hDoc.FirstChildElement().Element();
    for(; pElem; pElem=pElem->NextSiblingElement())
    {
        const char *pKey=pElem->Value();
        tixmlCodeNode *node = new tixmlCodeNode();
        node->init(pElem);
        if (node->nodeName == CODE)
        {
            parseCode(node);
        }
        else if (node->nodeName == READ)
        {
            std::string fileName = node->getAttr("file");
            init(fileName.c_str()); // 加载其他文本进入当前执行环境
        }
        else
        {
            takeNode(node); // 调用使用者的方法
        }
    }
    return  true;
}
Example #14
0
bool CGUIColorManager::LoadXML(TiXmlDocument &xmlDoc)
{
  TiXmlElement* pRootElement = xmlDoc.RootElement();

  CStdString strValue = pRootElement->Value();
  if (strValue != CStdString("colors"))
  {
    CLog::Log(LOGERROR, "color file doesnt start with <colors>");
    return false;
  }

  const TiXmlElement *color = pRootElement->FirstChildElement("color");

  while (color)
  {
    if (color->FirstChild() && color->Attribute("name"))
    {
      color_t value = 0xffffffff;
      sscanf(color->FirstChild()->Value(), "%x", (unsigned int*) &value);
      CStdString name = color->Attribute("name");
      iColor it = m_colors.find(name);
      if (it != m_colors.end())
        (*it).second = value;
      else
        m_colors.insert(make_pair(name, value));
    }
    color = color->NextSiblingElement("color");
  }
  return true;
}
Example #15
0
   virtual void process(TiXmlElement* root, int version)
   {
      static_cast<void>(version);
      std::string mngr;
      utilib::get_string_attribute( root, "process_manager", mngr, 
                            ExecuteManager::default_process_mngr );
      ExecuteMngr().set_process_manager(mngr);
      

      // each child element should be a valid command...
      TiXmlElement* node = root->FirstChildElement();

      // special case: if it is an empty element, just execute the last
      // solver
      if ( node == NULL )
      {
         string solver = SolverMngr().get_newest_solver();
         if ( ! solver.empty() )
            ExecuteMngr().run_command(string("solve:") + solver);
         return;
      }
      
      int rank;
      int myRank = ExecuteMngr().rank();

      // step through all the commands
      for( ; node != NULL; node = node->NextSiblingElement() )
      {
         utilib::get_num_attribute( node, "rank", rank, ExecuteManager::local );
         if (( rank == ExecuteManager::local ) || ( rank == myRank ))
            ExecuteMngr().run_command(node->ValueStr(), rank, node);
      }
   }
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;
}
Example #17
0
bool PeerManage::DelayInitialize()
{
    if (NULL == (m_pCallBackSystem = (CallBackSystem *)m_pCoreModuleManage->GetModule("CallBackSystem")))
    {
        Assert(false);
        LOG_ERROR("Get CallBackSystem error");
        return false;
    }

    char strConfigPath[PATH_LENGTH] = {0};
    const char * pStrPathFolder = GetAppPath();
    sprintf_s(strConfigPath, "%s/%s", pStrPathFolder, CONFIG_PATH_PEERCONFIG);

    TiXmlDocument xmlConfig;
    if (false == xmlConfig.LoadFile(strConfigPath))
    {
        LOG_ERROR("Load PeerManage Error");
        return false;
    }

    TiXmlElement * pRootElement = xmlConfig.RootElement();
    TiXmlElement * pPeerTypeElm = pRootElement->FirstChildElement("PeerType");

    while (pPeerTypeElm != NULL)
    {
        if (false == GetConfig(pPeerTypeElm))
        {
            LOG_ERROR("Load PeerManage Error");
        }
        pPeerTypeElm = pPeerTypeElm->NextSiblingElement();
    }

    return true;
}
void wxsItemResData::SaveExtraDataReq(wxsItem* Item,TiXmlElement* Node)
{
    if ( Item->GetPropertiesFlags() && flId )
    {
        wxString Id = Item->GetIdName();
        if ( !Id.empty() )
        {
            TiXmlElement* Object = Node->InsertEndChild(TiXmlElement("object"))->ToElement();
            if ( Item!=m_RootItem )
            {
                Object->SetAttribute("name",cbU2C(Id));
                Object->SetAttribute("class",cbU2C(Item->GetClassName()));
            }
            else
            {
                // TOP-level items have different attributes in extra node
                Object->SetAttribute("root","1");
            }
            Item->XmlWrite(Object,false,true);
        }
    }

    wxsParent* AsParent = Item->ConvertToParent();
    if ( AsParent )
    {
        for ( int i=0; i<AsParent->GetChildCount(); i++ )
        {
            SaveExtraDataReq(AsParent->GetChild(i),Node);
        }
    }
}
// static member function
HeeksObj* COrientationModifier::ReadFromXMLElement(TiXmlElement* element)
{
	COrientationModifier* new_object = new COrientationModifier();

	std::list<TiXmlElement *> elements_to_remove;

	// read point and circle ids
	for(TiXmlElement* pElem = TiXmlHandle(element).FirstChildElement().Element(); pElem; pElem = pElem->NextSiblingElement())
	{
		std::string name(pElem->Value());
		if(name == "params"){
			new_object->m_params.ReadParametersFromXMLElement(pElem);
			elements_to_remove.push_back(pElem);
		}
	}

	for (std::list<TiXmlElement*>::iterator itElem = elements_to_remove.begin(); itElem != elements_to_remove.end(); itElem++)
	{
		element->RemoveChild(*itElem);
	}

	new_object->ReadBaseXML(element);

	return new_object;
}
void ModelLibrary::LoadAnimsFromXML(TiXmlElement* parent, vector<SAnimation*>* anims, vector<SSound*>* sounds)
{
	TiXmlElement* child;
	for(child = parent->FirstChildElement(); child; child = child->NextSiblingElement())
	{
		if (child->ValueStr() == "sound") 
		{
			SSound* s = new SSound();
			s->filename = child->Attribute(FILENAME);
			child->Attribute(SOUNDLOOP, &s->soundloop);
			sounds->push_back(s);

			Ogre::LogManager::getSingleton().logMessage("XML: SOUND: "+s->filename);
		}
		else if (child->ValueStr() == "animation")
		{
			SAnimation* a = new SAnimation();
			a->name = child->Attribute(ANIMNAME);
			child->Attribute(FRAMES, &a->frames);
			child->Attribute(LOOP, &a->loop);
			anims->push_back(a);

			Ogre::LogManager::getSingleton().logMessage("XML: ANIM: "+a->name);
		}
		else
		{
			Ogre::LogManager::getSingleton().logMessage("XML: subPart : should never get here *giggles*");
			Ogre::LogManager::getSingleton().logMessage("XML: subPart : culporate: "+child->ValueStr());
		};
	}
}
Example #21
0
TiXmlElement* SceneObjectNode::getSceneNodeValueAsXmlElement() {
	//printf("getSceneNodeAsXmlElement \n");
	TiXmlElement* element = new TiXmlElement("ObjectNode");
	element->LinkEndChild(drawable->getDrawableAsXmlElement());
	//element->LinkEndChild(((Mesh*)(drawable))->getDrawableAsXmlElement());
	return element;
}
Example #22
0
bool CreateXmlFile(std::string& szFileName)
{//创建xml文件,szFilePath为文件保存的路径,若创建成功返回true,否则false
	try
	{
		//创建一个XML的文档对象。
		TiXmlDocument *myDocument = new TiXmlDocument();
		//创建一个根元素并连接。
		TiXmlElement *RootElement = new TiXmlElement("Persons");
		myDocument->LinkEndChild(RootElement);
		//创建一个Person元素并连接。
		TiXmlElement *PersonElement = new TiXmlElement("Person");
		RootElement->LinkEndChild(PersonElement);
		//设置Person元素的属性。
		PersonElement->SetAttribute("ID", "1");
		//创建name元素、age元素并连接。
		TiXmlElement *NameElement = new TiXmlElement("name");
		TiXmlElement *AgeElement = new TiXmlElement("age");
		PersonElement->LinkEndChild(NameElement);
		PersonElement->LinkEndChild(AgeElement);
		//设置name元素和age元素的内容并连接。
		TiXmlText *NameContent = new TiXmlText("周星星");
		TiXmlText *AgeContent = new TiXmlText("22");
		NameElement->LinkEndChild(NameContent);
		AgeElement->LinkEndChild(AgeContent);
		std::string fullPath = GetAppPath();
		fullPath += "\\";
		fullPath += szFileName;
		myDocument->SaveFile(fullPath.c_str());//保存到文件
	}
	catch (std::string& e)
	{
		return false;
	}
	return true;
}
Example #23
0
int ServerConf::ReadSpConfig(TiXmlElement *root)
{
	TiXmlElement *spElement = root->FirstChildElement("spcfg");
	if(!spElement){
		AC_ERROR("read dbcfg error");
		return -1;	
	}
	const char * str;

	str = spElement->Attribute("spname");
	if(!str)	
	{		
		AC_ERROR("read spname error");		
		return -1;	
	}	
	m_spcfg.spname = str;
	AC_INFO("read spname :%s ",str);

	str = spElement->Attribute("arg",&m_spcfg.numDay);
	if(!str)	
	{		
		AC_ERROR("read arg error");		
		return -1;	
	}	
	return 0;
}
Example #24
0
  const char *getDefaultImage(char* cControlType, char* cTextureType)
  {
    // create an xml block so that we can resolve our defaults
    // <control type="type">
    //   <description />
    // </control>
    TiXmlElement control("control");
    control.SetAttribute("type", cControlType);
    TiXmlElement filler("description");
    control.InsertEndChild(filler);
    g_SkinInfo->ResolveIncludes(&control);

    // ok, now check for our texture type
    TiXmlElement *pTexture = control.FirstChildElement(cTextureType);
    if (pTexture)
    {
      // found our textureType
      TiXmlNode *pNode = pTexture->FirstChild();
      if (pNode && pNode->Value()[0] != '-')
      {
        strncpy(defaultImage, pNode->Value(), sizeof(defaultImage));
        defaultImage[sizeof(defaultImage) - 1] = '\0';
        return defaultImage;
      }
    }
    return "";
  }
Example #25
0
bool CScraperUrl::ParseEpisodeGuide(CStdString strUrls)
{
    if (strUrls.IsEmpty())
        return false;

    // ok, now parse the xml file
    if (strUrls.Find("encoding=\"utf-8\"") < 0)
        g_charsetConverter.stringCharsetToUtf8(strUrls);

    TiXmlDocument doc;
    doc.Parse(strUrls.c_str(),0,TIXML_ENCODING_UTF8);
    if (doc.RootElement())
    {
        TiXmlHandle docHandle( &doc );
        TiXmlElement *link = docHandle.FirstChild( "episodeguide" ).FirstChild( "url" ).Element();
        while (link)
        {
            ParseElement(link);
            link = link->NextSiblingElement("url");
        }
    }
    else
        return false;
    return true;
}
Example #26
0
bool CController::LoadLayout(void)
{
  if (!m_bLoaded)
  {
    std::string strLayoutXmlPath = LibPath();

    CLog::Log(LOGINFO, "Loading controller layout: %s", CURL::GetRedacted(strLayoutXmlPath).c_str());

    CXBMCTinyXML xmlDoc;
    if (!xmlDoc.LoadFile(strLayoutXmlPath))
    {
      CLog::Log(LOGDEBUG, "Unable to load file: %s at line %d", xmlDoc.ErrorDesc(), xmlDoc.ErrorRow());
      return false;
    }

    TiXmlElement* pRootElement = xmlDoc.RootElement();
    if (!pRootElement || pRootElement->NoChildren() || pRootElement->ValueStr() != LAYOUT_XML_ROOT)
    {
      CLog::Log(LOGERROR, "Can't find root <%s> tag", LAYOUT_XML_ROOT);
      return false;
    }

    m_layout->Deserialize(pRootElement, this, m_features);
    if (m_layout->IsValid(true))
    {
      m_bLoaded = true;
    }
    else
    {
      m_layout->Reset();
    }
  }

  return m_bLoaded;
}
Example #27
0
TiXmlElement* CSiteManager::GetElementByPath(TiXmlElement* pNode, std::list<wxString> const& segments)
{
	for (std::list<wxString>::const_iterator it = segments.begin(); it != segments.end(); ++it)
	{
		const wxString & segment = *it;
		
		TiXmlElement* pChild;
		for (pChild = pNode->FirstChildElement(); pChild; pChild = pChild->NextSiblingElement())
		{
			const char* value = pChild->Value();
			if (strcmp(value, "Server") && strcmp(value, "Folder") && strcmp(value, "Bookmark"))
				continue;

			wxString name = GetTextElement_Trimmed(pChild, "Name");
			if (name.empty())
				name = GetTextElement_Trimmed(pChild);
			if (name.empty())
				continue;

			if (name == segment)
				break;
		}
		if (!pChild)
			return 0;

		pNode = pChild;
		continue;
	}

	return pNode;
}
Example #28
0
bool CScraperUrl::ParseString(CStdString strUrl)
{
  if (strUrl.empty())
    return false;

  CXBMCTinyXML doc;
  /* strUrl is coming from internal sources (usually generated by scraper or from database)
   * so strUrl is always in UTF-8 */
  doc.Parse(strUrl, TIXML_ENCODING_UTF8);

  TiXmlElement* pElement = doc.RootElement();
  if (!pElement)
  {
    SUrlEntry url;
    url.m_url = strUrl;
    url.m_type = URL_TYPE_GENERAL;
    url.m_season = -1;
    url.m_post = false;
    url.m_isgz = false;
    m_url.push_back(url);
    m_xml = strUrl;
  }
  else
  {
    while (pElement)
    {
      ParseElement(pElement);
      pElement = pElement->NextSiblingElement(pElement->Value());
    }
  }

  return true;
}
Example #29
0
void User::Save(bool force) {
  if (!force) {
    // If no save operation is scheduled, exit now
    if (!scheduledSaveTimer_) return;
    if (!scheduledSaveTimer_->IsRunning()) return;
  }

  settings_->Save();
  wxGetApp().GetPluginManager()->Save();

  TiXmlDocument doc;
  doc.LinkEndChild(new TiXmlDeclaration("1.0", "UTF-8", ""));

  TiXmlElement* xmlRoot = new TiXmlElement("FolderItems");
  xmlRoot->SetAttribute("version", "1.0");
  doc.LinkEndChild(xmlRoot);

  for (int i = 0; i < autoAddExclusions_.size(); i++) {
    XmlUtil::AppendTextElement(xmlRoot, "ExcludedPath", autoAddExclusions_[i]);
  }

  FolderItemVector folderItems = rootFolderItem_->GetChildren();
  for (int i = 0; i < folderItems.size(); i++) {
    FolderItem* folderItem = folderItems.at(i);
    xmlRoot->LinkEndChild(folderItem->ToXml());   
  }

  FilePaths::CreateSettingsDirectory();
  bool saved = doc.SaveFile(FilePaths::GetFolderItemsFile().mb_str());
  if (!saved) ELOG(_T("Could not save file"));
}
Example #30
0
int ExportAnyData(CString filename, vector<string> &orders)
{
	Book* book = xlCreateBook();
	if(!book)
		return 0;

	for(vector<string>::iterator it = orders.begin(); it != orders.end(); it++)
	{
		CString Filename = it->c_str();
		Filename += ".xml";
		TiXmlElement *Root = getXMLRoot(Filename);
		Sheet* sheet = book->addSheet(it->c_str());
		if(!sheet)
			return 0;
		addOneSheet(sheet, Root);

		delete Root->GetDocument();
	}

	if(book->save(_T(filename.GetBuffer(0)) )) 
	{
		return 1;
	}
	else
	{
		return 0;
	}

	book->release();
}