bool CLastFMDirectory::ParseArtistList(CStdString url, CFileItemList &items)
{
  if (!RetrieveList(url))
    return false;

  TiXmlElement* pRootElement = m_xmlDoc.RootElement();

  TiXmlElement* pEntry = pRootElement->FirstChildElement("artist");

  while(pEntry)
  {
    TiXmlNode* name = pEntry->FirstChild("name");
    TiXmlNode* count;
    const char *countstr = NULL;
    const char *namestr = NULL;

    count = pEntry->FirstChild("count");
    if (!count) count = pEntry->FirstChild("playcount");
    if (!count) count = pEntry->FirstChild("match");
    if (!count && pEntry->Attribute("count"))
      countstr = pEntry->Attribute("count");
    else
      countstr = count->FirstChild()->Value();
    if (name)
      namestr = name->FirstChild()->Value();
    else
      namestr = pEntry->Attribute("name");


    if (namestr)
      AddListEntry(namestr, NULL, countstr, NULL, NULL,
          "lastfm://xbmc/artist/" + (CStdString)namestr + "/", items);

    pEntry = pEntry->NextSiblingElement("artist");
  }

  m_xmlDoc.Clear();
  return true;
}
示例#2
0
	bool Overlay::load(std::string name)
	{
		std::string fullpath = Engine::get().getGameDirectory() + "/overlays/" + name;
		TiXmlDocument doc(fullpath.c_str());
		if(!doc.LoadFile())
		{
			std::cerr << "Could not find overlay file " << fullpath << std::endl;
			return false;
		}
		TiXmlNode *xmlroot;
		TiXmlNode *xmlnode;
		TiXmlElement *xmlelement;
		if((xmlroot = doc.FirstChild("overlay")))
		{
			std::cerr << "Could not find <overlay> in " << fullpath << std::endl;
			return false;
		}
		xmlelement = xmlroot->ToElement();
		if(!xmlelement->Attribute("name"))
		{
			std::cerr << "Could not find \"name\" for <overlay> in overlay file " << fullpath << std::endl;
			return false;
		}
		name = xmlelement->Attribute("name");
		
		// Parsing groups
		xmlnode = xmlroot->FirstChild("group");
		while(xmlnode)
		{
			if((xmlelement = xmlnode->ToElement()))
			{
				if(!xmlelement->Attribute("name"))
				{
					std::cerr << "Could not find \"name\" for <group> in overlay file " << fullpath << std::endl;
					return false;
				}
				// Instantiate new group
				groups[xmlelement->Attribute("name")] = new OverlayGroup;
				// Load group from node
				if(!groups[xmlelement->Attribute("name")]->load(xmlnode))
				{
					std::cout << "Error on loading overlay group from " << fullpath << std::endl;
					return false;
				}
			}

			xmlnode = xmlroot->IterateChildren("group", xmlnode);
		}
		
		return true;
	}
