本文整理汇总了C++中TiXmlText::SetCDATA方法的典型用法代码示例。如果您正苦于以下问题:C++ TiXmlText::SetCDATA方法的具体用法?C++ TiXmlText::SetCDATA怎么用?C++ TiXmlText::SetCDATA使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TiXmlText
的用法示例。
在下文中一共展示了TiXmlText::SetCDATA方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: WriteXmlNode
TiXmlNode* WriteXmlNode(const std::string& tag, const std::string& data, bool cdata)
{
TiXmlNode* node = new TiXmlElement(tag);
TiXmlText* text = new TiXmlText(data);
text->SetCDATA(cdata);
node->LinkEndChild(text);
return node;
}
示例2: ModifyElemValueCDATA
void CXml::ModifyElemValueCDATA(const char *pszElemValue)
{
if (NULL == pszElemValue)
{
return;
}
if (NULL == m_pXmlNode)
{
return;
}
TiXmlText *pXmlText = m_pXmlNode->FirstChild()->ToText();
//判断指针是否为空
CHECK_POINTER_VOID(pXmlText);
pXmlText->SetCDATA(true); // 添加CDATA属性
pXmlText->SetValue(pszElemValue);
}
示例3: SetElemValueCDATA
/**************************************************************************
* name : SetElemValueCDATA
* description: 设定当前元素值 <![CDATA[ElemValue]]>
* input : pszElemValue 待设定的元素值
* output : NA
* return : true - 成功,false - 失败
* remark : NA
**************************************************************************/
bool CXml::SetElemValueCDATA(const char* pszElemValue)
{
CHECK_POINTER(pszElemValue, false);
CHECK_POINTER(m_pXmlElem, false);
TiXmlText *pXmlText = NULL;
try
{
pXmlText = new TiXmlText(pszElemValue);
CHECK_POINTER(pXmlText, false);//lint !e774
pXmlText->SetCDATA(true); // 设置该文本为CDATA,无需解析
}
catch (...)
{
pXmlText = NULL;
return false;//lint !e438
}
CHECK_POINTER(pXmlText, false);//lint !e774
(void)(m_pXmlElem->LinkEndChild(pXmlText));
return true;//lint !e429
}
示例4: serialiseToXML
TiXmlElement* CqDisplayServerImage::serialiseToXML()
{
TiXmlElement* imageXML = new TiXmlElement("Image");
TiXmlElement* typeXML = new TiXmlElement("Type");
TiXmlText* typeText = new TiXmlText("managed");
typeXML->LinkEndChild(typeText);
imageXML->LinkEndChild(typeXML);
TiXmlElement* nameXML = new TiXmlElement("Name");
TiXmlText* nameText = new TiXmlText(name());
nameXML->LinkEndChild(nameText);
imageXML->LinkEndChild(nameXML);
if(filename().empty())
{
TiXmlElement* dataXML = new TiXmlElement("Bitmap");
std::stringstream base64Data;
size_t dataLen = m_displayData->width() * m_displayData->height() * numChannels() * sizeof(TqUchar);
std::copy( base64_text(BOOST_MAKE_PFTO_WRAPPER(m_displayData->rawData())),
base64_text(BOOST_MAKE_PFTO_WRAPPER(m_displayData->rawData() + dataLen)),
std::ostream_iterator<char>(base64Data));
TiXmlText* dataTextXML = new TiXmlText(base64Data.str());
dataTextXML->SetCDATA(true);
dataXML->LinkEndChild(dataTextXML);
imageXML->LinkEndChild(dataXML);
}
else
{
TiXmlElement* filenameXML = new TiXmlElement("Filename");
TiXmlText* filenameText = new TiXmlText(filename());
filenameXML->LinkEndChild(filenameText);
imageXML->LinkEndChild(filenameXML);
}
return(imageXML);
}
示例5: Identify
TiXmlNode* TiXmlNode::Identify( const char* p, TiXmlEncoding encoding )
{
TiXmlNode* returnNode = 0;
p = SkipWhiteSpace( p, encoding );
if( !p || !*p || *p != '<' )
{
return 0;
}
p = SkipWhiteSpace( p, encoding );
if ( !p || !*p )
{
return 0;
}
// What is this thing?
// - Elements start with a letter or underscore, but xml is reserved.
// - Comments: <!--
// - Decleration: <?xml
// - Everthing else is unknown to tinyxml.
//
const char* xmlHeader = { "<?xml" };
const char* commentHeader = { "<!--" };
const char* dtdHeader = { "<!" };
const char* cdataHeader = { "<![CDATA[" };
if ( StringEqual( p, xmlHeader, true, encoding ) )
{
#ifdef DEBUG_PARSER
TIXML_LOG( "XML parsing Declaration\n" );
#endif
returnNode = new TiXmlDeclaration();
}
else if ( StringEqual( p, commentHeader, false, encoding ) )
{
#ifdef DEBUG_PARSER
TIXML_LOG( "XML parsing Comment\n" );
#endif
returnNode = new TiXmlComment();
}
else if ( StringEqual( p, cdataHeader, false, encoding ) )
{
#ifdef DEBUG_PARSER
TIXML_LOG( "XML parsing CDATA\n" );
#endif
TiXmlText* text = new TiXmlText( "" );
text->SetCDATA( true );
returnNode = text;
}
else if ( StringEqual( p, dtdHeader, false, encoding ) )
{
#ifdef DEBUG_PARSER
TIXML_LOG( "XML parsing Unknown(1)\n" );
#endif
returnNode = new TiXmlUnknown();
}
else if ( IsAlpha( *(p+1), encoding )
|| *(p+1) == '_' )
{
#ifdef DEBUG_PARSER
TIXML_LOG( "XML parsing Element\n" );
#endif
returnNode = new TiXmlElement( "" );
}
else
{
#ifdef DEBUG_PARSER
TIXML_LOG( "XML parsing Unknown(2)\n" );
#endif
returnNode = new TiXmlUnknown();
}
if ( returnNode )
{
// Set the parent, so it can report errors
returnNode->parent = this;
}
return returnNode;
}
示例6: WriteToXMLFile
bool ETHEntityProperties::WriteToXMLFile(TiXmlElement *pHeadRoot) const
{
TiXmlElement *pRoot = new TiXmlElement(GS_L("Entity"));
pHeadRoot->LinkEndChild(pRoot);
TiXmlElement *pElement;
if (emissiveColor != ETH_DEFAULT_EMISSIVE_COLOR)
ETHEntityProperties::SetColorPropertyToXmlElement(pRoot, GS_L("EmissiveColor"), emissiveColor);
if (spriteCut != ETH_DEFAULT_SPRITE_CUT)
ETHEntityProperties::SetVector2iPropertyToXmlElement(pRoot, GS_L("SpriteCut"), spriteCut);
if (scale != ETH_DEFAULT_SCALE)
ETHEntityProperties::SetVector2PropertyToXmlElement(pRoot, GS_L("Scale"), scale);
if (pivotAdjust != ETH_DEFAULT_PIVOT_ADJUST)
ETHEntityProperties::SetVector2PropertyToXmlElement(pRoot, GS_L("PivotAdjust"), pivotAdjust);
if (spriteFile != GS_L(""))
{
pElement = new TiXmlElement(GS_L("Sprite"));
pElement->LinkEndChild(new TiXmlText(spriteFile));
pRoot->LinkEndChild(pElement);
}
if (normalFile != GS_L(""))
{
pElement = new TiXmlElement(GS_L("Normal"));
pElement->LinkEndChild(new TiXmlText(normalFile));
pRoot->LinkEndChild(pElement);
}
if (glossFile != GS_L(""))
{
pElement = new TiXmlElement(GS_L("Gloss"));
pElement->LinkEndChild(new TiXmlText(glossFile));
pRoot->LinkEndChild(pElement);
}
if (!particleSystems.empty())
{
TiXmlElement *pParticles = new TiXmlElement(GS_L("Particles"));
pRoot->LinkEndChild(pParticles);
for (unsigned int t=0; t<particleSystems.size(); t++)
{
if (particleSystems[t]->nParticles > 0)
particleSystems[t]->WriteToXMLFile(pParticles);
}
}
if (light)
{
light->WriteToXMLFile(pRoot);
}
if (collision)
{
TiXmlElement *pCollisionRoot = collision->WriteToXMLFile(pRoot);
if (pCollisionRoot)
{
// Write polygon data
if (polygon)
{
pElement = new TiXmlElement(GS_L("Polygon"));
TiXmlText* text = new TiXmlText(polygon->GetENMLDeclaration());
text->SetCDATA(true);
pElement->LinkEndChild(text);
pCollisionRoot->LinkEndChild(pElement);
}
else if (shape == BS_POLYGON) // if the polygon data is empty, write sample data into it
{
pElement = new TiXmlElement(GS_L("Polygon"));
TiXmlText* text = new TiXmlText(POLYGON_ENML_SAMPLE);
text->SetCDATA(true);
pElement->LinkEndChild(text);
pCollisionRoot->LinkEndChild(pElement);
}
// Write compound shape data
if (compoundShape)
{
pElement = new TiXmlElement(GS_L("Compound"));
TiXmlText* text = new TiXmlText(compoundShape->GetENMLDeclaration());
text->SetCDATA(true);
pElement->LinkEndChild(text);
pCollisionRoot->LinkEndChild(pElement);
}
else if (shape == BS_COMPOUND) // it the compound data is empty, write sample data into it
{
pElement = new TiXmlElement(GS_L("Compound"));
TiXmlText* text = new TiXmlText(COMPOUND_SHAPE_ENML_SAMPLE);
text->SetCDATA(true);
pElement->LinkEndChild(text);
pCollisionRoot->LinkEndChild(pElement);
}
// Write joint data
if (enmlJointDefinitions != GS_L(""))
{
//.........这里部分代码省略.........
示例7: Identify
TiXmlNode* TiXmlNode::Identify( const TIXML_CHAR* p, TiXmlEncoding encoding )
{
TiXmlNode* returnNode = 0;
p = SkipWhiteSpace( p, encoding );
if( !p || !*p || *p != _TIXML_L('<') )
{
return 0;
}
TiXmlDocument* doc = GetDocument();
p = SkipWhiteSpace( p, encoding );
if ( !p || !*p )
{
return 0;
}
// What is this thing?
// - Elements start with a letter or underscore, but xml is reserved.
// - Comments: <!--
// - Decleration: <?xml
// - Everthing else is unknown to tinyxml.
//
const TIXML_CHAR* xmlHeader = { _TIXML_L("<?xml") };
const TIXML_CHAR* commentHeader = { _TIXML_L("<!--") };
const TIXML_CHAR* dtdHeader = { _TIXML_L("<!") };
const TIXML_CHAR* cdataHeader = { _TIXML_L("<![CDATA[") };
if ( StringEqual( p, xmlHeader, true, encoding ) )
{
#ifdef DEBUG_PARSER
TIXML_LOG( _TIXML_L("XML parsing Declaration\n") );
#endif
returnNode = new TiXmlDeclaration();
}
else if ( StringEqual( p, commentHeader, false, encoding ) )
{
#ifdef DEBUG_PARSER
TIXML_LOG( _TIXML_L("XML parsing Comment\n") );
#endif
returnNode = new TiXmlComment();
}
else if ( StringEqual( p, cdataHeader, false, encoding ) )
{
#ifdef DEBUG_PARSER
TIXML_LOG( _TIXML_L("XML parsing CDATA\n") );
#endif
TiXmlText* text = new TiXmlText( _TIXML_L("") );
text->SetCDATA( true );
returnNode = text;
}
else if ( StringEqual( p, dtdHeader, false, encoding ) )
{
#ifdef DEBUG_PARSER
TIXML_LOG( _TIXML_L("XML parsing Unknown(1)\n") );
#endif
returnNode = new TiXmlUnknown();
}
else if ( IsAlpha( *(p+1), encoding )
|| *(p+1) == _TIXML_L('_') )
{
#ifdef DEBUG_PARSER
TIXML_LOG( _TIXML_L("XML parsing Element\n") );
#endif
returnNode = new TiXmlElement( _TIXML_L("") );
}
else
{
#ifdef DEBUG_PARSER
TIXML_LOG( _TIXML_L("XML parsing Unknown(2)\n") );
#endif
returnNode = new TiXmlUnknown();
}
if ( returnNode )
{
// Set the parent, so it can report errors
returnNode->parent = this;
}
else
{
if ( doc )
doc->SetError( TIXML_ERROR_OUT_OF_MEMORY, 0, 0, TIXML_ENCODING_UNKNOWN );
}
return returnNode;
}
示例8: Identify
// We're expecting a tag; identify what kind here and allocate the
// appropriate type of node (but don't parse yet). We'll return null if
// we can't find a "<" as the next non-whitespace character, or if we
// find the "<" but it is followed by nothing but whitespace. Note that
// we're only looking at the beginning of the tag, we won't check to see
// if it is terminated properly.
TiXmlNode* TiXmlNode::Identify( const char* p, TiXmlEncoding encoding )
{
TiXmlNode* returnNode = 0;
p = SkipWhiteSpace( p, encoding );
if( !p || !*p || *p != '<' )
{
return 0; // couldn't find the tag-opening "<"
}
TiXmlDocument* doc = GetDocument();
p = SkipWhiteSpace( p, encoding );
if ( !p || !*p )
{
return 0; // a lone "<" at the end of the document
}
// What is this thing?
// - Elements: < X where X is a letter or underscore;
// white space optional between "<" and "X".
// - Comments: <!--
// - Declaration: <?xml
// - CDATA Text: <![CDATA[
// - All other tags are unknown to tinyxml.
//
const char* xmlHeader = { "<?xml" };
const char* commentHeader = { "<!--" };
const char* dtdHeader = { "<!" }; // treated as "unknown"
const char* cdataHeader = { "<![CDATA[" };
if ( StringEqual( p, xmlHeader, true, encoding ) )
{
#ifdef DEBUG_PARSER
TIXML_LOG( "XML parsing Declaration\n" );
#endif
returnNode = new TiXmlDeclaration();
}
else if ( StringEqual( p, commentHeader, false, encoding ) )
{
#ifdef DEBUG_PARSER
TIXML_LOG( "XML parsing Comment\n" );
#endif
returnNode = new TiXmlComment();
}
else if ( StringEqual( p, cdataHeader, false, encoding ) )
{
#ifdef DEBUG_PARSER
TIXML_LOG( "XML parsing CDATA\n" );
#endif
TiXmlText* text = new TiXmlText( "" );
text->SetCDATA( true );
returnNode = text;
}
else if ( StringEqual( p, dtdHeader, false, encoding ) )
{
#ifdef DEBUG_PARSER
TIXML_LOG( "XML parsing Unknown(1)\n" );
#endif
returnNode = new TiXmlUnknown();
}
else if ( IsAlpha( *(p+1), encoding )
|| *(p+1) == '_' )
{
#ifdef DEBUG_PARSER
TIXML_LOG( "XML parsing Element\n" );
#endif
returnNode = new TiXmlElement( "" );
}
else
{
#ifdef DEBUG_PARSER
TIXML_LOG( "XML parsing Unknown(2)\n" );
#endif
returnNode = new TiXmlUnknown();
}
if ( returnNode )
{
// Set the parent, so it can report errors
returnNode->parent = this;
}
else
{
if ( doc )
doc->SetError( TIXML_ERROR_OUT_OF_MEMORY, 0, 0, TIXML_ENCODING_UNKNOWN );
}
return returnNode;
}
示例9: serializeCVar
void CVar::serializeCVar(TiXmlNode* rootNode, bool oldDeveloper)
{
if (rootNode == NULL)
return;
TiXmlElement* cvarNode = rootNode->FirstChildElement("CVar");
while (cvarNode != NULL)
{
if (!std::string(cvarNode->Attribute("name")).compare(name()))
break;
cvarNode = cvarNode->NextSiblingElement("CVar");
}
TiXmlText* text = NULL;
TiXmlText* oldText = NULL;
if (!cvarNode)
{
cvarNode = new TiXmlElement("CVar");
cvarNode->SetAttribute("name", name());
rootNode->LinkEndChild(cvarNode);
}
else
{
if (cvarNode->FirstChild())
{
oldText = cvarNode->FirstChild()->ToText();
}
}
switch(type())
{
case CVar::Boolean:
{
cvarNode->SetAttribute("type", "boolean");
std::string val;
if (com_developer == this)
val = (oldDeveloper ? "true" : "false");
else
val = (toBoolean() ? "true" : "false");
text = new TiXmlText(val);
break;
}
case CVar::Integer:
cvarNode->SetAttribute("type", "integer");
break;
case CVar::Float:
cvarNode->SetAttribute("type", "float");
break;
case CVar::Literal:
{
cvarNode->SetAttribute("type", "literal");
text = new TiXmlText(toLiteral());
text->SetCDATA(true);
break;
}
case CVar::Color:
{
Colori col = toColori();
cvarNode->SetAttribute("type", "color");
cvarNode->SetAttribute("r", (col.r & 255));
cvarNode->SetAttribute("g", (col.g & 255));
cvarNode->SetAttribute("b", (col.b & 255));
cvarNode->SetAttribute("a", (col.a & 255));
}
break;
default: break;
}
if (!text && type() != Color)
text = new TiXmlText(toLiteral());
if (oldText && type() != Color)
{
cvarNode->RemoveChild(oldText);
}
if (text && type() != Color)
cvarNode->LinkEndChild(text);
}
示例10: final_xml_file
bool final_xml_file(const char* xml_name, cat_items_mgr& mgr)
{
if(xml_name == NULL)return false;
TiXmlDocument* pdoc = new TiXmlDocument;
TiXmlElement* root = new TiXmlElement("Items");
pdoc->LinkEndChild(root);
std::map<int, cat_items>::iterator pItr = mgr.cat_items_map.begin();
for(; pItr != mgr.cat_items_map.end(); ++pItr)
{
cat_items* p_cat = &(pItr->second);
TiXmlElement* pCat = new TiXmlElement("Cat");
pCat->SetAttribute("ID", p_cat->cat_id);
pCat->SetAttribute("DbCatID", p_cat->db_cat_id);
pCat->SetAttribute("Name", p_cat->name);
pCat->SetAttribute("Max", p_cat->max);
map<int, item_attire_data>::iterator pItr2 = p_cat->item_map.begin();
for(; pItr2 != p_cat->item_map.end(); ++pItr2)
{
item_attire_data* p_data= &(pItr2->second);
TiXmlElement* pData = new TiXmlElement("Item");
pData->SetAttribute("ID", p_data->id);
pData->SetAttribute("Name", p_data->name);
pData->SetAttribute("DropLv", p_data->droplv);
pData->SetAttribute("QualityLevel", p_data->quality_level);
pData->SetAttribute("EquipPart", p_data->equip_part);
pData->SetAttribute("Price", p_data->price);
pData->SetAttribute("SellPrice", p_data->sell_price);
pData->SetAttribute("RepairPrice", p_data->repair_price);
pData->SetAttribute("UseLv", p_data->uselv);
pData->SetAttribute("Strength", p_data->strength);
pData->SetAttribute("Agility", p_data->agility);
pData->SetAttribute("BodyQuality", p_data->body_quality);
pData->SetAttribute("Stamina", p_data->stamina);
if(strlen(p_data->atk) > 0)
{
pData->SetAttribute("Atk", p_data->atk);
}
pData->SetAttribute("Def", p_data->def);
pData->SetAttribute("Duration", p_data->duration);
pData->SetAttribute("Hit", p_data->hit);
pData->SetAttribute("Dodge", p_data->dodge);
pData->SetAttribute("Crit", p_data->crit);
pData->SetAttribute("Hp", p_data->hp);
pData->SetAttribute("Mp", p_data->mp);
pData->SetAttribute("AddHp", p_data->add_hp);
pData->SetAttribute("AddMp", p_data->add_mp);
pData->SetAttribute("Slot", p_data->slot);
pData->SetAttribute("Tradability", p_data->trade_ability);
pData->SetAttribute("VipTradability", p_data->vip_trade_ability);
pData->SetAttribute("Tradable", p_data->trade_able);
pData->SetAttribute("ExploitValue", p_data->exploit_value);
pData->SetAttribute("SetID", p_data->setid);
pData->SetAttribute("honorLevel", p_data->honor_level);
pData->SetAttribute("LifeTime", p_data->life_time);
pData->SetAttribute("VipOnly", p_data->vip_only);
pData->SetAttribute("DailyId", p_data->dailyid);
pData->SetAttribute("decompose", p_data->decompose);
pData->SetAttribute("Shop", p_data->shop);
pData->SetAttribute("UnStorage", p_data->un_storage);
pData->SetAttribute("resID", p_data->res_id);
if(strlen(p_data->descipt) > 0)
{
TiXmlElement* pdescipt = new TiXmlElement("descript");
TiXmlText *pText = new TiXmlText(p_data->descipt);
pText->SetCDATA(true);
pdescipt->InsertEndChild(*pText);
pData->InsertEndChild(*pdescipt);
}
pCat->InsertEndChild(*pData);
}
root->InsertEndChild(*pCat);
}
return pdoc->SaveFile(xml_name);
}