Esempio n. 1
0
TiXmlDocument * TcxBase::getGpxDocument() {
    TiXmlDocument * doc = new TiXmlDocument();

    TiXmlDeclaration * decl = new TiXmlDeclaration( "1.0", "UTF-8", "no");
    doc->LinkEndChild( decl );

    TiXmlElement * gpx = new TiXmlElement( "gpx" );
    gpx->SetAttribute("xmlns","http://www.topografix.com/GPX/1/1");
    gpx->SetAttribute("xmlns:gpxx","http://www.garmin.com/xmlschemas/GpxExtensions/v3");
    gpx->SetAttribute("xmlns:gpxtpx","http://www.garmin.com/xmlschemas/TrackPointExtension/v1");
    gpx->SetAttribute("xmlns:xsi","http://www.w3.org/2001/XMLSchema-instance");
    gpx->SetAttribute("creator","GarminPlugin");
    gpx->SetAttribute("version","1.1");
    gpx->SetAttribute("xsi:schemaLocation","http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd http://www.garmin.com/xmlschemas/GpxExtensions/v3 http://www.garmin.com/xmlschemas/GpxExtensionsv3.xsd http://www.garmin.com/xmlschemas/TrackPointExtension/v1 http://www.garmin.com/xmlschemas/TrackPointExtensionv1.xsd");
    doc->LinkEndChild( gpx );

    vector<TcxActivities*>::iterator it;
    for ( it=activitiesList.begin() ; it < activitiesList.end(); it++ )
    {
        TcxActivities* activities = *it;
        vector<TiXmlElement*> trkElem = activities->getGpxTiXml();
        vector<TiXmlElement*>::iterator it;
        for ( it=trkElem.begin() ; it < trkElem.end(); it++ ) {
            TiXmlElement* elem = *it;
            gpx->LinkEndChild( elem );
        }
    }

    return doc;
}
Esempio n. 2
0
TiXmlDocument * TcxBase::getTcxDocument(bool readTrackData, string fitnessDetailId) {
    TiXmlDocument * doc = new TiXmlDocument();

    TiXmlDeclaration * decl = new TiXmlDeclaration( "1.0", "UTF-8", "no");
    doc->LinkEndChild( decl );

    TiXmlElement * train = new TiXmlElement( "TrainingCenterDatabase" );
    train->SetAttribute("xmlns","http://www.garmin.com/xmlschemas/TrainingCenterDatabase/v2");
    train->SetAttribute("xmlns:xsi","http://www.w3.org/2001/XMLSchema-instance");
    train->SetAttribute("xsi:schemaLocation","http://www.garmin.com/xmlschemas/TrainingCenterDatabase/v2 http://www.garmin.com/xmlschemas/TrainingCenterDatabasev2.xsd http://www.garmin.com/xmlschemas/ActivityExtension/v2 http://www.garmin.com/xmlschemas/ActivityExtensionv2.xsd");
    doc->LinkEndChild( train );

    vector<TcxActivities*>::iterator it;
    for ( it=activitiesList.begin() ; it < activitiesList.end(); it++ )
    {
        TcxActivities* activities = *it;
        train->LinkEndChild( activities->getTiXml(readTrackData, fitnessDetailId) );
    }

    if (this->author != NULL) {
        train->LinkEndChild(this->author->getTiXml());
    }

    return doc;
}
void EditorLevel::saveHashes() {
	TiXmlDocument doc;
	TiXmlDeclaration *decl = new TiXmlDeclaration( "1.0", "", "" );
	doc.LinkEndChild( decl );

	TiXmlElement *hashRoot = new TiXmlElement(SONICGLVL_LEVEL_HASH_ROOT);

	TiXmlElement *dataRoot = new TiXmlElement(SONICGLVL_LEVEL_HASH_DATA);
	for (size_t i=0; i<5; i++) {
		dataRoot->SetAttribute(SONICGLVL_LEVEL_HASH_VALUE_ATTRIBUTE + ToString(i), data_hash[i]);
	}
	hashRoot->LinkEndChild(dataRoot);

	TiXmlElement *terrainRoot = new TiXmlElement(SONICGLVL_LEVEL_HASH_TERRAIN);
	for (size_t i=0; i<5; i++) {
		terrainRoot->SetAttribute(SONICGLVL_LEVEL_HASH_VALUE_ATTRIBUTE + ToString(i), terrain_hash[i]);
	}
	hashRoot->LinkEndChild(terrainRoot);

	TiXmlElement *resourcesRoot = new TiXmlElement(SONICGLVL_LEVEL_HASH_RESOURCES);
	for (size_t i=0; i<5; i++) {
		resourcesRoot->SetAttribute(SONICGLVL_LEVEL_HASH_VALUE_ATTRIBUTE + ToString(i), resources_hash[i]);
	}
	hashRoot->LinkEndChild(resourcesRoot);

	doc.LinkEndChild(hashRoot);
	doc.SaveFile(cache_folder + SONICGLVL_LEVEL_HASH_FILENAME);
}
void Config::SaveConfigRule()
{
    std::string file = Utils::getConfigFile(RULES_CONFIG);
    std::string tmp = file + "_tmp";

    cInfo() <<  "Saving " << file << "...";

    TiXmlDocument document;
    TiXmlDeclaration *decl = new TiXmlDeclaration("1.0", "UTF-8", "");
    TiXmlElement *rulesnode = new TiXmlElement("calaos:rules");
    rulesnode->SetAttribute("xmlns:calaos", "http://www.calaos.fr");
    document.LinkEndChild(decl);
    document.LinkEndChild(rulesnode);

    for (int i = 0;i < ListeRule::Instance().size();i++)
    {
        Rule *rule = ListeRule::Instance().get_rule(i);
        rule->SaveToXml(rulesnode);
    }

    if (document.SaveFile(tmp))
    {
        ecore_file_unlink(file.c_str());
        ecore_file_mv(tmp.c_str(), file.c_str());
    }

    cInfo() <<  "Done.";
}
Esempio n. 5
0
VAUTILS_API bool SaveInitParams(const char* lpFileName, TVAInitParams* params)
{
	if (lpFileName == NULL || params == NULL)
		return false;
	
	TiXmlElement* element = new TiXmlElement("VAPARAMS");
	TiXmlElement* e = new TiXmlElement("Camera");
	
	e->SetDoubleAttribute("height", params->Camera.Height);
	e->SetDoubleAttribute("angle", params->Camera.Angle);
	e->SetDoubleAttribute("focus", params->Camera.Focus);
	e->SetDoubleAttribute("wsize", params->Camera.WChipSize);
	e->SetDoubleAttribute("hsize", params->Camera.HChipSize);

	element->LinkEndChild(e);

	TiXmlElement* e1 = new TiXmlElement("Zones");
	//
	for (int i = 0; i < params->NumZones; i++)
	{
		if (params->Zones[i].IsRect)
		{
			//сохранить прямоугольник
			TiXmlElement* e3 = new TiXmlElement("rect");
			e3->SetDoubleAttribute("x", params->Zones[i].Rect.LeftTop.X);
			e3->SetDoubleAttribute("y", params->Zones[i].Rect.LeftTop.Y);
			e3->SetDoubleAttribute("bx", params->Zones[i].Rect.RightBottom.X);
			e3->SetDoubleAttribute("by", params->Zones[i].Rect.RightBottom.Y);
			e1->LinkEndChild(e3);
		}
		else
		{
			//сохранить контур
			TiXmlElement* e3 = new TiXmlElement("contour");
			for (int j = 0; j < params->Zones[i].NumPoints; j++)
			{
				TiXmlElement* e2 = new TiXmlElement("Point");
				e2->SetDoubleAttribute("x", params->Zones[i].Points[j].X);
				e2->SetDoubleAttribute("y", params->Zones[i].Points[j].Y);
				e3->LinkEndChild(e2);
			}
			e1->LinkEndChild(e3);
		}
	}
	element->LinkEndChild(e1);

	TiXmlElement* e3 = new TiXmlElement("sensitivity");
	e3->SetDoubleAttribute("eventsens", params->EventSens);
	e3->SetDoubleAttribute("eventtimesens", params->EventTimeSens);
	element->LinkEndChild(e3);

    TiXmlDocument doc;
    TiXmlDeclaration* decl = new TiXmlDeclaration( "1.0", "", "" );
    doc.LinkEndChild( decl );
	doc.LinkEndChild( element );



	return doc.SaveFile(lpFileName);
}
Esempio n. 6
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"));
}
Esempio n. 7
0
/*
	Функция сохраняет массив прямоугольников в xml файл out_r.xml
	параметры w,h предназначены для сохранения в относительных координатах
*/
void SaveRects(int w, int h)
{
	double value = 0;
	TiXmlElement* element = new TiXmlElement("Rects");
	for (int i = 0; i < g_rects_count; i++)
	{
		TiXmlElement* e = new TiXmlElement("rect");
		value = 100.*g_rects[i].x / (double)w;
		e->SetDoubleAttribute("x", value);
		value = 100.*g_rects[i].y / (double)h;
		e->SetDoubleAttribute("y", value);
		value = 100.*g_rects[i].width / (double)w;
		e->SetDoubleAttribute("w", value);
		value = 100.*g_rects[i].height / (double)h;
		e->SetDoubleAttribute("h", value);
		element->LinkEndChild(e);
	}

    TiXmlDocument doc;
    TiXmlDeclaration* decl = new TiXmlDeclaration( "1.0", "", "" );
    doc.LinkEndChild( decl );
	doc.LinkEndChild( element );

	doc.SaveFile("out_r.xml");
}
Esempio n. 8
0
void SaveSystemsetXml(const char *path, const t_SystemSet *systemSet) {
	char max_speed[16];
	char before_second[16];
	char after_second[16];
	char cal_before_second[16];
	char cal_after_second[16];

	TiXmlDocument *doc = new TiXmlDocument();
	TiXmlDeclaration *declar = new TiXmlDeclaration( "1.0", "UTF-8", "" );
	TiXmlElement *root = new TiXmlElement("SystemSet");
	doc->LinkEndChild(declar);
	doc->LinkEndChild(root);
	sprintf(max_speed, "%d", systemSet->m_max_speed);
	sprintf(before_second, "%d", systemSet->m_before_second);
	sprintf(after_second, "%d", systemSet->m_after_second);
	sprintf(cal_before_second, "%d", systemSet->m_cal_before_second);
	sprintf(cal_after_second, "%d", systemSet->m_cal_after_second);
	root->SetAttribute("MaxSpeed", max_speed);
	root->SetAttribute("BeforeSecond", before_second);
	root->SetAttribute("AfterSecond", after_second);
	root->SetAttribute("CalBeforeSecond", cal_before_second);
	root->SetAttribute("CalAfterSecond", cal_after_second);
	doc->SaveFile(path);
	delete doc;
}
Esempio n. 9
0
void CCardProcess::CreateResponXML(int nID, const char *szResult, char *RetXML)
{
	TiXmlDocument *XmlDoc;
	TiXmlElement *RootElement;
	TiXmlElement *Segment;
	TiXmlDeclaration HeadDec;
	TiXmlPrinter Printer;

	// 创建XML文档
	XmlDoc = new TiXmlDocument();

	// 增加XML的头部说明
	HeadDec.Parse("<?xml version=\"1.0\" encoding=\"gb2312\" ?>", 0, TIXML_ENCODING_UNKNOWN);
	XmlDoc->LinkEndChild(&HeadDec);

	RootElement = new TiXmlElement("CardProcess");
	Segment = new TiXmlElement("ReturnInfo");
	Segment->SetAttribute("ID", nID);
	Segment->SetAttribute("Desc", szResult);

	RootElement->LinkEndChild(Segment);
	XmlDoc->LinkEndChild(RootElement);

	XmlDoc->Accept(&Printer);
	strcpy(RetXML, Printer.CStr());

}
bool mitk::TransferFunctionPropertySerializer::SerializeTransferFunction( const char * filename, TransferFunction::Pointer tf )
{
  TransferFunctionPropertySerializer::Pointer tfps=TransferFunctionPropertySerializer::New();
  tfps->SetProperty( TransferFunctionProperty::New( tf ) );
  TiXmlElement* s=tfps->Serialize();
   
  if(!s)
  {
    MITK_ERROR << "cant serialize transfer function";
    return false;
  }
   
  TiXmlDocument document;
  TiXmlDeclaration* decl = new TiXmlDeclaration( "1.0", "UTF-8", "" ); // TODO what to write here? encoding? standalone would mean that we provide a DTD somewhere...
  document.LinkEndChild( decl );

  TiXmlElement* version = new TiXmlElement("Version");
  version->SetAttribute("TransferfunctionVersion",  1 );

  document.LinkEndChild(version);
  document.LinkEndChild(s);
  
  if ( !document.SaveFile( filename ) )
  {
    MITK_ERROR << "Could not write scene to " << filename << "\nTinyXML reports '" << document.ErrorDesc() << "'";
    return false;
  }
  return true;
}
void MontagingToTraceEditorXMLConverter::writeXMLFile()
{
	TiXmlDocument doc;
	TiXmlDeclaration* decl = new TiXmlDeclaration("1.0", "", "");
	doc.LinkEndChild(decl);

	TiXmlElement* root = new TiXmlElement("Source");
	doc.LinkEndChild(root);

	std::vector<ImageTransformData*>::iterator image_transforms_data_iter;

	int counter = 0;
	for (image_transforms_data_iter = image_transforms_data.begin(); image_transforms_data_iter != image_transforms_data.end(); image_transforms_data_iter++)
	{
		TiXmlElement *File = new TiXmlElement("File");
		root->LinkEndChild(File);

		ImageTransformData *image_transform = *image_transforms_data_iter;

		File->SetDoubleAttribute("tX", -1.0 * (*image_transforms_data_iter)->gettX());
		File->SetDoubleAttribute("tY", -1.0 * (*image_transforms_data_iter)->gettY());
		File->SetDoubleAttribute("tZ", -1.0 * (*image_transforms_data_iter)->gettZ());
		File->SetAttribute("FileName", (*image_transforms_data_iter)->getFileName());
		File->SetAttribute("Type", "Image");
	}

	doc.SaveFile("project.xml");
}
Esempio n. 12
0
bool MultiMarker::SaveXML(const char* fname) {
	TiXmlDocument document;
	document.LinkEndChild(new TiXmlDeclaration("1.0", "UTF-8", "no"));
	document.LinkEndChild(new TiXmlElement("multimarker"));
	TiXmlElement *xml_root = document.RootElement();

	int n_markers = marker_indices.size();
	xml_root->SetAttribute("markers", n_markers);

	for(int i = 0; i < n_markers; ++i) {
		TiXmlElement *xml_marker = new TiXmlElement("marker");
		xml_root->LinkEndChild(xml_marker);

		xml_marker->SetAttribute("index", marker_indices[i]);
		xml_marker->SetAttribute("status", marker_status[i]);

		for(int j = 0; j < 4; ++j) {
			TiXmlElement *xml_corner = new TiXmlElement("corner");
			xml_marker->LinkEndChild(xml_corner);
			CvPoint3D64f X = pointcloud[pointcloud_index(marker_indices[i], j)];
			xml_corner->SetDoubleAttribute("x", X.x);
			xml_corner->SetDoubleAttribute("y", X.y);
			xml_corner->SetDoubleAttribute("z", X.z);
		}
	}
	return document.SaveFile(fname);
}
Esempio n. 13
0
/*! Writes the entire interface to a file in the following order:
	- the size of the eg space
	- the size of the dof space
	- all eigengrasps
	- the origin
	Seems not to be compatible with the readFromFile fucntion
	of this class.
*/
int
EigenGraspInterface::writeToFile(const char *filename)
{
	TiXmlDocument doc;  
 	TiXmlDeclaration* decl = new TiXmlDeclaration( "1.0", "", "" );  
	doc.LinkEndChild( decl );  
 
	TiXmlElement * root = new TiXmlElement( "EigenGrasps" );  
	root->SetAttribute("dimensions", mRobot->getNumDOF());
	doc.LinkEndChild( root );  

	TiXmlElement * ep;
	for (int i=0; i<eSize; i++) {
	    	ep= new TiXmlElement("EG");
		mGrasps[i]->writeToFile(ep);
		root->LinkEndChild(ep);
		
	}
	//TODO Should ouput norm here
    	ep = new TiXmlElement("ORIGIN");
	mOrigin->writeToFile(ep);
	root->LinkEndChild(ep);

	doc.SaveFile(filename);

	return 1;
}
Esempio n. 14
0
// create new xml file
bool CCUserDefault::createXMLFile()
{
	bool bRet = false;
	// ?¡§¨°?¨°???TiXmlDocument¨¤¨¤????   
    TiXmlDocument *pDoc = new TiXmlDocument;  
    if (NULL==pDoc)  
    {  
        return false;  
    }  
	TiXmlDeclaration *pDeclaration = new TiXmlDeclaration("1.0","","");  
	if (NULL==pDeclaration)  
	{  
		return false;  
	}  
	pDoc->LinkEndChild(pDeclaration); 
	// ¨¦¨²3¨¦¨°????¨´?¨²¦Ì?¡êoMyApp  
	TiXmlElement *pRootEle = new TiXmlElement(USERDEFAULT_ROOT_NAME);  
	if (NULL==pRootEle)  
	{  
		return false;  
	}  
	pDoc->LinkEndChild(pRootEle);  
	bRet = pDoc->SaveFile(m_wsFilePath.c_str());

	if(pDoc)
	{
		delete pDoc;
	}

	return bRet;
}
Esempio n. 15
0
void dBone::Save(const char* fileName, const dList<dBone*>& list)
{
	TiXmlText* header;
	TiXmlElement *root;

	TiXmlDeclaration* decl;

	TiXmlDocument out (fileName);
	decl = new TiXmlDeclaration( "1.0", "", "" );
	out.LinkEndChild( decl );

	root = new TiXmlElement( "root" );
	out.LinkEndChild(root);

	header = new TiXmlText (XML_HEADER);
	root->LinkEndChild(header);
	for (dList<dBone*>::dListNode* node = list.GetFirst(); node; node = node->GetNext()) {
		int stack;
		TiXmlElement *skeleton;
		const dBone* nodeArray[1024];

		skeleton = new TiXmlElement( "skeleton" );

		stack = 1;
		nodeArray[0] = node->GetInfo();
		while (stack) {
			const char* name;

			const dBone* node;
			TiXmlElement* xmlNode;

			stack --;
			node = nodeArray[stack];

			name = node->GetName();

			xmlNode = new TiXmlElement( "bone" );
			skeleton->LinkEndChild(xmlNode);

			xmlNode->SetAttribute("name", name);
			if (node->GetParent()) {
				const char* parentName;
				parentName = node->GetParent()->GetName();
				xmlNode->SetAttribute("parent", parentName);
			}
			xmlNode->SetAttribute("boneID", node->GetBoneID());

			char matrixBuffer[512];
			dModel::FloatsToString (matrixBuffer, &node->m_localMatrix[0][0], 16);
			xmlNode->SetAttribute("matrix", matrixBuffer);
			for (node = node->GetChild(); node; node = node->GetSibling()) {
				nodeArray[stack] = node;
				stack ++;
			}
		}
		root->LinkEndChild(skeleton);
	}

	out.SaveFile (fileName);
}
Esempio n. 16
0
void creatXml(char *name, char *number, char *text, char *dstime)
{

	
	strcpy( NAME[num++],name);//???????????

	string n = name;
	TiXmlDocument *myDocument = new TiXmlDocument(n.c_str());        //创建一个根结点
	TiXmlDeclaration *pDeclaration = new TiXmlDeclaration("1.0", "utf-8", "");   //创建xml文件头
	myDocument->LinkEndChild(pDeclaration);           //加入文件头
	time_t tm;
	
	TiXmlElement *Contacts = new TiXmlElement(n.c_str());   //创建一个节点
	TiXmlText *Contactstxt = new TiXmlText(text);
	Contacts->LinkEndChild(Contactstxt);
	Contacts->SetAttribute("Number", number);             //创建节点的一个属性IP
	Contacts->SetAttribute("Timing", dstime);      //是否定时 
	Contacts->SetAttribute("Name", name);
	Contacts->SetAttribute("Date", time(&tm));//传入时间
	myDocument->LinkEndChild(Contacts);            //加入节点

	myDocument->SaveFile();   //保存文件????如何用特定名字保存!
	delete myDocument;
	myDocument = NULL;
}
Esempio n. 17
0
void ParticleEditor::SaveAs()
{
	char path[___OUTPUT_LENGTH], file[___OUTPUT_LENGTH];
	if (SaveSystem(path, file))
	{
		strcpy(path, ETHGlobal::AppendExtensionIfNeeded(path, ".par").c_str());

		TiXmlDocument doc;
		TiXmlDeclaration *pDecl = new TiXmlDeclaration(GS_L("1.0"), GS_L(""), GS_L(""));
		doc.LinkEndChild(pDecl);

		TiXmlElement *pElement = new TiXmlElement(GS_L("Ethanon"));
		doc.LinkEndChild(pElement);

		m_system.WriteToXMLFile(doc.RootElement());
		const str_type::string filePath = utf8::c(path).wstr();
		doc.SaveFile(filePath);
		#ifdef GS2D_STR_TYPE_ANSI
		  m_provider->GetFileManager()->ConvertAnsiFileToUTF16LE(filePath);
		#endif

		SetCurrentFile(path);
		m_untitled = false;
	}
}
Esempio n. 18
0
void HierClassifier::saveCache(boost::filesystem::path file){
	TiXmlDocument doc;
	TiXmlDeclaration* decl = new TiXmlDeclaration("1.0", "UTF-8", "");
	doc.LinkEndChild(decl);
	TiXmlElement* pWeakClassifiers = new TiXmlElement("weak_classifiers");
	doc.LinkEndChild(pWeakClassifiers);
	pWeakClassifiers->SetAttribute("num_labels", numLabels);
	for(int c = 0; c < classifiers.size(); c++){
		TiXmlElement* pClassifier = new TiXmlElement("classifier");
		if(classifiers[c]->type() == Classifier::SVM){
			pClassifier->SetAttribute("type", "SVM");
		}
		else if(classifiers[c]->type() == Classifier::RF){
			pClassifier->SetAttribute("type", "RF");
		}
		pWeakClassifiers->LinkEndChild(pClassifier);
		char buffer[10];
		sprintf(buffer, ".%02d.cache", c);
		pClassifier->SetAttribute("cache_file", file.string() + string(buffer));
		pClassifier->SetDoubleAttribute("weight", weights[c]);
		pClassifier->SetAttribute("desc_beg", classifiersInfo[c].descBeg);
		pClassifier->SetAttribute("desc_end", classifiersInfo[c].descEnd);

		classifiers[c]->saveCache(pClassifier, file.string() + string(buffer));
	}
	if(!doc.SaveFile(file.c_str())){
		cout << "Could not save cache" << endl;
		throw "Could not save cache";
	}
}
Esempio n. 19
0
void HouseManager::save(const std::string& fileName)
{
    try {
        TiXmlDocument doc;
        doc.SetTabSize(2);

        TiXmlDeclaration* decl = new TiXmlDeclaration("1.0", "UTF-8", "");
        doc.LinkEndChild(decl);

        TiXmlElement* root = new TiXmlElement("houses");
        doc.LinkEndChild(root);

        for(auto house : m_houses) {
            TiXmlElement *elem = new TiXmlElement("house");
            house->save(elem);
            root->LinkEndChild(elem);
        }

        std::string savePath = g_resources.getRealPath(fileName);
        if(!doc.SaveFile(savePath))
            stdext::throw_exception(stdext::format("failed to save houses XML %s: %s", savePath, doc.ErrorDesc()));
    } catch(std::exception& e) {
        g_logger.error(stdext::format("Failed to save '%s': %s", fileName, e.what()));
    }
}
Esempio n. 20
0
bool LabelSetImageIO::SaveLabelSetImagePreset(const std::string & presetFilename, LabelSetImage::Pointer & inputImage)
{
  TiXmlDocument * presetXmlDoc =  new TiXmlDocument();

  TiXmlDeclaration * decl = new TiXmlDeclaration( "1.0", "", "" );
  presetXmlDoc->LinkEndChild( decl );

  TiXmlElement * presetElement = new TiXmlElement("LabelSetImagePreset");
  presetElement->SetAttribute("layers", inputImage->GetNumberOfLayers());

  presetXmlDoc->LinkEndChild(presetElement);

  for (unsigned int layerIdx=0; layerIdx<inputImage->GetNumberOfLayers(); layerIdx++)
  {
    TiXmlElement * layerElement = new TiXmlElement("Layer");
    layerElement->SetAttribute("index", layerIdx);
    layerElement->SetAttribute("labels", inputImage->GetNumberOfLabels(layerIdx));

    presetElement->LinkEndChild(layerElement);

    for (unsigned int labelIdx=0; labelIdx<inputImage->GetNumberOfLabels(layerIdx); labelIdx++)
    {
      TiXmlElement * labelAsXml = LabelSetImageIO::GetLabelAsTiXmlElement(inputImage->GetLabel(labelIdx,layerIdx));
      layerElement->LinkEndChild(labelAsXml);
    }
  }

  bool wasSaved = presetXmlDoc->SaveFile(presetFilename);
  delete presetXmlDoc;

  return wasSaved;
}
Esempio n. 21
0
 int Webserver::SendPollResponse(struct MHD_Connection *conn)
 {
    char fntemp[128];
    int fd;
    int ret;
    TiXmlDocument doc;


    TiXmlDeclaration* decl = new TiXmlDeclaration( "1.0", "utf-8", "" );
    doc.LinkEndChild(decl);
    TiXmlElement* pollElement = new TiXmlElement("poll");
    doc.LinkEndChild(pollElement);
 
    pollElement->SetAttribute("mydata",mydata->get_data().c_str());
    
    strncpy(fntemp, "data/OZWCP_web_src/ozwcp.poll.XXXXXX", sizeof(fntemp));
    fd = mkstemp(fntemp);
    if (fd == -1){
        return MHD_YES;
    }
    close(fd);
    if(unlink(fntemp))
        return MHD_YES;
    strncat(fntemp, ".xml", sizeof(fntemp));
    doc.SaveFile(fntemp);
    ret = web_send_file(conn, fntemp, MHD_HTTP_OK, true);
    fprintf(stderr,"OZWCP: send  tmp xml file ok\n");
    return ret;
 }