示例#3
0
void zzzSndSystem::LoadSounds()
{
	//read xml & load sets
	DataStreamPtr data = ResourceGroupManager::getSingleton().openResource("sounds.xml");
	String str = data->getAsString();
	TiXmlDocument doc;
	doc.Parse(str.c_str());

	if (!doc.Error())
	{
		TiXmlNode* node;
		node=doc.FirstChild();
		node=node->FirstChild();
		for (;node!=0;node=node->NextSibling()) 
		{
			if (node->Type() == TiXmlNode::ELEMENT)
			{
				//get params
				String name = "";
				String file = "";

				if (strcmp(node->Value(), "sound") == 0)
				{
					TiXmlAttribute* att = node->ToElement()->FirstAttribute();
					while (att)
					{
						if (strcmp(att->Name(), "name") == 0)
						{
							name = att->Value();
						}
						else if (strcmp(att->Name(), "file") == 0)
						{
							file = att->Value();
						}
						att = att->Next();
					}

					if (name.length() > 0)
					{
						SND->LoadSound(name, file);
					}
				}
			}
		}
	}
	else
	{
		throw Exception(Exception::ERR_FILE_NOT_FOUND, std::string(doc.ErrorDesc()) + " : particles.xml", __FUNCTION__);
	}
}
示例#4
0
void LangHelper::SetMainMenu(HMENU hMenu)
{
	if (!hMenu){
		return ;
	}

// 	<Menu>
// 		<Main>
// 			<Entries>

	TiXmlNode *mainMenu = _pXmlDoc->FirstChild("Language");
	ASSERT_POINTER(mainMenu);

	mainMenu = mainMenu->FirstChild("Menu");
	ASSERT_POINTER(mainMenu);

	mainMenu = mainMenu->FirstChild("Main");
	ASSERT_POINTER(mainMenu);

	SetMenuEntries(mainMenu->FirstChild("Entries"), hMenu);
	SetMenuSubEntries(mainMenu->FirstChild("SubEntries"), hMenu);
	SetCommandMenu(mainMenu->FirstChild("Command"), hMenu);
}
示例#5
0
const String& MimeType::comment(void) {
	// calling without mime loaded do nothing
	if(!(status & MIME_LOADED))
		return mcmt;

	if(status & COMMENT_LOADED)
		return mcmt;

	String ttype = mtype;
	ttype += ".xml";

	const char* p = xdg_mime_find_data(ttype.c_str());
	if(!p)
		return mcmt;

	String path = p;
	
	TiXmlDocument doc(path.c_str());

	if(!doc.LoadFile()) {
		E_DEBUG(E_STRLOC ": MimeType::comment() %s malformed\n", path.c_str());
		return mcmt;
	}

	TiXmlNode* el = doc.FirstChild("mime-type");

	/*
	 * First element which does not have "xml:lang" attribute
	 * is default one. So hunt that one :)
	 *
	 * Btw. TinyXML does not handle XML namespaces and will return
	 * "<namespace>:<attribute>" value. This is not big deal as long
	 * as correctly fetch attribute values.
	 */
	for(el = el->FirstChildElement(); el; el = el->NextSibling()) {
		if(strncmp(el->Value(), "comment", 7) == 0) {
			// TODO: add locale here
			if(!el->ToElement()->Attribute("xml:lang")) {
				TiXmlText* data = el->FirstChild()->ToText();
				if(data) {
					mcmt = data->Value();
					break;
				}
			}
		}
	}

	status |= COMMENT_LOADED;
	return mcmt;
}
示例#6
0
	TiXmlElement* TiXmlFindElement(TiXmlDocument* doc, const xdl_char* elements) {
		std::vector<std::string> tokens;
		size_t number = xstd::tokenize(elements, tokens, "/");
		TiXmlNode* child = doc;
		size_t count = 0;
		while(count < number) {
			child = child->FirstChild(tokens[count].c_str());
			count++;;
		}
		if(child != NULL)
			return child->ToElement();

		return NULL;
	}
