当前位置: 首页>>代码示例>>C++>>正文


C++ TiXmlText::SetCDATA方法代码示例

本文整理汇总了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;

}
开发者ID:jonesgithub,项目名称:luacode,代码行数:12,代码来源:XmlUtility.cpp

示例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);
}
开发者ID:eSDK,项目名称:esdk_elte,代码行数:20,代码来源:eLTE_Xml.cpp

示例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
}
开发者ID:eSDK,项目名称:esdk_elte,代码行数:31,代码来源:eLTE_Xml.cpp

示例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);
}
开发者ID:maya2renderer,项目名称:maya2renderer,代码行数:37,代码来源:displayserverimage.cpp

示例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;
}
开发者ID:fangbaolei,项目名称:EC700IR,代码行数:82,代码来源:tinyxmlparser.cpp

示例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(""))
			{
//.........这里部分代码省略.........
开发者ID:ArthurCalazans,项目名称:ethanon,代码行数:101,代码来源:ETHEntityProperties.cpp

示例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;
}
开发者ID:ThePirateOld,项目名称:four-mp,代码行数:88,代码来源:tinyxmlparser.cpp

示例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;
}
开发者ID:thomasklau,项目名称:simbody,代码行数:96,代码来源:tinyxmlparser.cpp

示例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);
}
开发者ID:Antidote,项目名称:Orion,代码行数:83,代码来源:CVar.cpp

示例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);
}
开发者ID:Zhanyin,项目名称:taomee,代码行数:78,代码来源:item_attire.cpp


注:本文中的TiXmlText::SetCDATA方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。