Esempio n. 22
0
void SaveDevicegroupXml(const char *path, const t_DeviceGroup *deviceGroup) {
	int count;
	int index;
	char ach_index[8];
	char qjPort[8];

	TiXmlDocument *doc = new TiXmlDocument();
	TiXmlDeclaration *declar = new TiXmlDeclaration( "1.0", "UTF-8", "" );
	TiXmlElement *root = new TiXmlElement("DeviceGroup");
	TiXmlElement *first = new TiXmlElement("IpGroup");
	doc->LinkEndChild(declar);
	doc->LinkEndChild(root);
	root->LinkEndChild(first);
	count = deviceGroup->m_ipgroup_count;
	for (index = 0; index < count; index++) {
		sprintf(ach_index, "group%d", index + 1);
		const t_IpGroup *ipGroup = &deviceGroup->m_ipgroup_array[index];
		TiXmlElement *element = new TiXmlElement(ach_index);
		first->LinkEndChild(element);
		element->SetAttribute("kakou", ipGroup->m_kakou_ip);
		element->SetAttribute("qiuji", ipGroup->m_qiuji_ip);
		element->SetAttribute("quanjing", ipGroup->m_quanjing_ip);
		element->SetAttribute("quanjing_user", ipGroup->m_quanjing_user);
		element->SetAttribute("quanjing_pwd", ipGroup->m_quanjing_pwd);
		sprintf(qjPort, "%d", ipGroup->m_quanjing_port);
		element->SetAttribute("quanjing_port", qjPort);
	}
	doc->SaveFile(path);
	delete doc;
}
Esempio n. 23
0
/*
	Функция сохраняет массив контуров в xml файл out_с.xml
	параметры w,h предназначены для сохранения в относительных координатах
*/
void SaveContours(int w, int h)
{
	double value = 0;
	TiXmlElement* element = new TiXmlElement("Contours");
	for (int i = 0; i < g_contours_count; i++)
	{
		TiXmlElement* e = new TiXmlElement("Contour");
		for (int j = 0; j < g_contours[i].NumPoints; j++)
		{
			TiXmlElement* e1 = new TiXmlElement("Point");
			value = 100.*g_contours[i].Points[j].X / (double)w;
			e1->SetDoubleAttribute("x", value);
			value = 100.*g_contours[i].Points[j].Y / (double)h;
			e1->SetDoubleAttribute("y", value);
			e->LinkEndChild(e1);
		}
		element->LinkEndChild(e);
	}

    TiXmlDocument doc;
    TiXmlDeclaration* decl = new TiXmlDeclaration( "1.0", "", "" );
    doc.LinkEndChild( decl );
	doc.LinkEndChild( element );

	doc.SaveFile("out_c.xml");
	
}
Esempio n. 24
0
void gen_catfee_xml(std::vector<FeeCatXML*>& feeCat)
{
	// Make xml: <?xml ..><Hello>World</Hello>
	TiXmlDocument doc;
	TiXmlDeclaration * decl = new TiXmlDeclaration("1.0", "", "");
	TiXmlElement * element = new TiXmlElement("import");

	//TiXmlText * text = new TiXmlText("World");
	element->SetAttribute("mode", "synchronize");
	doc.LinkEndChild(decl);
	doc.LinkEndChild(element);

	{
		
		for (std::vector < FeeCatXML* >::iterator iter = feeCat.begin();
			iter != feeCat.end(); iter++) {
			TiXmlElement * feescats = new TiXmlElement("clientfeecat");
			element->LinkEndChild(feescats);
			FeeCatXML *feeCat =  *iter;

			TiXmlElement * id = new TiXmlElement("id");
			TiXmlElement * name = new TiXmlElement("name");
		
			feescats->LinkEndChild(id);
			feescats->LinkEndChild(name);
		
			id->LinkEndChild(new TiXmlText((feeCat->id).c_str() ));
			name->LinkEndChild(new TiXmlText( (feeCat->name).c_str() ));

		}


		doc.SaveFile("BSBFeeCat.xml");
	}
}
Esempio n. 25
0
bool TMeasurementColorHistory::Delete(AnsiString strId)
{
  //
	TiXmlDocument doc;
	TiXmlDeclaration* decl = new TiXmlDeclaration( "1.0", "", "" );
	doc.LinkEndChild( decl );
	TiXmlElement* root = new TiXmlElement( "TMeasurementColorHistory" );
	doc.LinkEndChild( root );

	TiXmlElement* e = Root();
	for(TiXmlNode* child = e->FirstChild(); child; child = child->NextSibling() )
	{
	  TiXmlElement* e1 = child->ToElement();
	  AnsiString str_id = e1->Attribute("id");
	  if (str_id != strId)
	  {
		TiXmlNode* e2 = e1->Clone();
		root->LinkEndChild(e2);
	  }
	  else
	  {
		AnsiString str = e1->Attribute("image");
		UnicodeString str1 = ExtractFilePath(this->m_strFileName);
		str1 += str;
		DeleteFile(str1);
	  }
	}
	doc.SaveFile(this->m_strFileName.c_str());


	bool res = m_doc.LoadFile(m_strFileName.c_str());
	m_root = m_doc.FirstChildElement("TMeasurementColorHistory");
	return res;
}
void CelestialNavigationDialog::SaveXML(wxString filename)
{
    TiXmlDocument doc;
    TiXmlDeclaration* decl = new TiXmlDeclaration( "1.0", "utf-8", "" );
    doc.LinkEndChild( decl );

    TiXmlElement * root = new TiXmlElement( "OpenCPNCelestialNavigation" );
    doc.LinkEndChild( root );

    char version[24];
    sprintf(version, "%d.%d", PLUGIN_VERSION_MAJOR, PLUGIN_VERSION_MINOR);
    root->SetAttribute("version", version);
    root->SetAttribute("creator", "Opencpn Celestial Navigation plugin");

    TiXmlElement *c = new TiXmlElement( "ClockError" );
    c->SetAttribute("Seconds", m_ClockCorrectionDialog.m_sClockCorrection->GetValue());
    root->LinkEndChild(c);

    for(int i = 0; i<m_lSights->GetItemCount(); i++) {
        TiXmlElement *c = new TiXmlElement( "Sight" );

        Sight *s = (Sight*)wxUIntToPtr(m_lSights->GetItemData(i));

        c->SetAttribute("Visible", s->m_bVisible);
        c->SetAttribute("Type", s->m_Type);
        c->SetAttribute("Body", s->m_Body.mb_str());
        c->SetAttribute("BodyLimb", s->m_BodyLimb);

        c->SetAttribute("Date", s->m_DateTime.FormatISODate().mb_str());
        c->SetAttribute("Time", s->m_DateTime.FormatISOTime().mb_str());

        c->SetDoubleAttribute("TimeCertainty", s->m_TimeCertainty);

        c->SetDoubleAttribute("Measurement", s->m_Measurement);
        c->SetDoubleAttribute("MeasurementCertainty", s->m_MeasurementCertainty);

        c->SetDoubleAttribute("EyeHeight", s->m_EyeHeight);
        c->SetDoubleAttribute("Temperature", s->m_Temperature);
        c->SetDoubleAttribute("Pressure", s->m_Pressure);
        c->SetDoubleAttribute("IndexError", s->m_IndexError);
                        
        c->SetDoubleAttribute("ShiftNm", s->m_ShiftNm);
        c->SetDoubleAttribute("ShiftBearing", s->m_ShiftBearing);
        c->SetDoubleAttribute("MagneticShiftBearing", s->m_bMagneticShiftBearing);

        c->SetAttribute("ColourName", s->m_ColourName.mb_str());
        c->SetAttribute("Colour", s->m_Colour.GetAsString().mb_str());
        c->SetAttribute("Transparency", s->m_Colour.Alpha());

        root->LinkEndChild(c);
    }

    if(!doc.SaveFile(filename.mb_str())) {
        wxMessageDialog mdlg(this, _("Failed to save xml file: ") + filename,
                             _("Celestial Navigation"), wxOK | wxICON_ERROR);
        mdlg.ShowModal();
    }
}
Esempio n. 27
0
// save world information into file
void MapInfoXmlWriter::SaveWorld(const std::string &Filename, WorldInfo & wi)
{
	TiXmlDocument doc;
	std::string s;

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

	TiXmlElement * root = new TiXmlElement("World");
	doc.LinkEndChild( root );
	root->SetAttribute("name", wi.Name);
	root->SetAttribute("firstmap", wi.FirstMap);
	root->SetAttribute("firstsparea", wi.FirstSpawning);

	TiXmlElement * desc = new TiXmlElement( "description" );
	root->LinkEndChild(desc);
	desc->LinkEndChild(new TiXmlText(wi.Description));


	TiXmlElement * maps = new TiXmlElement( "maps" );
	root->LinkEndChild(maps);

	std::map<std::string, MapInfo>::iterator it = wi.Maps.begin();
	std::map<std::string, MapInfo>::iterator end = wi.Maps.end();
	for(; it != end; ++it)
	{
		TiXmlElement * map = new TiXmlElement( "Map" );
		maps->LinkEndChild(map);


		std::string worldmapname = "Lba1Original";
		std::string mapname2 = it->second.Files["Maps"];
		mapname2 = mapname2.substr(0, mapname2.find_last_of("/"));
		mapname2 = mapname2.substr(mapname2.find_last_of("/")+1);
		if(mapname2 == "Lba2")
			worldmapname = "Lba2Original";


		map->SetAttribute("name", it->first);
		map->SetAttribute("type", it->second.Type);
		map->SetAttribute("music", "Worlds/"+worldmapname+"/"+it->second.Music);
		map->SetAttribute("repeatmusic", it->second.MusicLoop);

		map->SetAttribute("AutoCameraType", 1);
		map->SetAttribute("IsInstance", "false");
		map->SetAttribute("HurtFallFactor", 2);


		TiXmlElement * descm = new TiXmlElement( "description" );
		map->LinkEndChild(descm);
		descm->LinkEndChild(new TiXmlText(it->second.Description));



	}

	doc.SaveFile(Filename);
}
Esempio n. 28
0
bool XMLRW::CreateXml(char* XmlFile)  
{  
	// 定义一个TiXmlDocument类指针  
	TiXmlDocument *pDoc = new TiXmlDocument;  
	if (NULL==pDoc)  
	{  
		return false;  
	}  
	TiXmlDeclaration *pDeclaration = new TiXmlDeclaration(_T("1.0"),_T("utf-8"),_T(""));  
	if (NULL==pDeclaration)  
	{  
		return false;  
    }  

	pDoc->LinkEndChild(pDeclaration);  
	// 生成一个根节点:pRootEle 
	TiXmlElement *pRootEle = new TiXmlElement(_T("ROWDATA"));  
	if (NULL==pRootEle)  
	{  
		return false;  
	}  
	pDoc->LinkEndChild(pRootEle);  

#if ALLTAB_DETECT_CAR_MODE
//汽车
	total=OracleIO.CAR_BlackTable_GetNum();

#else
//电动车
	total=OracleIO.ELECAR_BlackTable_GetNum();

#endif
	if(0==total)
	{
		pDlgBlackInout->m_info.Format("数据库无数据");
		pDlgBlackInout->GetDlgItem(IDC_STATIC_INFO)->SetWindowText(pDlgBlackInout->m_info);
		return true;
	}

	unsigned long int i;
	//设置进度条
	pDlgBlackInout->m_progress.SetRange32(0,total);
	pDlgBlackInout->m_progress.SetStep(1);

	//有N条数据 就有N条这个
	for(i=1; (pDlgBlackInout->ThreadFlag) && (i<=total) ;i++)
	{
		if(!CreateRow(pRootEle,i))
			break;
		//填写进度
		pDlgBlackInout->m_progress.StepIt();
		pDlgBlackInout->m_info.Format("已导出:%d / %d 条",i,total);
		pDlgBlackInout->GetDlgItem(IDC_STATIC_INFO)->SetWindowText(pDlgBlackInout->m_info);
	}
	//保存文件
	pDoc->SaveFile(XmlFile);  
    return true;  
}   
Esempio n. 29
0
void kore::ProjectLoader::saveProject(const std::string& path) const {
  ResourceManager* ResMgr = ResourceManager::getInstance();

  TiXmlDocument doc;
  TiXmlDeclaration* decl = new TiXmlDeclaration("1.0", "", "yes");
  doc.LinkEndChild(decl);

  TiXmlComment * comment = new TiXmlComment();
  time_t rawtime;
  time(&rawtime);
  comment->SetValue(ctime(&rawtime));
  doc.LinkEndChild(comment);

  // Resources
  TiXmlElement* resources = new TiXmlElement("Resources");
  doc.LinkEndChild(resources);

  // Textures
  TiXmlElement* texture;
  std::map<std::string, TexturePtr>::iterator texIt;
  for(texIt = ResMgr->_textures.begin();
      texIt != ResMgr->_textures.end();
      texIt++) {
    texture = new TiXmlElement("Texture");
    STextureProperties prop = texIt->second->getProperties();
    texture->SetAttribute("name", texIt->second->getName().c_str());
    texture->SetAttribute("width", prop.width);
    texture->SetAttribute("height", prop.height);
    resources->LinkEndChild(texture);
  }

  // TODO(dospelt) the rest

  TiXmlElement* scene = new TiXmlElement("Scene");
  doc.LinkEndChild(scene);
  kore::SceneNodePtr root = kore::SceneManager::getInstance()->getRootNode();

  //saveSceneNode(scene, root);

  

  // finally, save to file
  if(doc.SaveFile(path.c_str())) {
    kore::Log::getInstance()->write("[DEBUG] writing file '%s'\n",
                                    path.c_str());
  } else {
    kore::Log::getInstance()->write("[ERROR] could not write file '%s'\n",
                                    path.c_str());
  }

  // TODO(dospelt) runtime error when deleting created pointers.
  // it seems they get automatically deleted when saving File -> tinyxmlDoku?

  // delete resources;
  // delete comment;
}
Esempio n. 30
0
bool Tileset::saveXml( const std::string& savefilename ){
    filename_ = correctFilepath(savefilename);

    //xml doc
	TiXmlDocument doc;

    //xml header
	TiXmlDeclaration *decl = new TiXmlDeclaration( "1.0", "", "" );
	doc.LinkEndChild( decl );
    //tileset header
	TiXmlElement *root = new TiXmlElement( "Tileset" );
	doc.LinkEndChild( root );


    //tlieset details
    //tileset imageFilename
    TiXmlElement *fnEl = new TiXmlElement( "ImageFilename" );
	root->LinkEndChild( fnEl );
	TiXmlText *fnText = new TiXmlText( imageFilename );
	fnEl->LinkEndChild( fnText );

	//tileset name
    TiXmlElement *tsName = new TiXmlElement( "TilesetName" );
	root->LinkEndChild( tsName );
	TiXmlText *tsText = new TiXmlText( alias );
	tsName->LinkEndChild( tsText );

	//trans key
    TiXmlElement *transKeyEl = new TiXmlElement( "TransKey" );
	root->LinkEndChild( transKeyEl );
	if( transKey != NULL ){
        transKeyEl->SetAttribute("use", 1);
        transKeyEl->SetAttribute("r", transKey->r);
        transKeyEl->SetAttribute("g", transKey->g);
        transKeyEl->SetAttribute("b", transKey->b);
    } else {
        transKeyEl->SetAttribute("use", 0);
        transKeyEl->SetAttribute("r", 0);
        transKeyEl->SetAttribute("g", 0);
        transKeyEl->SetAttribute("b", 0);
    }

	//TileSize
    TiXmlElement *sizeEl = new TiXmlElement( "TileSize" );
	root->LinkEndChild( sizeEl );
    sizeEl->SetAttribute("w", tileWidth);
    sizeEl->SetAttribute("h", tileHeight);

	//TileSize
    TiXmlElement *offsetEl = new TiXmlElement( "Offset" );
	root->LinkEndChild( offsetEl );
    offsetEl->SetAttribute("x", xOffset);
    offsetEl->SetAttribute("y", yOffset);

	return doc.SaveFile( filename_ );
}