bool RequestLCGetVideoTask::HandleCallback(const string& url, bool requestRet, const char* buf, int size)
{
	FileLog("httprequest", "RequestLCGetVideoTask::HandleResult( "
			"url : %s,"
			"requestRet : %s "
			")",
			url.c_str(),
			requestRet?"true":"false"
			);

	if (size < MAX_LOG_BUFFER) {
		FileLog("httprequest", "RequestLCGetVideoTask::HandleResult( buf( %d ) : %s )", size, buf);
	}

	string errnum = "";
	string errmsg = "";
	string videoUrl = "";
	bool bFlag = false;
	bool bContinue = true;
	if (requestRet) {
		// request success
		TiXmlDocument doc;
		if( HandleResult(buf, size, errnum, errmsg, doc, &bContinue) ) {
			bFlag = true;

			TiXmlNode *rootNode = doc.FirstChild(COMMON_ROOT);
			if (NULL != rootNode) {
				// group list
				TiXmlNode *videoNode = rootNode->FirstChild(LC_GETVIDEO_VIDEO_URL);
				if (NULL != videoNode) {
					TiXmlElement* videoUrlElement  = videoNode->ToElement();
					if (NULL != videoUrlElement) {
						videoUrl = videoUrlElement->GetText();
					}
				}

			}
		}
	} else {
		// request fail
		errnum = LOCAL_ERROR_CODE_TIMEOUT;
		errmsg = LOCAL_ERROR_CODE_TIMEOUT_DESC;
	}

	if( bContinue && mpCallback != NULL ) {
		mpCallback->OnGetVideo(bFlag, errnum, errmsg, videoUrl, this);
	}

	return bFlag;
}
示例#8
0
int CXGseScd::FindLNType(TiXmlNode *pLN0Node, const std::string &prefix, const std::string &ln_class, const std::string &ln_inst, const std::string &do_name, std::string &ds_desc, std::string &ln_type)
{
    TiXmlNode *pXmlLNNode = pLN0Node->NextSibling("LN");
    TiXmlElement *pLNElement = NULL;
    while (pXmlLNNode != NULL)
    {
        pLNElement = pXmlLNNode->ToElement();
        if ((ln_class == pLNElement->Attribute("lnClass"))
            && (ln_inst == pLNElement->Attribute("inst"))
            && ((prefix == "")
            || (prefix == pLNElement->Attribute("prefix"))))
        {
            ln_type = pLNElement->Attribute("lnType");
            TiXmlNode *pDONode = pXmlLNNode->FirstChild("DOI");
            while (pDONode != NULL)
            {
                if (pDONode->ToElement()->Attribute("name") == do_name)
                {
                    TiXmlNode *pDANode = pDONode->FirstChild("DAI");
                    while (pDANode != NULL)
                    {
                        if (pDANode->ToElement()->Attribute("name") == std::string("dU"))
                        {
                            ds_desc = pDANode->FirstChildElement("Val")->GetText();
                            break;
                        }
                        pDANode = pDANode->NextSibling();
                    }
                    return J_OK;
                }
                pDONode = pDONode->NextSibling();
            }
        }
        pXmlLNNode = pXmlLNNode->NextSibling("LN");
    }
    return J_NOT_FOUND;
}
示例#9
0
void find_fileconfiguration( TiXmlElement* pElement , const char* filepath )
{	
	char buffer[128] = STR_FALSE;
	TiXmlNode* pNode = pElement->FirstChild();
	while( pNode )
	{		
		if ( strcmp( pNode->Value() , ELEMENT_NAME ) )
		{
			TiXmlNode* ptemp = pNode->NextSibling();
			pNode = ptemp;
			continue;
		}

		const char* text = pNode->FirstChild()->ToText()->Value();
		const char* check_str = pNode->ToElement()->Attribute( ATTRIBUTE_NAME );

		if ( !strcmp( check_str , ATTRIBUTE_TEXT_DEBUG ) )
		{
			strcpy_s( buffer , pNode->FirstChild()->ToText()->Value() );
			if ( !strcmp( buffer , STR_TRUE ) )
			{		
				g_except_file_table.push_back( filepath );
			}
		}

		TiXmlNode* ptemp = pNode->NextSibling();
		pElement->RemoveChild( pNode );
		pNode = ptemp;
	}

	push_excludedfrombuild( pElement , ELEMENT_NAME, ATTRIBUTE_NAME, ATTRIBUTE_TEXT_DEBUG, buffer );
	push_excludedfrombuild( pElement , ELEMENT_NAME, ATTRIBUTE_NAME, ATTRIBUTE_TEXT_DEBUG_UNITY, "true" );

	push_excludedfrombuild( pElement , ELEMENT_NAME, ATTRIBUTE_NAME, ATTRIBUTE_TEXT_RELEASE, buffer );
	push_excludedfrombuild( pElement , ELEMENT_NAME, ATTRIBUTE_NAME, ATTRIBUTE_TEXT_RELEASE_UNITY, "true" );	

}
示例#10
0
void XMLreader::mainProcessorIni( std::vector<TiXmlNode*> pParentVect )
{
    std::map<int, TiXmlNode*> parents;
    for (unsigned iParent=0; iParent<pParentVect.size(); ++iParent) {
        EPC_ASSERT( pParentVect[iParent]->Type()==TiXmlNode::DOCUMENT ||
                          pParentVect[iParent]->Type()==TiXmlNode::ELEMENT );

        TiXmlElement* pParentElement = pParentVect[iParent]->ToElement();
        int id=0;
        if (pParentElement) {
            const char* attribute = pParentElement->Attribute("id");
            if (attribute) {
                std::stringstream attributestr(attribute);
                attributestr >> id;
            }
        }
        parents[id] = pParentVect[iParent];
    }

    std::map<int, TiXmlNode*>::iterator it = parents.begin();
    name = it->second->ValueStr();

    for (; it != parents.end(); ++it) {
        int id = it->first;

        TiXmlNode* pParent = it->second;
        Data& data = data_map[id];
        data.text="";

        typedef std::map<std::string, std::vector<TiXmlNode*> > ChildMap;
        ChildMap childMap;
        TiXmlNode* pChild;
        for ( pChild = pParent->FirstChild(); pChild != 0; pChild = pChild->NextSibling()) 
        {
            int type = pChild->Type();
            if ( type==TiXmlNode::ELEMENT ) {
                std::string name(pChild->Value());
                childMap[name].push_back(pChild);
            }
            else if ( type==TiXmlNode::TEXT ) {
                data.text = pChild->ToText()->ValueStr();
            }
        }
        for (ChildMap::iterator it = childMap.begin(); it != childMap.end(); ++it) {
            std::vector<TiXmlNode*> pChildVect = it->second;
            data.children.push_back( new XMLreader( pChildVect ) );
        }
    }
}
示例#11
0
  int tixmldocument_write(lua_State *L) {
    TiXmlDocument *xmldoc;
    TiXmlDocument_ud* xmldoc_userdata = (TiXmlDocument_ud *) luaL_checkudata(L, 1, "TiXmlDocument");
    xmldoc = xmldoc_userdata->xmldoc;
    const char *path = luaL_checkstring(L, 2); // path
    const char *value = luaL_checkstring(L, 3); // new value

    lua_pop(L, 3);

    char *attr_name;
    TiXmlNode *node = find_node(path, xmldoc->RootElement(), &attr_name);

    if (node) {
      if (attr_name) {
	if (node->Type() == TiXmlNode::ELEMENT) {
	  TiXmlElement *elt_node = dynamic_cast<TiXmlElement *>(node);

	  if (elt_node->Attribute(attr_name)) {
	    elt_node->SetAttribute(attr_name, value);
	    delete attr_name;
	    lua_pushboolean(L, 1);
	    return 1;
	  }
	}
	luaL_error(L, "invalid attribute: %s", attr_name);
	delete attr_name;
	return 0;
      } else {
	TiXmlNode *n = node->FirstChild();
	if (n) {
	  if (n->Type()==TiXmlNode::TEXT) {
	    n->SetValue(value);
	  } else {
	    return luaL_error(L, "%s does not point to a text node", path);
	  }
	} else {
	  // create the text child
	  TiXmlText *new_text_node = new TiXmlText(value);
	  // and add it
	  node->LinkEndChild(new_text_node);
	}
      }

      lua_pushboolean(L, 1);
      return 1;
    } else {
      return luaL_error(L, "path not found: %s", path);
    }
  }
