本文整理汇总了C++中TiXmlElement::SetAttribute方法的典型用法代码示例。如果您正苦于以下问题:C++ TiXmlElement::SetAttribute方法的具体用法?C++ TiXmlElement::SetAttribute怎么用?C++ TiXmlElement::SetAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TiXmlElement
的用法示例。
在下文中一共展示了TiXmlElement::SetAttribute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: FlattenSkinVariableConditions
void CGUIIncludes::FlattenSkinVariableConditions()
{
for (auto& variable : m_skinvariables)
{
TiXmlElement* valueNode = variable.second.FirstChildElement("value");
while (valueNode)
{
const char *condition = valueNode->Attribute("condition");
if (condition)
valueNode->SetAttribute("condition", ResolveExpressions(condition));
valueNode = valueNode->NextSiblingElement("value");
}
}
}
示例2: _FormatWrite
static int _FormatWrite(std::map<int, std::string> &mapAll, char *strFMTWrite)
{
TiXmlDocument *XmlDoc;
TiXmlElement *RootElement;
TiXmlElement *Segment;
TiXmlElement *Colum;
TiXmlDeclaration HeadDec;
TiXmlPrinter Printer;
// 增加XML的头部说明
XmlDoc = new TiXmlDocument();
HeadDec.Parse("<?xml version=\"1.0\" encoding=\"gb2312\" ?>", 0, TIXML_ENCODING_UNKNOWN);
XmlDoc->LinkEndChild(&HeadDec);
RootElement = new TiXmlElement("SEGMENTS");
RootElement->SetAttribute("PROGRAMID", "001");
Segment = new TiXmlElement("SEGMENT");
Segment->SetAttribute("ID", 2);
std::map<int, std::string>::iterator iter = mapAll.begin();
for (; iter != mapAll.end(); ++iter)
{
Colum = new TiXmlElement("COLUMN");
Colum->SetAttribute("ID", iter->first);
Colum->SetAttribute("VALUE", iter->second.c_str());
Segment->LinkEndChild(Colum);
}
RootElement->LinkEndChild(Segment);
XmlDoc->LinkEndChild(RootElement);
XmlDoc->Accept(&Printer);
strcpy(strFMTWrite, Printer.CStr());
return 0;
}
示例3: SaveToXml
bool ConditionStd::SaveToXml(TiXmlElement *node)
{
TiXmlElement *cond_node = new TiXmlElement("calaos:condition");
cond_node->SetAttribute("type", "standard");
cond_node->SetAttribute("trigger", trigger?"true":"false");
node->LinkEndChild(cond_node);
for (uint i = 0;i < inputs.size();i++)
{
Input *in = inputs[i];
TiXmlElement *cnode = new TiXmlElement("calaos:input");
cnode->SetAttribute("id", in->get_param("id"));
cnode->SetAttribute("oper", ops[in->get_param("id")]);
cnode->SetAttribute("val", params[in->get_param("id")]);
if (params_var[in->get_param("id")] != "")
cnode->SetAttribute("val_var", params_var[in->get_param("id")]);
cond_node->LinkEndChild(cnode);
}
return true;
}
示例4: SaveTraitsXML
TiXmlElement* SaveTraitsXML(TiXmlElement* pRoot, std::string TagName, const int numTraits, sTrait* traits[], int tempTraits[])
{
TiXmlElement* pTraits = new TiXmlElement(TagName);
pRoot->LinkEndChild(pTraits);
for (int i = 0; i < numTraits; i++) // save the trait names
{
if (traits[i])
{
TiXmlElement* pTrait = new TiXmlElement(XMLifyString(traits[i]->m_Name)); // Trait name
pTraits->LinkEndChild(pTrait);
if (tempTraits) pTrait->SetAttribute("Temp", tempTraits[i]); // Is temporary
}
}
return pTraits;
}
示例5: ExceptionThrown
STDMETHODIMP CYashProfiler::ExceptionThrown(ObjectID thrownObjectID)
{
LogString("Exception %d Thrown\r\n\r\n", thrownObjectID);
ThreadID threadId;
m_pICorProfilerInfo->GetCurrentThreadID(&threadId);
std::stringstream threadStr;
threadStr << threadId;
// add to XML
TiXmlElement * methodEvent = new TiXmlElement( "exceptionEvent" );
char *exceptionId = new char(256);
sprintf(exceptionId, "%d", thrownObjectID);
methodEvent->SetAttribute("exceptionId", exceptionId);
methodEvent->SetAttribute("threadId", threadStr.str().c_str());
methodEvent->SetAttribute("type", "ExceptionThrown");
LARGE_INTEGER time, freq;
QueryPerformanceCounter(&time);
QueryPerformanceFrequency(&freq);
methodEvent->SetDoubleAttribute("timestamp", (float) time.QuadPart / (float) freq.QuadPart);
m_events->LinkEndChild( methodEvent );
return S_OK;
}
示例6: serialise
void SceneImporter::serialise()
{
BinaryDataStore<char> binaryDataStore;
TiXmlDocument doc;
TiXmlDeclaration* decl = new TiXmlDeclaration("1.0", "", "");
doc.LinkEndChild(decl);
TiXmlElement* root = new TiXmlElement("root");
doc.LinkEndChild(root);
TiXmlElement* header = new TiXmlElement("Header");
header->SetAttribute("type", "SkinnedCharacter");
root->LinkEndChild(header);
TiXmlElement* prefab = new TiXmlElement("Model");
root->LinkEndChild(prefab);
TiXmlElement* meshes = new TiXmlElement("Meshes");
prefab->LinkEndChild(meshes);
meshes->SetAttribute("count", _meshes.size());
for (auto It = _meshes.begin(); It != _meshes.end(); It++)
{
auto_ptr<Mesh>& meshPtr = *(It);
meshPtr->serialise(meshes, binaryDataStore);
}
Animator::get()->serialise(prefab, binaryDataStore);
const char* fileName = "prefab.xml";
ofstream os;
binaryDataStore.compact();
os.open(fileName, ios::binary);
long numBinaryBytes = binaryDataStore.size();
os.write((const char*)&numBinaryBytes, sizeof(long));
const vector<char>& buffer = binaryDataStore.getBuffer();
os.write(&buffer[0], numBinaryBytes);
os.close();
FILE* fp;
fp = fopen(fileName, "a");
doc.Print(fp);
fclose(fp);
}
示例7: SaveToXml
bool Internal::SaveToXml(TiXmlElement *node)
{
TiXmlElement *cnode = new TiXmlElement("calaos:internal");
node->LinkEndChild(cnode);
for (int i = 0;i < get_params().size();i++)
{
string key, value;
get_params().get_item(i, key, value);
if (key == "value" && get_param("save") != "true") continue;
cnode->SetAttribute(key, value);
}
return true;
}
示例8: FillTextures
void xmlFrondsSave::FillTextures( const dataFronds &_data , TiXmlElement* root )
{
//заполнить данными о текстурах
//создать запись для текстур
TiXmlElement *pTextures = NULL;
pTextures = new TiXmlElement( m_FrondsNames.m_sTextures.c_str() );
//количество текстур
pTextures->SetAttribute( m_FrondsNames.m_sNum.c_str() , _data.m_vTextures.size() );
for ( int i = 0 ; i < _data.m_vTextures.size() ; ++i )
{
TiXmlElement *pTexture = NULL;
pTexture = new TiXmlElement( m_FrondsNames.m_sTexture.c_str() );
//количество текстур
pTexture->SetAttribute( m_FrondsNames.m_sVal.c_str() , _data.m_vTextures[ i ].c_str() );
pTextures->LinkEndChild( pTexture );
}
root->LinkEndChild( pTextures );
}
示例9: TiXmlElement
bool ParsingXml::storeScore(std::string &playerName, int data)
{
TiXmlElement *players = this->_doc.FirstChildElement("players");
if (players)
{
unsigned int nb = 0;
for(TiXmlElement *player = players->FirstChildElement("player"); player; player = player->NextSiblingElement("player"))
{
nb++;
if (player->Attribute("name") == playerName)
{
player->SetAttribute("score", data);
return _doc.SaveFile();
}
}
TiXmlElement *player = new TiXmlElement("player");
player->SetAttribute("id", nb);
player->SetAttribute("name", playerName);
player->SetAttribute("score", data);
players->LinkEndChild(player);
return _doc.SaveFile();
}
return false;
}
示例10:
int em::EmXml::WriteRootAttr( const char* szAttrName, const char* szAttrValue )
{
int iResult = 0;
TiXmlElement *pElemRoot = m_pDoc->RootElement();
if(pElemRoot == NULL)
{
return EM_ERR_XML_LOST_ROOT;
}
pElemRoot->SetAttribute(szAttrName,szAttrValue);
m_bUpdated = true;
return iResult;
}
示例11: SetPowerOpt
BOOL SetPowerOpt(BOOL bAllowSuspendMode)
{
TiXmlDocument doc;
if( CheckValidXML(&doc) == FALSE )
{
return FALSE;
}
TiXmlElement* pElem = doc.FirstChild("BBS_WiFiConfig")->FirstChild("Setting")->FirstChild("Option")->FirstChildElement("PowerOption");
pElem->SetAttribute("AllowSuspend", bAllowSuspendMode);
return doc.SaveFile();
}
示例12: ToXml
bool ConferenceInfo::ToXml(const char* szPath)
{
TiXmlDocument xmlDocument;
TiXmlDeclaration *pDeclaration = new TiXmlDeclaration(_T("1.0"),_T("utf-8"),_T(""));
if (!pDeclaration) return false;
xmlDocument.LinkEndChild(pDeclaration);
TiXmlElement *rootElement = TinyXmlFunction::DocNewElement("root", &xmlDocument);
if (!rootElement) return false;
rootElement->SetAttribute("updatetime", updatetime);
rootElement->SetAttribute("version", version);
TiXmlElement *boxElement = TinyXmlFunction::NewElement("box", rootElement);
if (!boxElement) return false;
boxElement->SetAttribute("boxnos", boxnos);
list<ConferenceRecord>::iterator it;
for (it = record.begin(); it != record.end(); it++)
{
SetRecord(boxElement, it);
}
xmlDocument.SaveFile(szPath);//保存到文件
return true;
}
示例13: CreateElement
TiXmlElement* Base64CreateElement(const string& name,const string& value)
{
TiXmlElement* e = NULL;
if (value != "")
{
e = CreateElement(name,base64_encode((const unsigned char*)value.c_str(),value.size()));
if (e != NULL) e->SetAttribute("encode","base64");
}
else
{
e = CreateElement(name,value);
}
return e;
}
示例14: SaveToFile
void Template::SaveToFile(const std::string &path)
{
TiXmlDocument *doc = new TiXmlDocument();
TiXmlElement *baseEle = new TiXmlElement("Template");
TiXmlElement *descEle = new TiXmlElement("Description");
descEle->LinkEndChild(new TiXmlText(m_description.c_str()));
TiXmlElement *ele = new TiXmlElement("Keyframes");
ele->SetDoubleAttribute("period", m_period);
ele->SetAttribute("types", m_types);
for(std::map<std::string, BoneAnimation>::iterator it = m_keyFrames.begin(); it != m_keyFrames.end(); it++)
{
TiXmlElement *boneEle = new TiXmlElement("Bone");
boneEle->SetAttribute("name", it->first.c_str());
for(std::map<KeyFrameType, std::vector<KeyFrame> >::iterator it2 = it->second.keyFrames.begin(); it2 != it->second.keyFrames.end(); it2++)
{
TiXmlElement *keyframetypeEle = new TiXmlElement("Type");
keyframetypeEle->SetDoubleAttribute("type", static_cast<int>(it2->first));
for(unsigned int a = 0; a < it2->second.size(); a++)
{
TiXmlElement *timefloatEle = new TiXmlElement("Keyframe");
timefloatEle->SetDoubleAttribute("time", it2->second.at(a).time);
timefloatEle->SetDoubleAttribute("value", it2->second.at(a).value);
timefloatEle->SetAttribute("valueStr", it2->second.at(a).valueStr.c_str());
timefloatEle->SetAttribute("interpolation", it2->second.at(a).interpolation.c_str());
keyframetypeEle->LinkEndChild(timefloatEle);
}
boneEle->LinkEndChild(keyframetypeEle);
}
ele->LinkEndChild(boneEle);
}
TiXmlElement *descriptionsEle = baseEle->LinkEndChild(new TiXmlElement("BonesDescriptions"))->ToElement();
for(unsigned int a = 0; a < m_boneDescriptions.size(); a++)
{
TiXmlElement *boneDescrEle = new TiXmlElement("BoneDescription");
boneDescrEle->SetAttribute("bone", m_boneDescriptions[a].first.c_str());
boneDescrEle->SetAttribute("description", m_boneDescriptions[a].second.c_str());
descriptionsEle->LinkEndChild(boneDescrEle);
}
baseEle->LinkEndChild(descEle);
baseEle->LinkEndChild(ele);
doc->LinkEndChild(baseEle);
doc->SaveFile(path.c_str());
}
示例15: SaveSegment
void XMLSaver::SaveSegment(Segment *s, TiXmlElement *m)
{
TiXmlElement *se = new TiXmlElement("Segment");
se->SetAttribute("name", s->name);
se->SetDoubleAttribute("mass", s->mass);
se->SetDoubleAttribute("rot_inertia", s->rot_inertia);
for (list <Connector *>::iterator i = s->connectors.begin(); i != s->connectors.end(); i++)
{
Connector *c = *i;
if (c != s->polus)
SaveConnector(c, se);
}
m->LinkEndChild(se);
}