本文整理汇总了C++中TiXmlDocument::LoadFile方法的典型用法代码示例。如果您正苦于以下问题:C++ TiXmlDocument::LoadFile方法的具体用法?C++ TiXmlDocument::LoadFile怎么用?C++ TiXmlDocument::LoadFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TiXmlDocument
的用法示例。
在下文中一共展示了TiXmlDocument::LoadFile方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: RunPipe
void Preprocess::RunPipe(std::string filename)
{
TiXmlDocument doc;
if ( !doc.LoadFile( filename.c_str() ) )
return;
TiXmlElement* rootElement = doc.FirstChildElement();
const char* docname = rootElement->Value();
if ( strcmp( docname, "Preprocess" ) != 0 )
return;
TiXmlElement* parentElement = rootElement->FirstChildElement();
while (parentElement)
{
const char * parent = parentElement->Value();
if ( strcmp( parent, "LaplacianOfGaussian" ) == 0 )
{
int sigma = 10;
int min = 0;
parentElement->QueryIntAttribute("sigma", &sigma);
parentElement->QueryIntAttribute("min", &min);
std::cout << "Starting LOG...";
this->LaplacianOfGaussian(sigma, min);
std::cout << "done\n";
}
else if( strcmp( parent, "InvertIntensity" ) == 0 )
{
std::cout << "Starting InvertIntensity...";
this->InvertIntensity();
std::cout << "done\n";
}
else if( strcmp( parent, "DownSample" ) == 0 )
{
std::cout << "Starting DownSample...";
this->DownSample();
std::cout << "done\n";
}
else if( strcmp( parent, "OtsuBinarize" ) == 0 )
{
int numThresh = 2, numFore = 1;
int fgrndDark = 0;
parentElement->QueryIntAttribute("num_thresholds",&numThresh);
parentElement->QueryIntAttribute("num_in_foreground",&numFore);
parentElement->QueryIntAttribute("fgrnd_dark", &fgrndDark);
std::cout << "Starting OtsuBinarize...";
this->OtsuBinarize(numThresh,numFore, (bool)fgrndDark);
std::cout << "done\n";
}
else if( strcmp( parent, "ManualThreshold" ) == 0 )
{
int threshold = 128;
int binary = 0;
parentElement->QueryIntAttribute("threshold", &threshold);
parentElement->QueryIntAttribute("binary", &binary);
std::cout << "Starting Manual Threshold of " << threshold << "...";
this->ManualThreshold(threshold, (bool)binary);
std::cout << "done\n";
}
else if( strcmp( parent, "RemoveConnectedComponents" ) == 0 )
{
int minObjSize = 1000;
parentElement->QueryIntAttribute("minObjSize", &minObjSize);
std::cout << "Starting RemoveCC...";
this->RemoveConnectedComponents(minObjSize);
std::cout << "done\n";
}
else if( strcmp( parent, "BinaryThinning" ) == 0 )
{
std::cout << "Starting BinaryThinning...";
this->BinaryThinning();
std::cout << "done\n";
}
else if( strcmp( parent, "DanielssonDistanceMap" ) == 0 )
{
std::cout << "Starting DanielssonDistanceMap...";
this->DanielssonDistanceMap();
std::cout << "done\n";
}
else if( strcmp( parent, "MedianFilter" ) == 0 )
{
int radiusX=2, radiusY=3, radiusZ=0;
parentElement->QueryIntAttribute("radiusX",&radiusX);
parentElement->QueryIntAttribute("radiusY",&radiusY);
parentElement->QueryIntAttribute("radiusZ",&radiusZ);
std::cout << "Starting MedianFilter...";
this->MedianFilter(radiusX,radiusY,radiusZ);
std::cout << "done\n";
}
else if( strcmp( parent, "MinErrorThresholding" ) == 0 )
{
float alpha_B, alpha_F, P_I;
std::cout << "Starting MinErrorThresholding...";
this->MinErrorThresholding(&alpha_B, &alpha_F, &P_I);
std::cout << "done\n";
}
else if( strcmp( parent, "GraphCutBinarize" ) == 0 )
{
int xyDivs=1;//, zDivs=1;
parentElement->QueryIntAttribute("xyDivs",&xyDivs);
std::cout << "Starting GraphCutBinarize...";
//.........这里部分代码省略.........
示例2: ParseCrashDescription
int CCrashInfoReader::ParseCrashDescription(CString sFileName, BOOL bParseFileItems, ErrorReportInfo& eri)
{
strconv_t strconv;
TiXmlDocument doc;
bool bOpen = doc.LoadFile(strconv.t2a(sFileName));
if(!bOpen)
return 1;
TiXmlHandle hRoot = doc.FirstChild("CrashRpt");
if(hRoot.ToElement()==NULL)
return 1;
{
TiXmlHandle hCrashGUID = hRoot.FirstChild("CrashGUID");
if(hCrashGUID.FirstChild().ToText()!=NULL)
{
const char* szCrashGUID = hCrashGUID.FirstChild().ToText()->Value();
if(szCrashGUID!=NULL)
eri.m_sCrashGUID = strconv.utf82t(szCrashGUID);
}
}
{
TiXmlHandle hAppName = hRoot.FirstChild("AppName");
const char* szAppName = hAppName.FirstChild().ToText()->Value();
if(szAppName!=NULL)
eri.m_sAppName = strconv.utf82t(szAppName);
}
{
TiXmlHandle hAppVersion = hRoot.FirstChild("AppVersion");
const char* szAppVersion = hAppVersion.FirstChild().ToText()->Value();
if(szAppVersion!=NULL)
eri.m_sAppVersion = strconv.utf82t(szAppVersion);
}
{
TiXmlHandle hImageName = hRoot.FirstChild("ImageName");
const char* szImageName = hImageName.FirstChild().ToText()->Value();
if(szImageName!=NULL)
eri.m_sImageName = strconv.utf82t(szImageName);
}
{
TiXmlHandle hSystemTimeUTC = hRoot.FirstChild("SystemTimeUTC");
const char* szSystemTimeUTC = hSystemTimeUTC.FirstChild().ToText()->Value();
if(szSystemTimeUTC!=NULL)
eri.m_sSystemTimeUTC = strconv.utf82t(szSystemTimeUTC);
}
if(bParseFileItems)
{
// Get directory name
CString sReportDir = sFileName;
int pos = sFileName.ReverseFind('\\');
if(pos>=0)
sReportDir = sFileName.Left(pos);
if(sReportDir.Right(1)!=_T("\\"))
sReportDir += _T("\\");
TiXmlHandle fl = hRoot.FirstChild("FileList");
if(fl.ToElement()==0)
{
return 1;
}
TiXmlHandle fi = fl.FirstChild("FileItem");
while(fi.ToElement()!=0)
{
const char* pszDestFile = fi.ToElement()->Attribute("name");
const char* pszDesc = fi.ToElement()->Attribute("description");
if(pszDestFile!=NULL)
{
CString sDestFile = strconv.utf82t(pszDestFile);
FileItem item;
item.m_sDestFile = sDestFile;
item.m_sSrcFile = sReportDir + sDestFile;
if(pszDesc)
item.m_sDesc = strconv.utf82t(pszDesc);
item.m_bMakeCopy = FALSE;
// Check that file really exists
DWORD dwAttrs = GetFileAttributes(item.m_sSrcFile);
if(dwAttrs!=INVALID_FILE_ATTRIBUTES &&
(dwAttrs&FILE_ATTRIBUTE_DIRECTORY)==0)
{
eri.m_FileItems[sDestFile] = item;
}
}
fi = fi.ToElement()->NextSibling("FileItem");
}
}
return 0;
}
示例3: LoadGraphFromXML
bool CPlanarGraph::LoadGraphFromXML(const char* fileName, bool flagDetectFaces /* = true */, bool flagIgnoreIndiv /* = true */)
{
// Clear the current graph...
ClearGraph();
TiXmlDocument doc;
bool loadFlag = doc.LoadFile(fileName);
if ( loadFlag == false )
{
std::cout << "Failed to load graph from " << fileName << "!\n";
return loadFlag;
}
//doc.Print();
TiXmlNode* xmlRoot = 0;
xmlRoot = doc.RootElement();
assert( xmlRoot );
TiXmlNode* xmlNode = xmlRoot->FirstChild();
while ( xmlNode != 0 )
{
if ( strcmp(xmlNode->Value(), "Node") == 0 )
{
// Parse a node...
CGraphNode graphNode;
float px, py;
int rx = xmlNode->ToElement()->QueryFloatAttribute("px", &px);
int ry = xmlNode->ToElement()->QueryFloatAttribute("py", &py);
if ( rx != TIXML_SUCCESS || ry != TIXML_SUCCESS )
{
graphNode.RandomlyInitPos();
}
else
{
graphNode.SetPos(px, py);
}
int type;
int r = xmlNode->ToElement()->QueryIntAttribute("type", &type);
if ( r == TIXML_SUCCESS )
{
graphNode.SetType(type);
}
int boundary;
int rb = xmlNode->ToElement()->QueryIntAttribute("boundary", &boundary);
if ( rb == TIXML_SUCCESS )
{
graphNode.SetBoundaryType(boundary);
}
int fixed;
int rf = xmlNode->ToElement()->QueryIntAttribute("fix", &fixed);
if ( rf == TIXML_SUCCESS && fixed != 0 )
{
graphNode.SetFlagFixed(true);
}
const char* str = xmlNode->ToElement()->Attribute("name");
if ( *str != '\0' )
{
graphNode.SetName(str);
}
AddGraphNode(graphNode);
}
else if ( strcmp(xmlNode->Value(), "Edge") == 0 )
{
// Parse an edge...
int idx0 = -1;
int idx1 = -1;
int r0 = xmlNode->ToElement()->QueryIntAttribute("node0", &idx0);
int r1 = xmlNode->ToElement()->QueryIntAttribute("node1", &idx1);
if ( r0 != TIXML_SUCCESS )
{
const char* str = xmlNode->ToElement()->Attribute("name0");
idx0 = FindNodeAccordingToName(str);
}
if ( r1 != TIXML_SUCCESS )
{
const char* str = xmlNode->ToElement()->Attribute("name1");
idx1 = FindNodeAccordingToName(str);
}
if ( idx0 >= 0 && idx1 >= 0 )
{
CGraphEdge graphEdge(idx0, idx1);
AddGraphEdge(graphEdge);
}
}
// Move to the next sibling...
xmlNode = xmlNode->NextSibling();
}
SetNodeNeighbors();
if ( flagIgnoreIndiv == true )
{
RemoveIndividualNodes();
}
if ( flagDetectFaces == false )
{
return loadFlag;
}
//PrintGraph();
//.........这里部分代码省略.........
示例4: loadActorsData
void loadActorsData(char *filaname)
{
TiXmlDocument doc;
doc.SetTabSize(8);
doc.LoadFile(filaname);
TiXmlNode *unit = doc.FirstChild("units");
unit = unit->FirstChild("unit");
while (unit)
{
ActorData* actorData = new ActorData();
actorData->ActorType = ActorsData.size();
ActorsData.push_back(actorData);
actorData->Caption = unit->FirstChildElement("name")->GetText();
actorData->Name = unit->FirstChildElement("id")->GetText();
actorData->Price = atoi(unit->FirstChildElement("price")->GetText());
actorData->RequireUpgrade = atoi(unit->FirstChildElement("RequireUpgrade")->GetText());
actorData->BattleUpgradeClass = unit->FirstChildElement("BattleUpgradeClass")->GetText();
actorData->Damage[ActorData::DamageLight] = (float)atof(unit->FirstChildElement("DamageLight")->GetText());
actorData->Damage[ActorData::DamageArmored] = (float)atof(unit->FirstChildElement("DamageArmored")->GetText());
actorData->Damage[ActorData::DamageMassive] = (float)atof(unit->FirstChildElement("DamageMassive")->GetText());
actorData->Damage[ActorData::DamageShield] = (float)atof(unit->FirstChildElement("DamageShield")->GetText());
actorData->Damage[ActorData::DamageOrganic] = (float)atof(unit->FirstChildElement("DamageOrganic")->GetText());
actorData->Damage[ActorData::DamageBuilding] = (float)atof(unit->FirstChildElement("DamageBuilding")->GetText());
actorData->Damage[ActorData::DamageLightAir] = (float)atof(unit->FirstChildElement("DamageLightAir")->GetText());
actorData->Damage[ActorData::DamageArmoredAir] = (float)atof(unit->FirstChildElement("DamageArmoredAir")->GetText());
actorData->Damage[ActorData::DamageMassiveAir] = (float)atof(unit->FirstChildElement("DamageMassiveAir")->GetText());
actorData->Damage[ActorData::DamageShieldAir] = (float)atof(unit->FirstChildElement("DamageShieldAir")->GetText());
actorData->Damage[ActorData::DamageOrganicAir] = (float)atof(unit->FirstChildElement("DamageOrganicAir")->GetText());
actorData->DamageUpgradeFactor[ActorData::DamageLight] = (float)atof(unit->FirstChildElement("DamageLightUpgradeFactor")->GetText());
actorData->DamageUpgradeFactor[ActorData::DamageArmored] = (float)atof(unit->FirstChildElement("DamageArmoredUpgradeFactor")->GetText());
actorData->DamageUpgradeFactor[ActorData::DamageMassive] = (float)atof(unit->FirstChildElement("DamageMassiveUpgradeFactor")->GetText());
actorData->DamageUpgradeFactor[ActorData::DamageShield] = (float)atof(unit->FirstChildElement("DamageShieldUpgradeFactor")->GetText());
actorData->DamageUpgradeFactor[ActorData::DamageOrganic] = (float)atof(unit->FirstChildElement("DamageOrganicUpgradeFactor")->GetText());
actorData->DamageUpgradeFactor[ActorData::DamageBuilding] = (float)atof(unit->FirstChildElement("DamageBuildingUpgradeFactor")->GetText());
actorData->DamageUpgradeFactor[ActorData::DamageLightAir] = (float)atof(unit->FirstChildElement("DamageLightAirUpgradeFactor")->GetText());
actorData->DamageUpgradeFactor[ActorData::DamageArmoredAir] = (float)atof(unit->FirstChildElement("DamageArmoredAirUpgradeFactor")->GetText());
actorData->DamageUpgradeFactor[ActorData::DamageMassiveAir] = (float)atof(unit->FirstChildElement("DamageMassiveAirUpgradeFactor")->GetText());
actorData->DamageUpgradeFactor[ActorData::DamageShieldAir] = (float)atof(unit->FirstChildElement("DamageShieldAirUpgradeFactor")->GetText());
actorData->DamageUpgradeFactor[ActorData::DamageOrganicAir] = (float)atof(unit->FirstChildElement("DamageOrganicAirUpgradeFactor")->GetText());
actorData->SplashDamage = (float)atof(unit->FirstChildElement("SplashDamage")->GetText());
actorData->SplashDamageShield = (float)atof(unit->FirstChildElement("SplashDamageShield")->GetText());
actorData->SplashType = unit->FirstChildElement("SplashType")->GetText();
actorData->DistanceSplash = (float)atof(unit->FirstChildElement("DistanceSplash")->GetText());
actorData->AttackDelayAir = 1000.0f * TIME_SCALE * (float)atof(unit->FirstChildElement("AttackDelayAir")->GetText());
actorData->AttackDelayGround = 1000.0f * TIME_SCALE * (float)atof(unit->FirstChildElement("AttackDelayGround")->GetText());
actorData->armour = (float)atof(unit->FirstChildElement("armour")->GetText());
actorData->shield = (float)atof(unit->FirstChildElement("shield")->GetText());
actorData->HP = (float)atof(unit->FirstChildElement("HP")->GetText());
actorData->mana = (float)atof(unit->FirstChildElement("mana")->GetText());
actorData->MoveSpeed = (float)atof(unit->FirstChildElement("MoveSpeed")->GetText());
actorData->UndergroundSpeed = (float)atof(unit->FirstChildElement("UndergroundSpeed")->GetText());
actorData->ImmediateAttack = (bool)atoi(unit->FirstChildElement("ImmediateAttack")->GetText());
actorData->DistanceGround = (float)atof(unit->FirstChildElement("DistanceGround")->GetText());
actorData->DistanceAir = (float)atof(unit->FirstChildElement("DistanceAir")->GetText());
actorData->DetectionDistance = DETECTION_DISTANCE;
actorData->AttackCountGround = atoi(unit->FirstChildElement("AttackCountGround")->GetText());
actorData->AttackCountAir = atoi(unit->FirstChildElement("AttackCountAir")->GetText());
actorData->Detection = (float)atof(unit->FirstChildElement("Detection")->GetText());
actorData->TargetGround = (bool)atoi(unit->FirstChildElement("TargetGround")->GetText());
actorData->TargetAir = (bool)atoi(unit->FirstChildElement("TargetAir")->GetText());
actorData->MovementGround = (bool)atoi(unit->FirstChildElement("MovementGround")->GetText());
actorData->MovementAir = (bool)atoi(unit->FirstChildElement("MovementAir")->GetText());
actorData->LightArmor = (bool)atoi(unit->FirstChildElement("LightArmor")->GetText());
actorData->HavyArmor = (bool)atoi(unit->FirstChildElement("HavyArmor")->GetText());
actorData->Organic = (bool)atoi(unit->FirstChildElement("Organic")->GetText());
actorData->Psionic = (bool)atoi(unit->FirstChildElement("Psionic")->GetText());
actorData->Mechanic = (bool)atoi(unit->FirstChildElement("Mechanic")->GetText());
actorData->Massive = (bool)atoi(unit->FirstChildElement("Massive")->GetText());
actorData->Building = (bool)atoi(unit->FirstChildElement("Building")->GetText());
actorData->effectivity = unit->FirstChildElement("effectivity")->GetText();
actorData->noneffectivity = unit->FirstChildElement("noneffectivity")->GetText();
actorData->GeometryRadius = (float)atof(unit->FirstChildElement("GeometryRadius")->GetText());
unit = unit->NextSibling("unit");
}
//empty data
ActorData* actorData = new ActorData();
ActorsData.push_back(actorData);
}
示例5: docHandle
int SC2Map::readObjects( const HANDLE archive )
{
if( debugObjects > 0 )
{
printMessage( "Debugging Objects.\n" );
}
char strFilename[] = "Objects";
int bufferSize;
u8* bufferFreeAfterUse;
if( readArchiveFile( archive, strFilename, &bufferSize, &bufferFreeAfterUse ) < 0 )
{
return -1;
}
bool continueProcessing = true;
// we need a FILE* instead of data buffer for tinyxml lib
char strTemp[] = "Objects.tmp";
FILE* fileTemp = fopen( strTemp, "w+" );
if( fileTemp == NULL )
{
printError( "Could not open temp file for %s.\n", strFilename );
continueProcessing = false;
}
if( continueProcessing )
{
int bytesWritten = fwrite( (char*)bufferFreeAfterUse, 1, bufferSize, fileTemp );
if( bytesWritten != bufferSize )
{
printError( "Could not dump %s to temp file.\n", strFilename );
continueProcessing = false;
}
// from here on out a temporary file holds the XML
// so after processing delete the file
fclose( fileTemp );
}
// whether or not we continue processing we have to
// release the buffer with the file's data
delete bufferFreeAfterUse;
bool continueXML = false;
if( continueProcessing )
{
continueXML = true;
}
TiXmlDocument doc;
if( continueXML )
{
// open temp file as XML stream
if( !doc.LoadFile( strTemp ) )
{
printError( "Could not open temp file for %s.\n", strFilename );
continueXML = false;
}
}
TiXmlHandle docHandle( &doc );
TiXmlElement* placedObjects = NULL;
if( continueXML )
{
placedObjects = docHandle
.FirstChildElement( "PlacedObjects" )
.ToElement();
if( !placedObjects )
{
printWarning( "%s is not valid.\n", strFilename );
continueXML = false;
}
}
ObjectMode objMode;
if( continueXML )
{
const char* strVersion;
// try the OBJMODE_BETAPH1_v26 format first
const char* strVersion1 = placedObjects->Attribute( "version" );
if( strVersion1 != NULL )
{
strVersion = strVersion1;
objMode = OBJMODE_BETAPH1_v26;
} else {
const char* strVersion2 = placedObjects->Attribute( "Version" );
if( strVersion2 != NULL )
{
strVersion = strVersion2;
objMode = OBJMODE_BETAPH2_v26;
//.........这里部分代码省略.........
示例6: GetBitCometDownloadDirs
// 获得比特彗星的下载目录
BOOL bigfilehelper::GetBitCometDownloadDirs(std::vector<CString>& vDirs)
{
BOOL retval = FALSE;
TiXmlDocument xmlDoc;
const TiXmlElement *pBT = NULL;
const TiXmlElement *pSet = NULL;
const TiXmlElement *pDownLoad = NULL;
const char* szDefaultDownPath = NULL;
CString strDirs;
int pos = -1;
TCHAR szAppPath[MAX_PATH] = { 0 };
ULONG dwLength = MAX_PATH;
CRegKey regKey;
LONG lRetCode;
WCHAR szAppDataPath[MAX_PATH] = {0};
szAppDataPath[0] = GetSystemDrive();
wcscat(szAppDataPath,L":\\downloads");
vDirs.push_back(szAppDataPath);
lRetCode = regKey.Open(HKEY_CURRENT_USER, _T("Software\\BitComet"), KEY_READ);
if (lRetCode)
goto clean0;
lRetCode = regKey.QueryStringValue(NULL, szAppPath, &dwLength);
if (lRetCode)
goto clean0;
PathRemoveFileSpec(szAppPath);
PathAppend(szAppPath, _T("BitComet.xml"));
if (GetFileAttributes(szAppPath) == INVALID_FILE_ATTRIBUTES)
goto clean0;
if (!xmlDoc.LoadFile(UnicodeToAnsi(szAppPath).c_str(), TIXML_ENCODING_UTF8))
goto clean0;
pBT = xmlDoc.FirstChildElement("BitComet");
if (!pBT)
goto clean0;
pSet = xmlDoc.FirstChildElement("Settings");
if (!pSet)
goto clean0;
pDownLoad = xmlDoc.FirstChildElement("DefaultDownloadPath");
if (!pDownLoad)
goto clean0;
szDefaultDownPath = pDownLoad->GetText();
if (!szDefaultDownPath)
goto clean0;
strDirs = Utf8ToUnicode(szDefaultDownPath).c_str();
if (GetFileAttributes(strDirs) != INVALID_FILE_ATTRIBUTES)
{
if(strDirs.GetAt(0)==GetSystemDrive()||strDirs.GetAt(0)==GetSystemDrive()-32||strDirs.GetAt(0)==GetSystemDrive()+32)
vDirs.push_back(strDirs);
else goto clean0;
}
retval = TRUE;
clean0:
return retval;
}
示例7: parseLevel
Level* LevelParser::parseLevel(const char *levelFile)
{
// create a tinyXML document and load the map xml
TiXmlDocument levelDocument;
levelDocument.LoadFile(levelFile);
// create the level object
Level* pLevel = new Level();
// get the root node and display some values
TiXmlElement* pRoot = levelDocument.RootElement();
std::cout << "Loading level:\n" << "Version: " << pRoot->Attribute("version") << "\n";
std::cout << "Width:" << pRoot->Attribute("width") << " - Height:" << pRoot->Attribute("height") << "\n";
std::cout << "Tile Width:" << pRoot->Attribute("tilewidth") << " - Tile Height:" << pRoot->Attribute("tileheight") << "\n";
pRoot->Attribute("tilewidth", &m_tileSize);
pRoot->Attribute("width", &m_width);
pRoot->Attribute("height", &m_height);
//we know that properties is the first child of the root
TiXmlElement* pProperties = pRoot->FirstChildElement();
// we must parse the textures needed for this level, which have been added to properties
for(TiXmlElement* e = pProperties->FirstChildElement(); e != NULL; e = e->NextSiblingElement())
{
if(e->Value() == std::string("property"))
{
parseTextures(e);
}
}
// we must now parse the tilesets
for(TiXmlElement* e = pRoot->FirstChildElement(); e != NULL; e = e->NextSiblingElement())
{
if(e->Value() == std::string("tileset"))
{
parseTilesets(e, pLevel->getTilesets());
}
}
// parse any object layers
for(TiXmlElement* e = pRoot->FirstChildElement(); e != NULL; e = e->NextSiblingElement())
{
if(e->Value() == std::string("objectgroup") || e->Value() == std::string("layer"))
{
if(e->FirstChildElement()->Value() == std::string("object"))
{
parseObjectLayer(e, pLevel->getLayers(), pLevel);
}
else if(e->FirstChildElement()->Value() == std::string("data") ||
(e->FirstChildElement()->NextSiblingElement() != 0 && e->FirstChildElement()->NextSiblingElement()->Value() == std::string("data")))
{
parseTileLayer(e, pLevel->getLayers(), pLevel->getTilesets(), pLevel->getCollisionLayers());
}
}
}
// set the players collision layer
// pLevel->getPlayer()->setCollisionLayers(pLevel->getCollisionLayers());
return pLevel;
}
示例8: LoadFromXML
bool CMinotaurSpawn::LoadFromXML(const char* prefabName, CObjectManager* objManager)
{
TiXmlDocument doc;
string path = "../Game/Assets/Scripts/Prefabs/";
path += prefabName;
path += ".xml";
if (doc.LoadFile(path.c_str(), TiXmlEncoding::TIXML_ENCODING_UTF8))
{
CAssetManager* pAssetManager = CAssetManager::GetInstance();
TiXmlElement * root = doc.RootElement();
TiXmlElement * ContentList = root->FirstChildElement("Meshes");
if (ContentList)
{
TiXmlElement * Mesh = ContentList->FirstChildElement("Mesh");
while (Mesh != nullptr)
{
double pos[4] = { 0.0 };
XMFLOAT3 position;
const char* name = Mesh->Attribute("name");
const char* diffuse = Mesh->Attribute("diffuse");
const char* normal = Mesh->Attribute("normalMap");
Mesh->Attribute("transX", &pos[0]);
Mesh->Attribute("transY", &pos[1]);
Mesh->Attribute("transZ", &pos[2]);
if (diffuse)
diffuseTextures.push_back(diffuse);
if (normal)
normalMaps.push_back(normal);
CMesh* mesh = pAssetManager->GetPrefabMesh(name);
if (pos[3] == 90.0f)
{
for (size_t i = 0; i < mesh->GetPlanes().size(); i++)
std::swap(mesh->GetPlanes()[i].extents.x, mesh->GetPlanes()[i].extents.z);
for (size_t i = 0; i < mesh->GetAABBs().size(); i++)
std::swap(mesh->GetAABBs()[i].extents.x, mesh->GetAABBs()[i].extents.z);
}
XMFLOAT4X4 local = {};
XMStoreFloat4x4(&local, XMMatrixTranslation(pos[0], pos[1], pos[2]));
meshLocalMatricies.push_back(local);
meshes.push_back(mesh);
Mesh = Mesh->NextSiblingElement();
}
}
ContentList = root->FirstChildElement("Objects");
if (ContentList && objManager)
{
TiXmlElement * Object = ContentList->FirstChildElement("Object");
while (Object != nullptr)
{
int _type = 0;
double data[4];
XMFLOAT3 position;
Object->Attribute("type", &_type);
Object->Attribute("transX", &data[0]);
Object->Attribute("transY", &data[1]);
Object->Attribute("transZ", &data[2]);
position = XMFLOAT3(float(data[0]), float(data[1]), float(data[2]));
int orientation = 0;
Object->Attribute("dir", &orientation);
m_vObjects.push_back(new CItemCrate((IChest::EDirection)orientation, position, m_pDayNight));
Object = Object->NextSiblingElement();
}
}
}
return true;
}
示例9: LoadParticle
result nekoParticleInstance::LoadParticle(const char8 *fileName, bool forUseOnly)
{
char8 *fileData;
TiXmlDocument doc;
if(forUseOnly)
{
if(FAILED(GetNekoNovel()->GetFileSystem()->LoadData( (string("ÆÄƼŬ\\") + fileName).c_str(), &fileData)))
return E_NOT_EXIST;
doc.Parse(fileData);
// ¸Þ¸ð¸® ¾ø¾Ö±â..
delete []fileData;
mForUseOnly = true;
}
else
{
doc.LoadFile(fileName);
}
mFileName = fileName;
if(doc.Error())
{
LogPrint(LOG_LEVEL_WARN, "'%s' ÆÄÀÏÀº XML ±¸¹®ÀÌ À߸øµÇ¾ú½À´Ï´Ù.", fileName);
return E_FAIL;
}
TiXmlElement *root = doc.FirstChildElement("NekoNovel_Particle");
if(!root)
{
LogPrint(LOG_LEVEL_WARN, "'%s' ÆÄÀÏ¿¡ ÆÄƼŬ Á¤º¸°¡ Á¸ÀçÇÏÁö ¾Ê½À´Ï´Ù.", fileName);
return E_FAIL;
}
Clear();
TiXmlElement *emitter = root->FirstChildElement("Emitter");
TiXmlElement *events;
TiXmlElement *event;
while(emitter)
{
nekoParticleEmitter *emt = AddEmitter(emitter->Attribute("Name"));
emt->mEmitDelay = atof(emitter->Attribute("EmitDelay"));
emt->mMinDir.x = atof(emitter->Attribute("MinDirX"));
emt->mMinDir.y = atof(emitter->Attribute("MinDirY"));
emt->mMaxDir.x = atof(emitter->Attribute("MaxDirX"));
emt->mMaxDir.y = atof(emitter->Attribute("MaxDirY"));
emt->mMinScale = atof(emitter->Attribute("MinScale"));
emt->mMaxScale = atof(emitter->Attribute("MaxScale"));
emt->mMaxCount = atoi(emitter->Attribute("MaxCount"));
emt->mLoop = stricmp(emitter->Attribute("Loop"), "true") == 0;
emt->mSpawnPos.x = atof(emitter->Attribute("SpawnPosX"));
emt->mSpawnPos.y = atof(emitter->Attribute("SpawnPosY"));
emt->mSpawnRadius.x = atof(emitter->Attribute("SpawnRadiusX"));
emt->mSpawnRadius.y = atof(emitter->Attribute("SpawnRadiusY"));
emt->mMinLifeTime = atof(emitter->Attribute("MinLifeTime"));
emt->mMaxLifeTime = atof(emitter->Attribute("MaxLifeTime"));
if(emitter->Attribute("MinFirstAppearTime"))
emt->mMinFirstAppearTime = atof(emitter->Attribute("MinFirstAppearTime"));
if(emitter->Attribute("MaxFirstAppearTime"))
emt->mMaxFirstAppearTime = atof(emitter->Attribute("MaxFirstAppearTime"));
emt->mMinStartColor = _atoi64(emitter->Attribute("MinStartColor"));
emt->mMaxStartColor = _atoi64(emitter->Attribute("MaxStartColor"));
emt->mMinEndColor = _atoi64(emitter->Attribute("MinEndColor"));
emt->mMaxEndColor = _atoi64(emitter->Attribute("MaxEndColor"));
emt->mRotation = atof(emitter->Attribute("Rotation"));
emt->mRotationSpeed = atof(emitter->Attribute("RotationSpeed"));
emt->mScaleSpeed = atof(emitter->Attribute("ScaleSpeed"));
emt->mGravity.x = atof(emitter->Attribute("GravityX"));
emt->mGravity.y = atof(emitter->Attribute("GravityY"));
emt->mSrcBlend = atoi(emitter->Attribute("SrcBlend"));
emt->mDestBlend = atoi(emitter->Attribute("DestBlend"));
emt->SetTexture(emitter->Attribute("Image"));
events = emitter->FirstChildElement("Events");
if(events)
{
event = events->FirstChildElement("Event");
while(event)
{
nekoParticleEvent pevt;
pevt.mTime = atof(event->Attribute("Time"));
pevt.mFlags = atoi(event->Attribute("Flags"));
pevt.mMinDir.x = atof(event->Attribute("MinDirX"));
//.........这里部分代码省略.........
示例10: Load
bool CAdvancedSettings::Load()
{
// NOTE: This routine should NOT set the default of any of these parameters
// it should instead use the versions of GetString/Integer/Float that
// don't take defaults in. Defaults are set in the constructor above
CStdString advancedSettingsXML;
advancedSettingsXML = g_settings.GetUserDataItem("advancedsettings.xml");
TiXmlDocument advancedXML;
if (!CFile::Exists(advancedSettingsXML))
{ // tell the user it doesn't exist
CLog::Log(LOGNOTICE, "No advancedsettings.xml to load (%s)", advancedSettingsXML.c_str());
return false;
}
if (!advancedXML.LoadFile(advancedSettingsXML))
{
CLog::Log(LOGERROR, "Error loading %s, Line %d\n%s", advancedSettingsXML.c_str(), advancedXML.ErrorRow(), advancedXML.ErrorDesc());
return false;
}
TiXmlElement *pRootElement = advancedXML.RootElement();
if (!pRootElement || strcmpi(pRootElement->Value(),"advancedsettings") != 0)
{
CLog::Log(LOGERROR, "Error loading %s, no <advancedsettings> node", advancedSettingsXML.c_str());
return false;
}
// succeeded - tell the user it worked
CLog::Log(LOGNOTICE, "Loaded advancedsettings.xml from %s", advancedSettingsXML.c_str());
// Dump contents of AS.xml to debug log
TiXmlPrinter printer;
printer.SetLineBreak("\n");
printer.SetIndent(" ");
advancedXML.Accept(&printer);
CLog::Log(LOGNOTICE, "Contents of %s are...\n%s", advancedSettingsXML.c_str(), printer.CStr());
TiXmlElement *pElement = pRootElement->FirstChildElement("audio");
if (pElement)
{
XMLUtils::GetFloat(pElement, "ac3downmixgain", m_ac3Gain, -96.0f, 96.0f);
XMLUtils::GetInt(pElement, "headroom", m_audioHeadRoom, 0, 12);
XMLUtils::GetFloat(pElement, "karaokesyncdelay", m_karaokeSyncDelay, -3.0f, 3.0f);
// 101 on purpose - can be used to never automark as watched
XMLUtils::GetFloat(pElement, "playcountminimumpercent", m_audioPlayCountMinimumPercent, 0.0f, 101.0f);
XMLUtils::GetBoolean(pElement, "usetimeseeking", m_musicUseTimeSeeking);
XMLUtils::GetInt(pElement, "timeseekforward", m_musicTimeSeekForward, 0, 6000);
XMLUtils::GetInt(pElement, "timeseekbackward", m_musicTimeSeekBackward, -6000, 0);
XMLUtils::GetInt(pElement, "timeseekforwardbig", m_musicTimeSeekForwardBig, 0, 6000);
XMLUtils::GetInt(pElement, "timeseekbackwardbig", m_musicTimeSeekBackwardBig, -6000, 0);
XMLUtils::GetInt(pElement, "percentseekforward", m_musicPercentSeekForward, 0, 100);
XMLUtils::GetInt(pElement, "percentseekbackward", m_musicPercentSeekBackward, -100, 0);
XMLUtils::GetInt(pElement, "percentseekforwardbig", m_musicPercentSeekForwardBig, 0, 100);
XMLUtils::GetInt(pElement, "percentseekbackwardbig", m_musicPercentSeekBackwardBig, -100, 0);
XMLUtils::GetInt(pElement, "resample", m_musicResample, 0, 48000);
TiXmlElement* pAudioExcludes = pElement->FirstChildElement("excludefromlisting");
if (pAudioExcludes)
GetCustomRegexps(pAudioExcludes, m_audioExcludeFromListingRegExps);
pAudioExcludes = pElement->FirstChildElement("excludefromscan");
if (pAudioExcludes)
GetCustomRegexps(pAudioExcludes, m_audioExcludeFromScanRegExps);
XMLUtils::GetBoolean(pElement, "applydrc", m_audioApplyDrc);
XMLUtils::GetBoolean(pElement, "dvdplayerignoredtsinwav", m_dvdplayerIgnoreDTSinWAV);
}
pElement = pRootElement->FirstChildElement("video");
if (pElement)
{
XMLUtils::GetFloat(pElement, "subsdelayrange", m_videoSubsDelayRange, 10, 600);
XMLUtils::GetFloat(pElement, "audiodelayrange", m_videoAudioDelayRange, 10, 600);
XMLUtils::GetInt(pElement, "blackbarcolour", m_videoBlackBarColour, 0, 255);
XMLUtils::GetBoolean(pElement, "fullscreenonmoviestart", m_fullScreenOnMovieStart);
// 101 on purpose - can be used to never automark as watched
XMLUtils::GetFloat(pElement, "playcountminimumpercent", m_videoPlayCountMinimumPercent, 0.0f, 101.0f);
XMLUtils::GetInt(pElement, "ignoresecondsatstart", m_videoIgnoreSecondsAtStart, 0, 900);
XMLUtils::GetFloat(pElement, "ignorepercentatend", m_videoIgnorePercentAtEnd, 0, 100.0f);
XMLUtils::GetInt(pElement, "smallstepbackseconds", m_videoSmallStepBackSeconds, 1, INT_MAX);
XMLUtils::GetInt(pElement, "smallstepbacktries", m_videoSmallStepBackTries, 1, 10);
XMLUtils::GetInt(pElement, "smallstepbackdelay", m_videoSmallStepBackDelay, 100, 5000); //MS
XMLUtils::GetBoolean(pElement, "usetimeseeking", m_videoUseTimeSeeking);
XMLUtils::GetInt(pElement, "timeseekforward", m_videoTimeSeekForward, 0, 6000);
XMLUtils::GetInt(pElement, "timeseekbackward", m_videoTimeSeekBackward, -6000, 0);
XMLUtils::GetInt(pElement, "timeseekforwardbig", m_videoTimeSeekForwardBig, 0, 6000);
XMLUtils::GetInt(pElement, "timeseekbackwardbig", m_videoTimeSeekBackwardBig, -6000, 0);
XMLUtils::GetInt(pElement, "percentseekforward", m_videoPercentSeekForward, 0, 100);
XMLUtils::GetInt(pElement, "percentseekbackward", m_videoPercentSeekBackward, -100, 0);
XMLUtils::GetInt(pElement, "percentseekforwardbig", m_videoPercentSeekForwardBig, 0, 100);
XMLUtils::GetInt(pElement, "percentseekbackwardbig", m_videoPercentSeekBackwardBig, -100, 0);
TiXmlElement* pVideoExcludes = pElement->FirstChildElement("excludefromlisting");
if (pVideoExcludes)
//.........这里部分代码省略.........
示例11: LoadPredefinedResultFromFile
void ResultMap::LoadPredefinedResultFromFile(const wxString& FileName)
{
TiXmlDocument Doc;
if ( !Doc.LoadFile(FileName.mb_str(wxConvFile)) ) return;
wxString CBBase = ConfigManager::GetFolder(sdBase) + wxFileName::GetPathSeparator();
for ( TiXmlElement* RootElem = Doc.FirstChildElement("predefined_library");
RootElem;
RootElem = RootElem->NextSiblingElement("predefined_library") )
{
for ( TiXmlElement* Elem = RootElem->FirstChildElement();
Elem;
Elem = Elem->NextSiblingElement() )
{
LibraryResult* Result = new LibraryResult();
Result->Type = rtPredefined;
Result->LibraryName = wxString(Elem->Attribute("name") ,wxConvUTF8);
Result->ShortCode = wxString(Elem->Attribute("short_code"),wxConvUTF8);
Result->BasePath = wxString(Elem->Attribute("base_path") ,wxConvUTF8);
Result->PkgConfigVar = wxString(Elem->Attribute("pkg_config"),wxConvUTF8);
if ( TiXmlElement* Sub = Elem->FirstChildElement("description") )
{
Result->Description = wxString(Sub->GetText(),wxConvUTF8);
}
for ( TiXmlAttribute* Attr = Elem->FirstAttribute(); Attr; Attr=Attr->Next() )
{
// if ( !strncasecmp(Attr->Name(),"category",8) )
if ( !strncmp(Attr->Name(),"category",8) )
{
Result->Categories.Add(wxString(Attr->Value(),wxConvUTF8));
}
}
for ( TiXmlElement* Sub = Elem->FirstChildElement(); Sub; Sub=Sub->NextSiblingElement() )
{
wxString Name = wxString(Sub->Value(),wxConvUTF8).Lower();
if ( Name == _T("path") )
{
wxString Include = wxString(Sub->Attribute("include"),wxConvUTF8);
wxString Lib = wxString(Sub->Attribute("lib"),wxConvUTF8);
wxString Obj = wxString(Sub->Attribute("obj"),wxConvUTF8);
if ( !Include.IsEmpty() )
{
Result->IncludePath.Add(wxFileName(Include).IsRelative() ? CBBase + Include : Include);
}
if ( !Lib.IsEmpty() )
{
Result->LibPath.Add(wxFileName(Lib).IsRelative() ? CBBase + Lib : Lib);
}
if ( !Obj.IsEmpty() )
{
Result->ObjPath.Add(wxFileName(Obj).IsRelative() ? CBBase + Obj : Obj);
}
}
if ( Name == _T("add") )
{
wxString Lib = wxString(Sub->Attribute("lib"),wxConvUTF8);
wxString Define = wxString(Sub->Attribute("define"),wxConvUTF8);
wxString CFlags = wxString(Sub->Attribute("cflags"),wxConvUTF8);
wxString LFlags = wxString(Sub->Attribute("lflags"),wxConvUTF8);
if ( !Lib.IsEmpty() ) Result->Libs.Add(Lib);
if ( !Define.IsEmpty() ) Result->Defines.Add(Define);
if ( !CFlags.IsEmpty() ) Result->CFlags.Add(CFlags);
if ( !LFlags.IsEmpty() ) Result->LFlags.Add(LFlags);
}
if ( Name == _T("compiler") )
{
Result->Compilers.Add(wxString(Sub->Attribute("name"),wxConvUTF8));
}
if ( Name == _T("header") )
{
Result->Headers.Add(wxString(Sub->Attribute("file"),wxConvUTF8));
}
if ( Name == _T("require") )
{
Result->Require.Add(wxString(Sub->Attribute("library"),wxConvUTF8));
}
}
if ( Result->LibraryName.IsEmpty() ||
Result->ShortCode.IsEmpty() )
{
delete Result;
continue;
}
GetShortCode(Result->ShortCode).Add(Result);
}
//.........这里部分代码省略.........
示例12: sFileName
///////////////////////////////////////////////////////////////////////////////
/// This is the main API for users.
mvl_camera_t *mvl_read_camera(
const char *filename, //< Input:
double *hpose //< Output:
)
{
mvl_camera_t* cam;
cam = (mvl_camera_t*)calloc( 1, sizeof( mvl_camera_t ));
// if not found, try adding .gz
string sFileName( filename ), sPath;
if( _mvl_camera_is_file( sFileName ) == false ){
if( _mvl_camera_is_file( sFileName+".gz" ) ){
sFileName = sFileName+".gz";
}
}
string sTmp1, sTmp2;
_FilePartsMVL( sFileName, sPath, sTmp1, sTmp2 );
int nPos = sFileName.find_last_of(".");
string sExt = sFileName.substr( nPos );
std::transform( sExt.begin(), sExt.end(), sExt.begin(), ::tolower );
// load from zipped file or not
TiXmlDocument doc;
bool success = false;
if( sExt == ".gz" ){
char* pBuf = AllocReadIntoBuffer( sFileName.c_str() );
success = doc.Parse( pBuf );
free( pBuf );
}
else{
success = doc.LoadFile( sFileName.c_str() );
}
if( !success ){
fprintf( stderr, "ERROR: opening or parsing camera model XML file '%s'\n", sFileName.c_str() );
return NULL;
}
TiXmlElement* pCamNode = doc.FirstChildElement( "camera_model" );
if( !pCamNode ){
return NULL;
}
/// Get version
const char* sVer = pCamNode->Attribute("version");
if( !sVer ){
fprintf( stderr, "ERROR: Unknown camera model version (no version attribute)" );
return NULL;
}
cam->version = atoi(sVer);
/// Get name
const char* sName = pCamNode->Attribute("name");
sprintf( cam->name, "%s", sName ? sName : "" );
/// Get index
const char* sIndex = pCamNode->Attribute("index");
cam->index = sIndex ? atoi(sIndex) : 0;
/// Get serial number
const char* sSerial = pCamNode->Attribute("serialno");
cam->serialno = sSerial ? atoi(sSerial) : -1;
/// Get Type
const char* sType = pCamNode->Attribute("type");
if( !sType ){
fprintf( stderr, "ERROR: Unknown camera model type (no type attribute)" );
return NULL;
}
if( !strcmp( sType, "MVL_CAMERA_WARPED" ) ) {
cam->type = MVL_CAMERA_WARPED;
}
else if( !strcmp( sType, "MVL_CAMERA_LINEAR") ) {
cam->type = MVL_CAMERA_LINEAR;
}
else if( !strcmp( sType, "MVL_CAMERA_LUT") ) {
cam->type = MVL_CAMERA_LUT;
}
else {
cam->type = -1;
}
if( g_nMvlCameraModelVerbosityLevel > 0 &&
cam->version != CURRENT_CMOD_XML_FILE_VERSION ){
printf( "WARNING: Camera model v%d is outdated -- things should be fine, but you\n"
" should consider updating your camera models.\n", cam->version );
printf( " To do so, just run the 'cmodupdate' utility.\n\n" );
// printf( " *** WILL TRY TO CONTINUE BUT BEHAVIOUR IS UNDEFINED AFTER THIS POINT ***\n\n\n" );
}
success = false;
switch( cam->type ) {
case MVL_CAMERA_LINEAR:
//.........这里部分代码省略.........
示例13: AddMapDefinition
/*!
* \brief
* Processes an xml document to parse the map part definition it contains and add it to the list.
*
* \param definition_path
* The path to the xml document on disk.
*
* \returns
* Returns true if the xml was valid and processed successfully otherwise returns false.
*
* Processes an xml document to parse the map part definition it contains and add it to the list.
*/
static bool AddMapDefinition(const char* definition_path)
{
TiXmlDocument definition;
// load the map part definition
definition.LoadFile(definition_path);
// check the xml loaded correctly
if(definition.Error())
{
blam::console_printf("Failed to load and parse the map part definition\nError: %s", definition.ErrorDesc());
return false;
}
// get the xml root
TiXmlElement* root_node = definition.FirstChildElement("osHTTPServer");
if(!root_node)
{
blam::console_printf(false, "The map part definition has no osHTTPServer root node");
return false;
}
// get the map element
const TiXmlElement* map_node = root_node->FirstChildElement("map_download");
if(!map_node)
{
blam::console_printf(false, "The map part definition has no map_download node");
return false;
}
const char* name = map_node->Attribute("name");
const char* md5 = map_node->Attribute("md5");
const char* algorithm = map_node->Attribute("algorithm");
const char* host_directory = map_node->Attribute("host_directory");
// check the md5 string is the correct length
bool md5_valid = false;
if(md5)
md5_valid = (strlen(md5) == 32);
// if the map is valid, create a new map element
if(name && md5 && md5_valid && algorithm)
{
// remove the extension from the map name
std::string map_name(name);
std::string::size_type extension_offset = std::string::npos;
if((extension_offset = map_name.find(Cache::K_MAP_FILE_EXTENSION)) != std::string::npos)
map_name.resize(extension_offset);
else if((extension_offset = map_name.find(Cache::K_MAP_FILE_EXTENSION_YELO)) != std::string::npos)
map_name.resize(extension_offset);
if(FindMap(map_name.c_str()))
{
blam::console_printf(false, "Map definition for %s already exists", map_name.c_str());
return false;
}
c_map_element* map_element = new c_map_element();
map_element->Ctor();
// assign the name of the map and remove its extension for later comparisons
map_element->m_name = map_name;
// create a copy of the maps part definition to send to the client
// remove the host_directory attribute from the client copy as it is unnecessary
map_element->m_part_definition = map_node->Clone()->ToElement();
map_element->m_part_definition->RemoveAttribute("host_directory");
// add the parts to the map element, host_directory can be null
if(!AddMapParts(map_element, map_node, host_directory))
{
// a problem occurred when adding the maps part elements so delete the map element and return
delete map_element;
return false;
}
// add the completed map element to the definition lists
if(!AddMapToList(map_element))
{
RemoveMapParts(map_element);
delete map_element;
return false;
}
}
else
{
if(!name)
//.........这里部分代码省略.........
示例14: ParseError
SystemParser::SystemParser(const char* filename, unsigned int verbosity, LeafType leaf_type)
{
// Open the document
TiXmlDocument document = TiXmlDocument(filename);
if (!document.LoadFile()) {
throw ParseError("[ERROR] Could not load the input file.");
}
// Get the root node of the XML-document
TiXmlNode* rootNode = document.RootElement();
if (rootNode == NULL) {
throw ParseError("[ERROR] Could not access the root node of the XML-tree");
}
// Find out the type of the transition system (lts, ctmc, imc)
const std::string type_str = readStringAttribute(rootNode, "type");
if (type_str == "lts") system_type = lts_type;
else if (type_str == "ctmc") system_type = ctmc_type;
else if (type_str == "imc") system_type = imc_type;
else system_type = lts_type;
this->leaf_type = leaf_type;
// Traverse the children of the root node and collect the pointers to the parts we need.
TiXmlNode* varinfoNode = NULL;
TiXmlNode* initialstateNode = NULL;
TiXmlNode* transNode = NULL;
TiXmlNode* markovtransNode = NULL;
TiXmlNode* initialpartitionNode = NULL;
TiXmlNode* tauNode = NULL;
for (TiXmlNode* currentNode = rootNode->FirstChild();
currentNode != NULL;
currentNode = currentNode->NextSibling()) {
if (currentNode->ToElement() == NULL) continue;
const char* const name = currentNode->ToElement()->Value();
if (strcmp(name, "variables") == 0) {
varinfoNode = currentNode;
} else if (strcmp(name, "dd") == 0) {
std::string bdd_type = readStringAttribute(currentNode, "type");
if (bdd_type == "initial_state") {
initialstateNode = currentNode;
} else if (bdd_type == "trans") {
transNode = currentNode;
} else if (bdd_type == "markov_trans") {
markovtransNode = currentNode;
} else if (bdd_type == "tau") {
tauNode = currentNode;
}
} else if (strcmp(name, "initial_partition") == 0) {
initialpartitionNode = currentNode;
}
}
// Check if we have found the variable information
if (varinfoNode == NULL) {
throw ParseError("[ERROR] No variable information found!");
}
// Check if the correct information exists for the system type
switch (system_type) {
case lts_type:
if (markovtransNode != NULL) {
throw ParseError("[ERROR] LTS must not have any Markov transitions!");
}
if (transNode == NULL) {
throw ParseError("[ERROR] LTS must have an interactive transition relation!");
}
break;
case ctmc_type:
if (transNode != NULL) {
throw ParseError("[ERROR] CTMCs must not have any interactive transitions!");
}
if (markovtransNode == NULL) {
throw ParseError("[ERROR] CTMCs must have a Markov transition relation!");
}
break;
case imc_type:
if (transNode == NULL) {
throw ParseError("[ERROR] IMCs must have an interactive transition relation!");
}
if (markovtransNode == NULL) {
throw ParseError("[ERROR] IMCs must have a Markov transition relation!");
}
break;
}
// Parse the variable information and create the BDD variables
// together with an appropriate order for refinement
if (verbosity > 0) std::cout << "[INFO] Creating BDD variables ... " << std::flush;
createVariables(varinfoNode);
if (verbosity > 0) std::cout << "finished." << std::endl;
// Build the BDDs/ADDs for all parts
if (verbosity > 0) std::cout << "[INFO] Building BDDs ... " << std::flush;
std::vector<std::pair<Bdd, Bdd>> transitions;
//.........这里部分代码省略.........
示例15: Load
int CCrashDescReader::Load(CString sFileName)
{
TiXmlDocument doc;
FILE* f = NULL;
strconv_t strconv;
if(m_bLoaded)
return 1; // already loaded
// Check that the file exists
#if _MSC_VER<1400
f = _tfopen(sFileName, _T("rb"));
#else
_tfopen_s(&f, sFileName, _T("rb"));
#endif
if(f==NULL)
return -1; // File can't be opened
// Open XML document
bool bLoaded = doc.LoadFile(f);
if(!bLoaded)
{
fclose(f);
return -2; // XML is corrupted
}
TiXmlHandle hDoc(&doc);
TiXmlHandle hRoot = hDoc.FirstChild("CrashRpt").ToElement();
if(hRoot.ToElement()==NULL)
{
if(LoadXmlv10(hDoc)==0)
{
fclose(f);
return 0;
}
return -3; // Invalid XML structure
}
// Get generator version
const char* szCrashRptVersion = hRoot.ToElement()->Attribute("version");
if(szCrashRptVersion!=NULL)
{
m_dwGeneratorVersion = atoi(szCrashRptVersion);
}
// Get CrashGUID
TiXmlHandle hCrashGUID = hRoot.ToElement()->FirstChild("CrashGUID");
if(hCrashGUID.ToElement())
{
TiXmlText* pTextElem = hCrashGUID.FirstChild().Text();
if(pTextElem)
{
const char* text = pTextElem->Value();
if(text)
m_sCrashGUID = strconv.utf82t(text);
}
}
// Get AppName
TiXmlHandle hAppName = hRoot.ToElement()->FirstChild("AppName");
if(hAppName.ToElement())
{
TiXmlText* pTextElem = hAppName.FirstChild().Text();
if(pTextElem)
{
const char* text = pTextElem->Value();
if(text)
m_sAppName = strconv.utf82t(text);
}
}
// Get AppVersion
TiXmlHandle hAppVersion = hRoot.ToElement()->FirstChild("AppVersion");
if(hAppVersion.ToElement())
{
TiXmlText* pTextElem = hAppVersion.FirstChild().Text();
if(pTextElem)
{
const char* text = pTextElem->Value();
if(text)
m_sAppVersion = strconv.utf82t(text);
}
}
// Get ImageName
TiXmlHandle hImageName = hRoot.ToElement()->FirstChild("ImageName");
if(hImageName.ToElement())
{
TiXmlText* pTextElem = hImageName.FirstChild().Text();
if(pTextElem)
{
const char* text = pTextElem->Value();
if(text)
m_sImageName = strconv.utf82t(text);
}
}
//.........这里部分代码省略.........