示例#12
0
GupExtraOptions::GupExtraOptions(const char * xmlFileName) : _proxyServer(""), _port(-1)//, _hasProxySettings(false)
{
	_xmlDoc.LoadFile(xmlFileName);

	TiXmlNode *root = _xmlDoc.FirstChild("GUPOptions");
	if (!root)
		return;
		
	TiXmlNode *proxyNode = root->FirstChildElement("Proxy");
	if (proxyNode)
	{
		TiXmlNode *serverNode = proxyNode->FirstChildElement("server");
		if (serverNode)
		{
			TiXmlNode *server = serverNode->FirstChild();
			if (server)
			{
				const char *val = server->Value();
				if (val)
					_proxyServer = val;
			}
		}

		TiXmlNode *portNode = proxyNode->FirstChildElement("port");
		if (portNode)
		{
			TiXmlNode *port = portNode->FirstChild();
			if (port)
			{
				const char *val = port->Value();
				if (val)
					_port = atoi(val);
			}
		}
	}
}
示例#13
0
void ConfigManager::Read(const wxString& name, ConfigManagerContainer::StringToStringMap* map)
{
    wxString key(name);
    TiXmlElement* e = AssertPath(key);

    TiXmlHandle parentHandle(e);
    TiXmlNode *mNode = parentHandle.FirstChild(cbU2C(key)).FirstChild("ssmap").Node();

    TiXmlNode *curr = 0;
    if(mNode)
    {
        while((curr = mNode->IterateChildren(curr)))
            (*map)[cbC2U(curr->Value())] = cbC2U(curr->FirstChild()->ToText()->Value());
    }
}
示例#14
0
void DownloadToolTask::validateTools()
{
	std::vector<DesuraId> toolList;
	getItemInfo()->getCurrentBranch()->getToolList(toolList);

	if (toolList.size() == 0)
		return;

	if (!getUserCore()->getToolManager()->areAllToolsValid(toolList))
	{
		//missing tools. Gather info again
		TiXmlDocument doc;

		getWebCore()->getItemInfo(getItemId(), doc, MCFBranch(), MCFBuild());

		TiXmlNode *uNode = doc.FirstChild("iteminfo");

		if (!uNode)
			throw gcException(ERR_BADXML);

		TiXmlNode *toolNode = uNode->FirstChild("toolinfo");

		if (toolNode)
			getUserCore()->getToolManager()->parseXml(toolNode);

		TiXmlNode *gameNode = uNode->FirstChild("games");

		if (!gameNode)
			throw gcException(ERR_BADXML);

		getItemInfo()->getCurrentBranch()->getToolList(toolList);
	}

	if (!getUserCore()->getToolManager()->areAllToolsValid(toolList))
		throw gcException(ERR_INVALID, "Tool ids cannot be resolved into tools.");
}
void sqr_tools::CAnimationGroupEditImp::SaveNewAGPFile( std::string name )
{
	std::string keyName = "AddAGPBt";
	string pathFileValue;
	TiXmlNode* pConfigXml = CEditorConfig::GetInst()->GetEditorConfig("FileDialogSetting");
	TiXmlElement* pElement = pConfigXml->ToElement();
	TiXmlNode* pNode = NULL;
	pNode = pConfigXml->FirstChild(keyName);
	if(pNode)
	{
		pElement=pNode->ToElement();
		pElement->SetAttribute("Path",name);
		CEditorConfig::GetInst()->SaveEditorConfig();
	}
}
示例#16
0
void ConfigManager::Read(const wxString& name, ConfigManagerContainer::StringSet* set)
{
    wxString key(name);
    TiXmlElement* e = AssertPath(key);

    TiXmlHandle parentHandle(e);
    TiXmlNode *mNode = parentHandle.FirstChild(cbU2C(key)).FirstChild("sset").Node();

    TiXmlNode *curr = nullptr;
    if (mNode)
    {
        while ((curr = mNode->IterateChildren(curr)))
            set->insert(cbC2U(curr->FirstChild()->ToText()->Value()));
    }
}
示例#17
0
void ConfigManager::Read(const wxString& name, wxArrayString *arrayString)
{
    wxString key(name);
    TiXmlElement* e = AssertPath(key);

    TiXmlHandle parentHandle(e);
    TiXmlNode *asNode = parentHandle.FirstChild(cbU2C(key)).FirstChild("astr").Node();

    TiXmlNode *curr = nullptr;
    if (asNode)
    {
        while ((curr = asNode->IterateChildren("s", curr)))
            arrayString->Add(cbC2U(curr->FirstChild()->ToText()->Value()));
    }
}
void CKSXML_Read_Project::Read_Track_Region_Fade(TiXmlElement* pElement, CRegion_Data* pRegion_Data)
{
	if ( !pElement ) return ;
	
	TiXmlNode* pChild;
	
	for ( pChild = pElement->FirstChild(); pChild != 0; pChild = pChild->NextSibling()) {
		
		if(pChild->Type() == TiXmlNode::ELEMENT){
			
			if (stricmp("in", pChild->Value()) == 0) {
				
				TiXmlNode* pValue = pChild->FirstChild();
				
				if(pValue) {
					std::string sValue = pValue->Value();
					tuint uiValue = atoi(sValue.c_str());
					pRegion_Data->Fade_In_Duration(uiValue);
				}

			}
			else if (stricmp("out", pChild->Value()) == 0) {

				TiXmlNode* pValue = pChild->FirstChild();
				
				if(pValue) {
					std::string sValue = pValue->Value();
					tuint uiValue = atoi(sValue.c_str());
					pRegion_Data->Fade_Out_Duration(uiValue);
				}

			}

		}
	}
}
示例#19
0
void SetupInfo::LoadFromFile()
{
	//DEBUG

	// opening XML file
	TiXmlDocument doc( "settings.xml" );
	bool result = doc.LoadFile();
	assert( result == true && "Could not load settings correctly!");

	TiXmlNode* node = 0;
	TiXmlElement* resolutionElement = 0;
	TiXmlNode* sessionName = 0;
	TiXmlNode* applicationName = 0;

	node = doc.FirstChild( "Settings" );
	resolutionElement = node->FirstChildElement("Resolution");
	sessionName = node->FirstChildElement("SessionName");
	applicationName = node->FirstChildElement("ApplicationName");

	resolutionElement->Attribute("Width", &myResolutionWidth);
	resolutionElement->Attribute("Height", &myResolutionHeight);
	mySessionName = sessionName->FirstChild()->Value();
	myApplicationName = applicationName->FirstChild()->Value();
}
示例#20
0
文件: IO.cpp 项目: BruceJawn/animata
/**
 * Loads XML scene.
 * \param filename filename to load the scene from
 * \return layers pointer,
 * the returned pointer must be freed by the caller
 **/
