Exemple #1
0
list<BuildStep *> *getBuildStep()
{
	string ProcessNode = "Process";
	TiXmlElement *pNode = NULL;
	vector<TiXmlElement *> Nodes;

	if (GetNodePointerByName(pProjectNodes,ProcessNode,pNode))
	{
		string name = "Name";
		string program = "Program";
		string options = "Options";
		GetNodePointer(pNode,&Nodes);

		list<BuildStep *> *buildStep = new list<BuildStep *>();
		for (int i=0;i<Nodes.size();i++)
		{
			BuildStep *step = new BuildStep();
			if (GetNodePointerByName(Nodes.at(i),name,pNode))
			{
				step->SetName(pNode->GetText());
			} 
			else
			{
				return false;
			}
			if (GetChildNodeByName(Nodes.at(i),program,pNode))
			{
				step->SetProgram(pNode->GetText());
			}else return false;
			if (GetChildNodeByName(Nodes.at(i),options,pNode))
			{
				if (pNode==NULL)
				{
					step->SetOptions("");
				}
				else
				step->SetOptions(pNode->GetText());
			}else return false;

			buildStep->push_back(step);

			//delete step;
		}
		//delete pNode;
		return buildStep;
	} 
	else
	{
		return NULL;
	}
}
bool CRedisProxyCfg::saveProxyLastState(RedisProxy* proxy) {
    TiXmlElement* pRootNode = (TiXmlElement*)m_operateXmlPointer->get_rootElement();
    string nodeHash = "hash_mapping";
    TiXmlElement* pOldHashMap;
    if (GetNodePointerByName(pRootNode, nodeHash, pOldHashMap)) {
        pRootNode->RemoveChild(pOldHashMap);
    }
    TiXmlElement hashMappingNode("hash_mapping");
    for (int i = 0; i < proxy->slotCount(); ++i) {
        TiXmlElement hashNode("hash");
        hashNode.SetAttribute("value", i);
        hashNode.SetAttribute("group_name", proxy->groupBySlot(i)->groupName());
        hashMappingNode.InsertEndChild(hashNode);
    }
    pRootNode->InsertEndChild(hashMappingNode);

    // key mapping
    string nodeKey = "key_mapping";
    TiXmlElement* pKey;
    if (GetNodePointerByName(pRootNode, nodeKey, pKey)) {
        pRootNode->RemoveChild(pKey);
    }
    TiXmlElement keyMappingNode("key_mapping");

    StringMap<RedisServantGroup*>& keyMapping = proxy->keyMapping();
    StringMap<RedisServantGroup*>::iterator it = keyMapping.begin();
    for (; it != keyMapping.end(); ++it) {
        String key = it->first;
        TiXmlElement keyNode("key");
        keyNode.SetAttribute("key_name", key.data());
        RedisServantGroup* group = it->second;
        if (group != NULL) {
            keyNode.SetAttribute("group_name", group->groupName());
        }
        keyMappingNode.InsertEndChild(keyNode);
    }
    pRootNode->InsertEndChild(keyMappingNode);

    // add time
    time_t now = time(NULL);
    char fileName[512];
    struct tm* current_time = localtime(&now);
    sprintf(fileName,"onecache%d%02d%02d%02d.xml",
        current_time->tm_year + 1900,
        current_time->tm_mon + 1,
        current_time->tm_mday,
        current_time->tm_hour);

    bool ok = m_operateXmlPointer->m_docPointer->SaveFile(fileName);
    return ok;
}
Exemple #3
0
SourceCode* getSourceCode()
{
	string SourceCodeNode = "SourceCode";
	TiXmlElement *pNode = NULL;

	vector<TiXmlElement *> Nodes;

	if (GetNodePointerByName(pProjectNodes,SourceCodeNode,pNode))
	{
		string urlNode = "Url";
		string versionNode = "Version";
		string localPathNode = "LocalPath";
		TiXmlElement *pTempNode = pNode;
		SourceCode* sourceCode = new SourceCode();
		if (GetChildNodeByName(pTempNode,urlNode,pNode))
		{
			sourceCode->SetUrl(pNode->GetText());
			if (GetChildNodeByName(pTempNode,versionNode,pNode))
			{
				sourceCode->SetVersion(pNode->GetText());
				if (GetChildNodeByName(pTempNode,localPathNode,pNode))
				{
					sourceCode->SetLocalPath(pNode->GetText());

					//delete pNode;
					//delete pTempNode;
					return sourceCode;
				}
			}
		}
	}

	return NULL;
}
Exemple #4
0
PDMBUILDER_API bool setConfigXML(char *xml)
{
	string xmlFile = xml;
	
	pDoc = new TiXmlDocument();
	if (pDoc==NULL)
	{
		return false;
	}
	//printf("xml:%s\n",xmlFile.c_str());
	pDoc->LoadFile(xmlFile.c_str());
	
	TiXmlElement *pRootEle = pDoc->RootElement();
	if(NULL == pRootEle){
		return false;
	}
	
	string entryNode = "Project";
	GetNodePointerByName(pRootEle, entryNode, pProjectNodes);
	
	int index = xmlFile.find_last_of("\\");
	fileName = xmlFile.substr(index+1);
	index = fileName.find_last_of(".");
	fileName = fileName.substr(0,index);
	//printf("xml\n");
	return true;
}
Exemple #5
0
string getName()
{
	string NameNode = "Name";
	TiXmlElement *pNode = NULL;
	//vector<TiXmlElement *> Nodes;
	if(GetNodePointerByName(pProjectNodes, NameNode, pNode))
	{
		return pNode->GetText();
		
	}
	
	return "";
}
Exemple #6
0
bool GetNodePointerByName(TiXmlElement* pRootEle, string &strNodeName,TiXmlElement* &Node)
{
	if (strNodeName==pRootEle->Value()){
		Node = pRootEle;
		return true;
	}

	TiXmlElement *pEle = pRootEle;
	for (pEle = pRootEle->FirstChildElement(); pEle; pEle = pEle->NextSiblingElement()){
		if(GetNodePointerByName(pEle, strNodeName, Node)){
			return true;
		}
	}

	return false;
}
Exemple #7
0
Publish * getPublish()
{
	string PublishNode = "Publish";
	TiXmlElement *pNode = NULL;
	vector<TiXmlElement *> Nodes;

	if (GetNodePointerByName(pProjectNodes,PublishNode,pNode))
	{
		string url = "Url";
		string category = "Category";
		string component = "Component";
		string version = "Version";
		string importItem = "ImportItem";
					
		Publish *publish = new Publish();
			
		TiXmlElement * pTempNode = pNode;
		GetNodePointer(pTempNode,&Nodes);
		publish->SetUrl(Nodes.at(0)->GetText());
		publish->SetCategory(Nodes.at(1)->GetText());
		publish->SetComponent(Nodes.at(2)->GetText());
		publish->SetVersion(Nodes.at(3)->GetText());
		list<ImportItem *> itemList ;
		for(int i=4;i<Nodes.size();i++){
			string source = "Source";
			string target = "Target";
			ImportItem *item = new ImportItem();
			if (GetChildNodeByName(Nodes.at(i),source,pNode))
			{
				item->SetSource(pNode->GetText());
			}else return false;
			if (GetChildNodeByName(Nodes.at(i),target,pNode))
			{
				item->SetTarget(pNode->GetText());
			}else return false;

			itemList.push_back(item);
		}
		publish->SetImportItem(itemList);

		return publish;
	} 
	else
	{
		return NULL;
	}
}
Exemple #8
0
list<ImportStep *> * getImportStep()
{
	string ImportNode = "Import";
	TiXmlElement *pNode = NULL;
	vector<TiXmlElement *> Nodes;

	if (GetNodePointerByName(pProjectNodes,ImportNode,pNode))
	{
		string name	= "Name";
		string url = "Url";
		string importItem = "ImportItem";
		GetNodePointer(pNode,&Nodes);
		list<ImportStep *> *importStep = new list<ImportStep *>();
		for (int i=0;i<Nodes.size();i++)
		{
			ImportStep *step = new ImportStep();
			vector<TiXmlElement *> tNodes;
			GetNodePointer(Nodes.at(i),&tNodes);
			step->SetName(tNodes.at(0)->GetText());
			step->SetUrl(tNodes.at(1)->GetText());
			list<ImportItem *> itemList;
			for(int i=2;i<tNodes.size();i++){

				string source = "Source";
				string target = "Target";
				ImportItem *item = new ImportItem();
				if (GetChildNodeByName(tNodes.at(i),source,pNode))
				{
					item->SetSource(pNode->GetText());
				}else return false;
				if (GetChildNodeByName(tNodes.at(i),target,pNode))
				{
					item->SetTarget(pNode->GetText());
				}else return false;

				itemList.push_back(item);
				//delete item;
			}
			step->setItem(itemList);
			importStep->push_back(step);
			//delete step;
		}
		//delete pNode;
		return importStep;
	}else 
		return NULL;
}
Exemple #9
0
list<Dependence *> * getDependences()
{
	vector<TiXmlElement *> Nodes;
	TiXmlElement *pNode = NULL;
	string DependencesNode = "Dependences";

	if (GetNodePointerByName(pProjectNodes,DependencesNode,pNode))
	{
		string DependenceNode = "Dependence";

		GetNodePointer(pNode, &Nodes);
		list<Dependence *> *depList = new list<Dependence *>();
		for (int i=0;i<Nodes.size();i++)
		{

			TiXmlElement *pTempNode = Nodes.at(i);
			string server = "Server";
			string flag = "Flag";
			string repository = "Repository";
			string name = "Name";
			string version = "Version";
			string path = "Path";
			string localPath = "LocalPath";

			Dependence *dep = new Dependence();
			if (GetChildNodeByName(pTempNode,server,pNode))
			{
				dep->SetServer(pNode->GetText());
			}else
			{
				return false;
			}
			if (GetChildNodeByName(pTempNode,flag,pNode))
			{
				dep->SetFlag(pNode->GetText());
			}else
			{
				return false;
			}
			if (GetChildNodeByName(pTempNode,repository,pNode))
			{
				dep->SetRepository(pNode->GetText());
			}else
			{
				return false;
			}

			if (GetChildNodeByName(pTempNode,name,pNode))
			{
				dep->SetName(pNode->GetText());
			} 
			else
			{
				return false;
			}
			if (GetChildNodeByName(pTempNode,version,pNode))
			{
				dep->SetVersion(pNode->GetText());
			}else
			{
				return false;
			}
			if(GetChildNodeByName(pTempNode,path,pNode)){
				dep->SetPath(pNode->GetText());
			}else
			{
				return false;
			}
			if (GetChildNodeByName(pTempNode,localPath,pNode))
			{
				dep->SetLocalPath(pNode->GetText());
			} 
			else
			{
				return false;
			}

			depList->push_back(dep);
			//delete dep;
			//delete pTempNode;
		}
		//delete pNode;
		return depList;
	}else
	{
		return NULL;
	}
}