本文整理汇总了C++中TiXmlDocument::SaveFile方法的典型用法代码示例。如果您正苦于以下问题:C++ TiXmlDocument::SaveFile方法的具体用法?C++ TiXmlDocument::SaveFile怎么用?C++ TiXmlDocument::SaveFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TiXmlDocument
的用法示例。
在下文中一共展示了TiXmlDocument::SaveFile方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: guardar_archivo
void XmlExcel::guardar_archivo(TiXmlDocument doc,char archivo[]){
doc.SaveFile(archivo);
}
示例2: Save
void Puppet::Save(Entity *entity)
{
// save to filename
TiXmlDocument xmlDoc;
/// TextureAtlas
if (textureAtlas)
{
textureAtlas->Save(&xmlDoc);
}
/// Parts
//TiXmlElement *xmlParts = xmlDoc.FirstChildElement("Parts");
TiXmlElement xmlParts("Parts");
SaveParts(&xmlParts, entity);
xmlDoc.InsertEndChild(xmlParts);
/// Animations
TiXmlElement xmlAnimations("Animations");
{
/// Animation
for (std::list<Animation>::iterator i = animations.begin(); i != animations.end(); ++i)
{
TiXmlElement xmlAnimation("Animation");
Animation *animation = &(*i);
XMLFileNode xmlFileNodeKeyFrameAnim(&xmlAnimation);
animation->Save(&xmlFileNodeKeyFrameAnim);
/// PartKeyFrames
for (std::list<Part*>::iterator j = parts.begin(); j != parts.end(); ++j)
{
PartKeyFrames *partKeyFrames = animation->GetPartKeyFrames(*j);
if (partKeyFrames)
{
TiXmlElement xmlPartKeyFrames("PartKeyFrames");
XMLFileNode xmlFileNodePartKeyFrames(&xmlPartKeyFrames);
partKeyFrames->Save(&xmlFileNodePartKeyFrames);
/// KeyFrame
std::list<KeyFrame> *keyFrames = partKeyFrames->GetKeyFrames();
for (std::list<KeyFrame>::iterator i = keyFrames->begin(); i != keyFrames->end(); ++i)
{
KeyFrame *keyFrame = &(*i);
TiXmlElement xmlKeyFrame("KeyFrame");
XMLFileNode xmlFileNodeKeyFrame(&xmlKeyFrame);
keyFrame->Save(&xmlFileNodeKeyFrame);
xmlPartKeyFrames.InsertEndChild(xmlKeyFrame);
}
xmlAnimation.InsertEndChild(xmlPartKeyFrames);
}
}
xmlAnimations.InsertEndChild(xmlAnimation);
}
}
xmlDoc.InsertEndChild(xmlAnimations);
xmlDoc.SaveFile(Assets::GetContentPath() + filename);
}
示例3: itemsElement
OsStatus
CallerAliasDB::store()
{
UtlString fileName = DbName + ".xml";
UtlString pathName = SipXecsService::Path(SipXecsService::DatabaseDirType,
fileName.data());
// Create an empty document
TiXmlDocument document;
// Create a hard coded standalone declaration section
document.Parse ("<?xml version=\"1.0\" standalone=\"yes\"?>");
// Create the root node container
TiXmlElement itemsElement ( "items" );
itemsElement.SetAttribute( "type", sType.data() );
itemsElement.SetAttribute( "xmlns", sXmlNamespace.data() );
// Critical Section while actually opening and using the database
{
OsLock lock( sLockMutex );
if ( mpFastDB != NULL )
{
// Thread Local Storage
mpFastDB->attach();
// Search our memory for rows
dbCursor< CallerAliasRow > cursor;
// Select everything in the IMDB and add as item elements if present
int rowNumber;
int rows;
for (rowNumber = 0, rows = cursor.select();
rowNumber < rows;
rowNumber++, cursor.next()
)
{
// Create an item container
TiXmlElement itemElement ("item");
if ( *cursor->identity )
{
// Add an identity element and put the value in it
TiXmlElement identityElement(IdentityKey.data());
TiXmlText identityValue(cursor->identity);
identityElement.InsertEndChild(identityValue);
itemElement.InsertEndChild(identityElement);
}
// add the domain element and put the value in it
TiXmlElement domainElement(DomainKey.data());
TiXmlText domainValue(cursor->domain);
domainElement.InsertEndChild(domainValue);
itemElement.InsertEndChild(domainElement);
// add the alias element and put the value in it
TiXmlElement aliasElement(AliasKey.data());
TiXmlText aliasValue(cursor->alias);
aliasElement.InsertEndChild(aliasValue);
itemElement.InsertEndChild(aliasElement);
// add this item (row) to the parent items container
itemsElement.InsertEndChild ( itemElement );
}
// Commit rows to memory - multiprocess workaround
mpFastDB->detach(0);
mTableLoaded = true;
}
} // release mutex around database use
// Attach the root node to the document
document.InsertEndChild ( itemsElement );
document.SaveFile ( pathName );
return OS_SUCCESS;
}
示例4: SaveXmlFile
bool SaveXmlFile(const wxFileName& file, TiXmlNode* node, wxString* error /*=0*/, bool move /*=false*/)
{
if (!node)
return true;
const wxString& fullPath = file.GetFullPath();
TiXmlDocument* pDocument = node->GetDocument();
bool exists = false;
bool isLink = false;
int flags = 0;
if (CLocalFileSystem::GetFileInfo( fullPath, isLink, 0, 0, &flags ) == CLocalFileSystem::file)
{
#ifdef __WXMSW__
if (flags & FILE_ATTRIBUTE_HIDDEN)
SetFileAttributes(fullPath, flags & ~FILE_ATTRIBUTE_HIDDEN);
#endif
exists = true;
bool res;
if (!move)
{
wxLogNull null;
res = wxCopyFile(fullPath, fullPath + _T("~"));
}
else
{
wxLogNull null;
res = wxRenameFile(fullPath, fullPath + _T("~"));
}
if (!res)
{
const wxString msg = _("Failed to create backup copy of xml file");
if (error)
*error = msg;
else
wxMessageBoxEx(msg);
return false;
}
}
wxFFile f(fullPath, _T("w"));
if (!f.IsOpened() || !pDocument->SaveFile(f.fp()))
{
wxRemoveFile(fullPath);
if (exists)
{
wxLogNull null;
wxRenameFile(fullPath + _T("~"), fullPath);
}
const wxString msg = _("Failed to write xml file");
if (error)
*error = msg;
else
wxMessageBoxEx(msg);
return false;
}
if (exists)
wxRemoveFile(fullPath + _T("~"));
return true;
}
示例5: saveFile
// 子类实现父类的函数
bool XMLNetworkFileLoader::saveFile()
{
mutex.lock();
//生成xml文件
TiXmlDocument *doc = new TiXmlDocument();
TiXmlDeclaration dec("1.0","gb2312","yes");
doc->InsertEndChild(dec);
TiXmlElement *my_root1 = new TiXmlElement("network_config");
doc->LinkEndChild(my_root1);
my_root1->SetAttribute("calibration_file", NetworkConfigList::getNetworkConfigListInstance()->getCalibrationFile().c_str());
my_root1->SetAttribute("master_ip", NetworkConfigList::getNetworkConfigListInstance()->getMasterIP().toLocal8Bit().constData());
my_root1->SetAttribute("master_backup_nasip", NetworkConfigList::getNetworkConfigListInstance()->getMasterBackupNasIP().toLocal8Bit().constData());
my_root1->SetAttribute("db_server_ip", NetworkConfigList::getNetworkConfigListInstance()->getDBServerIP().toLocal8Bit().constData());
// string slaveip[9]={"10.13.29.210","10.13.29.210","10.13.29.210","10.13.29.210","10.13.29.210","10.13.29.210","10.13.29.210","10.13.29.210","10.13.29.210"};
for (int i = 0; i <= NetworkConfigList::getNetworkConfigListInstance()->listsnid()->size(); i++)
{
SlaveModel slavemodel = NetworkConfigList::getNetworkConfigListInstance()->listsnid()->at(0);
TiXmlElement *my_root2 = new TiXmlElement("slave");
my_root2->SetAttribute("slaveid", slavemodel.getIndex());
//my_root2->SetAttribute("ip", "10.13.29.217");
my_root2->SetAttribute("ip", slavemodel.getHostAddress().c_str());
my_root2->SetAttribute("port",slavemodel.getPort());
my_root2->SetAttribute("is_rt_slave", slavemodel.getIsRT());
my_root2->SetAttribute("backup_nasip", slavemodel.getBackupNasIP().c_str());
for (int j = 0; j <= 1; j++)
{
CameraPair x;
switch (j)
{
case 0: x = slavemodel.box1;
break;
case 1: x = slavemodel.box2;
break;
default: break;
}
TiXmlElement *my_root3 =new TiXmlElement("camera_pair");
my_root3->SetAttribute("index", x.boxindex);
my_root3->SetAttribute("camera_calib_file", x.box_camera_calib_file.c_str());
my_root3->SetAttribute("index", x.box_fenzhong_calib_file.c_str());
{
TiXmlElement *my_root4 =new TiXmlElement("camera_ref");
my_root4->SetAttribute("cameraid", x.camera_ref.c_str());
my_root4->SetAttribute("sn", x.camera_ref_sn.c_str());
my_root4->SetAttribute("paramfile", x.camera_ref_file.c_str());
my_root3->LinkEndChild(my_root4);
TiXmlElement *my_root5 =new TiXmlElement("camera");
my_root5->SetAttribute("cameraid", x.camera.c_str());
my_root5->SetAttribute("sn", x.camera_sn.c_str());
my_root5->SetAttribute("calibration_file", x.camera_file.c_str());
my_root3->LinkEndChild(my_root5);
}
my_root2->LinkEndChild(my_root3);
}
my_root1->LinkEndChild(my_root2);
}
// 【注意!】QString转cchar不能用QString().toStdString().c_str(),否则可能会出问题
QByteArray tempstr = getFilename().toAscii();
bool ret = doc->SaveFile(tempstr.constData());
mutex.unlock();
return ret;
}
开发者ID:fanxiang090909,项目名称:Railway-Tunnel-Construction-Dlearance-Measure-LanZhou,代码行数:66,代码来源:xmlnetworkfileloader.cpp
示例6: SaveActors
//.........这里部分代码省略.........
case 11: //hurt area class
{
{
HurtArea * tmpa = static_cast<HurtArea *>(it->second);
act->SetDoubleAttribute("zonesizeX", tmpa->GetZoneX());
act->SetDoubleAttribute("zonesizeY", tmpa->GetZoneY());
act->SetDoubleAttribute("zonesizeZ", tmpa->GetZoneZ());
act->SetDoubleAttribute("lifetaken", tmpa->GetLifeTaken());
}
}
break;
case 12: //NPC actor class
{
{
NPCActor * tmpa = static_cast<NPCActor *>(it->second);
act->SetAttribute("NPCType", tmpa->GetNPCType());
act->SetDoubleAttribute("activationdistance", tmpa->GetActivationDistance());
act->SetAttribute("Name", tmpa->GetName());
const std::vector<PlayerScriptPart> & scriptsV = tmpa->GetScripts();
if(scriptsV.size() > 0)
{
TiXmlElement * scripts = new TiXmlElement( "scripts" );
act->LinkEndChild(scripts);
for(size_t cci=0; cci<scriptsV.size(); ++cci)
{
TiXmlElement * script = new TiXmlElement( "script" );
scripts->LinkEndChild(script);
script->SetAttribute("type", scriptsV[cci].Type);
script->SetDoubleAttribute("ValueA", scriptsV[cci].ValueA);
script->SetDoubleAttribute("ValueB", scriptsV[cci].ValueB);
script->SetDoubleAttribute("ValueC", scriptsV[cci].ValueC);
script->SetDoubleAttribute("Speed", scriptsV[cci].Speed);
script->SetAttribute("Sound", scriptsV[cci].Sound);
script->SetAttribute("SoundNum", scriptsV[cci].SoundNum);
script->SetAttribute("Animation", scriptsV[cci].Animation);
script->SetAttribute("Flag", scriptsV[cci].Flag);
}
}
}
}
break;
case 13: //scripted zone actor
{
{
ScriptedZoneActor * tmpa = static_cast<ScriptedZoneActor *>(it->second);
act->SetDoubleAttribute("zonesizeX", tmpa->GetZoneX());
act->SetDoubleAttribute("zonesizeY", tmpa->GetZoneY());
act->SetDoubleAttribute("zonesizeZ", tmpa->GetZoneZ());
act->SetAttribute("activationtype", tmpa->GetActivationType());
act->SetAttribute("neededitem", tmpa->GetNeededItemId());
act->SetAttribute("destroyitem", tmpa->GetDesItem());
act->SetAttribute("abortedmessage", tmpa->GetAbortedMessage());
TiXmlElement * scripts = new TiXmlElement( "scripts" );
act->LinkEndChild(scripts);
const std::vector<PlayerScriptPart> & scriptsV = tmpa->GetScripts();
for(size_t cci=0; cci<scriptsV.size(); ++cci)
{
TiXmlElement * script = new TiXmlElement( "script" );
scripts->LinkEndChild(script);
script->SetAttribute("type", scriptsV[cci].Type);
script->SetDoubleAttribute("ValueA", scriptsV[cci].ValueA);
script->SetDoubleAttribute("ValueB", scriptsV[cci].ValueB);
script->SetDoubleAttribute("ValueC", scriptsV[cci].ValueC);
script->SetDoubleAttribute("Speed", scriptsV[cci].Speed);
script->SetAttribute("Sound", scriptsV[cci].Sound);
script->SetAttribute("SoundNum", scriptsV[cci].SoundNum);
script->SetAttribute("Animation", scriptsV[cci].Animation);
script->SetAttribute("Flag", scriptsV[cci].Flag);
script->SetAttribute("newMap", scriptsV[cci].NewMap);
script->SetAttribute("spawning", scriptsV[cci].Spawning);
}
}
}
break;
case 14: //mailbox class
{
{
MailboxActor * tmpa = static_cast<MailboxActor *>(it->second);
act->SetDoubleAttribute("activationdistance", tmpa->GetActivationDistance());
act->SetAttribute("activationtype", tmpa->GetActivationType());
}
}
break;
}
}
doc.SaveFile(Filename);
}
示例7: SaveSprites
// save all sprites info
void MapInfoXmlWriter::SaveSprites(const std::string &Filename, std::map<long, SpriteInfo> *vec)
{
TiXmlDocument doc;
TiXmlDeclaration* decl = new TiXmlDeclaration( "1.0", "UTF8", "" );
doc.LinkEndChild( decl );
TiXmlElement * root = new TiXmlElement("sprites");
doc.LinkEndChild( root );
std::map<long, SpriteInfo>::const_iterator it = vec->begin();
std::map<long, SpriteInfo>::const_iterator end = vec->end();
for(; it != end; ++it)
{
TiXmlElement * act = new TiXmlElement( "sprite" );
root->LinkEndChild(act);
act->SetAttribute("id", it->first);
act->SetAttribute("filename", it->second.filename);
std::vector<QuadImageInfo>::const_iterator itq = it->second.quadsInfo.begin();
std::vector<QuadImageInfo>::const_iterator endq = it->second.quadsInfo.end();
for(; itq != endq; ++itq)
{
TiXmlElement * quad = new TiXmlElement( "textpart" );
act->LinkEndChild(quad);
quad->SetAttribute("UseFullImage", itq->UseFullImage);
quad->SetDoubleAttribute("BottomLeftCornerX", itq->BottomLeftCornerX);
quad->SetDoubleAttribute("BottomLeftCornerY", itq->BottomLeftCornerY);
quad->SetDoubleAttribute("BottomLeftCornerZ", itq->BottomLeftCornerZ);
quad->SetDoubleAttribute("TopRightCornerX", itq->TopRightCornerX);
quad->SetDoubleAttribute("TopRightCornerY", itq->TopRightCornerY);
quad->SetDoubleAttribute("TopRightCornerZ", itq->TopRightCornerZ);
quad->SetDoubleAttribute("BottomRightCornerX", itq->BottomRightCornerX);
quad->SetDoubleAttribute("BottomRightCornerY", itq->BottomRightCornerY);
quad->SetDoubleAttribute("BottomRightCornerZ", itq->BottomRightCornerZ);
quad->SetDoubleAttribute("TopLeftCornerX", itq->TopLeftCornerX);
quad->SetDoubleAttribute("TopLeftCornerY", itq->TopLeftCornerY);
quad->SetDoubleAttribute("TopLeftCornerZ", itq->TopLeftCornerZ);
//quad->SetDoubleAttribute("BottomRightCornerX",itq->TopRightCornerX);//itq->BottomRightCornerX);
//quad->SetDoubleAttribute("BottomRightCornerY",itq->BottomLeftCornerY);//itq->BottomRightCornerY);
//quad->SetDoubleAttribute("BottomRightCornerZ",itq->TopRightCornerZ);//itq->BottomRightCornerZ);
//quad->SetDoubleAttribute("TopLeftCornerX",itq->BottomLeftCornerX);//itq->TopLeftCornerX);
//quad->SetDoubleAttribute("TopLeftCornerY",itq->TopRightCornerY);//itq->TopLeftCornerY);
//quad->SetDoubleAttribute("TopLeftCornerZ",itq->BottomLeftCornerZ);//itq->TopLeftCornerZ);
quad->SetAttribute("BottomLeftTextcoordX", itq->BottomLeftTextcoordX);
quad->SetAttribute("BottomLeftTextcoordY", itq->BottomLeftTextcoordY);
quad->SetAttribute("BottomRightTextcoordX", itq->BottomRightTextcoordX);
quad->SetAttribute("BottomRightTextcoordY", itq->BottomRightTextcoordY);
quad->SetAttribute("TopLeftTextcoordX", itq->TopLeftTextcoordX);
quad->SetAttribute("TopLeftTextcoordY", itq->TopLeftTextcoordY);
quad->SetAttribute("TopRightTextcoordX", itq->TopRightTextcoordX);
quad->SetAttribute("TopRightTextcoordY", itq->TopRightTextcoordY);
}
}
doc.SaveFile(Filename);
}
示例8: lock
OsStatus
UserLocationDB::store()
{
// Critical Section here
OsLock lock( sLockMutex );
OsStatus result = OS_SUCCESS;
if ( m_pFastDB != NULL )
{
UtlString fileName = mDatabaseName + ".xml";
UtlString pathName = SipXecsService::Path(SipXecsService::DatabaseDirType,
fileName.data());
// Create an empty document
TiXmlDocument document;
// Create a hard coded standalone declaration section
document.Parse ("<?xml version=\"1.0\" standalone=\"yes\"?>");
// Create the root node container
TiXmlElement itemsElement ( "items" );
itemsElement.SetAttribute( "type", sType.data() );
itemsElement.SetAttribute( "xmlns", sXmlNamespace.data() );
// Thread Local Storage
m_pFastDB->attach();
// Search our memory for rows
dbCursor< UserLocationRow > cursor;
// Select everything in the IMDB and add as item elements if present
if ( cursor.select() > 0 )
{
// metadata contains column names
dbTableDescriptor* pTableMetaData = &UserLocationRow::dbDescriptor;
do {
// Create an item container
TiXmlElement itemElement ("item");
byte* base = (byte*)cursor.get();
// Add the column name value pairs
for ( dbFieldDescriptor* fd = pTableMetaData->getFirstField();
fd != NULL; fd = fd->nextField )
{
// if the column name does not contain the
// np_prefix we must_presist it
if ( strstr( fd->name, "np_" ) == NULL )
{
// Create the a column element named after the IMDB column name
TiXmlElement element (fd->name );
// See if the IMDB has the predefined SPECIAL_NULL_VALUE
UtlString textValue;
SIPDBManager::getFieldValue(base, fd, textValue);
// If the value is not null append a text child element
if ( textValue != SPECIAL_IMDB_NULL_VALUE )
{
// Text type assumed here... @todo change this
TiXmlText value ( textValue.data() );
// Store the column value in the element making this
// <colname>coltextvalue</colname>
element.InsertEndChild ( value );
}
// Store this in the item tag as follows
// <item>
// .. <col1name>col1textvalue</col1name>
// .. <col2name>col2textvalue</col2name>
// .... etc
itemElement.InsertEndChild ( element );
}
}
// add the line to the element
itemsElement.InsertEndChild ( itemElement );
} while ( cursor.next() );
}
// Attach the root node to the document
document.InsertEndChild ( itemsElement );
document.SaveFile ( pathName );
// Commit rows to memory - multiprocess workaround
m_pFastDB->detach(0);
mTableLoaded = true;
} else
{
result = OS_FAILED;
}
return result;
}
示例9: updateConfig
void ConfigFile::updateConfig(ConfigState myConfigState)
{
boost::recursive_mutex::scoped_lock lock(m_configMutex);
size_t i;
if(myConfigState == NONEXISTING) {
//Create a new ConfigFile!
TiXmlDocument doc;
TiXmlDeclaration * decl = new TiXmlDeclaration( "1.0", "UTF-8", "");
doc.LinkEndChild( decl );
TiXmlElement * root = new TiXmlElement( "PokerTH" );
doc.LinkEndChild( root );
TiXmlElement * config;
config = new TiXmlElement( "Configuration" );
root->LinkEndChild( config );
for (i=0; i<configList.size(); i++) {
TiXmlElement *tmpElement = new TiXmlElement(configList[i].name);
config->LinkEndChild( tmpElement );
tmpElement->SetAttribute("value", myQtToolsInterface->stringToUtf8(configList[i].defaultValue));
if(configList[i].type == CONFIG_TYPE_INT_LIST || configBufferList[i].type == CONFIG_TYPE_STRING_LIST) {
tmpElement->SetAttribute("type", "list");
list<string> tempList = configList[i].defaultListValue;
list<string>::iterator it;
for(it = tempList.begin(); it != tempList.end(); ++it) {
TiXmlElement *tmpSubElement = new TiXmlElement(configList[i].defaultValue);
tmpElement->LinkEndChild( tmpSubElement );
tmpSubElement->SetAttribute("value", *it);
}
}
}
doc.SaveFile( configFileName );
}
if(myConfigState == OLD) {
TiXmlDocument oldDoc(configFileName);
//load the old one
if(oldDoc.LoadFile()) {
string tempString1("");
string tempString2("");
TiXmlDocument newDoc;
//Create the new one
TiXmlDeclaration * decl = new TiXmlDeclaration( "1.0", "UTF-8", "");
newDoc.LinkEndChild( decl );
TiXmlElement * root = new TiXmlElement( "PokerTH" );
newDoc.LinkEndChild( root );
TiXmlElement * config;
config = new TiXmlElement( "Configuration" );
root->LinkEndChild( config );
//change configRev and AppDataPath
std::list<std::string> noUpdateElemtsList;
TiXmlElement * confElement0 = new TiXmlElement( "ConfigRevision" );
config->LinkEndChild( confElement0 );
confElement0->SetAttribute("value", configRev);
noUpdateElemtsList.push_back("ConfigRevision");
TiXmlElement * confElement1 = new TiXmlElement( "AppDataDir" );
config->LinkEndChild( confElement1 );
confElement1->SetAttribute("value", myQtToolsInterface->stringToUtf8(myQtToolsInterface->getDataPathStdString(myArgv0)));
noUpdateElemtsList.push_back("AppDataDir");
///////// VERSION HACK SECTION ///////////////////////
//this is the right place for special version depending config hacks:
//0.9.1 - log interval needs to be set to 1 instead of 0
if (configRev >= 95 && configRev <= 98) { // this means 0.9.1 or 0.9.2 or 1.0
TiXmlElement * confElement2 = new TiXmlElement( "LogInterval" );
config->LinkEndChild( confElement2 );
confElement2->SetAttribute("value", 1);
noUpdateElemtsList.push_back("LogInterval");
}
if (configRev == 98) { // this means 1.0
TiXmlElement * confElement3 = new TiXmlElement( "CurrentCardDeckStyle" );
config->LinkEndChild( confElement3 );
confElement3->SetAttribute("value", "");
noUpdateElemtsList.push_back("CurrentCardDeckStyle");
}
///////// VERSION HACK SECTION ///////////////////////
TiXmlHandle oldDocHandle( &oldDoc );
for (i=0; i<configList.size(); i++) {
//.........这里部分代码省略.........
示例10: _SaveToFile
BOOL CStubbornFiles::_SaveToFile()
{
BOOL retval = FALSE;
CDataFileLoader dataLoader;
TiXmlDocument xmlDoc;
TiXmlElement* pXmlItem = NULL;
TiXmlElement* pXmlTime = NULL;
TiXmlElement* pXmlItems = NULL;
TiXmlText* pXmlText = NULL;
TCHAR szConfPathTemp[MAX_PATH] = { 0 };
TCHAR szConfPath[MAX_PATH] = { 0 };
TiXmlDeclaration *pXmlDecl = new TiXmlDeclaration("1.0", "utf-8", "yes");
POSITION pos = NULL;
CStringW strPathUtf16;
CStringA strPathUtf8;
CString strXmlUtf16;
CStringA strXmlAnsi;
LARGE_INTEGER ver;
BOOL fRetCode;
FILE* pFile = NULL;
SYSTEMTIME sysTime = { 0 };
CStringA strTime;
GetModuleFileName(NULL, szConfPath, MAX_PATH);
PathRemoveFileSpec(szConfPath);
_tcscpy_s(szConfPathTemp, MAX_PATH, szConfPath);
PathAppend(szConfPathTemp, _T("data\\~strash.dat"));
PathAppend(szConfPath, _T("data\\strash.dat"));
xmlDoc.LinkEndChild(pXmlDecl);
pXmlItems = new TiXmlElement("items");
if (!pXmlItems)
goto clean0;
pos = m_fileList.GetHeadPosition();
while (pos)
{
strPathUtf16 = m_fileList.GetNext(pos);
strPathUtf8 = KUTF16_To_UTF8(strPathUtf16);
pXmlText = new TiXmlText(strPathUtf8);
if (!pXmlText)
goto clean0;
pXmlItem = new TiXmlElement("item");
if (!pXmlItem)
goto clean0;
pXmlItem->LinkEndChild(pXmlText);
pXmlItems->LinkEndChild(pXmlItem);
}
xmlDoc.LinkEndChild(pXmlItems);
GetLocalTime(&sysTime);
strTime.Format("%d.%d.%d", sysTime.wYear, sysTime.wMonth, sysTime.wDay);
pXmlTime = new TiXmlElement("time");
if (!pXmlTime)
goto clean0;
pXmlText = new TiXmlText(strTime);
if (!pXmlText)
goto clean0;
pXmlTime->LinkEndChild(pXmlText);
xmlDoc.LinkEndChild(pXmlTime);
if (!xmlDoc.SaveFile(KUTF16_To_ANSI(szConfPathTemp)))
goto clean0;
pFile = _wfopen(szConfPathTemp, L"r");
if (!pFile)
goto clean0;
{
fseek(pFile, 0, SEEK_END);
int nSize = ftell(pFile);
fseek(pFile, 0, SEEK_SET);
char* pXml = strXmlAnsi.GetBuffer(nSize + 1);
memset(pXml, 0, nSize + 1);
fread(pXml, 1, nSize, pFile);
fclose(pFile);
pFile = NULL;
strXmlAnsi.ReleaseBuffer();
strXmlUtf16 = KANSI_TO_UTF16(strXmlAnsi);
}
{
ver.QuadPart = 1;
fRetCode = dataLoader.Save(
szConfPath, BkDatLibEncodeParam2(enumLibTypePlugine, ver, strXmlUtf16, 1).GetEncodeParam()
);
}
if (!fRetCode)
goto clean0;
retval = TRUE;
//.........这里部分代码省略.........
示例11: Calculate
//.........这里部分代码省略.........
for (c = 1; c <= count_pts ; c++){
destRhumb(latF, lonF, myBrng,speed*c, &lati, &loni);
// print mid points
my_point.lat = wxString::Format(wxT("%f"),lati);
my_point.lon = wxString::Format(wxT("%f"),loni);
my_point.routepoint = 0;
my_points.push_back(my_point);
// End of prints
}
latF = lati;
lonF = loni;
total_dist = 0;
//
//
// All the DR positions inserted
}
if (total_dist == 0){
distRhumb(latF, lonF, latN[i+1], lonN[i+1], &myDistForBrng, &myBrng);
total_dist = myDistForBrng;
latF = latN[i+1];
lonF = lonN[i+1];
}
}
else{
//
latF = latN[i+1];
lonF = lonN[i+1];
//
//
//
//
} //
}
// End of new logic
// print the last routepoint
my_point.lat = wxString::Format(wxT("%f"),latN[i]);
my_point.lon = wxString::Format(wxT("%f"),lonN[i]);
my_point.routepoint = 1;
my_point.wpt_num = wxString::Format(wxT("%d"),(int)i);
my_points.push_back(my_point);
//
for(std::vector<Position>::iterator itOut = my_points.begin(); itOut != my_points.end(); itOut++){
//wxMessageBox((*it).lat, _T("*it.lat"));
double value, value1;
if(!(*itOut).lat.ToDouble(&value)){ /* error! */ }
lati = value;
if(!(*itOut).lon.ToDouble(&value1)){ /* error! */ }
loni = value1;
if ((*itOut).routepoint == 1){
if (write_file){Addpoint(Route, wxString::Format(wxT("%f"),lati), wxString::Format(wxT("%f"),loni), (*itOut).wpt_num ,_T("diamond"),_T("WPT"));}
}
else{
if ((*itOut).routepoint == 0){
if (write_file){Addpoint(Route, wxString::Format(wxT("%f"),lati), wxString::Format(wxT("%f"),loni), _T("DR") ,_T("square"),_T("WPT"));}
}
}
}
my_points.clear();
break;
}
default:
{ // Note the colon, not a semicolon
cout<<"Error, bad input, quitting\n";
break;
}
}
if (write_file){
root->LinkEndChild( Route );
// check if string ends with .gpx or .GPX
if (!wxFileExists(s)){
s = s + _T(".gpx");
}
wxCharBuffer buffer=s.ToUTF8();
if (dbg) std::cout<< buffer.data()<<std::endl;
doc.SaveFile( buffer.data() );}
//} //end of if no error occured
if (error_occured==true) {
wxLogMessage(_("Error in calculation. Please check input!") );
wxMessageBox(_("Error in calculation. Please check input!") );
}
}
}
示例12: OnSave
void CCreateDefmaDlg::OnSave()
{
BOOL queryRet = TRUE;
UpdateData(TRUE); //Interface -> Variable
if(m_tag.IsEmpty()){
AfxMessageBox("请输入标签描述\n");
return;
}
CString fileName,folderName,fullPathName;
if(m_bNewFile) {
//(1) Add new record to database
DefMADataSet *pNewSet = new DefMADataSet();
pNewSet->Open();
pNewSet->AddNew();
pNewSet->m_Mode = this->m_thickMode;
pNewSet->m_Tag = this->m_tag;
pNewSet->Update();
Sleep(200);
//(2) Query last
pNewSet->m_strSort=_T("ID DESC");
if(!pNewSet->Requery()){
AfxMessageBox(_T("CCreateDefmaDlg::OnSave(), Requery failed!"));
queryRet = FALSE;
}
int index = pNewSet->m_ID; // default new file name
pNewSet->Close();
delete pNewSet;
if(queryRet){
//(3) Save defMA to 00xx.xma
SaveDataToPtr();
fileName.Format("%04d",index);
fullPathName = ((CTMeterApp*)AfxGetApp())->m_AppWorkDirectory + "\\DefineMA\\" + fileName + ".xma";
TiXmlDocument doc;
m_pDefMa->XMLSerialize(TRUE,&doc);
if(!doc.SaveFile((LPTSTR)(LPCTSTR)fullPathName))
{
CString text;
text.Format("%s 保存失败",fullPathName);
AfxMessageBox(text);
return;
}
}
}
else
{
// for debugging watch, delete the codes when release
OneLayerDefine* pOneLayer;
CClassicalElement* pElem;
CString eleName; double content; BOOL active;
int winLeft,winRight;
int nLayers = m_pDefMa->m_layerArray.GetSize();
for(int m=0;m<nLayers;m++)
{
pOneLayer = m_pDefMa->m_layerArray.GetAt(m);
int nEle = pOneLayer->m_elementList.GetSize();
for(int n=0;n<nEle;n++)
{
pElem = pOneLayer->m_elementList.GetAt(n);
eleName = pElem->Name; //watch
content = pElem->Content; //watch
active = pElem->beActive; //watch
winLeft = pElem->WinLeft;
winRight = pElem->WinRight;
}
}
// end : debugging watch
// Rewrite defMA to 00xx.xma
SaveDataToPtr();
folderName.Format("%04d",m_pWz->GetDirIndex());
fullPathName = ((CTMeterApp*)AfxGetApp())->m_AppWorkDirectory + "\\DefineFP\\" + folderName + "\\analysis.xma";
TiXmlDocument doc;
m_pDefMa->XMLSerialize(TRUE,&doc);
if(!doc.SaveFile((LPTSTR)(LPCTSTR)fullPathName))
{
CString text;
text.Format("%s 保存失败",fullPathName);
AfxMessageBox(text);
return;
}
}
CDialog::EndDialog(TRUE);
}
示例13: Export
//.........这里部分代码省略.........
TiXmlElement *pResourceLocation = pResourceLocations->InsertEndChild(TiXmlElement("resourceLocation"))->ToElement();
Ogre::String loc = pOpt->ResourceDirectories[r];
loc.erase(0,3);
if(pOpt->ResourceDirectories[r].substr(0,2) == "ZP")
pResourceLocation->SetAttribute("type", "Zip");
else
pResourceLocation->SetAttribute("type", "FileSystem");
std::replace(loc.begin(),loc.end(),'\\','/');
pResourceLocation->SetAttribute("name", loc.c_str());
}
//TODO: do we need all those object id's ?
TiXmlElement *pEnvironment = pRoot->InsertEndChild(TiXmlElement("environment"))->ToElement();
// export octree scenemanagers
NameObjectPairList smList = ogRoot->GetObjectsByTypeName("OctreeSceneManager");
NameObjectPairList::const_iterator smIt = smList.begin();
while(smIt != smList.end())
{
smIt->second->exportDotScene(pEnvironment);
smIt++;
}
// export viewports
NameObjectPairList vpList = ogRoot->GetObjectsByTypeName("Viewport Object");
NameObjectPairList::const_iterator vpIt = vpList.begin();
while(vpIt != vpList.end())
{
vpIt->second->exportDotScene(pEnvironment);
vpIt++;
}
// export terrains
NameObjectPairList terrainList = ogRoot->GetObjectsByType(ETYPE_TERRAIN_MANAGER);
NameObjectPairList::const_iterator tlIt = terrainList.begin();
while(tlIt != terrainList.end())
{
tlIt->second->exportDotScene(pRoot);
tlIt++;
}
NameObjectPairList items = ogRoot->GetSceneManagerEditor()->getChildren();
// export lights
NameObjectPairList::const_iterator nodeIt = items.begin();
while(nodeIt != items.end())
{
if(nodeIt->second->getEditorType() == ETYPE_LIGHT)
{
TiXmlElement *result = nodeIt->second->exportDotScene(pRoot);
saveUserData(nodeIt->second->getCustomProperties(), result);
}
nodeIt++;
}
// export cameras
nodeIt = items.begin();
while(nodeIt != items.end())
{
if(nodeIt->second->getEditorType() == ETYPE_CAMERA)
{
TiXmlElement *result = nodeIt->second->exportDotScene(pRoot);
saveUserData(nodeIt->second->getCustomProperties(), result);
}
nodeIt++;
}
// export nodes
TiXmlElement *pNodes = pRoot->InsertEndChild(TiXmlElement("nodes"))->ToElement();
nodeIt = items.begin();
while(nodeIt != items.end())
{
if( nodeIt->second->getEditorType() != ETYPE_TERRAIN_MANAGER &&
nodeIt->second->getEditorType() != ETYPE_LIGHT &&
nodeIt->second->getEditorType() != ETYPE_CAMERA )
{
TiXmlElement *result = nodeIt->second->exportDotScene(pNodes);
saveUserData(nodeIt->second->getCustomProperties(), result);
}
nodeIt++;
}
if (pXMLDoc->SaveFile(fileName.c_str()))
{
OgitorsSystem::getSingletonPtr()->DisplayMessageDialog(OTR("Scene has been exported succesfully"), DLGTYPE_OK);
delete pXMLDoc;
}
else
OgitorsSystem::getSingletonPtr()->DisplayMessageDialog(OTR("An error occured during export.. :("), DLGTYPE_OK);
*pOpt = tmpOPT;
return SCF_OK;
}
示例14: getenv
TiXmlDocument * ConfigManager::createNewConfiguration() {
if (Log::enabledDbg()) Log::dbg("Creating new initial configuration");
createdNew = true;
string homeDir = getenv ("HOME");
string storagePath = homeDir + "/.config";
struct stat st;
if(stat(storagePath.c_str(),&st) == 0) {
// directory exists
storagePath += "/garminplugin";
if(stat(storagePath.c_str(),&st) == 0) {
// directory already exists
storagePath += "/";
} else {
if(mkdir(storagePath.c_str(), 0755) == -1)
{
if (Log::enabledErr()) Log::err("Failed to create directory "+storagePath);
storagePath = homeDir+"/.";
} else {
storagePath += "/";
}
}
} else {
storagePath = homeDir+"/.";
}
string configFile = storagePath + "garminplugin.xml";
TiXmlDocument * doc = new TiXmlDocument();
TiXmlDeclaration * decl = new TiXmlDeclaration( "1.0", "UTF-8", "no" );
doc->LinkEndChild( decl );
/* <GarminPlugin logfile="" level="ERROR">
<Devices>
<Device enabled="false">
<Name>My Oregon 300</Name>
<StoragePath>/tmp</StoragePath>
<StorageCommand></StorageCommand>
<FitnessDataPath></FitnessDataPath>
<GpxDataPath></GpxDataPath>
</Device>
</Devices>
</GarminPlugin> */
TiXmlElement * plugin = new TiXmlElement( "GarminPlugin" );
plugin->SetAttribute("logfile", "");
plugin->SetAttribute("level", "ERROR");
doc->LinkEndChild( plugin );
TiXmlElement * devices = new TiXmlElement( "Devices" );
plugin->LinkEndChild( devices );
TiXmlElement * device = new TiXmlElement( "Device" );
device->SetAttribute("enabled", "false");
devices->LinkEndChild( device );
TiXmlElement * name = new TiXmlElement( "Name" );
name->LinkEndChild(new TiXmlText("Home Directory "+homeDir));
device->LinkEndChild( name );
TiXmlElement * storePath = new TiXmlElement( "StoragePath" );
storePath->LinkEndChild(new TiXmlText(homeDir));
device->LinkEndChild( storePath );
TiXmlElement * storageCmd = new TiXmlElement( "StorageCommand" );
storageCmd->LinkEndChild(new TiXmlText(""));
device->LinkEndChild( storageCmd );
TiXmlElement * fitnessPath = new TiXmlElement( "FitnessDataPath" );
fitnessPath->LinkEndChild(new TiXmlText(""));
device->LinkEndChild( fitnessPath );
TiXmlElement * gpxPath = new TiXmlElement( "GpxDataPath" );
gpxPath->LinkEndChild(new TiXmlText(""));
device->LinkEndChild( gpxPath );
/*
<Settings>
<ForerunnerTools enabled ="true"/>
</Settings>
*/
TiXmlElement * settings = new TiXmlElement( "Settings" );
plugin->LinkEndChild( settings );
TiXmlElement * forerunnertools = new TiXmlElement( "ForerunnerTools" );
settings->LinkEndChild( forerunnertools );
forerunnertools->SetAttribute("enabled", "true");
doc->SaveFile(configFile);
configurationFile = configFile;
return doc;
}
示例15: WriteXmlToFile
void WriteXmlToFile(IXMLDataBound* aXml, std::string aFileName)
{
TiXmlDocument doc;
aXml->toXml(&doc, true, true);
if(!doc.SaveFile(aFileName)) throw Exception(LOCATION, "Unspecified error while saving");
}