Layer *IO::load(const char *filename)
{
	filepath = filename;

	TiXmlDocument doc(filename);
	if (!doc.LoadFile())
		return NULL;

	TiXmlHandle docHandle(&doc);

	TiXmlNode *animataNode = docHandle.FirstChild("animata").ToNode();
	TiXmlNode *rootLayerNode  = animataNode->FirstChild("layer");
	Layer *rootLayer = loadLayer(rootLayerNode);

	return rootLayer;
}
bool CLastFMDirectory::ParseTrackList(CStdString url, CFileItemList &items)
{
  if (!RetrieveList(url))
    return false;

  TiXmlElement* pRootElement = m_xmlDoc.RootElement();

  TiXmlElement* pEntry = pRootElement->FirstChildElement("track");

  while(pEntry)
  {
    TiXmlNode* name = pEntry->FirstChild("name");
    TiXmlNode* artist = pEntry->FirstChild("artist");
    TiXmlElement *date = pEntry->FirstChildElement("date");

    TiXmlNode* count;
    count = pEntry->FirstChild("count");
    if (!count) count = pEntry->FirstChild("playcount");
    if (!count) count = pEntry->FirstChild("match");

    if (name)
    {
      if (artist)
        AddListEntry((name) ? name->FirstChild()->Value() : NULL,
            (artist) ? artist->FirstChild()->Value() : NULL,
            (count) ? count->FirstChild()->Value() : ((date) ? date->FirstChild()->Value() : NULL),
            (date) ? date->Attribute("uts") : NULL,
            NULL, "lastfm://xbmc/artist/" + (CStdString)artist->FirstChild()->Value() + "/", items);
      else
        // no artist in xml, assuming we're retrieving track list for the artist in m_objname...
        AddListEntry((name) ? name->FirstChild()->Value() : NULL,
            m_objname.c_str(),
            (count) ? count->FirstChild()->Value() : NULL,
            NULL, NULL, "lastfm://xbmc/artist/" + m_objname + "/", items);
    }
    else
    {
      // no luck, try another way :)
      const char *name = pEntry->Attribute("name");
      const char *artist = pEntry->FirstChildElement("artist")->Attribute("name");
      const char *count = pEntry->Attribute("count");

      if (name)
        AddListEntry(name, artist, count, NULL, NULL,
            "lastfm://xbmc/artist/" + (CStdString)artist + "/", items);
    }

    pEntry = pEntry->NextSiblingElement("track");
  }

  m_xmlDoc.Clear();
  return true;
}
示例#22
0
tcSoundConsole::tcSoundConsole(wxWindow *parent, 
                         const wxPoint& pos, const wxSize& size, 
						 const wxString& configFile,
                         const wxString& name,
						 tc3DWindow2* graphicsHost) :
    tcXmlWindow(parent, pos, size, configFile, name, graphicsHost),
    soundEffect("consolebeep"),
	lastEffect(0)
{

	if (!config)
	{
		fprintf(stderr, "tcSoundConsole::tcSoundConsole - Missing xml config\n");
        return;
	}

    TiXmlNode* root = config->FirstChild("Window");
    if (!root)
    {
        fprintf(stderr, "tcSoundConsole::tcSoundConsole - Missing top level <Window> tag\n");
        return;
    }

	TiXmlNode* current = root->FirstChild("TextBox");
	
	int topMargin = 0;
	int bottomMargin = 0;
	int wrap = 30;
	if (current)
	{
		TiXmlElement* elt = current->ToElement();
		elt->Attribute("TopMargin", &topMargin);
		elt->Attribute("BottomMargin", &bottomMargin);
		elt->Attribute("Wrap", &wrap);
	}

	textBox = new tcConsoleBox(this, current);
	textBox->SetActive(true);
	textBox->SetSize(0, topMargin, 
		size.GetWidth(), size.GetHeight()  - (topMargin + bottomMargin));

	SetWrap(wrap);
    SetBorderDraw(true);

}
示例#23
0
bool ValidateProjXML(char* path)
{
	TiXmlDocument doc(path);
	if (doc.LoadFile())
	{
		TiXmlNode* first = doc.FirstChild();
		while (first->Type() != TiXmlNode::TINYXML_ELEMENT)
		{
			first = first->NextSibling();
		}
		if (!strncmp(first->Value(), "TRSProject", strlen(first->Value())))
		{
			TiXmlAttribute* art = first->ToElement()->FirstAttribute();
			if (!art)
				return false;
			if (strncmp(art->Name(), "name", 4))
			{
				return false;
			}
			art = art->Next();
			if (art)
			{
				if (strncmp(art->Name(), "ProjectPath", 11))
				{
					return false;
				}
			}
			else
			{
				return false;
			}
			TiXmlNode* head = first->FirstChild();
			for (head; head != 0; head = head->NextSibling())
			{
				if (strncmp(head->Value(), "path", strlen(head->Value())))
				{
					return false;
				}
			}
			return true;
		}
		return false;
	}
	return false;
}
示例#24
0
void SE_UnitHeightHandler::handle(SE_Element* parent, TiXmlElement* xmlElement, unsigned int indent)
{
    SE_TextureCoordAnimation* anim = (SE_TextureCoordAnimation*)parent->getAnimation();
    if(anim == NULL)
        return;
    TiXmlNode* pChild;
    TiXmlNode* currNode = xmlElement;
    for(pChild = currNode->FirstChild() ; pChild != NULL ; pChild = pChild->NextSibling())
    {
        int t = pChild->Type();
        if(t != TiXmlNode::TINYXML_TEXT)
            return;
        TiXmlText* pText = pChild->ToText();
        const char* value = pText->Value();
        int h = atoi(value);
        anim->setUnitHeight(h);
    }
}
void CKSXML_Read_Project::Read_Sample_Object(TiXmlElement* pElement)
{
	if ( !pElement ) return ;
	
	TiXmlAttribute* pAttrib	=	pElement->FirstAttribute();
	CSample_Data Sample_Data;
	
	// set sample uuid
	if(pAttrib)	{
		std::string sUUID = pAttrib->Value();
		Sample_Data.Set_UUID(sUUID);
	}
	
	TiXmlNode* pChild;
	TiXmlText* pText;
	
	for ( pChild = pElement->FirstChild(); pChild != 0; pChild = pChild->NextSibling()) {
		
		if(pChild->Type() == TiXmlNode::ELEMENT){
			
			if (stricmp("name", pChild->Value()) == 0) {

				TiXmlNode* pName = pChild->FirstChild();
				if(pName) {
					pText = pName->ToText();
					if(pText)
						Sample_Data.Name(pText->Value());
				}
			}
			else if (stricmp("take", pChild->Value()) == 0) {
				
				CTake_Data* pTake_Data		=	Sample_Data.Get_Take_Data();
				// set take name
				pTake_Data->Screen_Name( Sample_Data.Name() );
				
				Read_Take_Object(pChild->ToElement(), pTake_Data);

			}
		}
	}
	
	// store sample data in list
	mSample_Data_List.push_back(Sample_Data);
}
示例#26
0
void ConfigManager::Read(const wxString& name, ConfigManagerContainer::IntToStringMap* map)
{
    wxString key(name);
    TiXmlElement* e = AssertPath(key);

    TiXmlHandle parentHandle(e);
    TiXmlNode *mNode = parentHandle.FirstChild(cbU2C(key)).FirstChild("ismap").Node();

    TiXmlNode *curr = nullptr;
    long tmp;
    if (mNode)
    {
        while ((curr = mNode->IterateChildren(curr)))
        {
            cbC2U(curr->Value()).Mid(1).ToLong(&tmp);
            (*map)[tmp] = cbC2U(curr->FirstChild()->ToText()->Value());
        }
    }
}
示例#27
0
static T createValue(const char* name, TiXmlElement* elm)
{
	T value(0);
	TiXmlNode *node = elm->FirstChild(name);

	if (node)
	{	
		TiXmlNode *text = node->FirstChild();
		if (text)
		{            
			if (elementEquals(text, "INF"))
				value = static_cast<T>(INFINITY);
			else
				value = stringToValue<T>(text->Value());			
		}
	}
	
	return value;
}
示例#28
0
/*
	функция считывает контура  из файла out_с.xml 
	в массив g_zones
*/
void LoadContours(int w, int h)
{
   TiXmlDocument doc("out_c.xml");
   if (!doc.LoadFile())
    return;	

   TiXmlHandle hDoc(&doc);
   TiXmlElement* pElem = NULL;
   TiXmlHandle hRoot(0);

   pElem = hDoc.FirstChildElement().Element();
   if (pElem == NULL)
	   return;

   if (strcmp(pElem->Value(), "Contours") != 0)
	   return;
   int count = 0;
   double v = 0;
   for (TiXmlNode* child = pElem->FirstChild(); child; child = child->NextSibling())
   {
	   if (strcmp(child->Value(), "Contour") != 0)
		   continue;	
	   int np = 0;
	   for (TiXmlNode* child1 = child->FirstChild(); child1; child1 = child1->NextSibling())
	   {
		   
		   child1->ToElement()->QueryDoubleAttribute("x",&v);
		   g_contours[count].Points[np].X = (float)(w*v/100.);
		   child1->ToElement()->QueryDoubleAttribute("y",&v);
		   g_contours[count].Points[np].Y = (float)(h*v/100.);
		   np++;
		   g_contours[count].NumPoints = np;
		   if (np >= C_MAX_POINTS)
			   break;
	   }
	   count++;
	   if (count >= C_MAX_OBJECTS)
		   break;
   }
   g_contours_count = count;
   MakeMaskImage(g_mask);
}
示例#29
0
int CXGseScd::MakeDataSetInfo(TiXmlNode *pLN0Node, const std::string &ds_name, GSE_DataSetInfo *pDsInfo)
{
    TiXmlNode *pDataSetNode = pLN0Node->FirstChild("DataSet");
    while (pDataSetNode != NULL)
    {
        if (pDataSetNode->ToElement()->Attribute("name") == ds_name)
        {
            pDsInfo->desc = pDataSetNode->ToElement()->Attribute("desc");
            TiXmlNode *pXmlFCDA = pDataSetNode->FirstChild("FCDA");
            TiXmlElement *pFCDAElement = NULL;
            while (pXmlFCDA != NULL)
            {
                pFCDAElement = pXmlFCDA->ToElement();
                const char *pStrVal = pFCDAElement->Attribute("prefix");
                std::string prefix = (pStrVal == NULL) ? "" : pStrVal;
                std::string ln_class = pFCDAElement->Attribute("lnClass");
                std::string ln_inst = pFCDAElement->Attribute("lnInst");
                std::string do_name = pFCDAElement->Attribute("doName");
                std::string da_name = pFCDAElement->Attribute("daName");
                std::string ln_type;
                //生成数据信息
                GSE_DataInfo *pDataInfo = new GSE_DataInfo;
                pDataInfo->fc = pFCDAElement->Attribute("fc");
                if (FindLNType(pLN0Node, prefix, ln_class, ln_inst, do_name, pDataInfo->desc, ln_type) != J_OK)
                {
                    //未找到逻辑节点类型
                    assert(false);
                }
                if (FindDAType(ln_type, do_name, da_name, pDataInfo->data_type) != J_OK)
                {
                    //未找到数据类型
                    assert(false);
                }

                pDsInfo->all_data.push_back(pDataInfo);
                pXmlFCDA = pXmlFCDA->NextSibling();
            }
        }
        pDataSetNode = pDataSetNode->NextSibling("DataSet");
    }
    return J_OK;
}
示例#30
0
void make_solution_for_ub( project_info_table& info )
{	
	TiXmlDocument root;
	std::string path = util::string::wc2mb( info.project_file_path.c_str() );
	root.LoadFile( path.c_str() );

	std::string backup_path = path + "_backup";
	root.SaveFile( backup_path.c_str() );

	if ( root.Error() == true )
	{
		printf( "loading error file : %s errorID : %d , errorRow : %d errorCol : %d"
				, path.c_str()
				, root.ErrorId()
				, root.ErrorRow()
				, root.ErrorCol()
				);

		return;
	}

	TiXmlNode* pRoot = root.FirstChildElement("Project");
	if ( pRoot == NULL )
		return;

	TiXmlNode* pItemGroup = pRoot->FirstChild("ItemGroup");
	if ( pItemGroup == NULL )
		return;

	
	search_node( pItemGroup , info.filepath_table );

	print_unity_x( info );
	
	clear_unity_file( pRoot );
	add_unity_file( pRoot );


	root.SaveFile( path.c_str() );
	root.Clear();
}