本文整理汇总了C++中TiXmlElement::GetDocument方法的典型用法代码示例。如果您正苦于以下问题:C++ TiXmlElement::GetDocument方法的具体用法?C++ TiXmlElement::GetDocument怎么用?C++ TiXmlElement::GetDocument使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TiXmlElement
的用法示例。
在下文中一共展示了TiXmlElement::GetDocument方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ThemeHasSize
bool CThemeProvider::ThemeHasSize(const wxString& themePath, const wxString& size)
{
wxFileName fn(wxGetApp().GetResourceDir() + themePath, _T("theme.xml"));
TiXmlElement* pDocument = GetXmlFile(fn.GetFullPath(), false);
if (!pDocument)
return false;
TiXmlElement* pTheme = pDocument->FirstChildElement("Theme");
if (!pTheme)
{
delete pDocument->GetDocument();
return false;
}
for (TiXmlElement* pSize = pTheme->FirstChildElement("size"); pSize; pSize = pSize->NextSiblingElement("size"))
{
const char* txt = pSize->GetText();
if (!txt)
continue;
if (size == ConvLocal(txt))
{
delete pDocument->GetDocument();
return true;
}
}
delete pDocument->GetDocument();
return false;
}
示例2: SetWidthToCache
void CWrapEngine::SetWidthToCache(const char* name, int width)
{
if (!m_use_cache)
return;
if (!name || !*name)
return;
// We have to synchronize access to layout.xml so that multiple processed don't write
// to the same file or one is reading while the other one writes.
CInterProcessMutex mutex(MUTEX_LAYOUT);
wxFileName file(COptions::Get()->GetOption(OPTION_DEFAULT_SETTINGSDIR), _T("layout.xml"));
TiXmlElement* pDocument = GetXmlFile(file);
if (!pDocument)
return;
TiXmlElement* pElement = pDocument->FirstChildElement("Layout");
if (!pElement)
{
delete pDocument->GetDocument();
return;
}
wxString language = wxGetApp().GetCurrentLanguageCode();
if (language.empty())
language = _T("default");
TiXmlElement* pLanguage = FindElementWithAttribute(pElement, "Language", "id", language.mb_str());
if (!pLanguage)
{
delete pDocument->GetDocument();
return;
}
TiXmlElement* pDialog = FindElementWithAttribute(pLanguage, "Dialog", "name", name);
if (!pDialog)
{
pDialog = pLanguage->LinkEndChild(new TiXmlElement("Dialog"))->ToElement();
pDialog->SetAttribute("name", name);
}
pDialog->SetAttribute("width", width);
wxString error;
SaveXmlFile(file, pDocument, &error);
delete pDocument->GetDocument();
}
示例3: ExportAnyData
int ExportAnyData(CString filename, vector<string> &orders)
{
Book* book = xlCreateBook();
if(!book)
return 0;
for(vector<string>::iterator it = orders.begin(); it != orders.end(); it++)
{
CString Filename = it->c_str();
Filename += ".xml";
TiXmlElement *Root = getXMLRoot(Filename);
Sheet* sheet = book->addSheet(it->c_str());
if(!sheet)
return 0;
addOneSheet(sheet, Root);
delete Root->GetDocument();
}
if(book->save(_T(filename.GetBuffer(0)) ))
{
return 1;
}
else
{
return 0;
}
book->release();
}
示例4: LoadDataFromXML
bool StoryDataCenter::LoadDataFromXML()
{
if (mIsLoadAllData)
{
return true;
}
mIsLoadAllData = true;
std::string filePath = std::string("Data/") + std::string("cutscene.xml");
TiXmlElement *RootElement = initXML(filePath.c_str());
if (0 != RootElement)
{
TiXmlElement *childElement = RootElement->FirstChildElement();
while (0 != childElement)
{
ReadOneXmlItem(childElement);
childElement = childElement->NextSiblingElement();
}
TiXmlDocument *doc = RootElement->GetDocument();
doc->Clear();
CC_SAFE_DELETE(doc);
GetMainLandStoryData();
}
else
{
return false;
}
return true;
}
示例5: Load
TiXmlElement* CXmlFile::Load(const wxFileName& fileName)
{
if (fileName.IsOk())
SetFileName(fileName);
wxCHECK(m_fileName.IsOk(), 0);
delete m_pDocument;
m_pDocument = 0;
TiXmlElement* pElement = GetXmlFile(m_fileName);
if (!pElement)
{
m_modificationTime = wxDateTime();
return 0;
}
{
wxLogNull log;
m_modificationTime = m_fileName.GetModificationTime();
}
m_pDocument = pElement->GetDocument();
return pElement;
}
示例6: Load
TiXmlElement* CXmlFile::Load(const wxFileName& fileName)
{
if (fileName.IsOk())
SetFileName(fileName);
wxCHECK(m_fileName.IsOk(), 0);
delete m_pDocument;
m_pDocument = 0;
wxString error;
TiXmlElement* pElement = GetXmlFile(m_fileName, &error);
if (!pElement)
{
if (!error.empty())
{
m_error.Printf(_("The file '%s' could not be loaded."), m_fileName.GetFullPath().c_str());
if (!error.empty())
m_error += _T("\n") + error;
else
m_error += wxString(_T("\n")) + _("Make sure the file can be accessed and is a well-formed XML document.");
m_modificationTime = wxDateTime();
}
return 0;
}
{
wxLogNull log;
m_modificationTime = m_fileName.GetModificationTime();
}
m_pDocument = pElement->GetDocument();
return pElement;
}
示例7: fn
std::list<wxString> CThemeProvider::GetThemeSizes(const wxString& themePath)
{
std::list<wxString> sizes;
wxFileName fn(wxGetApp().GetResourceDir() + themePath, _T("theme.xml"));
TiXmlElement* pDocument = GetXmlFile(fn.GetFullPath(), false);
if (!pDocument)
return sizes;
TiXmlElement* pTheme = pDocument->FirstChildElement("Theme");
if (pTheme)
{
for (TiXmlElement* pSize = pTheme->FirstChildElement("size"); pSize; pSize = pSize->NextSiblingElement("size"))
{
const char* txt = pSize->GetText();
if (!txt)
continue;
wxString size = ConvLocal(txt);
if (size == _T(""))
continue;
sizes.push_back(size);
}
}
delete pDocument->GetDocument();
return sizes;
}
示例8: VisitExit
bool XMLSceneVisitor::VisitExit( const TiXmlElement& element)
{
if(element.ValueStr() == "scene")
{
return (element.Parent() == element.GetDocument());
}
else if (element.ValueStr() == "materials")
{
return true;
}
else if (element.ValueStr() == "primitives")
{
return true;
}
else if (element.ValueStr() == "plane")
{
m_scene->insert_primitive(m_current);
m_current = NULL;
return true;
}
else if (element.ValueStr() == "sphere")
{
m_scene->insert_primitive(m_current);
m_current = NULL;
return true;
}
else
return false;
}
示例9: SetAttributeAsFloat
void csTinyXmlNode::SetAttributeAsFloat (const char* name, float value)
{
TiXmlElement* el = node->ToElement ();
if (el)
{
csString v;
v.Format ("%g", value);
el->SetAttribute (el->GetDocument (), name, v);
}
}
示例10: VisitEnter
bool XMLSceneVisitor::VisitEnter(const TiXmlElement& element, const TiXmlAttribute* attribute)
{
if(element.ValueStr() == "scene")
{
return (element.Parent() == element.GetDocument());
}
else if (element.ValueStr() == "materials")
{
return true;
}
else if (element.ValueStr() == "primitives")
{
return (element.Parent()->ValueStr() == "scene");
}
else if (element.ValueStr() == "plane")
{
if(element.Parent()->ValueStr() != "primitives")
return false;
assert(m_current == NULL);
double nx(0.0f), ny(1.0f), nz(0.0f), value(0.0f);
element.Attribute("nx", &nx);
element.Attribute("ny", &ny);
element.Attribute("nz", &nz);
element.Attribute("value", &value);
glm::vec3 normal(nx, ny, nz);
normal = glm::normalize(normal);
m_current = new Scene::Plane(normal, value);
return true;
}
else if (element.ValueStr() == "sphere")
{
if(element.Parent()->ValueStr() != "primitives")
return false;
assert(m_current == NULL);
double cx(0.0f), cy(1.0f), cz(0.0f), radius(0.0f);
element.Attribute("cx", &cx);
element.Attribute("cy", &cy);
element.Attribute("cz", &cz);
element.Attribute("radius", &radius);
glm::vec3 center(cx, cy, cz);
m_current = new Scene::Sphere(center, radius);
return true;
}
else
return false;
}
示例11: InitXML
void ParticleFactory::InitXML()
{
std::string pPath =
GameResourceManager::sharedManager()->storedFullPathFromRelativePath("Data/particles.xml");
unsigned long _size;
char *_pFileContent = (char*)CCFileUtils::sharedFileUtils()->getFileData(pPath.c_str() , "r", &_size);
TiXmlDocument *_document = new TiXmlDocument();
_document->Parse(_pFileContent, 0, TIXML_ENCODING_UTF8);
CC_SAFE_DELETE_ARRAY(_pFileContent);
TiXmlElement *RootElement = _document->RootElement();
if (RootElement)
{
TiXmlElement *childElement = RootElement->FirstChildElement();
while (0 != childElement)
{
OneParticleInfo oneParticleInfo;
TiXmlAttribute* pAttribute = childElement->FirstAttribute();
while(pAttribute)
{
std::string strName(pAttribute->Name());
std::string content = childElement->Attribute(strName.c_str());
if (strName == "ID")
{
unsigned int id = atoi(content.c_str());
oneParticleInfo.id = id;
}
else if (strName == "fileName")
{
oneParticleInfo.fileName = content;
}
pAttribute = pAttribute->Next();
}
m_particleListInfo.insert(std::make_pair(oneParticleInfo.id,oneParticleInfo));
childElement = childElement->NextSiblingElement();
}
TiXmlDocument *doc = RootElement->GetDocument();
doc->Clear();
CC_SAFE_DELETE(doc);
}
}
示例12: GetThemeData
bool CThemeProvider::GetThemeData(const wxString& themePath, wxString& name, wxString& author, wxString& email)
{
wxFileName fn(wxGetApp().GetResourceDir() + themePath, _T("theme.xml"));
TiXmlElement* pDocument = GetXmlFile(fn.GetFullPath(), false);
if (!pDocument)
return false;
TiXmlElement* pTheme = pDocument->FirstChildElement("Theme");
if (pTheme)
{
name = GetTextElement(pTheme, "Name");
author = GetTextElement(pTheme, "Author");
email = GetTextElement(pTheme, "Mail");
}
delete pDocument->GetDocument();
return pTheme != 0;
}
示例13: LoadFilters
void CFilterManager::LoadFilters()
{
if (m_loaded)
return;
m_loaded = true;
CInterProcessMutex mutex(MUTEX_FILTERS);
wxFileName file(wxGetApp().GetSettingsDir(), _T("filters.xml"));
if (!file.FileExists())
{
wxFileName defaults(wxGetApp().GetResourceDir(), _T("defaultfilters.xml"));
if (defaults.FileExists())
{
TiXmlElement* pDocument = GetXmlFile(defaults);
if (pDocument)
{
SaveXmlFile(file, pDocument);
delete pDocument->GetDocument();
}
}
}
CXmlFile xml(file);
TiXmlElement* pDocument = xml.Load();
if (!pDocument)
{
wxString msg = xml.GetError() + _T("\n\n") + _("Any changes made to the filters will not be saved.");
wxMessageBox(msg, _("Error loading xml file"), wxICON_ERROR);
return;
}
TiXmlElement *pFilters = pDocument->FirstChildElement("Filters");
if (!pFilters)
return;
TiXmlElement *pFilter = pFilters->FirstChildElement("Filter");
while (pFilter)
{
CFilter filter;
filter.name = GetTextElement(pFilter, "Name");
if (filter.name == _T(""))
{
pFilter = pFilter->NextSiblingElement("Filter");
continue;
}
filter.filterFiles = GetTextElement(pFilter, "ApplyToFiles") == _T("1");
filter.filterDirs = GetTextElement(pFilter, "ApplyToDirs") == _T("1");
wxString type = GetTextElement(pFilter, "MatchType");
if (type == _T("Any"))
filter.matchType = CFilter::any;
else if (type == _T("None"))
filter.matchType = CFilter::none;
else
filter.matchType = CFilter::all;
filter.matchCase = GetTextElement(pFilter, "MatchCase") == _T("1");
TiXmlElement *pConditions = pFilter->FirstChildElement("Conditions");
if (!pConditions)
{
pFilter = pFilter->NextSiblingElement("Filter");
continue;
}
TiXmlElement *pCondition = pConditions->FirstChildElement("Condition");
while (pCondition)
{
CFilterCondition condition;
int type = GetTextElementInt(pCondition, "Type", 0);
switch (type)
{
case 0:
condition.type = filter_name;
break;
case 1:
condition.type = filter_size;
break;
case 2:
condition.type = filter_attributes;
break;
case 3:
condition.type = filter_permissions;
break;
case 4:
condition.type = filter_path;
break;
default:
pCondition = pCondition->NextSiblingElement("Condition");
continue;
}
condition.condition = GetTextElementInt(pCondition, "Condition", 0);
condition.strValue = GetTextElement(pCondition, "Value");
condition.matchCase = filter.matchCase;
if (condition.strValue == _T(""))
{
//.........这里部分代码省略.........
示例14: VisitEnter
/// Visit an element.
virtual bool VisitEnter( const TiXmlElement& element, const TiXmlAttribute* attribute)
{
if(element.ValueStr() == "world")
{
if(element.Parent() != element.GetDocument()) return false;
return true;
}
else if(element.ValueStr() == "materials")
{
if(element.Parent()->ValueStr() != "world") return false;
return true;
}
else if(element.ValueStr() == "material")
{
if(element.Parent()->ValueStr() != "materials") return false;
char const* name;
double density = 1;
double friction = 0;
double restitution = 0;
double cr = 0;
double cg = 0;
double cb = 0;
name = element.Attribute("name");
if(!name)
{
return false;
}
element.Attribute("density", &density);
element.Attribute("friction", &friction);
element.Attribute("restitution", &restitution);
element.Attribute("cr", &cr);
element.Attribute("cg", &cg);
element.Attribute("cb", &cb);
// populate sound parameters
double thickness;
double youngsModulus;
double fluidDamping;
double viscoelasticDamping;
element.Attribute("thickness", &thickness);
element.Attribute("youngsModulus", &youngsModulus);
element.Attribute("fluidDamping", &fluidDamping);
element.Attribute("viscoelasticDamping", &viscoelasticDamping);
// if any values are NULL then set them to the default
thickness = thickness == NULL ? 0.1 : thickness;
youngsModulus = youngsModulus == NULL ? 900 : youngsModulus;
fluidDamping = fluidDamping == NULL ? 0.00001 : fluidDamping;
viscoelasticDamping = viscoelasticDamping == NULL ? 0.1 : viscoelasticDamping;
m_curMaterial = new Material(float(density), float(friction), float(restitution), Vector3(float(cr), float(cg), float(cb)),
float(thickness), float(youngsModulus), float(fluidDamping), float(viscoelasticDamping));
m_materials[name] = m_curMaterial;
return true;
}
else if(element.ValueStr() == "bodies")
{
if(element.Parent()->ValueStr() != "world") return false;
return true;
}
else if(element.ValueStr() == "ground")
{
if(element.Parent()->ValueStr() != "bodies") return false;
assert(m_curBody == NULL);
m_curBody = new Ground();
return true;
}
else if(element.ValueStr() == "box")
{
if(element.Parent()->ValueStr() != "bodies") return false;
assert(m_curBody == NULL);
double hx = 1;
double hy = 1;
double hz = 1;
element.Attribute("hx", &hx);
element.Attribute("hy", &hy);
element.Attribute("hz", &hz);
m_curBody = new Box(Vector3(float(hx), float(hy), float(hz)));
return true;
}
else if(element.ValueStr() == "sphere")
{
if(element.Parent()->ValueStr() != "bodies") return false;
assert(m_curBody == NULL);
double r = 1;
//.........这里部分代码省略.........
示例15: SaveFilters
void CFilterDialog::SaveFilters()
{
CInterProcessMutex mutex(MUTEX_FILTERS);
wxFileName file(wxGetApp().GetSettingsDir(), _T("filters.xml"));
TiXmlElement* pDocument = GetXmlFile(file);
if (!pDocument)
{
wxString msg = wxString::Format(_("Could not load \"%s\", please make sure the file is valid and can be accessed.\nAny changes made in the Site Manager could not be saved."), file.GetFullPath().c_str());
wxMessageBox(msg, _("Error loading xml file"), wxICON_ERROR);
return;
}
TiXmlElement *pFilters = pDocument->FirstChildElement("Filters");
while (pFilters)
{
pDocument->RemoveChild(pFilters);
pFilters = pDocument->FirstChildElement("Filters");
}
pFilters = pDocument->InsertEndChild(TiXmlElement("Filters"))->ToElement();
for (std::vector<CFilter>::const_iterator iter = m_globalFilters.begin(); iter != m_globalFilters.end(); iter++)
{
const CFilter& filter = *iter;
TiXmlElement* pFilter = pFilters->InsertEndChild(TiXmlElement("Filter"))->ToElement();
AddTextElement(pFilter, "Name", filter.name);
AddTextElement(pFilter, "ApplyToFiles", filter.filterFiles ? _T("1") : _T("0"));
AddTextElement(pFilter, "ApplyToDirs", filter.filterDirs ? _T("1") : _T("0"));
AddTextElement(pFilter, "MatchType", (filter.matchType == CFilter::any) ? _T("Any") : ((filter.matchType == CFilter::none) ? _T("None") : _T("All")));
AddTextElement(pFilter, "MatchCase", filter.matchCase ? _T("1") : _T("0"));
TiXmlElement* pConditions = pFilter->InsertEndChild(TiXmlElement("Conditions"))->ToElement();
for (std::vector<CFilterCondition>::const_iterator conditionIter = filter.filters.begin(); conditionIter != filter.filters.end(); conditionIter++)
{
const CFilterCondition& condition = *conditionIter;
TiXmlElement* pCondition = pConditions->InsertEndChild(TiXmlElement("Condition"))->ToElement();
AddTextElement(pCondition, "Type", condition.type);
AddTextElement(pCondition, "Condition", condition.condition);
AddTextElement(pCondition, "Value", condition.strValue);
}
}
TiXmlElement *pSets = pDocument->FirstChildElement("Sets");
while (pSets)
{
pDocument->RemoveChild(pSets);
pSets = pDocument->FirstChildElement("Sets");
}
pSets = pDocument->InsertEndChild(TiXmlElement("Sets"))->ToElement();
SetTextAttribute(pSets, "Current", wxString::Format(_T("%d"), m_currentFilterSet));
for (std::vector<CFilterSet>::const_iterator iter = m_globalFilterSets.begin(); iter != m_globalFilterSets.end(); iter++)
{
const CFilterSet& set = *iter;
TiXmlElement* pSet = pSets->InsertEndChild(TiXmlElement("Set"))->ToElement();
if (iter != m_globalFilterSets.begin())
AddTextElement(pSet, "Name", set.name);
for (unsigned int i = 0; i < set.local.size(); i++)
{
TiXmlElement* pItem = pSet->InsertEndChild(TiXmlElement("Item"))->ToElement();
AddTextElement(pItem, "Local", set.local[i] ? _T("1") : _T("0"));
AddTextElement(pItem, "Remote", set.remote[i] ? _T("1") : _T("0"));
}
}
SaveXmlFile(file, pDocument);
delete pDocument->GetDocument();
}