本文整理汇总了C++中TiXmlElement::Clone方法的典型用法代码示例。如果您正苦于以下问题:C++ TiXmlElement::Clone方法的具体用法?C++ TiXmlElement::Clone怎么用?C++ TiXmlElement::Clone使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TiXmlElement
的用法示例。
在下文中一共展示了TiXmlElement::Clone方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CombineMasterSlaveXmlParam
HRESULT CombineMasterSlaveXmlParam(
const char* szXmlParamMaster,
const char* szXmlParamSlave,
char* szXmlParamAll,
DWORD32& dwLen
)
{
TiXmlElement* pMasterRootElement = NULL;
TiXmlDocument cXmlDocMaster;
if ( szXmlParamMaster && cXmlDocMaster.Parse(szXmlParamMaster) )
{
pMasterRootElement = cXmlDocMaster.RootElement();
}
TiXmlElement* pSlaveRootElement = NULL;
TiXmlDocument cXmlDocSlave;
if ( szXmlParamSlave && cXmlDocSlave.Parse(szXmlParamSlave) )
{
pSlaveRootElement = cXmlDocSlave.RootElement();
}
if ( NULL == pMasterRootElement || NULL == pSlaveRootElement )
{
dwLen = 0;
return E_FAIL;
}
else
{
// 将主CPU参数内的所有Section结点插入到从CPU参数内的HvParam结点下。
TiXmlElement* pMasterHvParamElement = NULL;
TiXmlElement* pSlaveHvParamElement = NULL;
pMasterHvParamElement = pMasterRootElement->FirstChildElement("HvParam");
pSlaveHvParamElement = pSlaveRootElement->FirstChildElement("HvParam");
if ( pMasterHvParamElement && pSlaveHvParamElement)
{
TiXmlElement* pMasterSectionElement = NULL;
pMasterSectionElement = pMasterHvParamElement->FirstChildElement();
while (pMasterSectionElement)
{
pSlaveHvParamElement->LinkEndChild(pMasterSectionElement->Clone());
pMasterSectionElement = pMasterSectionElement->NextSiblingElement();
}
}
TiXmlPrinter cTxPr;
cXmlDocSlave.Accept(&cTxPr);
DWORD32 dwXmlLen = (DWORD32)cTxPr.Size();
if ( dwLen > dwXmlLen )
{
dwLen = dwXmlLen;
memcpy(szXmlParamAll, cTxPr.CStr(), dwXmlLen);
return S_OK;
}
else
{
dwLen = 0;
return E_FAIL;
}
}
}
示例2: LoadConfig
bool CXmlConfig::LoadConfig(const char* szRootNodeName,const char* szFileName)
{
if( !szRootNodeName )
GenErr("配置文件的根节点名称不能为NULL");
TiXmlDocument XmlDoc;
if( !XmlDoc.LoadFile( szFileName ) )
return false;
TiXmlElement* pRoot = XmlDoc.FirstChildElement( szRootNodeName );
if( !pRoot )
{
ostringstream strm;
strm<<"配置文件的根节点不是\""<<szRootNodeName<<"\"";
GenErr( strm.str() );
}
Clear();
m_pRoot = static_cast<TiXmlElement*>( pRoot->Clone() );
return true;
}
示例3: ExportXML
std::string ConfigFile::ExportXML()
{
TiXmlDocument doc( m_strFilename.c_str() );
TiXmlElement configData( m_strIdentifier.c_str() );
configData.SetAttribute( "version", "1.0");
//Loop through all the configurations
std::map<std::string, ConfigAttribute>::iterator configIter;
for(configIter = m_mapConfig.begin(); configIter != m_mapConfig.end(); configIter++)
{
ConfigAttribute item = configIter->second;
std::string firstItem = item.strAttribute;
//replace whitespace with underscore
std::replace(firstItem.begin(), firstItem.end(), ' ', '_');
TiXmlElement elementConfigItem (firstItem.c_str() );
elementConfigItem.SetAttribute( "value", item.strValue.c_str());
//Add array sub items to the xml
if(item.bIsArray)
{
for(std::vector<std::string>::iterator iter = item.listValues.begin(); iter != item.listValues.end(); iter++)
{
std::string strTemp = *iter;
TiXmlElement elementArrayItem (firstItem.c_str() );
elementArrayItem.SetAttribute( "value", strTemp.c_str());
elementConfigItem.LinkEndChild(elementArrayItem.Clone());
}
}
configData.LinkEndChild(elementConfigItem.Clone());
}
doc.LinkEndChild(configData.Clone());
std::string strReturnXML;
std::ostringstream strStream;
strStream << doc;
strReturnXML = strStream.str();
//Save the config file
return strReturnXML;
}
示例4: GetLevelScriptAdditionsXmlSize
//
// GetActorXmlSize - Chapter 22, page 757
//
int GetLevelScriptAdditionsXmlSize ( )
{
TiXmlDocument *optionsDoc = g_pApp->m_Options.m_pDoc;
TiXmlElement *pRoot = optionsDoc->RootElement();
if (!pRoot)
return 0;
TiXmlElement *worldScriptAdditions = pRoot->FirstChildElement("WorldScriptAdditions");
TiXmlDocument outDoc;
TiXmlNode *node = worldScriptAdditions->Clone();
outDoc.LinkEndChild(node);
TiXmlPrinter printer;
outDoc.Accept(&printer);
std::string xml = printer.CStr();
return xml.length();
}
示例5: GetLevelScriptAdditionsXml
//
// GetActorXml - Chapter 22, page 758
//
void GetLevelScriptAdditionsXml ( int *xmlAddress )
{
TiXmlDocument *optionsDoc = g_pApp->m_Options.m_pDoc;
TiXmlElement *pRoot = optionsDoc->RootElement();
if (!pRoot)
return;
TiXmlElement *worldScriptAdditions = pRoot->FirstChildElement("WorldScriptAdditions");
TiXmlDocument outDoc;
TiXmlNode *node = worldScriptAdditions->Clone();
outDoc.LinkEndChild(node);
TiXmlPrinter printer;
outDoc.Accept(&printer);
std::string xml = printer.CStr();
strncpy_s(reinterpret_cast<char *>(xmlAddress), xml.length()+1, xml.c_str(), xml.length());
}